diff --git a/jobs/integration/conftest.py b/jobs/integration/conftest.py index 4db8730f0..64ce44619 100644 --- a/jobs/integration/conftest.py +++ b/jobs/integration/conftest.py @@ -343,7 +343,8 @@ async def model(request, tools): @pytest.fixture(scope="module") -async def k8s_cloud(kubeconfig, tools): +@pytest.mark.usefixtures("kubeconfig") +async def k8s_cloud(tools): clouds = await tools.run( "juju", "clouds", "--format", "yaml", "-c", tools.controller_name ) @@ -430,19 +431,6 @@ async def k8s_model(k8s_cloud, tools): ) -@pytest.fixture -def system_arch(): - return arch - - -@pytest.fixture(autouse=True) -def skip_by_arch(request, system_arch): - """Skip tests on specified arches""" - if request.node.get_closest_marker("skip_arch"): - if system_arch in request.node.get_closest_marker("skip_arch").args[0]: - pytest.skip("skipped on this arch: {}".format(system_arch)) - - @pytest.fixture(scope="module") async def proxy_app(model): proxy_app = model.applications.get("squid-forwardproxy") @@ -502,14 +490,15 @@ def _apps_by_charm(charm): return _apps_by_charm -@pytest.fixture(autouse=True) -def skip_by_model(request, model): +def skip_by_model(item) -> bool: """Skips tests if model isn't referenced, ie validate-vault for only running tests applicable to vault """ - if request.node.get_closest_marker("on_model"): - if request.node.get_closest_marker("on_model").args[0] not in model.info.name: - pytest.skip("skipped on this model: {}".format(model.info.name)) + model_name = item.config.getoption("--model") + on_models = [mark.args[0] for mark in item.iter_markers(name="on_model")] + if on_models: + if model_name not in on_models: + pytest.skip(f"skipped on this model: {model_name!r}") @pytest.fixture @@ -574,7 +563,6 @@ async def addons_model(request): model_name = request.config.getoption("--addons-model") if not model_name: pytest.skip("--addons-model not specified") - return model = Model() await model.connect(controller_name + ":" + model_name) yield model @@ -719,6 +707,11 @@ def pytest_metadata(metadata): ) +def pytest_runtest_setup(item): + """Called to perform the setup phase for a test item.""" + skip_by_model(item) # skip tests if model marking on test mismatches + + @pytest.fixture(scope="module") async def kubeconfig(model): control_planes = model.applications["kubernetes-control-plane"].units diff --git a/jobs/integration/validation.py b/jobs/integration/validation.py index 374494cda..1abd64016 100644 --- a/jobs/integration/validation.py +++ b/jobs/integration/validation.py @@ -1586,7 +1586,6 @@ async def test_storage_class(self, model, log_open, storage_class): await validate_storage_class(model, storage_class, "Ceph", **kwds) -@pytest.mark.skip_arch(["aarch64"]) @pytest.mark.clouds(["ec2", "vsphere"]) async def test_keystone(model, keystone_deployment): control_plane = model.applications["kubernetes-control-plane"] @@ -1629,7 +1628,6 @@ async def test_keystone(model, keystone_deployment): assert output.code == 0, output.stderr -@pytest.mark.skip_arch(["aarch64"]) @pytest.mark.on_model("validate-vault") async def test_encryption_at_rest(model, tools): """Testing integrating vault secrets into cluster"""