Skip to content

Commit

Permalink
tests: mark slow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lengau committed Jan 29, 2025
1 parent 64c4cef commit 46f6aa2
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/integration/git/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from craft_application.git import NO_PUSH_URL, Commit, GitError, GitRepo


@pytest.mark.slow
def test_fetching_hello_repository(
empty_repository: pathlib.Path,
hello_repository_lp_url: str,
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/launchpad/test_anonymous_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from craft_application import launchpad


@pytest.mark.slow
@pytest.mark.parametrize(
"root",
[
Expand Down Expand Up @@ -46,6 +47,7 @@ def test_anonymous_login(tmp_path, root):
# assert recipe.owner_name == "lengau"


@pytest.mark.slow
@pytest.mark.parametrize(
("name", "path"),
[
Expand All @@ -60,6 +62,7 @@ def test_get_real_repository_by_path(anonymous_lp, name, path):
assert repo.name == name


@pytest.mark.slow
@pytest.mark.parametrize(
("name", "owner", "project"),
[
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/services/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ def app_service(app_metadata, fake_services, fake_project, fake_build_plan):
fetch_service.shutdown(force=True)


@pytest.mark.slow
def test_start_service(app_service):
assert not fetch.is_service_online()
app_service.setup()
assert fetch.is_service_online()


@pytest.mark.slow
def test_start_service_already_up(app_service, request):
# Create a fetch-service "manually"
fetch_process = fetch.start_service()
Expand All @@ -122,6 +124,7 @@ def test_start_service_already_up(app_service, request):
fetch._DEFAULT_CONFIG.proxy,
],
)
@pytest.mark.slow
def test_start_service_port_taken(app_service, request, port):
# "Occupy" one of the necessary ports manually.
soc = socket.create_server(("localhost", port), reuse_port=True)
Expand All @@ -137,6 +140,7 @@ def test_start_service_port_taken(app_service, request, port):
app_service.setup()


@pytest.mark.slow
def test_shutdown_service(app_service):
assert not fetch.is_service_online()

Expand All @@ -153,6 +157,7 @@ def test_shutdown_service(app_service):
assert not fetch.is_service_online()


@pytest.mark.slow
def test_create_teardown_session(
app_service, mocker, tmp_path, monkeypatch, mock_instance
):
Expand All @@ -171,6 +176,7 @@ def test_create_teardown_session(
assert "artifacts" in report


@pytest.mark.slow
def test_service_logging(app_service, mocker, tmp_path, monkeypatch, mock_instance):
monkeypatch.chdir(tmp_path)
mocker.patch.object(fetch, "_get_gateway", return_value="127.0.0.1")
Expand Down Expand Up @@ -270,6 +276,7 @@ def lxd_instance(snap_safe_tmp_path, provider_service):
executor.delete()


@pytest.mark.slow
def test_build_instance_integration(
app_service,
lxd_instance,
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/services/test_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def parts_lifecycle(
return service


@pytest.mark.slow
def test_run_and_clean_all_parts(parts_lifecycle, emitter, check, tmp_path):
parts_lifecycle.run("prime")

Expand All @@ -67,6 +68,7 @@ def test_run_and_clean_all_parts(parts_lifecycle, emitter, check, tmp_path):
pytest_check.is_false([*(tmp_path / "work").iterdir()])


@pytest.mark.slow
def test_run_and_clean_my_part(parts_lifecycle, emitter, check):
parts_lifecycle.run("prime", ["my-part"])

Expand All @@ -81,6 +83,7 @@ def test_run_and_clean_my_part(parts_lifecycle, emitter, check):
emitter.assert_progress("Cleaning parts: my-part")


@pytest.mark.slow
def test_lifecycle_messages_no_duplicates(parts_lifecycle, request, capsys):
if request.node.callspec.id != "basic":
pytest.skip("Hardcoded expected output assumes 'basic' lifecycle parts.")
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/services/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
# This is due to an upstream LXD bug that appears to still be present in LXD 5.14:
# https://github.com/lxc/lxd/issues/11422
@pytest.mark.flaky(reruns=3, reruns_delay=2)
@pytest.mark.slow
def test_provider_lifecycle(
snap_safe_tmp_path, app_metadata, provider_service, name, base_name
):
Expand Down Expand Up @@ -95,6 +96,7 @@ def test_provider_lifecycle(
],
)
@pytest.mark.parametrize("provider_name", [pytest.param("lxd", marks=pytest.mark.lxd)])
@pytest.mark.slow
def test_proxy_variables_forwarded(
monkeypatch, snap_safe_tmp_path, provider_service, base, proxy_vars, provider_name
):
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/services/test_remotebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ def public_project_name(request):
return request.param


@pytest.mark.slow
def test_use_public_project(anonymous_remote_build_service, public_project_name):
"""Test that we can get a real (public) project using an anonymous client."""
anonymous_remote_build_service.set_project(public_project_name)

assert anonymous_remote_build_service._lp_project.name == public_project_name


@pytest.mark.slow
def test_error_with_nonexistent_project(anonymous_remote_build_service):
"""Test failing gracefully with a nonexistent project."""
name = "this launchpad project does not exist!"
Expand All @@ -42,6 +44,7 @@ def test_error_with_nonexistent_project(anonymous_remote_build_service):
anonymous_remote_build_service.set_project(name)


@pytest.mark.slow
def test_project_is_public(anonymous_remote_build_service, public_project_name):
"""Test that the given project is public."""
anonymous_remote_build_service.set_project(public_project_name)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/services/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
)
],
)
@pytest.mark.slow
def test_get_real_file(tmp_path, emitter, request_service, url, checksum, size):
result = request_service.download_with_progress(url, tmp_path)
actual_hash = hashlib.sha256(result.read_bytes()).hexdigest()
Expand Down Expand Up @@ -61,6 +62,7 @@ def test_get_real_file(tmp_path, emitter, request_service, url, checksum, size):
},
],
)
@pytest.mark.slow
def test_get_real_files(tmp_path, request_service, files):
result = request_service.download_files_with_progress({f: tmp_path for f in files})

Expand Down
5 changes: 5 additions & 0 deletions tests/integration/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def test_registering_new_commands(

@pytest.mark.usefixtures("pretend_jammy")
@pytest.mark.parametrize("project", (d.name for d in VALID_PROJECTS_DIR.iterdir()))
@pytest.mark.slow
def test_project_managed(capsys, monkeypatch, tmp_path, project, create_app):
monkeypatch.setenv("CRAFT_DEBUG", "1")
monkeypatch.setenv("CRAFT_MANAGED_MODE", "1")
Expand All @@ -197,6 +198,7 @@ def test_project_managed(capsys, monkeypatch, tmp_path, project, create_app):

@pytest.mark.usefixtures("full_build_plan", "pretend_jammy")
@pytest.mark.parametrize("project", (d.name for d in VALID_PROJECTS_DIR.iterdir()))
@pytest.mark.slow
def test_project_destructive(
capsys,
monkeypatch,
Expand Down Expand Up @@ -331,6 +333,7 @@ def test_invalid_command_argument(monkeypatch, capsys, app):
["--platform", "my-platform"],
],
)
@pytest.mark.slow
def test_global_environment(
arguments,
create_app,
Expand Down Expand Up @@ -428,6 +431,7 @@ def _inner():

@pytest.mark.usefixtures("pretend_jammy")
@pytest.mark.enable_features("build_secrets")
@pytest.mark.slow
def test_build_secrets_destructive(
monkeypatch, setup_secrets_project, check_secrets_output
):
Expand All @@ -445,6 +449,7 @@ def test_build_secrets_destructive(

@pytest.mark.usefixtures("pretend_jammy")
@pytest.mark.enable_features("build_secrets")
@pytest.mark.slow
def test_build_secrets_managed(
monkeypatch, tmp_path, setup_secrets_project, check_secrets_output
):
Expand Down
1 change: 1 addition & 0 deletions tests/unit/commands/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_remote_build_no_accept_upload(remote_build, mocker):
assert remote_build.run(parsed_args) == 77


@pytest.mark.slow
def test_remote_build_run(remote_build, mocker, fake_services, tmp_path, emitter):
builder = fake_services.remote_build

Expand Down

0 comments on commit 46f6aa2

Please sign in to comment.