Skip to content

Commit

Permalink
Fixed itde_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
ckunki committed Oct 22, 2024
1 parent 2d2a140 commit d5650f8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion exasol/nb_connector/itde_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def restart_itde(conf: Secrets) -> None:
container = docker_client.containers.get(container_name)
container.start()

if not ItdeContainerStatus.VISIBLE not in status: # type: ignore[operator]
if ItdeContainerStatus.VISIBLE not in status: # type: ignore[operator]
network_name = conf.get(AILabConfig.itde_network)
if network_name:
_add_current_container_to_db_network(network_name)
Expand Down
29 changes: 25 additions & 4 deletions test/integration/test_itde_manager_in_docker_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def dockerfile_content() -> str:
return cleandoc(
"""
FROM ubuntu:22.04
RUN apt-get update
RUN apt-get install --yes --no-install-recommends python3 python3-pip git
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install --upgrade pip
"""
)

Expand Down Expand Up @@ -224,7 +224,7 @@ def run_test():

restart_itde(secrets)
status = get_itde_status(secrets)
assert status is ItdeContainerStatus.READY, f'The status after restarting ITDE is {status.name}'
assert status is ItdeContainerStatus.RUNNING, f'The status after restarting ITDE is {status.name}'

function_source_code = textwrap.dedent(dill.source.getsource(run_test))
source_code = f"{function_source_code}\nrun_test()"
Expand Down Expand Up @@ -325,8 +325,29 @@ def test_itde_recreation_without_take_down(docker_container):
assert exec_result.exit_code == 0, exec_result.output


_IGNORE_WARNINGS1 = (
'-W "ignore::DeprecationWarning:luigi.*:" '
'-W "ignore::DeprecationWarning:pkg_resources.*:" '
'-W "ignore:pkg_resources is deprecated as an API:DeprecationWarning" '
'-W "ignore::DeprecationWarning:exasol_integration_test_docker_environment.*:"'
)


_IGNORE_WARNINGS = " ".join(
f'-W "ignore:{w}"' for w in [
":DeprecationWarning:luigi.*:",
":DeprecationWarning:pkg_resources.*:",
"pkg_resources is deprecated as an API:DeprecationWarning",
":DeprecationWarning:exasol_integration_test_docker_environment.*:",
])


def test_x1():
print(f'{_IGNORE_WARNINGS}')
assert _IGNORE_WARNINGS == _IGNORE_WARNINGS1

def test_itde_stop_and_restart(docker_container):
exec_result = docker_container.exec_run("python3 /tmp/itde_stop_and_restart.py")
exec_result = docker_container.exec_run(f"python3 {_IGNORE_WARNINGS} /tmp/itde_stop_and_restart.py")
assert exec_result.exit_code == 0, exec_result.output


Expand Down
2 changes: 2 additions & 0 deletions test/unit/test_container_by_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def create_container_mock(networks: Dict[str, str]) -> Union[MagicMock, Containe


class TestSetup:
__test__ = False

def __init__(self, containers: Dict[str, Dict[str, str]]):
self.docker_client_mock, self.container_mocks = create_docker_client_mock(containers)
self.container_by_ip = ContainerByIp(
Expand Down

0 comments on commit d5650f8

Please sign in to comment.