-
Notifications
You must be signed in to change notification settings - Fork 80
test: cross arch build/boot smoke test for ppc64le,s390x #2069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,11 +26,12 @@ func u(s string) string { | |
|
|
||
| func run() error { | ||
| // common args | ||
| var outputDir, osbuildStore, rpmCacheRoot, repositories string | ||
| var outputDir, osbuildStore, rpmCacheRoot, repositories, archName string | ||
| flag.StringVar(&outputDir, "output", ".", "artifact output directory") | ||
| flag.StringVar(&osbuildStore, "store", ".osbuild", "osbuild store for intermediate pipeline trees") | ||
| flag.StringVar(&rpmCacheRoot, "rpmmd", "/tmp/rpmmd", "rpm metadata cache directory") | ||
| flag.StringVar(&repositories, "repositories", "test/data/repositories", "path to repository file or directory") | ||
| flag.StringVar(&archName, "arch", "", "target architecture") | ||
|
|
||
| // osbuild checkpoint arg | ||
| var checkpoints cmdutil.MultiValue | ||
|
|
@@ -64,8 +65,10 @@ func run() error { | |
| return fmt.Errorf("invalid or unsupported distribution: %q", distroName) | ||
| } | ||
|
|
||
| archName := arch.Current().String() | ||
| arch, err := distribution.GetArch(archName) | ||
| if archName == "" { | ||
| archName = arch.Current().String() | ||
| } | ||
| archi, err := distribution.GetArch(archName) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: I don't have any problem with the rename of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its needed because we also import |
||
| if err != nil { | ||
| return fmt.Errorf("invalid arch name %q for distro %q: %w", archName, distroName, err) | ||
| } | ||
|
|
@@ -76,7 +79,7 @@ func run() error { | |
| return fmt.Errorf("failed to create target directory: %w", err) | ||
| } | ||
|
|
||
| imgType, err := arch.GetImageType(imgTypeName) | ||
| imgType, err := archi.GetImageType(imgTypeName) | ||
| if err != nil { | ||
| return fmt.Errorf("invalid image type %q for distro %q and arch %q: %w", imgTypeName, distroName, archName, err) | ||
| } | ||
|
|
@@ -109,6 +112,9 @@ func run() error { | |
| OverrideRepos: overrideRepos, | ||
| CustomSeed: &seedArg, | ||
| } | ||
| if archName != arch.Current().String() { | ||
| manifestOpts.UseBootstrapContainer = true | ||
| } | ||
| // add RHSM fact to detect changes | ||
| config.Options.Facts = &facts.ImageOptions{ | ||
| APIType: facts.TEST_APITYPE, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import os | ||
| import platform | ||
| import re | ||
| import shutil | ||
| import subprocess | ||
|
|
||
| import pytest | ||
| import scripts.imgtestlib as testlib | ||
|
|
||
| if os.getuid() != 0: | ||
| pytest.skip(reason="need root to build the images", allow_module_level=True) | ||
|
|
||
|
|
||
| @pytest.mark.images_integration | ||
| @pytest.mark.parametrize("arch", ["ppc64le", "s390x"]) | ||
| def test_build_boot_cross_arch_smoke(arch): | ||
| if arch == "s390x": | ||
| output = subprocess.check_output(["qemu-s390x-static", "--version"], text=True) | ||
| m = re.match(r'(?m).*version ([0-9]+)\.([0-9]+)\.([0-9]+)', output) | ||
| major, minor, patch = m.group(1, 2, 3) | ||
| if not (int(major) >= 10 and int(minor) >= 1 and int(patch) >= 91): | ||
| pytest.skip("need qemu-user >= 10.2 to run s390x builds") | ||
|
|
||
| # very minimal as this just a smoke test | ||
| distro = "centos-10" | ||
| image_type = "qcow2" | ||
| config_name = "empty" | ||
| subprocess.check_call( | ||
| ["./test/scripts/build-image", f"--arch={arch}", distro, image_type, f"test/configs/{config_name}.json"]) | ||
| build_dir = os.path.join("build", testlib.gen_build_name(distro, arch, image_type, config_name)) | ||
| subprocess.check_call( | ||
| ["./test/scripts/boot-image", build_dir]) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,8 +151,7 @@ def find_ovmf(): | |
|
|
||
|
|
||
| class QEMU(VM): | ||
|
|
||
| def __init__(self, img, arch="", snapshot=True, cdrom=None, extra_args=None, memory="2000"): | ||
| def __init__(self, img, arch="", snapshot=True, cdrom=None, extra_args=None, memory="2048"): | ||
| super().__init__() | ||
| self._img = pathlib.Path(img) | ||
| self._tmpdir = tempfile.mkdtemp(prefix="vmtest-", suffix=f"-{self._img.name}") | ||
|
|
@@ -172,23 +171,43 @@ def __del__(self): | |
| shutil.rmtree(self._tmpdir) | ||
|
|
||
| def _gen_qemu_cmdline(self, snapshot, use_ovmf): | ||
| virtio_scsi_hd = [ | ||
| "-device", "virtio-scsi-pci,id=scsi", | ||
| "-device", "scsi-hd,drive=disk0", | ||
| ] | ||
| virtio_net_device = "virtio-net-pci" | ||
| if self._arch in ("arm64", "aarch64"): | ||
| qemu_cmdline = [ | ||
| "qemu-system-aarch64", | ||
| "-machine", "virt", | ||
| "-cpu", "cortex-a57", | ||
| "-smp", "2", | ||
| "-bios", "/usr/share/AAVMF/AAVMF_CODE.fd", | ||
| ] | ||
| ] + virtio_scsi_hd | ||
| elif self._arch in ("amd64", "x86_64"): | ||
| qemu_cmdline = [ | ||
| "qemu-system-x86_64", | ||
| "-M", "accel=kvm", | ||
| # get "illegal instruction" inside the VM otherwise | ||
| "-cpu", "host", | ||
| ] | ||
| ] + virtio_scsi_hd | ||
| if use_ovmf: | ||
| qemu_cmdline.extend(["-bios", find_ovmf()]) | ||
| elif self._arch in ("ppc64le", "ppc64"): | ||
| qemu_cmdline = [ | ||
| "qemu-system-ppc64", | ||
| "-machine", "pseries", | ||
| "-smp", "2", | ||
| ] + virtio_scsi_hd | ||
| elif self._arch == "s390x": | ||
| qemu_cmdline = [ | ||
| "qemu-system-s390x", | ||
| "-machine", "s390-ccw-virtio", | ||
| "-smp", "2", | ||
| # sepcial disk setup | ||
lzap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "-device", "virtio-blk,drive=disk0,bootindex=1", | ||
| ] | ||
| virtio_net_device = "virtio-net-ccw" | ||
| else: | ||
| raise ValueError(f"unsupported architecture {self._arch}") | ||
|
|
||
|
|
@@ -197,9 +216,11 @@ def _gen_qemu_cmdline(self, snapshot, use_ovmf): | |
| "-m", self._memory, | ||
| "-serial", "stdio", | ||
| "-monitor", "none", | ||
| "-device", f"{virtio_net_device},netdev=net.0,id=net.0", | ||
| "-netdev", f"user,id=net.0,hostfwd=tcp::{self._ssh_port}-:22", | ||
| "-device", "e1000,netdev=net.0", | ||
| "-qmp", f"unix:{self._qmp_socket},server,nowait", | ||
| # boot | ||
| "-drive", f"file={self._img},if=none,id=disk0,format=qcow2", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This hunk sneaked into Which ends with QEMU complaining about raw image not being qcow2. That can be fixed, but then the issue is the image is passed twice on the command line - once via Another problem is few lines below when I will look into this later next week. Actually, let me try to do a quick fix and see how many tests are fixed: #2103 |
||
| ] | ||
| if not os.environ.get("OSBUILD_TEST_QEMU_GUI"): | ||
| qemu_cmdline.append("-nographic") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.