Skip to content

Commit

Permalink
Use self-hosted runners (#59)
Browse files Browse the repository at this point in the history
* Use self-hosted runners
* Drop application constraints when running on lxd
  • Loading branch information
addyess authored Apr 25, 2024
1 parent d5ddc02 commit db77b7c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 22 additions & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit db77b7c

Please sign in to comment.