Skip to content

Commit 2c11d55

Browse files
Johan-Liebert1cgwalters
authored andcommitted
tmt/tests: Add composefs/ostree distinguishing checks
The tests assume an ostree system right now, but we want the same tests for composefs systems as well. Add a `is_composefs` function to differentitate between the two backends during testing Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 73ab538 commit 2c11d55

13 files changed

Lines changed: 85 additions & 37 deletions

tmt/tests/booted/readonly/001-test-status.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ assert ($opts | any { |o| $o == "ro" }) "/sysroot should be mounted read-only"
1414

1515
let st = bootc status --json | from json
1616
# Detect composefs by checking if composefs field is present
17-
let is_composefs = ($st.status.booted.composefs? != null)
17+
let is_composefs = (tap is_composefs)
1818

1919
assert equal $st.apiVersion org.containers.bootc/v1
2020

tmt/tests/booted/readonly/010-test-bootc-container-store.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tap begin "verify bootc-owned container storage"
55

66
# Detect composefs by checking if composefs field is present
77
let st = bootc status --json | from json
8-
let is_composefs = ($st.status.booted.composefs? != null)
8+
let is_composefs = (tap is_composefs)
99

1010
if $is_composefs {
1111
print "# TODO composefs: skipping test - /usr/lib/bootc/storage doesn't exist with composefs"

tmt/tests/booted/readonly/011-test-ostree-ext-cli.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tap begin "verify bootc wrapping ostree-ext"
88
# Parse the status and get the booted image
99
let st = bootc status --json | from json
1010
# Detect composefs by checking if composefs field is present
11-
let is_composefs = ($st.status.booted.composefs? != null)
11+
let is_composefs = (tap is_composefs)
1212
if $is_composefs {
1313
print "# TODO composefs: skipping test - ostree-container commands don't work with composefs"
1414
} else {

tmt/tests/booted/readonly/011-test-resolvconf.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tap begin "verify there's not an empty /etc/resolv.conf in the image"
66
let st = bootc status --json | from json
77

88
# Detect composefs by checking if composefs field is present
9-
let is_composefs = ($st.status.booted.composefs? != null)
9+
let is_composefs = (tap is_composefs)
1010
if $is_composefs {
1111
print "# TODO composefs: skipping test - ostree commands don't work with composefs"
1212
} else {

tmt/tests/booted/readonly/012-test-unit-status.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tap begin "verify our systemd units"
66

77
# Detect composefs by checking if composefs field is present
88
let st = bootc status --json | from json
9-
let is_composefs = ($st.status.booted.composefs? != null)
9+
let is_composefs = (tap is_composefs)
1010

1111
if $is_composefs {
1212
print "# TODO composefs: skipping test - bootc-status-updated.path watches /ostree/bootc which doesn't exist with composefs"

tmt/tests/booted/readonly/015-test-fsck.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tap begin "Run fsck"
55

66
# Detect composefs by checking if composefs field is present
77
let st = bootc status --json | from json
8-
let is_composefs = ($st.status.booted.composefs? != null)
8+
let is_composefs = (tap is_composefs)
99

1010
if $is_composefs {
1111
print "# TODO composefs: skipping test - fsck requires ostree-booted host"

tmt/tests/booted/readonly/017-test-bound-storage.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if not (bootc_testlib have_hostexports) {
1010

1111
bootc status
1212
let st = bootc status --json | from json
13-
let is_composefs = ($st.status.booted.composefs? != null)
13+
let is_composefs = (tap is_composefs)
1414
if $is_composefs {
1515
# TODO we don't have imageDigest yet in status
1616
exit 0

tmt/tests/booted/readonly/030-test-composefs.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def parse_cmdline [] {
99

1010
# Detect composefs by checking if composefs field is present
1111
let st = bootc status --json | from json
12-
let is_composefs = ($st.status.booted.composefs? != null)
12+
let is_composefs = (tap is_composefs)
1313
let expecting_composefs = ($env.BOOTC_variant? | default "" | find "composefs") != null
1414
if $expecting_composefs {
1515
assert $is_composefs

tmt/tests/booted/tap.nu

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ export def ok [] {
1313
export def fail [] {
1414
print "not ok"
1515
}
16+
17+
export def is_composefs [] {
18+
let st = bootc status --json | from json
19+
$st.status.booted.composefs? != null
20+
}

tmt/tests/booted/test-image-pushpull-upgrade.nu

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const quoted_karg = '"thisarg=quoted with spaces"'
2222
bootc status
2323
let st = bootc status --json | from json
2424
let booted = $st.status.booted.image
25-
let is_composefs = ($st.status.booted.composefs? != null)
25+
let is_composefs = (tap is_composefs)
2626

2727
# Parse the kernel commandline into a list.
2828
# This is not a proper parser, but good enough
@@ -54,7 +54,11 @@ RUN echo test content > /usr/share/blah.txt
5454
let v = podman run --rm localhost/bootc-derived cat /usr/share/blah.txt | str trim
5555
assert equal $v "test content"
5656

57-
let orig_root_mtime = ls -Dl /ostree/bootc | get modified
57+
mut orig_root_mtime = null;
58+
59+
if not $is_composefs {
60+
$orig_root_mtime = ls -Dl /ostree/bootc | get modified
61+
}
5862

5963
# Now, fetch it back into the bootc storage!
6064
# We also test the progress API here
@@ -68,24 +72,25 @@ RUN echo test content > /usr/share/blah.txt
6872
systemd-run -u test-cat-progress -- /bin/bash -c $"exec cat ($progress_fifo) > ($progress_json)"
6973
# nushell doesn't do fd passing right now either, so run via bash
7074
bash -c $"bootc switch --progress-fd 3 --transport containers-storage localhost/bootc-derived 3>($progress_fifo)"
71-
# Now, let's do some checking of the progress json
72-
let progress = open --raw $progress_json | from json -o
73-
sanity_check_switch_progress_json $progress
7475

75-
# Check that /run/reboot-required exists and is not empty
76-
let rr_meta = (ls /run/reboot-required | first)
77-
assert ($rr_meta.size > 0b)
76+
if not $is_composefs {
77+
# Now, let's do some checking of the progress json
78+
let progress = open --raw $progress_json | from json -o
79+
sanity_check_switch_progress_json $progress
7880

79-
# Verify that we logged to the journal
80-
journalctl _MESSAGE_ID=3e2f1a0b9c8d7e6f5a4b3c2d1e0f9a8b7
81+
# Check that /run/reboot-required exists and is not empty
82+
let rr_meta = (ls /run/reboot-required | first)
83+
assert ($rr_meta.size > 0b)
8184

82-
# The mtime should change on modification
83-
let new_root_mtime = ls -Dl /ostree/bootc | get modified
84-
assert ($new_root_mtime > $orig_root_mtime)
85+
# Verify that we logged to the journal
86+
journalctl _MESSAGE_ID=3e2f1a0b9c8d7e6f5a4b3c2d1e0f9a8b7
8587

86-
# Test for https://github.com/ostreedev/ostree/issues/3544
87-
# Add a quoted karg using rpm-ostree if available
88-
if not $is_composefs {
88+
# The mtime should change on modification
89+
let new_root_mtime = ls -Dl /ostree/bootc | get modified
90+
assert ($new_root_mtime > $orig_root_mtime)
91+
92+
# Test for https://github.com/ostreedev/ostree/issues/3544
93+
# Add a quoted karg using rpm-ostree if available
8994
# Check rpm-ostree and rpm-ostreed service status before run rpm-ostree
9095
# And collect info for flaky error "error: System transaction in progress"
9196
rpm-ostree status

0 commit comments

Comments
 (0)