Skip to content

Commit

Permalink
test: add logically bound images
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaofeng Wang <[email protected]>
  • Loading branch information
henrywang committed Aug 15, 2024
1 parent 4fed0e4 commit 19f2c70
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/e2e/bootc-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,30 @@ case "$TEST_CASE" in
"to-existing-root")
SSH_USER="root"
SSH_KEY_PUB_CONTENT=$(cat "${SSH_KEY_PUB}")
mkdir -p "${TEMPDIR}/usr/share/containers/systemd"
cp files/caddy.container files/node_exporter.container "${TEMPDIR}/usr/share/containers/systemd"
tee -a "$INSTALL_CONTAINERFILE" > /dev/null << EOF
COPY usr/ usr/
RUN mkdir -p /usr/etc-system/ && \
echo 'AuthorizedKeysFile /usr/etc-system/%u.keys' >> /etc/ssh/sshd_config.d/30-auth-system.conf && \
echo "$SSH_KEY_PUB_CONTENT" > /usr/etc-system/root.keys && \
chmod 0600 /usr/etc-system/root.keys && \
dnf -y install qemu-guest-agent && \
dnf clean all && \
systemctl enable qemu-guest-agent
systemctl enable qemu-guest-agent && \
ln -s /usr/share/containers/systemd/caddy.container /usr/lib/bootc/bound-images.d/caddy.container && \
ln -s /usr/share/containers/systemd/node_exporter.container /usr/lib/bootc/bound-images.d/node_exporter.container
EOF
# logical bound image
LBI="enabled"
;;
"to-disk")
tee -a "$INSTALL_CONTAINERFILE" > /dev/null << EOF
RUN dnf -y install python3 cloud-init && \
dnf -y clean all
EOF
# LBI is disabled in to-disk test
LBI="disabled"
;;
esac

Expand Down Expand Up @@ -264,6 +273,7 @@ ansible-playbook -v \
-e bootc_image="$TEST_IMAGE_URL" \
-e image_label_version_id="$REDHAT_VERSION_ID" \
-e kargs="mitigations=on,nosmt,console=ttyS0,panic=0" \
-e lbi="$LBI" \
playbooks/check-system.yaml

# Prepare upgrade containerfile
Expand Down Expand Up @@ -309,6 +319,7 @@ ansible-playbook -v \
-e image_label_version_id="$REDHAT_VERSION_ID" \
-e upgrade="true" \
-e kargs="systemd.unified_cgroup_hierarchy=1,console=ttyS,panic=0" \
-e lbi="$LBI" \
playbooks/check-system.yaml

# bootc rollback test
Expand Down
11 changes: 11 additions & 0 deletions tests/e2e/files/caddy.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Run a demo webserver

[Container]
GlobalArgs=--storage-opt=additionalimagestore=/usr/lib/bootc/storage
Image=docker.io/library/caddy:2.8.4
PublishPort=80:80
ReadOnly=true

[Install]
WantedBy=default.target
13 changes: 13 additions & 0 deletions tests/e2e/files/node_exporter.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Prometheus node exporter

[Container]
Network=host
PodmanArgs=--pid=host --storage-opt=additionalimagestore=/usr/lib/bootc/storage
Volume=/:/host,ro,rslave
Image=quay.io/prometheus/node-exporter:v1.8.2
Exec=--path.rootfs=/host
ReadOnly=true

[Install]
WantedBy=default.target
45 changes: 45 additions & 0 deletions tests/e2e/playbooks/check-system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
bootc_image: ""
upgrade: ""
kargs: ""
lbi: ""
total_counter: "0"
failed_counter: "0"

Expand Down Expand Up @@ -437,6 +438,50 @@
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"

# case: check logically bound image caddy container status
- name: check LBI caddy container status
shell: podman ps --filter "name=systemd-caddy" --format json | jq -r '.[].State'
register: result_caddy_state
when: lbi == "enabled"

- name: run caddy container status test
block:
- assert:
that:
- result_caddy_state.stdout == "running"
fail_msg: "failed to run caddy container"
success_msg: "running caddy container"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: lbi == "enabled"

# case: check logically bound image node_exporter container status
- name: check LBI node_exporter container status
shell: podman ps --filter "name=systemd-node_exporter" --format json | jq -r '.[].State'
register: result_node_exporter_state
when: lbi == "enabled"

- name: run node_exporter container status test
block:
- assert:
that:
- result_node_exporter_state.stdout == "running"
fail_msg: "failed to run node_exporter container"
success_msg: "running node_exporter container"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: lbi == "enabled"

# case: check system reboot
- name: check system reboot
block:
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e/playbooks/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
command: dnf -y install podman
become: true

- name: Pull logical bound image
command: podman pull --tls-verify=false {{ item }}
become: true
loop:
- "docker.io/library/caddy:2.8.4"
- "quay.io/prometheus/node-exporter:v1.8.2"

- name: Install image
command:
"podman run \
Expand Down

0 comments on commit 19f2c70

Please sign in to comment.