Skip to content

Commit

Permalink
test: add additional charm config
Browse files Browse the repository at this point in the history
  • Loading branch information
yanksyoon committed Mar 7, 2024
1 parent 4b43821 commit 0a08ace
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
5 changes: 4 additions & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from juju.model import Model
from pytest_operator.plugin import OpsTest

from charm_state import OPENSTACK_CLOUDS_YAML_CONFIG_NAME
from github_client import GithubClient
from tests.integration.helpers import (
deploy_github_runner_charm,
Expand Down Expand Up @@ -213,7 +214,7 @@ async def app_no_runner(


@pytest_asyncio.fixture(scope="module")
async def app_vm_runner(
async def app_openstack_runner(
model: Model,
charm_file: str,
app_name: str,
Expand All @@ -222,6 +223,7 @@ async def app_vm_runner(
http_proxy: str,
https_proxy: str,
no_proxy: str,
openstack_clouds_yaml: str,
) -> AsyncIterator[Application]:
"""Application launching VMs and no runners."""
application = await deploy_github_runner_charm(
Expand All @@ -241,6 +243,7 @@ async def app_vm_runner(
"mem": 16 * 1024,
"virt-type": "virtual-machine",
},
config={OPENSTACK_CLOUDS_YAML_CONFIG_NAME: openstack_clouds_yaml},
)
return application

Expand Down
18 changes: 12 additions & 6 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ async def deploy_github_runner_charm(
no_proxy: str,
reconcile_interval: int,
constraints: dict | None = None,
config: dict | None = None,
wait_idle: bool = True,
) -> Application:
"""Deploy github-runner charm.
Expand Down Expand Up @@ -355,19 +356,24 @@ async def deploy_github_runner_charm(
if runner_storage == "juju-storage":
storage["runner"] = {"pool": "rootfs", "size": 11}

application = await model.deploy(
charm_file,
application_name=app_name,
series="jammy",
config={
default_config = {
"path": path,
"token": token,
"virtual-machines": 0,
"denylist": "10.10.0.0/16",
"test-mode": "insecure",
"reconcile-interval": reconcile_interval,
"runner-storage": runner_storage,
},
}

if config:
default_config.update(config)

application = await model.deploy(
charm_file,
application_name=app_name,
series="jammy",
config=default_config,
constraints=constraints or DEFAULT_RUNNER_CONSTRAINTS,
storage=storage,
)
Expand Down
9 changes: 3 additions & 6 deletions tests/integration/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
from juju.model import Model
from openstack.compute.v2.server import Server

from charm_state import OPENSTACK_CLOUDS_YAML_CONFIG_NAME
from tests.integration.helpers import DISPATCH_E2E_TEST_RUN_WORKFLOW_FILENAME, dispatch_workflow


async def test_openstack_integration(
model: Model,
app_vm_runner: Application,
openstack_clouds_yaml: str,
app_openstack_runner: Application,
openstack_connection: openstack.connection.Connection,
github_repository: Repository,
test_github_branch: Branch,
Expand All @@ -34,12 +32,11 @@ async def test_openstack_integration(
1. the workflow run completes successfully.
2. a server with image name jammy is created.
"""
await app_vm_runner.set_config({OPENSTACK_CLOUDS_YAML_CONFIG_NAME: openstack_clouds_yaml})
await model.wait_for_idle(apps=[app_vm_runner.name], timeout=30 * 60)
await model.wait_for_idle(apps=[app_openstack_runner.name], timeout=30 * 60)

# 1. when the e2e_test_run workflow is created.
workflow = await dispatch_workflow(
app=app_vm_runner,
app=app_openstack_runner,
branch=test_github_branch,
github_repository=github_repository,
conclusion="success",
Expand Down

0 comments on commit 0a08ace

Please sign in to comment.