From db77b7ca38e2634c3b72ef959235c3d05a2351bb Mon Sep 17 00:00:00 2001 From: Adam Dyess Date: Thu, 25 Apr 2024 15:21:08 -0500 Subject: [PATCH] Use self-hosted runners (#59) * Use self-hosted runners * Drop application constraints when running on lxd --- .github/workflows/integration_test.yaml | 2 ++ tests/integration/conftest.py | 25 ++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration_test.yaml b/.github/workflows/integration_test.yaml index 647d6b5e..6e898deb 100644 --- a/.github/workflows/integration_test.yaml +++ b/.github/workflows/integration_test.yaml @@ -48,6 +48,8 @@ jobs: extra-arguments: ${{needs.extra-args.outputs.args}} -k test_${{ matrix.suite }} load-test-enabled: false zap-enabled: false + self-hosted-runner: true + self-hosted-runner-label: "large" trivy-fs-enabled: true trivy-image-config: "trivy.yaml" tmate-debug: true diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index b393833b..967a0893 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -174,17 +174,34 @@ def switch(self, name: str, path: Path): app["charm"] = str(path.resolve()) app["channel"] = None + def drop_constraints(self): + """Remove constraints on applications. Useful for testing on lxd.""" + for app in self.applications.values(): + app["constraints"] = None -async def cloud_profile(ops_test: OpsTest): - """Apply lxd-profile to the model if the juju cloud is lxd. + +async def cloud_type(ops_test: OpsTest): + """Return current cloud type of the selected controller Args: ops_test (OpsTest): ops_test plugin + + Returns: + string describing current type of the underlying cloud """ assert ops_test.model, "Model must be present" controller = await ops_test.model.get_controller() cloud = await controller.cloud() - if cloud.cloud.type_ == "lxd": + return cloud.cloud.type_ + + +async def cloud_profile(ops_test: OpsTest): + """Apply lxd-profile to the model if the juju cloud is lxd. + + Args: + ops_test (OpsTest): ops_test plugin + """ + if await cloud_type(ops_test) == "lxd" and ops_test.model: lxd = LXDSubstrate("", "") profile_name = f"juju-{ops_test.model.name}" lxd.remove_profile(profile_name) @@ -257,6 +274,8 @@ async def kubernetes_cluster(request: pytest.FixtureRequest, ops_test: OpsTest): *[charm.resolve(request.config.option.charm_files) for charm in charms] ) bundle = Bundle(ops_test, Path(__file__).parent / "data" / bundle_file) + if await cloud_type(ops_test) == "lxd": + bundle.drop_constraints() for path, charm in zip(charm_files, charms): bundle.switch(charm.app_name, path) async with deploy_model(request, ops_test, model, bundle, raise_on_blocked) as the_model: