Skip to content

Commit

Permalink
Experimental refactor [run aws tests]
Browse files Browse the repository at this point in the history
  • Loading branch information
Shmuma committed Jun 19, 2024
1 parent 72f1e71 commit d12d089
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Optional
from pathlib import Path
from exasol.python_extension_common.deployment.language_container_deployer import LanguageContainerDeployer
import exasol.bucketfs as bfs


class SmeLanguageContainerDeployer(LanguageContainerDeployer):
Expand All @@ -17,6 +18,10 @@ def download_from_github_and_run(self, version: str,
alter_system=alter_system, allow_override=allow_override,
wait_for_completion=wait_for_completion)

@property
def bfs_path(self) -> bfs.path.PathLike:
return self._bucketfs_path

def run(self, container_file: Optional[Path] = None,
bucket_file_path: Optional[str] = None,
alter_system: bool = True,
Expand Down
30 changes: 20 additions & 10 deletions tests/ci_tests/fixtures/build_language_container_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import pytest
import subprocess
from typing import Tuple
from pathlib import Path
import pyexasol
import exasol_bucketfs_utils_python.upload as bfsupload
from exasol_bucketfs_utils_python.bucket_config import BucketConfig
from exasol_bucketfs_utils_python.bucketfs_config import BucketFSConfig
from exasol_bucketfs_utils_python.bucketfs_connection_config import \
BucketFSConnectionConfig

from tests.ci_tests.utils.parameters import db_params
from exasol_sagemaker_extension.deployment.sme_language_container_deployer import SmeLanguageContainerDeployer

from tests.ci_tests.utils.parameters import db_params, get_bfs_root_path


def find_script(script_name: str):
Expand All @@ -27,7 +31,7 @@ def find_script(script_name: str):


@pytest.fixture(scope="session")
def language_container():
def language_container() -> Tuple[Path, str]:
script_dir = find_script("build_language_container.sh")
completed_process = subprocess.run(
[script_dir], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Expand All @@ -46,11 +50,7 @@ def language_container():
container_path = \
[line for line in lines if line.startswith(container_path_selector)][0]
container_path = container_path[len(container_path_selector):]

return {
"container_path": container_path,
"alter_session": alter_session
}
return Path(container_path), alter_session


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -85,7 +85,17 @@ def upload_language_container(language_container, db_conn):
return alter_session


@pytest.fixture
def container_deployer(language_container, db_conn: pyexasol.ExaConnection) -> SmeLanguageContainerDeployer:
deployer = SmeLanguageContainerDeployer(
pyexasol_connection=db_conn,
language_alias='PYTHON3_TEST',
bucketfs_path=get_bfs_root_path(),
)
return deployer


@pytest.fixture(scope="session")
def register_language_container(upload_language_container, db_conn):
alter_session = upload_language_container
db_conn.execute(f"ALTER SYSTEM SET SCRIPT_LANGUAGES='{alter_session}'")
def register_language_container(language_container, container_deployer: SmeLanguageContainerDeployer, db_conn):
container_path, _ = language_container
container_deployer.run(container_path, alter_system=True)
15 changes: 15 additions & 0 deletions tests/ci_tests/utils/parameters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from collections import namedtuple
import exasol.bucketfs as bfs


POLLING_INTERVAL = 5 * 60 # seconds
TIMEOUT = 90 * 60 # seconds
Expand Down Expand Up @@ -41,3 +43,16 @@ def get_db_params():


db_params = get_db_params()


def get_bfs_root_path() -> bfs.path.PathLike:
root_path = bfs.path.build_path(
backend="onprem",
url=f"http://{db_params.host}:{db_params.port}",
username="w",
password="write",
bucket_name="bfsdefault",
verify=False,
)

return root_path

0 comments on commit d12d089

Please sign in to comment.