Let the image be responsible for running its own test, and simply listen for the output from the testsuite. Hook this up with a standard f30 image that contains a simple boot test case, using systemctl to verify that all services started correctly. This replaces the old web-server test, giving similar functionality. The reason for the change is twofold: this way the tests are fully specificed in the pipeline, so easier to reproduce. Moreover, this is less intrusive, as the test does not require network support in the image. Signed-off-by: Tom Gundersen <teg@jklm.no>
38 lines
1,019 B
Python
38 lines
1,019 B
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
|
|
output_image: str
|
|
test_cases: List[Callable[[Any], None]]
|
|
type: IntegrationTestType
|
|
|
|
def run(self):
|
|
run_osbuild(rel_path(f"pipelines/{self.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__)
|