Skip to content

Commit b66a34f

Browse files
committed
Test: implement kargs e2e test
Update check-system.yaml to check the kargs in the installed system. Update the install Containerfile with install kargs in `/usr/lib/bootc/install` and day 2 kargs in `/usr/lib/bootc/kargs.d`, checking to see that the kargs are applied in the installed system. Update the upgrade Containerfile with different day 2 kargs, checking to see if the delta is applied properly. Signed-off-by: Luke Yang <[email protected]>
1 parent 2c4ca36 commit b66a34f

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

tests/e2e/bootc-install.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,23 @@ sed "s|REPLACE_COPR_PROJECT|${PACKIT_COPR_PROJECT}|; s|REPLACE_TEST_OS|${REPLACE
106106

107107
# Configure continerfile
108108
greenprint "Create $TEST_OS installation Containerfile"
109-
tee "$INSTALL_CONTAINERFILE" > /dev/null << EOF
109+
tee "$INSTALL_CONTAINERFILE" > /dev/null << REALEOF
110110
FROM "$TIER1_IMAGE_URL"
111111
COPY bootc.repo /etc/yum.repos.d/
112112
COPY domain.crt /etc/pki/ca-trust/source/anchors/
113113
RUN dnf -y update bootc && \
114114
update-ca-trust
115+
RUN cat <<EOF >> /usr/lib/bootc/install/00-mitigations.toml
116+
[install.filesystem.root]
117+
type = "xfs"
118+
[install]
119+
kargs = ["mitigations=on", "nosmt"]
115120
EOF
121+
RUN mkdir -p /usr/lib/bootc/kargs.d
122+
RUN cat <<EOF >> /usr/lib/bootc/kargs.d/01-console.toml
123+
kargs = ["systemd.unified_cgroup_hierarchy=0","console=ttyS0","panic=0"]
124+
EOF
125+
REALEOF
116126

117127
case "$TEST_CASE" in
118128
"to-existing-root")
@@ -244,15 +254,20 @@ ansible-playbook -v \
244254
-e test_os="$TEST_OS" \
245255
-e bootc_image="$TEST_IMAGE_URL" \
246256
-e image_label_version_id="$REDHAT_VERSION_ID" \
257+
-e kargs="mitigations=on,nosmt,systemd.unified_cgroup_hierarchy=0,console=ttyS0,panic=0" \
247258
playbooks/check-system.yaml
248259

249260
# Prepare upgrade containerfile
250261
greenprint "Create upgrade Containerfile"
251-
tee "$UPGRADE_CONTAINERFILE" > /dev/null << EOF
262+
tee "$UPGRADE_CONTAINERFILE" > /dev/null << REALEOF
252263
FROM "$TEST_IMAGE_URL"
253264
RUN dnf -y install wget && \
254265
dnf -y clean all
266+
RUN rm /usr/lib/bootc/kargs.d/01-console.toml
267+
RUN cat <<EOF >> /usr/lib/bootc/kargs.d/01-console.toml
268+
kargs = ["systemd.unified_cgroup_hierarchy=1","console=ttyS","panic=0"]
255269
EOF
270+
REALEOF
256271

257272
# Build upgrade container image and push to locay registry
258273
greenprint "Build $TEST_OS upgrade container image"
@@ -284,6 +299,7 @@ ansible-playbook -v \
284299
-e bootc_image="$BOOTC_IMAGE" \
285300
-e image_label_version_id="$REDHAT_VERSION_ID" \
286301
-e upgrade="true" \
302+
-e kargs="systemd.unified_cgroup_hierarchy=1,console=ttyS,panic=0" \
287303
playbooks/check-system.yaml
288304

289305
# bootc rollback test

tests/e2e/playbooks/check-system.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
vars:
55
bootc_image: ""
66
upgrade: ""
7+
kargs: ""
78
total_counter: "0"
89
failed_counter: "0"
910

@@ -355,6 +356,32 @@
355356
register: result_selinux_denied
356357
become: true
357358
ignore_errors: true
359+
360+
# case: check karg
361+
- name: grep for kargs
362+
shell: cat /proc/cmdline | grep {{item}}
363+
with_items: "{{ kargs.split(',') }}"
364+
register: kargs_check
365+
# grep will exit with 1 when no results found.
366+
# This causes the task not to halt play.
367+
ignore_errors: true
368+
when: kargs != ''
369+
370+
- name: check if kargs exist
371+
block:
372+
- assert:
373+
that:
374+
- kargs_check is succeeded
375+
fail_msg: install kargs not found
376+
success_msg: install kargs found
377+
always:
378+
- set_fact:
379+
total_counter: "{{ total_counter | int + 1 }}"
380+
rescue:
381+
- name: failed count + 1
382+
set_fact:
383+
failed_counter: "{{ failed_counter | int + 1 }}"
384+
when: kargs != ''
358385

359386
# case: check running container with podman in root
360387
- name: run CentOS Stream 9 image with podman in root

0 commit comments

Comments
 (0)