Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests/revise flaky lifecycle test #101

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
This is the test module for the project's command-line interface (CLI)
module.
"""
import logging

import docker
import pytest
from click.testing import CliRunner, Result
Expand Down Expand Up @@ -163,7 +165,9 @@ def test_remove_running_profile(self):
@pytest.mark.slow
@pytest.mark.trylast
class TestInstanceLifecycle:
def test_start_stop_reset(self, instance, docker_client):
def test_start_stop_reset(self, instance, docker_client, caplog):
caplog.set_level(logging.DEBUG)

def get_volume(volume_name):
try:
return docker_client.volumes.get(volume_name)
Expand All @@ -186,29 +190,29 @@ def assert_status_down():

# Start instance.
runner: CliRunner = CliRunner()
result: Result = runner.invoke(
cli.cli, ["-vvv", "start", "--no-browser", "--wait=300"]
)
result: Result = runner.invoke(cli.cli, ["start", "--no-browser", "--wait=300"])
assert result.exit_code == 0

assert_status_up()
assert get_volume(instance.profile.home_mount)
assert get_volume(instance.profile.conda_volume_name())

# Start instance again – should be noop.
result: Result = runner.invoke(
cli.cli, ["-vvv", "start", "--no-browser", "--wait=300"]
)
result: Result = runner.invoke(cli.cli, ["start", "--no-browser", "--wait=300"])
assert "Container was already running" in result.output.strip()
assert result.exit_code == 0
assert_status_up()

# Restart instance.
result: Result = runner.invoke(
cli.cli, ["-vvv", "start", "--no-browser", "--wait=600", "--restart"]
)
assert result.exit_code == 0
assert_status_up()
# TODO: This test is currently disabled, because it is too flaky. For
# a currently unknown reason, the docker client will not be able to
# reach the container anymore to check whether the notebook server is
# online.
# result: Result = runner.invoke(
# cli.cli, ["start", "--no-browser", "--wait=120", "--restart"]
# )
# assert result.exit_code == 0
# assert_status_up()

# Stop (and remove) instance.
result: Result = runner.invoke(cli.cli, ["stop", "--remove"])
Expand Down