Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ jobs:
run: |
# make sure test deps are available for root
sudo -E pip install --user -r test/requirements.txt
sudo -E pip install --user .
- name: Workarounds for GH runner diskspace
run: |
# use custom basetemp here because /var/tmp is on a smaller disk
Expand Down
20 changes: 0 additions & 20 deletions pyproject.toml

This file was deleted.

2 changes: 1 addition & 1 deletion test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pytest==7.4.3
flake8==6.1.0
paramiko==2.12.0
boto3==1.33.13
qmp==1.1.0
pylint==3.2.5
vmtest @ git+https://github.com/osbuild/images.git
54 changes: 23 additions & 31 deletions test/test_build_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ def test_build_container_works(image_type):


def assert_kernel_args(test_vm, image_type):
exit_status, kcmdline = test_vm.run("cat /proc/cmdline", user=image_type.username, password=image_type.password)
assert exit_status == 0
ret = test_vm.run(["cat", "/proc/cmdline"], user=image_type.username, password=image_type.password)
kcmdline = ret.stdout
# the kernel arg string must have a space as the prefix and either a space
# as suffix or be the last element of the kernel commandline
assert re.search(f" {re.escape(image_type.kargs)}( |$)", kcmdline)
Expand All @@ -560,31 +560,27 @@ def test_image_boots(image_type):
def assert_disk_image_boots(image_type):
with QEMU(image_type.img_path, arch=image_type.img_arch) as test_vm:
# user/password login works
exit_status, _ = test_vm.run("true", user=image_type.username, password=image_type.password)
assert exit_status == 0
test_vm.run("true", user=image_type.username, password=image_type.password)
# root/ssh login also works
exit_status, output = test_vm.run("id", user="root", keyfile=image_type.ssh_keyfile_private_path)
assert exit_status == 0
assert "uid=0" in output
ret = test_vm.run("id", user="root", keyfile=image_type.ssh_keyfile_private_path)
assert "uid=0" in ret.stdout
# check generic image options
assert_kernel_args(test_vm, image_type)
# ensure bootc points to the right image
_, output = test_vm.run("bootc status", user="root", keyfile=image_type.ssh_keyfile_private_path)
ret = test_vm.run(["bootc", "status"], user="root", keyfile=image_type.ssh_keyfile_private_path)
# XXX: read the fully yaml instead?
assert f"image: {image_type.container_ref}" in output
assert f"image: {image_type.container_ref}" in ret.stdout

if image_type.disk_config:
assert_disk_customizations(image_type, test_vm)
else:
assert_fs_customizations(image_type, test_vm)

# check file/dir customizations
exit_status, output = test_vm.run("stat /etc/some-file", user=image_type.username, password=image_type.password)
assert exit_status == 0
assert "File: /etc/some-file" in output
_, output = test_vm.run("stat /etc/some-dir", user=image_type.username, password=image_type.password)
assert exit_status == 0
assert "File: /etc/some-dir" in output
ret = test_vm.run(["stat", "/etc/some-file"], user=image_type.username, password=image_type.password)
assert "File: /etc/some-file" in ret.stdout
ret = test_vm.run(["stat", "/etc/some-dir"], user=image_type.username, password=image_type.password)
assert "File: /etc/some-dir" in ret.stdout


@pytest.mark.parametrize("image_type", gen_testcases("ami-boot"), indirect=["image_type"])
Expand All @@ -599,11 +595,9 @@ def test_ami_boots_in_aws(image_type, force_aws_upload):
# 4.30 GiB / 10.00 GiB [------------>____________] 43.02% 58.04 MiB p/s
assert "] 100.00%" in image_type.bib_output
with AWS(image_type.metadata["ami_id"]) as test_vm:
exit_status, _ = test_vm.run("true", user=image_type.username, password=image_type.password)
assert exit_status == 0
exit_status, output = test_vm.run("echo hello", user=image_type.username, password=image_type.password)
assert exit_status == 0
assert "hello" in output
test_vm.run("true", user=image_type.username, password=image_type.password)
ret = test_vm.run(["echo", "hello"], user=image_type.username, password=image_type.password)
assert "hello" in ret.stdout


def log_has_osbuild_selinux_denials(log):
Expand Down Expand Up @@ -686,12 +680,11 @@ def assert_fs_customizations(image_type, test_vm):
"""
# check the minsize specified in the build configuration for each mountpoint against the sizes in the image
# TODO: replace 'df' call with 'parted --json' and find the partition size for each mountpoint
exit_status, output = test_vm.run("df --all --output=target,size", user="root",
keyfile=image_type.ssh_keyfile_private_path)
assert exit_status == 0
ret = test_vm.run(["df", "--all", "--output=target,size"], user="root",
keyfile=image_type.ssh_keyfile_private_path)
# parse the output of 'df' to a mountpoint -> size dict for convenience
mountpoint_sizes = {}
for line in output.splitlines()[1:]:
for line in ret.stdout.splitlines()[1:]:
fields = line.split()
# some filesystems to not report a size with --all
if fields[1] == "-":
Expand All @@ -712,13 +705,12 @@ def assert_fs_customizations(image_type, test_vm):


def assert_disk_customizations(image_type, test_vm):
exit_status, output = test_vm.run("findmnt --json", user="root",
keyfile=image_type.ssh_keyfile_private_path)
assert exit_status == 0
findmnt = json.loads(output)
exit_status, swapon_output = test_vm.run("swapon --show", user="root",
keyfile=image_type.ssh_keyfile_private_path)
assert exit_status == 0
ret = test_vm.run(["findmnt", "--json"], user="root",
keyfile=image_type.ssh_keyfile_private_path)
findmnt = json.loads(ret.stdout)
swapon_ret = test_vm.run(["swapon", "--show"], user="root",
keyfile=image_type.ssh_keyfile_private_path)
swapon_output = swapon_ret.stdout
if dc := image_type.disk_config:
if dc == "lvm":
mnts = [mnt for mnt in findmnt["filesystems"][0]["children"]
Expand Down
11 changes: 4 additions & 7 deletions test/test_build_iso.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def test_iso_installs(image_type):
# boot test disk and do extremly simple check
with QEMU(test_disk_path) as vm:
vm.start(use_ovmf=True)
exit_status, _ = vm.run("true", user=image_type.username, password=image_type.password)
assert exit_status == 0
vm.run("true", user=image_type.username, password=image_type.password)
assert_kernel_args(vm, image_type)


Expand Down Expand Up @@ -198,8 +197,6 @@ def test_bootc_installer_iso_installs(tmp_path, build_container, container_ref):
# boot test disk and do extremly simple check
with QEMU(test_disk_path) as vm:
vm.start(use_ovmf=True)
exit_status, _ = vm.run("true", user=username, password=password)
assert exit_status == 0
exit_status, output = vm.run("bootc status", user="root", keyfile=ssh_keyfile_private_path)
assert exit_status == 0
assert f"image: {container_ref}" in output
vm.run("true", user=username, password=password)
ret = vm.run(["bootc", "status"], user="root", keyfile=ssh_keyfile_private_path)
assert f"image: {container_ref}" in ret.stdout
Empty file removed vmtest/__init__.py
Empty file.
24 changes: 0 additions & 24 deletions vmtest/util.py

This file was deleted.

47 changes: 0 additions & 47 deletions vmtest/util_test.py

This file was deleted.

Loading
Loading