The best practice for creating a pipeline should be to include at least one level of build-pipelines. This makes sure that the tools used to generate the target image are well-defined. In principle one could add several layers, though in pracite, one would hope that the envinment used to build the buildroot does not affect the final image (and as we anyway cannot recurr indefinitely, we fall back to simply using the host system in this case). This only makes sense, if the contents of the host system truly does not affect the generated image, and as such we do not include any information about the host when computing the hash that identifies a pipeline. In fact, any image could be used in its place, as long as the required tools are present. This commit takes advantage of that fact. Rather than run a pipeline with the host as the build root, take a second pipeline to generate the buildroot, but do not include this when computing the pipeline id (so it is different from simply editing the original JSON). This is necessary so we can use the same pipelines on significantly different host systems (run with different --bulid-pipeline arguments). In particular, it allows our test pipelines that generate f30 images to be run unmodified on Travis (which runs Ubuntu). Signed-off-by: Tom Gundersen <teg@jklm.no>
39 lines
1 KiB
Python
39 lines
1 KiB
Python
from dataclasses import dataclass
|
|
from enum import Enum
|
|
from typing import List, Callable, Any
|
|
|
|
from . import evaluate_test, rel_path
|
|
from .build import run_osbuild
|
|
from .run import run_image, extract_image
|
|
|
|
|
|
class IntegrationTestType(Enum):
|
|
EXTRACT=0
|
|
BOOT_WITH_QEMU=1
|
|
|
|
|
|
@dataclass
|
|
class IntegrationTestCase:
|
|
name: str
|
|
pipeline: str
|
|
build_pipeline: str
|
|
output_image: str
|
|
test_cases: List[Callable[[Any], None]]
|
|
type: IntegrationTestType
|
|
|
|
def run(self):
|
|
run_osbuild(rel_path(f"pipelines/{self.pipeline}"), self.build_pipeline)
|
|
if self.type == IntegrationTestType.BOOT_WITH_QEMU:
|
|
self.run_and_test()
|
|
else:
|
|
self.extract_and_test()
|
|
|
|
def run_and_test(self):
|
|
r = run_image(self.output_image)
|
|
for test in self.test_cases:
|
|
evaluate_test(test, r.stdout)
|
|
|
|
def extract_and_test(self):
|
|
with extract_image(self.output_image) as fstree:
|
|
for test in self.test_cases:
|
|
evaluate_test(lambda: test(fstree), name=test.__name__)
|