Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixing and moving to pytest plugins #62

Merged
merged 35 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
17f44ac
Add documentation build folder to .gitignore
ahsimb Mar 26, 2024
7875564
Merge remote-tracking branch 'origin/main'
ahsimb May 14, 2024
31cca39
Merge remote-tracking branch 'origin/main'
ahsimb May 16, 2024
a78e714
Merge remote-tracking branch 'origin/main'
ahsimb May 23, 2024
381181f
Merge remote-tracking branch 'origin/main'
ahsimb May 28, 2024
062aee7
Merge remote-tracking branch 'origin/main'
ahsimb Jun 7, 2024
1cb349f
Merge remote-tracking branch 'origin/main'
ahsimb Jun 11, 2024
ee5bd0e
Merge remote-tracking branch 'origin/main'
ahsimb Jun 12, 2024
8c40fad
Merge remote-tracking branch 'origin/main'
ahsimb Jun 12, 2024
4584c96
Merge remote-tracking branch 'origin/main'
ahsimb Jun 13, 2024
8e2bc62
Merge remote-tracking branch 'origin/main'
ahsimb Jun 25, 2024
0ca19e9
Merge remote-tracking branch 'origin/main'
ahsimb Jun 25, 2024
2e86c75
Merge remote-tracking branch 'origin/main'
ahsimb Jun 26, 2024
6746ead
Merge remote-tracking branch 'origin/main'
ahsimb Jun 26, 2024
a6e9e66
Merge remote-tracking branch 'origin/main'
ahsimb Aug 8, 2024
ccba19f
Merge remote-tracking branch 'origin/main'
ahsimb Aug 12, 2024
fb4107d
Merge remote-tracking branch 'origin/main'
ahsimb Aug 14, 2024
8f0bc20
Merge remote-tracking branch 'origin/main'
ahsimb Aug 14, 2024
5c7c13d
Merge remote-tracking branch 'origin/main'
ahsimb Sep 18, 2024
ec60b9a
#60 Fix the requirements in the SLC builder
ahsimb Sep 18, 2024
b4686f7
#60 Disabled GitHub summary
ahsimb Sep 18, 2024
2836a96
#60 Addressed review comments
ahsimb Sep 19, 2024
703e3eb
#60 Prepared the release
ahsimb Sep 19, 2024
1c459ea
#60 Fixed other bugs
ahsimb Sep 19, 2024
14bab30
Merge remote-tracking branch 'origin/main'
ahsimb Sep 19, 2024
c3d6a80
Merge branch 'bug/60-missing-requirements' into bug/58_35_36
ahsimb Sep 19, 2024
aab52f2
#60 Fixed two bugs, moved to pytest plugins
ahsimb Sep 19, 2024
af3b09d
#60 Fixed the version of the exasol-script-languages-container-tool
ahsimb Sep 19, 2024
fb452af
#60 Updated the workflow
ahsimb Sep 19, 2024
843466d
#60 Updated the workflow
ahsimb Sep 19, 2024
3c2aeb5
#60 Updated the workflow
ahsimb Sep 19, 2024
401af6e
#60 Updated the workflow
ahsimb Sep 19, 2024
66495dd
#60 Addressed review comments
ahsimb Sep 20, 2024
979bf84
#60 Removed language_alias from the LanguageContainerBuilder
ahsimb Sep 20, 2024
5d04367
#60 Fixed the slc builder unit tests
ahsimb Sep 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
run: true

slow-test-detection:
name: Run Slow or Expensive Tests (e.g. SaaS)?
name: Run Integration Tests?
runs-on: ubuntu-latest
steps:
- name: Detect Slow Tests
Expand All @@ -54,7 +54,7 @@ jobs:
slow-tests

run-slow-tests:
name: Run Slow or Expensive Tests (e.g. SaaS) if Requested
name: Run Integration Tests If Requested
uses: ./.github/workflows/run-tests.yml
needs: [ slow-test-detection ]
secrets: inherit
Expand Down
27 changes: 9 additions & 18 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set pytest markers
id: pytest-markers
if: ${{ ! inputs.slow-tests }}
run: echo slow-tests='-m "not saas"' >> "$GITHUB_OUTPUT"

- name: SCM Checkout
uses: actions/checkout@v4

Expand All @@ -33,20 +28,16 @@ jobs:
with:
python-version: ${{ inputs.python-version }}

- name: Run Tests and Calculate Coverage
- name: Run Unit Tests
if: ${{ ! inputs.slow-tests }}
run:
poetry run nox -s unit-tests

- name: Run Integration Tests
if: ${{ inputs.slow-tests }}
env:
SAAS_HOST: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_HOST }}
SAAS_ACCOUNT_ID: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_ACCOUNT_ID }}
SAAS_PAT: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_PAT }}
PYTEST_ADDOPTS: '${{ steps.pytest-markers.outputs.slow-tests }}'
run: |
echo "PYTEST_ADDOPTS = $PYTEST_ADDOPTS"
export PROJECT_SHORT_TAG=$(poetry run nox -s get-project-short-tag)
poetry run nox -s coverage -- -- --db-version ${{ inputs.exasol-version}}

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: .coverage
path: .coverage
overwrite: true
run:
poetry run nox -s integration-tests -- -- --db-version ${{ inputs.exasol-version}} --backend all
7 changes: 6 additions & 1 deletion doc/changes/changes_0.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The existing integration tests have been split into

