Skip to content

Commit

Permalink
amended the integration tests without the container.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsimb committed Mar 22, 2024
1 parent c8c9129 commit f22628f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
24 changes: 12 additions & 12 deletions exasol/nb_connector/itde_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ def _get_ipv4_ddresses():

def is_itde_running(conf: Secrets) -> Tuple[bool, bool]:
"""
Checks if the ITDE container exists and if it is running. Returns the two boolean
flags - (exists, running).
Checks if the ITDE container exists and if it's running and ready to be called by the
AI-Lab container. Returns the two boolean flags - (exists, running).
The name of the container is taken from the provided secret store.
If the name cannot be found in the secret store the function returns False, False.
"""
Expand All @@ -156,21 +156,21 @@ def is_itde_running(conf: Secrets) -> Tuple[bool, bool]:
with ContextDockerClient() as docker_client:
if docker_client.containers.list(all=True, filters={"name": container_name}):
container = docker_client.containers.get(container_name)
# Here we use a slightly bloated definition of running - the ITDE should
# actually be running and the AI-Lab container should be connected to its
# network. That's because if the latter is not true we want the user to
# think the ITDE is stopped and call the :start_itde: function, which will
# connect the container to the network.
is_running = (container.status == 'running' and
_is_current_container_in_db_network(network_name))
return True, is_running
# The ITDE is ready when it is running and the AI-Lab container is connected
# to its network. If the latter is not true we expect the user to call the
# :start_itde: function, which will make sure the container is connected.
is_ready = (container.status == 'running' and
_is_current_container_in_db_network(network_name))
return True, is_ready
return False, False


def start_itde(conf: Secrets) -> None:
"""
Starts an existing ITDE container. If the container is already running the function
takes no effect. For this function to work the container must exist. If it doesn't
Starts an existing ITDE container if it's not already running and connects the
AI-Lab container to its network, unless it's already connected to it.
For this function to work the container must exist. If it doesn't
the docker.errors.NotFound exception will be raised. Use the is_itde_running
function to check if the container exists.
Expand Down
8 changes: 6 additions & 2 deletions test/integration/test_itde_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def test_itde_exists_and_running(secrets):
bring_itde_up(secrets)
itde_exists, itde_running = is_itde_running(secrets)
assert itde_exists
assert itde_running
# The non-existent AI-Lab container is not connected to the Docker DB network, so
# even if the ITDE is actually running, the returned running flag should still be False.
assert not itde_running
finally:
remove_itde()

Expand Down Expand Up @@ -108,7 +110,9 @@ def test_itde_start(secrets):
start_itde(secrets)
itde_exists, itde_running = is_itde_running(secrets)
assert itde_exists
assert itde_running
# The non-existent AI-Lab container is not connected to the Docker DB network, so
# even if the ITDE is actually running, the returned running flag should still be False.
assert not itde_running
finally:
remove_itde()

Expand Down

0 comments on commit f22628f

Please sign in to comment.