Skip to content

Commit 932b29b

Browse files
committed
test(cpu-usage): fix archlinux container build and keep images between runs
Two fixes so the cpu-usage integration test actually runs on archlinux-vlatest and subsequent runs reuse cached layers: - The cached archlinux:latest base image can be months out of date, so its archlinux-keyring no longer trusts the current packagers and pacman -Syu fails with "signature ... is unknown trust". Refresh the keyring via pacman-key --init / --populate and pull in a fresh archlinux-keyring package before the full upgrade. Also pass --disable-sandbox so pacman 7.x's landlock download helper does not need to create the sandbox user inside rootless podman, which is not allowed. - Testcontainers' DockerImage defaults to clean_up=True, which untags the built image and prunes dangling parent layers on every run. That wipes the cached build context and turns each invocation into a full rebuild from the base image. Setting clean_up=False keeps the image on the host so subsequent runs hit the layer cache and finish in seconds instead of minutes.
1 parent d594d80 commit 932b29b

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

check-plugins/cpu-usage/unit-test/containerfiles/archlinux-vlatest

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
# Base image: Official Arch Linux
22
FROM archlinux:latest
33

4-
# Update and install Python 3, pip, and required build tools
5-
RUN pacman -Syu --noconfirm && \
6-
pacman -S --noconfirm python python-pip gcc && \
4+
# Arch is rolling release, and the cached archlinux:latest base image
5+
# can be months out of date; its archlinux-keyring no longer trusts
6+
# the current packagers. Refresh the keyring from the shipped files
7+
# and pull in the latest archlinux-keyring package before -Syu so the
8+
# full upgrade can verify signatures.
9+
#
10+
# --disable-sandbox disables pacman 7.x's landlock/alpm download
11+
# sandbox, which cannot be applied inside rootless podman.
12+
RUN pacman-key --init && \
13+
pacman-key --populate && \
14+
pacman -Sy --noconfirm --disable-sandbox archlinux-keyring && \
15+
pacman -Syu --noconfirm --disable-sandbox && \
16+
pacman -S --noconfirm --disable-sandbox python python-pip gcc && \
717
pacman -Scc --noconfirm
818

919
# Set the working directory in the container

check-plugins/cpu-usage/unit-test/run

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,16 @@ class TestCheck(unittest.TestCase):
8585
def _check_containerfile(test, containerfile):
8686
print(f'\n=== Testing {containerfile} ===', flush=True)
8787
image_tag = f'lfmp-cpu-usage-{containerfile}'.lower()
88+
# clean_up=False keeps the built image on the host so the next
89+
# run reuses all cached layers instead of rebuilding from the
90+
# base image. Testcontainers' default (clean_up=True) not only
91+
# untags the image but also prunes dangling parent layers, which
92+
# wipes the cache and makes every run a full rebuild.
8893
with DockerImage(
8994
path=HERE,
9095
dockerfile_path=f'containerfiles/{containerfile}',
9196
tag=image_tag,
97+
clean_up=False,
9298
) as image:
9399
# `,Z` relabels the mount for SELinux on podman/rhel hosts so
94100
# the container can actually read the bind-mounted files.

0 commit comments

Comments
 (0)