-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Environment preparation for module testing
This change uses containerfile for building container images with the local changes of autils for testing. This approach will help us to use containers for running selftests in different environments. Since autils uses only redhat based containers, we use on container file for removing duplicities and the actual system version is imported during the runtime. This solution supports multiple containerfiles in case that we will add different types of systems. The build procedure uses the `--no-cache` flag to ensure that we always test the latest changes. As a downside to this is that the images needs to be always built which increases the test runtime. Signed-off-by: Jan Richter <[email protected]>
- Loading branch information
Showing
3 changed files
with
31 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM centos:stream9 | ||
WORKDIR /home/autils | ||
COPY ./ ./ | ||
RUN dnf install -y git | ||
RUN python3 -m ensurepip && python3 -m pip install . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import asyncio | ||
import os | ||
import sys | ||
|
||
import yaml | ||
from avocado.core.job import Job | ||
from avocado.core.suite import TestSuite | ||
from avocado.utils.podman import Podman | ||
|
||
CONTAINER_IMAGE_MAPPING = { | ||
"CentOS Stream 9": "centos:stream9", | ||
"Fedora 36": "fedora:36", | ||
"Fedora 37": "fedora:37", | ||
"CentOS Stream 9": ("redhat_based", "centos:stream9"), | ||
"Fedora 36": ("redhat_based", "fedora:36"), | ||
"Fedora 37": ("redhat_based", "fedora:37"), | ||
} | ||
|
||
METADATA_PATH = sys.argv[1] | ||
with open(METADATA_PATH, "rb") as m: | ||
metadata = yaml.load(m, Loader=yaml.SafeLoader) | ||
|
||
images = [] | ||
test_suites = [] | ||
for platform in metadata["supported_platforms"]: | ||
name = platform.replace(" ", "_") | ||
image = CONTAINER_IMAGE_MAPPING.get(platform) | ||
containerfile, image_version = CONTAINER_IMAGE_MAPPING.get(platform) | ||
loop = asyncio.get_event_loop() | ||
_, result, _ = loop.run_until_complete(Podman().execute( | ||
"build", | ||
"--no-cache", | ||
"--from", | ||
image_version, | ||
"-f", | ||
os.path.join("tests", "containerfiles", containerfile), | ||
".", | ||
)) | ||
image = result.splitlines()[-1].decode() | ||
images.append(image) | ||
config = {"run.spawner": "podman", "spawner.podman.image": image} | ||
|
||
config["resolver.references"] = metadata["tests"] | ||
test_suites.append(TestSuite.from_config(config, name)) | ||
|
||
|
||
with Job(test_suites=test_suites) as j: | ||
sys.exit(j.run()) | ||
rc = j.run() | ||
for image in images: | ||
loop.run_until_complete(Podman().execute("image", "rm", "-f", image)) | ||
sys.exit(rc) |