Skip to content

Commit

Permalink
Added a dummy DummyExecFactory.
Browse files Browse the repository at this point in the history
In case of using an external DB for the RunDbTest command, the task SpawnTestEnvironment does not return a valid `container_info` for the Database (which makes totally sense because the external db can be a None-Docker Exasol DB). However, also the using `SshExecFactory` does not work because the user/pwd are not returned from SpawnTestEnvironment.
=> Added a DummyExecFactory which implements the interface but does nothing and throws an exception in case the `exec` function gets invoked.
  • Loading branch information
tomuben committed May 20, 2024
1 parent 6ef3807 commit bce4219
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from exasol_integration_test_docker_environment.lib.api.common import run_task, generate_root_task, \
set_docker_repository_config, set_build_config, import_build_steps, cli_function
from exasol_integration_test_docker_environment.lib.base.dependency_logger_base_task import DependencyLoggerBaseTask
from exasol_integration_test_docker_environment.lib.test_environment.parameter.docker_db_test_environment_parameter import \
DbOsAccess

from exasol_script_languages_container_tool.lib.api import api_errors
from exasol_script_languages_container_tool.lib.tasks.test.test_container import TestContainer, AllTestsResult
Expand Down Expand Up @@ -126,6 +128,7 @@ def root_task_generator() -> DependencyLoggerBaseTask:
reuse_database_setup=reuse_database_setup,
reuse_test_container=reuse_test_container,
reuse_database=reuse_database,
db_os_access=DbOsAccess[db_os_access],
no_test_container_cleanup_after_success=reuse_test_container,
no_test_container_cleanup_after_failure=reuse_test_container,
no_database_cleanup_after_success=reuse_database,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from typing import Generator, Any, Dict

import luigi
from docker.models.containers import ExecResult
from exasol_integration_test_docker_environment.lib.base.db_os_executor import DbOsExecFactory, SshExecFactory, \
DockerClientFactory, DockerExecFactory
DockerClientFactory, DockerExecFactory, DbOsExecutor
from exasol_integration_test_docker_environment.lib.base.json_pickle_parameter import JsonPickleParameter
from exasol_integration_test_docker_environment.lib.data.database_info import DatabaseInfo
from exasol_integration_test_docker_environment.lib.test_environment.parameter.docker_db_test_environment_parameter import \
Expand All @@ -26,6 +27,26 @@
from exasol_integration_test_docker_environment.lib.test_environment.spawn_test_environment import SpawnTestEnvironment


class DummyExecutor(DbOsExecutor):

def exec(self, cmd: str) -> ExecResult:
raise RuntimeError("Not supposed to be called.")

def prepare(self):
pass

def __enter__(self):
return self

def __exit__(self, type_, value, traceback):
pass


class DummyExecFactory(DbOsExecFactory):
def executor(self) -> DbOsExecutor:
return DummyExecutor()


class TestRunnerDBTestTask(FlavorBaseTask,
SpawnTestEnvironmentParameter,
RunDBTestsInTestConfigParameter):
Expand Down Expand Up @@ -71,10 +92,13 @@ def run_task(self):
self.return_object(test_results)

def _executor_factory(self, database_info: DatabaseInfo) -> DbOsExecFactory:

if self.db_os_access == DbOsAccess.SSH:
return SshExecFactory.from_database_info(database_info)
client_factory = DockerClientFactory(timeout=100000)
return DockerExecFactory(database_info.container_info.container_name, client_factory)
if database_info.container_info is not None:
return DockerExecFactory(database_info.container_info.container_name, client_factory)
return DummyExecFactory()

def upload_container(self, database_credentials: DatabaseCredentials, export_info: ExportInfo):
reuse = \
Expand Down

0 comments on commit bce4219

Please sign in to comment.