Skip to content

Commit

Permalink
Quick skip validation test if models mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Aug 19, 2024
1 parent 45b61c6 commit 1cef38a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
33 changes: 13 additions & 20 deletions jobs/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions jobs/integration/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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"""
Expand Down

0 comments on commit 1cef38a

Please sign in to comment.