Skip to content

Commit d41ce67

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 14bab30 + 50385b5 commit d41ce67

File tree

16 files changed

+562
-618
lines changed

16 files changed

+562
-618
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
run: true
4646

4747
slow-test-detection:
48-
name: Run Slow or Expensive Tests (e.g. SaaS)?
48+
name: Run Integration Tests?
4949
runs-on: ubuntu-latest
5050
steps:
5151
- name: Detect Slow Tests
@@ -54,7 +54,7 @@ jobs:
5454
slow-tests
5555

5656
run-slow-tests:
57-
name: Run Slow or Expensive Tests (e.g. SaaS) if Requested
57+
name: Run Integration Tests If Requested
5858
uses: ./.github/workflows/run-tests.yml
5959
needs: [ slow-test-detection ]
6060
secrets: inherit

.github/workflows/run-tests.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ jobs:
2020
runs-on: ubuntu-latest
2121

2222
steps:
23-
- name: Set pytest markers
24-
id: pytest-markers
25-
if: ${{ ! inputs.slow-tests }}
26-
run: echo slow-tests='-m "not saas"' >> "$GITHUB_OUTPUT"
27-
2823
- name: SCM Checkout
2924
uses: actions/checkout@v4
3025

@@ -33,20 +28,16 @@ jobs:
3328
with:
3429
python-version: ${{ inputs.python-version }}
3530

36-
- name: Run Tests and Calculate Coverage
31+
- name: Run Unit Tests
32+
if: ${{ ! inputs.slow-tests }}
33+
run:
34+
poetry run nox -s unit-tests
35+
36+
- name: Run Integration Tests
37+
if: ${{ inputs.slow-tests }}
3738
env:
3839
SAAS_HOST: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_HOST }}
3940
SAAS_ACCOUNT_ID: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_ACCOUNT_ID }}
4041
SAAS_PAT: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_PAT }}
41-
PYTEST_ADDOPTS: '${{ steps.pytest-markers.outputs.slow-tests }}'
42-
run: |
43-
echo "PYTEST_ADDOPTS = $PYTEST_ADDOPTS"
44-
export PROJECT_SHORT_TAG=$(poetry run nox -s get-project-short-tag)
45-
poetry run nox -s coverage -- -- --db-version ${{ inputs.exasol-version}}
46-
47-
- name: Upload Artifacts
48-
uses: actions/upload-artifact@v3
49-
with:
50-
name: .coverage
51-
path: .coverage
52-
overwrite: true
42+
run:
43+
poetry run nox -s integration-tests -- -- --db-version ${{ inputs.exasol-version}} --backend all

doc/changes/changes_0.5.0.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ Validation is implemented by
77
* running a UDF inside it,
88
* and making the UDF check for a specific file having been extracted from the SLC archive to be available on each node of the databasecluster.
99

10-
Addtionally this release refactors the existing CLI tests for the `LanguageContainerDeployer` which were integration tests involving the whole chain from the CLI down to the API, starting a database and uploading and activating SLCs.
10+
Additionally, this release refactors the existing CLI tests for the `LanguageContainerDeployer` which were integration tests involving the whole chain from the CLI down to the API, starting a database and uploading and activating SLCs.
1111

1212
The existing integration tests have been split into
13-
* either unit tests just verifiying that the CLI options are passed to the API
13+
* either unit tests just verifying that the CLI options are passed to the API
1414
* or ordinary integration tests not using the CLI.
1515

16-
This enables faster and more robust tests for the pure CLI-related features, faster turnaounds during development, and separation of concerns.
16+
This enables faster and more robust tests for the pure CLI-related features, faster turnarounds during development, and separation of concerns.
17+
18+
The integration tests now use the pytest plugin `pytest-exasol-backend`.
1719

1820
## Features
1921

@@ -23,7 +25,11 @@ This enables faster and more robust tests for the pure CLI-related features, fas
2325
# Refactoring
2426

2527
* #51: Split CLI integration tests
28+
* #63: Removed the language_alias parameter from the LanguageContainerBuilder.
2629

2730
## Bug Fixing
2831

29-
* #60: Fix handling pip requirements when creating an SLC
32+
* #60: Fixed handling pip requirements when creating an SLC.
33+
* #58: Fixed the bug in language_container_builder.find_path_backwards.
34+
* #36: Added SAAS_HOST environment variable to the user guide.
35+
* #35: Restoring pre-existing schema in the temp_schema module.

doc/user_guide/user-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ another source.
4444
| bucketfs-password | [x] | | Env. [BUCKETFS_PASSWORD] |
4545
| bucketfs-use-https | [x] | | Optional boolean, defaults to False |
4646
| bucket | [x] | | |
47-
| saas-url | | [x] | |
47+
| saas-url | | [x] | Env. [SAAS_HOST] |
4848
| saas-account-id | | [x] | Env. [SAAS_ACCOUNT_ID] |
4949
| saas-database-id | | [x] | Optional, Env. [SAAS_DATABASE_ID] |
5050
| saas-database-name | | [x] | Optional, provide if the database_id is unknown |

