Skip to content

Commit

Permalink
#5 Addressed review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsimb committed May 16, 2024
1 parent 6b6f4da commit 4a00dc2
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 103 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# - name: Checkout ITDE
# run: git clone https://github.com/exasol/integration-test-docker-environment.git
# working-directory: ..

# - name: Start EXASOL Test-Environment
# run: ./start-test-env spawn-test-environment --environment-name test --database-port-forward 8888 --bucketfs-port-forward 6666 --db-mem-size 4GB
# working-directory: ../integration-test-docker-environment

- name: Calculate Test Coverage
run: poetry run nox -s coverage -- -- --db-version ${{ matrix.exasol-version }}

Expand Down
70 changes: 27 additions & 43 deletions test/integration/test_language_container_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pathlib import Path

import pytest
from _pytest.fixtures import FixtureRequest

from pyexasol import ExaConnection
from pytest_itde import config
Expand All @@ -15,6 +14,9 @@
from test.utils.revert_language_settings import revert_language_settings
from test.utils.db_utils import (create_schema, assert_udf_running)

TEST_SCHEMA = "PEC_DEPLOYER_TESTS"
TEST_LANGUAGE_ALIAS = "PYTHON3_PEC_TESTS"


def create_container_deployer(language_alias: str,
pyexasol_connection: ExaConnection,
Expand All @@ -30,87 +32,69 @@ def create_container_deployer(language_alias: str,


def test_language_container_deployer(
itde,
request: FixtureRequest,
itde: config.TestConfig,
connection_factory: Callable[[config.Exasol], ExaConnection],
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
container_path: str):
"""
Tests the deployment of a container in one call, including the activation at the System level.
"""
test_name: str = request.node.name
schema = test_name
language_alias = f"PYTHON3_PEC_{test_name.upper()}"
with ExitStack() as stack:
pyexasol_connection = stack.enter_context(connection_factory(exasol_config))
pyexasol_connection = stack.enter_context(connection_factory(itde.db))
stack.enter_context(revert_language_settings(pyexasol_connection))
create_schema(pyexasol_connection, schema)
deployer = create_container_deployer(language_alias=language_alias,
create_schema(pyexasol_connection, TEST_SCHEMA)
deployer = create_container_deployer(language_alias=TEST_LANGUAGE_ALIAS,
pyexasol_connection=pyexasol_connection,
bucketfs_config=bucketfs_config)
bucketfs_config=itde.bucketfs)
deployer.run(container_file=Path(container_path), alter_system=True, allow_override=True)
new_connection = stack.enter_context(connection_factory(exasol_config))
assert_udf_running(new_connection, language_alias, schema)
new_connection = stack.enter_context(connection_factory(itde.db))
assert_udf_running(new_connection, TEST_LANGUAGE_ALIAS, TEST_SCHEMA)


def test_language_container_deployer_alter_session(
itde,
request: FixtureRequest,
itde: config.TestConfig,
connection_factory: Callable[[config.Exasol], ExaConnection],
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
container_url: str,
container_name: str):
"""
Tests the deployment of a container in two stages - uploading the container
followed by activation at the Session level.
"""
test_name: str = request.node.name
schema = test_name
language_alias = f"PYTHON3_PEC_{test_name.upper()}"
with ExitStack() as stack:
pyexasol_connection = stack.enter_context(connection_factory(exasol_config))
pyexasol_connection = stack.enter_context(connection_factory(itde.db))
stack.enter_context(revert_language_settings(pyexasol_connection))
create_schema(pyexasol_connection, schema)
deployer = create_container_deployer(language_alias=language_alias,
create_schema(pyexasol_connection, TEST_SCHEMA)
deployer = create_container_deployer(language_alias=TEST_LANGUAGE_ALIAS,
pyexasol_connection=pyexasol_connection,
bucketfs_config=bucketfs_config)
bucketfs_config=itde.bucketfs)
deployer.download_and_run(container_url, container_name, alter_system=False)
new_connection = stack.enter_context(connection_factory(exasol_config))
deployer = create_container_deployer(language_alias=language_alias,
new_connection = stack.enter_context(connection_factory(itde.db))
deployer = create_container_deployer(language_alias=TEST_LANGUAGE_ALIAS,
pyexasol_connection=new_connection,
bucketfs_config=bucketfs_config)
bucketfs_config=itde.bucketfs)
deployer.activate_container(container_name, LanguageActivationLevel.Session, True)
assert_udf_running(new_connection, language_alias, schema)
assert_udf_running(new_connection, TEST_LANGUAGE_ALIAS, TEST_SCHEMA)


def test_language_container_deployer_activation_fail(
itde,
request: FixtureRequest,
itde: config.TestConfig,
connection_factory: Callable[[config.Exasol], ExaConnection],
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
container_path: str,
container_name: str):
"""
Tests that an attempt to activate a container using an alias that already exists
causes an exception if overriding is disallowed.
"""
test_name: str = request.node.name
schema = test_name
language_alias = f"PYTHON3_PEC_{test_name.upper()}"
with ExitStack() as stack:
pyexasol_connection = stack.enter_context(connection_factory(exasol_config))
pyexasol_connection = stack.enter_context(connection_factory(itde.db))
stack.enter_context(revert_language_settings(pyexasol_connection))
create_schema(pyexasol_connection, schema)
deployer = create_container_deployer(language_alias=language_alias,
create_schema(pyexasol_connection, TEST_SCHEMA)
deployer = create_container_deployer(language_alias=TEST_LANGUAGE_ALIAS,
pyexasol_connection=pyexasol_connection,
bucketfs_config=bucketfs_config)
bucketfs_config=itde.bucketfs)
deployer.run(container_file=Path(container_path), alter_system=True, allow_override=True)
new_connection = stack.enter_context(connection_factory(exasol_config))
deployer = create_container_deployer(language_alias=language_alias,
new_connection = stack.enter_context(connection_factory(itde.db))
deployer = create_container_deployer(language_alias=TEST_LANGUAGE_ALIAS,
pyexasol_connection=new_connection,
bucketfs_config=bucketfs_config)
bucketfs_config=itde.bucketfs)
with pytest.raises(RuntimeError):
deployer.activate_container(container_name, LanguageActivationLevel.System, False)
84 changes: 32 additions & 52 deletions test/integration/test_language_container_deployer_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from contextlib import ExitStack

from urllib.parse import urlparse
from _pytest.fixtures import FixtureRequest
from click.testing import CliRunner
from pyexasol import ExaConnection, ExaConnectionFailedError
from pytest_itde import config
Expand All @@ -11,6 +10,10 @@
from test.utils.db_utils import (create_schema, assert_udf_running)


TEST_SCHEMA = "PEC_DEPLOYER_TESTS_CLI"
TEST_LANGUAGE_ALIAS = "PYTHON3_PEC_TESTS_CLI"


def call_language_definition_deployer_cli(func,
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
Expand Down Expand Up @@ -56,104 +59,81 @@ def call_language_definition_deployer_cli(func,


def test_language_container_deployer_cli_with_container_file(
itde,
request: FixtureRequest,
itde: config.TestConfig,
connection_factory: Callable[[config.Exasol], ExaConnection],
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
container_path: str,
main_func
):
test_name: str = request.node.name
schema = test_name
language_alias = f"PYTHON3_PEC_{test_name.upper()}"
with ExitStack() as stack:
pyexasol_connection = stack.enter_context(connection_factory(exasol_config))
pyexasol_connection = stack.enter_context(connection_factory(itde.db))
stack.enter_context(revert_language_settings(pyexasol_connection))
create_schema(pyexasol_connection, schema)
create_schema(pyexasol_connection, TEST_SCHEMA)
result = call_language_definition_deployer_cli(main_func,
container_path=container_path,
language_alias=language_alias,
exasol_config=exasol_config,
bucketfs_config=bucketfs_config)
language_alias=TEST_LANGUAGE_ALIAS,
exasol_config=itde.db,
bucketfs_config=itde.bucketfs)
assert result.exit_code == 0
assert result.exception is None
assert result.stdout == ""
new_connection = stack.enter_context(connection_factory(exasol_config))
assert_udf_running(new_connection, language_alias, schema)
new_connection = stack.enter_context(connection_factory(itde.db))
assert_udf_running(new_connection, TEST_LANGUAGE_ALIAS, TEST_SCHEMA)


def test_language_container_deployer_cli_by_downloading_container(
itde,
request: FixtureRequest,
itde: config.TestConfig,
connection_factory: Callable[[config.Exasol], ExaConnection],
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
container_version,
container_version: str,
main_func
):
test_name: str = request.node.name
schema = test_name
language_alias = f"PYTHON3_PEC_{test_name.upper()}"
with ExitStack() as stack:
pyexasol_connection = stack.enter_context(connection_factory(exasol_config))
pyexasol_connection = stack.enter_context(connection_factory(itde.db))
stack.enter_context(revert_language_settings(pyexasol_connection))
create_schema(pyexasol_connection, schema)
create_schema(pyexasol_connection, TEST_SCHEMA)
result = call_language_definition_deployer_cli(main_func,
version=container_version,
language_alias=language_alias,
exasol_config=exasol_config,
bucketfs_config=bucketfs_config)
language_alias=TEST_LANGUAGE_ALIAS,
exasol_config=itde.db,
bucketfs_config=itde.bucketfs)
assert result.exit_code == 0
assert result.exception is None
assert result.stdout == ""
new_connection = stack.enter_context(connection_factory(exasol_config))
assert_udf_running(new_connection, language_alias, schema)
new_connection = stack.enter_context(connection_factory(itde.db))
assert_udf_running(new_connection, TEST_LANGUAGE_ALIAS, TEST_SCHEMA)


def test_language_container_deployer_cli_with_missing_container_option(
itde,
request: FixtureRequest,
itde: config.TestConfig,
connection_factory: Callable[[config.Exasol], ExaConnection],
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
main_func
):
test_name: str = request.node.name
language_alias = f"PYTHON3_PEC_{test_name.upper()}"
with ExitStack() as stack:
pyexasol_connection = stack.enter_context(connection_factory(exasol_config))
pyexasol_connection = stack.enter_context(connection_factory(itde.db))
stack.enter_context(revert_language_settings(pyexasol_connection))
result = call_language_definition_deployer_cli(main_func,
language_alias=language_alias,
bucketfs_config=bucketfs_config,
exasol_config=exasol_config)
language_alias=TEST_LANGUAGE_ALIAS,
bucketfs_config=itde.bucketfs,
exasol_config=itde.db)
assert result.exit_code == 1
assert isinstance(result.exception, ValueError)


def test_language_container_deployer_cli_with_check_cert(
itde,
request: FixtureRequest,
itde: config.TestConfig,
connection_factory: Callable[[config.Exasol], ExaConnection],
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
container_path: str,
main_func
):
expected_exception_message = '[SSL: CERTIFICATE_VERIFY_FAILED]'
test_name: str = request.node.name
schema = test_name
language_alias = f"PYTHON3_PEC_{test_name.upper()}"
with ExitStack() as stack:
pyexasol_connection = stack.enter_context(connection_factory(exasol_config))
pyexasol_connection = stack.enter_context(connection_factory(itde.db))
stack.enter_context(revert_language_settings(pyexasol_connection))
create_schema(pyexasol_connection, schema)
create_schema(pyexasol_connection, TEST_SCHEMA)
result = call_language_definition_deployer_cli(main_func,
container_path=container_path,
language_alias=language_alias,
exasol_config=exasol_config,
bucketfs_config=bucketfs_config,
language_alias=TEST_LANGUAGE_ALIAS,
exasol_config=itde.db,
bucketfs_config=itde.bucketfs,
use_ssl_cert_validation=True)
assert result.exit_code == 1
assert expected_exception_message in result.exception.args[0].message
Expand Down

0 comments on commit 4a00dc2

Please sign in to comment.