Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/e2e_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
juju-channel: 3.6/stable
provider: lxd
test-tox-env: integration-juju3.6
Comment thread
cbartz marked this conversation as resolved.
test-tox-env: integration
modules: '["test_e2e"]'
# INTEGRATION_TOKEN, OS_PASSWORD, GITHUB_APP_INSTALLATION_ID,
# GITHUB_APP_PRIVATE_KEY are passed through
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
juju-channel: 3.6/stable
provider: lxd
test-tox-env: integration-juju3.6
test-tox-env: integration
modules: '["test_multi_unit_same_machine", "test_charm_fork_path_change", "test_charm_no_runner", "test_charm_upgrade"]'
# INTEGRATION_TOKEN, INTEGRATION_TOKEN_ALT, OS_* are passed through INTEGRATION_TEST_SECRET_ENV_VALUE_<N>
# mapping. See CONTRIBUTING.md for more details.
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
juju-channel: 3.6/stable
pre-run-script: tests/integration/setup-integration-tests.sh
provider: lxd
test-tox-env: integration-juju3.6
test-tox-env: integration
modules: '["test_prometheus_metrics"]'
# INTEGRATION_TOKEN, INTEGRATION_TOKEN_ALT, OS_* are passed through INTEGRATION_TEST_SECRET_ENV_VALUE_<N>
# mapping. See CONTRIBUTING.md for more details.
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
charmcraft-channel: latest/stable
juju-channel: 3.6/stable
provider: lxd
test-tox-env: integration-juju3.6
test-tox-env: integration
modules: '["test_charm_runner"]'
extra-arguments: |
-m=openstack \
Expand Down
39 changes: 39 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import os

import pytest
from pytest import Parser


Expand Down Expand Up @@ -184,3 +185,41 @@ def pytest_addoption(parser: Parser):
help="The GitHub App PEM-encoded private key for GitHub App authentication testing.",
default=os.environ.get("GITHUB_APP_PRIVATE_KEY"),
)
parser.addoption(
"--keep-models",
action="store_true",
default=False,
help="Keep temporary Juju models after test runs.",
)


def pytest_configure(config: pytest.Config):
"""Register custom markers.

Args:
config: The pytest Config object.
"""
config.addinivalue_line("markers", "abort_on_fail: skip remaining tests after a failure")


def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo):
"""Record abort_on_fail failures so subsequent tests in the module are skipped.

Args:
item: The test item.
call: The test call info.
"""
if call.when == "call" and call.excinfo is not None:
if any(item.iter_markers("abort_on_fail")):
item.session._abort_on_fail_module = item.module # type: ignore[attr-defined]


def pytest_runtest_setup(item: pytest.Item):
"""Skip tests if a prior abort_on_fail test in the same module failed.

Args:
item: The test item.
"""
failed_mod = getattr(item.session, "_abort_on_fail_module", None)
if failed_mod is not None and getattr(item, "module", None) is failed_mod:
pytest.skip("skipped: prior abort_on_fail test failed")
Comment thread
cbartz marked this conversation as resolved.
Loading
Loading