exasol/python_extension_common/deployment/language_container/flavor_base/build_steps.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# pylint: disable=import-error
2-
from exasol_script_languages_container_tool.lib.tasks.build.docker_flavor_image_task import DockerFlavorAnalyzeImageTask # type: ignore
1+
from exasol.slc.internal.tasks.build.docker_flavor_image_task import DockerFlavorAnalyzeImageTask # type: ignore
32

43

54
class AnalyzeDependencies(DockerFlavorAnalyzeImageTask):

exasol/python_extension_common/deployment/language_container/flavor_base/language_definition

Lines changed: 0 additions & 1 deletion
This file was deleted.

exasol/python_extension_common/deployment/language_container_builder.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
from pathlib import Path
77
from importlib import resources
88

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

1413

1514
def exclude_cuda(line: str) -> bool:
@@ -24,7 +23,8 @@ def find_path_backwards(target_path: str | Path, start_path: str | Path) -> Path
2423
error if the search is unsuccessful.
2524
"""
2625
current_path = Path(start_path).parent
27-
while current_path != current_path.root:
26+
root = Path(current_path.root)
27+
while current_path != root:
2828
result_path = Path(current_path, target_path)
2929
if result_path.exists():
3030
return result_path
@@ -44,9 +44,8 @@ def copy_slc_flavor(dest_dir: str | Path) -> None:
4444

4545
class LanguageContainerBuilder:
4646

47-
def __init__(self, container_name: str, language_alias: str):
47+
def __init__(self, container_name: str):
4848
self.container_name = container_name
49-
self.language_alias = language_alias
5049
self._root_path: Path | None = None
5150
self._output_path: Path | None = None
5251

@@ -58,9 +57,6 @@ def __enter__(self):
5857

5958
# Copy the flavor into the working directory
6059
copy_slc_flavor(self.flavor_path)
61-
62-
# Write the language alias to the language definition
63-
self._set_language_alias()
6460
return self
6561

6662
def __exit__(self, *exc_details):
@@ -140,16 +136,6 @@ def export(self, export_path: str | Path | None = None) -> ExportContainerResult
140136
export_path=str(export_path))
141137
return export_result
142138

143-
def _set_language_alias(self) -> None:
144-
"""
145-
Sets the language alias provided in the constractor to the language definition.
146-
"""
147-
lang_def_path = self.flavor_base / 'language_definition'
148-
lang_def_template = lang_def_path.read_text()
149-
lang_def_text = lang_def_template.split("=", maxsplit=1)[1]
150-
lang_def = f'{self.language_alias}={lang_def_text}'
151-
lang_def_path.write_text(lang_def)
152-
153139
def _add_requirements_to_flavor(self, project_directory: str | Path,
154140
requirement_filter: Callable[[str], bool] | None):
155141
"""

exasol/python_extension_common/deployment/language_container_deployer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ def __init__(self,
109109
)
110110
logger.debug("Init %s", LanguageContainerDeployer.__name__)
111111

112+
@property
113+
def pyexasol_connection(self) -> pyexasol.ExaConnection:
114+
return self._pyexasol_conn
115+
112116
def download_and_run(self, url: str,
113117
bucket_file_path: str,
114118
alter_system: bool = True,

exasol/python_extension_common/deployment/temp_schema.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
from tenacity import retry
88
from tenacity.stop import stop_after_attempt
99

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

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

1924

25+
def _get_schema(conn: pyexasol.ExaConnection) -> str | None:
26+
return conn.execute(f"SELECT CURRENT_SCHEMA;").fetchval()
27+
28+
29+
def _set_schema(conn: pyexasol.ExaConnection, schema: str | None):
30+
if schema:
31+
conn.execute(f'OPEN SCHEMA "{schema}";')
32+
else:
33+
conn.execute("CLOSE SCHEMA;")
34+
35+
2036
def _delete_schema(conn: pyexasol.ExaConnection, schema: str) -> None:
2137
sql = f'DROP SCHEMA IF EXISTS "{schema}" CASCADE;'
38+
conn.execute(query=sql)
2239

2340

2441
@contextmanager
@@ -33,9 +50,11 @@ def temp_schema(conn: pyexasol.ExaConnection,
3350
conn - pyexasol connection.
3451
schema_name_length - Number of characters in the temporary schema name.
3552
"""
53+
current_schema = _get_schema(conn)
3654
schema = ''
3755
try:
3856
schema = _create_random_schema(conn, schema_name_length)
3957
yield schema
4058
finally:
4159
_delete_schema(conn, schema)
60+
_set_schema(conn, current_schema)

0 commit comments

Comments
 (0)