Skip to content

Commit ca0ee81

Browse files
Use latest image-builder with external build (#444)
1 parent 5e348d5 commit ca0ee81

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

tests/integration/conftest.py

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,43 +321,70 @@ async def app_no_runner(
321321
yield basic_app
322322

323323

324+
@pytest_asyncio.fixture(scope="module")
325+
async def openstack_model_proxy(
326+
openstack_http_proxy: str,
327+
openstack_https_proxy: str,
328+
openstack_no_proxy: str,
329+
model: Model,
330+
) -> None:
331+
await model.set_config(
332+
{
333+
"juju-http-proxy": openstack_http_proxy,
334+
"juju-https-proxy": openstack_https_proxy,
335+
"juju-no-proxy": openstack_no_proxy,
336+
"logging-config": "<root>=INFO;unit=DEBUG",
337+
}
338+
)
339+
340+
324341
@pytest_asyncio.fixture(scope="module", name="image_builder")
325342
async def image_builder_fixture(
326343
model: Model,
327344
private_endpoint_config: PrivateEndpointConfigs | None,
328345
existing_app: Optional[str],
346+
flavor_name: str,
347+
network_name: str,
348+
openstack_model_proxy: None,
349+
openstack_connection,
329350
):
330351
"""The image builder application for OpenStack runners."""
331352
if not private_endpoint_config:
332353
raise ValueError("Private endpoints are required for testing OpenStack runners.")
333354
if not existing_app:
355+
application_name = f"github-runner-image-builder-{''.join(random.choices(string.ascii_lowercase + string.digits, k=8))}"
334356
app = await model.deploy(
335357
"github-runner-image-builder",
358+
application_name=application_name,
336359
channel="latest/edge",
337-
revision=2,
338-
constraints="cores=2 mem=2G root-disk=20G virt-type=virtual-machine",
360+
revision=55,
339361
config={
340-
"app-channel": "edge",
341362
"build-interval": "12",
342-
# There are several tests running simulteously, all with the same images.
343-
# Until we update the image-builder to create different names for the images,
344-
# the history limit should be big enough so that tests do not interfere.
345-
"revision-history-limit": "15",
363+
"revision-history-limit": "2",
346364
"openstack-auth-url": private_endpoint_config["auth_url"],
347365
# Bandit thinks this is a hardcoded password
348366
"openstack-password": private_endpoint_config["password"], # nosec: B105
349367
"openstack-project-domain-name": private_endpoint_config["project_domain_name"],
350368
"openstack-project-name": private_endpoint_config["project_name"],
351369
"openstack-user-domain-name": private_endpoint_config["user_domain_name"],
352370
"openstack-user-name": private_endpoint_config["username"],
371+
"experimental-external-build": "true",
372+
"experimental-external-build-flavor": flavor_name,
373+
"experimental-external-build-network": network_name,
353374
},
354375
)
355376
await model.wait_for_idle(
356-
apps=[app.name], wait_for_active=True, timeout=IMAGE_BUILDER_DEPLOY_TIMEOUT_IN_SECONDS
377+
apps=[app.name], status="blocked", timeout=IMAGE_BUILDER_DEPLOY_TIMEOUT_IN_SECONDS
357378
)
358379
else:
359380
app = model.applications["github-runner-image-builder"]
360-
return app
381+
yield app
382+
# The github-image-builder does not clean keypairs. Until it does,
383+
# we clean them manually here.
384+
for key in openstack_connection.list_keypairs():
385+
key_name: str = key.name
386+
if key_name.startswith(application_name):
387+
openstack_connection.delete_keypair(key_name)
361388

362389

363390
@pytest_asyncio.fixture(scope="module", name="app_openstack_runner")

0 commit comments

Comments
 (0)