This enables faster and more robust tests for the pure CLI-related features, faster turnaounds during development, and separation of concerns.

The integration tests now use the pytest plugin `pytest-exasol-backend`.

## Features

* #50: Created new implementation `ExtractValidator` for validating extraction of
Expand All @@ -26,4 +28,7 @@ This enables faster and more robust tests for the pure CLI-related features, fas

## Bug Fixing

* #60: Fix handling pip requirements when creating an SLC
* #60: Fixed handling pip requirements when creating an SLC.
* #58: Fixed the bug in language_container_builder.find_path_backwards.
ahsimb marked this conversation as resolved.
Show resolved Hide resolved
* #36: Added SAAS_HOST environment variable to the user guide.
* #35: Restoring pre-existing schema in the temp_schema module.
2 changes: 1 addition & 1 deletion doc/user_guide/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ another source.
| bucketfs-password | [x] | | Env. [BUCKETFS_PASSWORD] |
| bucketfs-use-https | [x] | | Optional boolean, defaults to False |
| bucket | [x] | | |
| saas-url | | [x] | |
| saas-url | | [x] | Env. [SAAS_HOST] |
| saas-account-id | | [x] | Env. [SAAS_ACCOUNT_ID] |
| saas-database-id | | [x] | Optional, Env. [SAAS_DATABASE_ID] |
| saas-database-name | | [x] | Optional, provide if the database_id is unknown |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# pylint: disable=import-error
from exasol_script_languages_container_tool.lib.tasks.build.docker_flavor_image_task import DockerFlavorAnalyzeImageTask # type: ignore
from exasol.slc.internal.tasks.build.docker_flavor_image_task import DockerFlavorAnalyzeImageTask # type: ignore


class AnalyzeDependencies(DockerFlavorAnalyzeImageTask):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
from pathlib import Path
from importlib import resources

# pylint: disable=import-error
from exasol_integration_test_docker_environment.lib.docker.images.image_info import ImageInfo # type: ignore
from exasol_script_languages_container_tool.lib import api # type: ignore
from exasol_script_languages_container_tool.lib.tasks.export.export_containers import ExportContainerResult # type: ignore
from exasol.slc import api # type: ignore
from exasol.slc.models.export_container_result import ExportContainerResult # type: ignore


def exclude_cuda(line: str) -> bool:
Expand All @@ -24,7 +23,8 @@ def find_path_backwards(target_path: str | Path, start_path: str | Path) -> Path
error if the search is unsuccessful.
"""
current_path = Path(start_path).parent
while current_path != current_path.root:
root = Path(current_path.root)
while current_path != root:
result_path = Path(current_path, target_path)
if result_path.exists():
return result_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def __init__(self,
)
logger.debug("Init %s", LanguageContainerDeployer.__name__)

@property
def pyexasol_connection(self) -> pyexasol.ExaConnection:
return self._pyexasol_conn

def download_and_run(self, url: str,
bucket_file_path: str,
alter_system: bool = True,
Expand Down
19 changes: 19 additions & 0 deletions exasol/python_extension_common/deployment/temp_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
from tenacity import retry
from tenacity.stop import stop_after_attempt


@retry(reraise=True, stop=stop_after_attempt(3))
def _create_random_schema(conn: pyexasol.ExaConnection, schema_name_length: int) -> str:
"""
The function creates a schema with randomly generated name. It makes a few retries,
as it's theoretically possible to create a collision with an existing schema.
"""

schema = ''.join(random.choice(string.ascii_letters)
for _ in range(schema_name_length))
Expand All @@ -17,8 +22,20 @@ def _create_random_schema(conn: pyexasol.ExaConnection, schema_name_length: int)
return schema


def _get_schema(conn: pyexasol.ExaConnection) -> str | None:
return conn.execute(f"SELECT CURRENT_SCHEMA;").fetchval()


def _set_schema(conn: pyexasol.ExaConnection, schema: str | None):
if schema:
conn.execute(f'OPEN SCHEMA "{schema}";')
else:
conn.execute("CLOSE SCHEMA;")


def _delete_schema(conn: pyexasol.ExaConnection, schema: str) -> None:
sql = f'DROP SCHEMA IF EXISTS "{schema}" CASCADE;'
conn.execute(query=sql)


@contextmanager
Expand All @@ -33,9 +50,11 @@ def temp_schema(conn: pyexasol.ExaConnection,
conn - pyexasol connection.
schema_name_length - Number of characters in the temporary schema name.
"""
current_schema = _get_schema(conn)
schema = ''
try:
schema = _create_random_schema(conn, schema_name_length)
yield schema
finally:
_delete_schema(conn, schema)
_set_schema(conn, current_schema)
Loading
Loading