Skip to content

Commit 974a62a

Browse files
committed
More unification of tmt flow
Signed-off-by: Colin Walters <[email protected]>
1 parent 7eab41e commit 974a62a

File tree

11 files changed

+116
-293
lines changed

11 files changed

+116
-293
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ jobs:
5656
run: sudo apt update && sudo apt install just
5757
- uses: actions/checkout@v4
5858
- name: Build and run container integration tests
59-
run: sudo just run-container-integration run-container-external-tests
59+
run: |
60+
sudo just build
61+
sudo just run-container-integration run-container-external-tests
6062
container-continuous:
6163
if: ${{ !contains(github.event.pull_request.labels.*.name, 'control/skip-ci') }}
6264
runs-on: ubuntu-24.04
@@ -105,6 +107,7 @@ jobs:
105107
set -xeu
106108
# Build images to test; TODO investigate doing single container builds
107109
# via GHA and pushing to a temporary registry to share among workflows?
110+
sudo just build
108111
sudo just build-integration-test-image
109112
sudo podman build -t localhost/bootc-fsverity -f ci/Containerfile.install-fsverity
110113

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
matrix:
1111
#test_os: [fedora-42, fedora-43, centos-9, centos-10]
1212
test_os: [centos-10]
13-
test_runner: [ubuntu-24.04, ubuntu-24.04-arm]
13+
test_runner: [ubuntu-24.04]
1414

1515
runs-on: ${{ matrix.test_runner }}
1616

Justfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ build *ARGS:
33
podman build --jobs=4 -t localhost/bootc {{ARGS}} .
44

55
# This container image has additional testing content and utilities
6-
build-integration-test-image *ARGS: build
6+
build-integration-test-image *ARGS:
77
podman build --jobs=4 -t localhost/bootc-integration -f hack/Containerfile {{ARGS}} .
88
# Keep these in sync with what's used in hack/lbi
9-
podman pull --retry 5 --retry-delay 5s quay.io/curl/curl:latest
10-
podman pull --retry 5 --retry-delay 5s quay.io/curl/curl-base:latest
11-
podman pull --retry 5 --retry-delay 5s registry.access.redhat.com/ubi9/podman:latest
9+
podman pull --policy=missing --retry 5 --retry-delay 5s quay.io/curl/curl:latest
10+
podman pull --policy=missing --retry 5 --retry-delay 5s quay.io/curl/curl-base:latest
11+
podman pull --policy=missing --retry 5 --retry-delay 5s registry.access.redhat.com/ubi9/podman:latest
1212

1313
# Run container integration tests
1414
run-container-integration: build-integration-test-image

hack/Containerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ ARG variant=
1515
RUN --mount=type=bind,from=context,target=/run/context <<EORUN
1616
set -xeuo pipefail
1717
cd /run/context/hack
18+
# https://gitlab.com/fedora/bootc/base-images/-/issues/65
19+
rm -rf /usr/lib/sysimage/rpm-ostree-base-db
20+
# cache blowout 20250915
1821
./provision-derived.sh "$variant"
1922

2023
# For test-22-logically-bound-install

hack/packages.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Needed by tmt
22
rsync
3+
cloud-init
34
/usr/bin/flock
45
/usr/bin/awk

hack/provision-derived.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ case "${ID}-${VERSION_ID}" in
2323
;;
2424
"centos-10"|"rhel-10."*)
2525
# nu is not available in CS10
26+
td=$(mktemp -d)
27+
cd $td
2628
curl -kL "https://github.com/nushell/nushell/releases/download/0.103.0/nu-0.103.0-$(uname -m)-unknown-linux-gnu.tar.gz" --output nu.tar.gz
2729
mkdir -p nu && tar zvxf nu.tar.gz --strip-components=1 -C nu
2830
mv nu/nu /usr/bin/nu
2931
rm -rf nu nu.tar.gz
32+
cd -
33+
rm -rf "${td}"
3034
;;
3135
"fedora-"*)
3236
dnf -y install nu
@@ -37,10 +41,20 @@ esac
3741
grep -Ev -e '^#' packages.txt | xargs dnf -y install
3842
dnf clean all
3943

44+
# Cloud bits
45+
cat <<KARGEOF >> /usr/lib/bootc/kargs.d/20-console.toml
46+
kargs = ["console=ttyS0,115200n8"]
47+
KARGEOF
48+
# And cloud-init stuff
49+
ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants
50+
4051
# Stock extra cleaning of logs and caches in general (mostly dnf)
4152
rm /var/log/* /var/cache /var/lib/{dnf,rpm-state,rhsm} -rf
4253
# And clean root's homedir
4354
rm /var/roothome/.config -rf
55+
cat >/usr/lib/tmpfiles.d/bootc-cloud-init.conf <<'EOF'
56+
d /var/lib/cloud 0755 root root - -
57+
EOF
4458

4559
# Fast track tmpfiles.d content from the base image, xref
4660
# https://gitlab.com/fedora/bootc/base-images/-/merge_requests/92
@@ -66,3 +80,13 @@ if ! grep -q -r sudo /usr/lib/sysusers.d; then
6680
g sudo 16
6781
EOF
6882
fi
83+
84+
# dhcpcd
85+
if ! grep -q -r dhcpcd /usr/lib/sysusers.d; then
86+
cat >/usr/lib/sysusers.d/bootc-dhcpcd-workaround.conf <<'EOF'
87+
u dhcpcd - 'Minimalistic DHCP client' /var/lib/dhcpcd
88+
EOF
89+
fi
90+
cat >/usr/lib/tmpfiles.d/bootc-dhcpd.conf <<'EOF'
91+
d /var/lib/dhcpcd 0755 root root - -
92+
EOF

tests/build.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -exuo pipefail
77
# If provided should be of the form fedora-42 or centos-10
88
target=${1:-}
99

10-
bcvk=$(which bcvk 2>/dev/null)
10+
bcvk=$(which bcvk 2>/dev/null || true)
1111
if test -z "${bcvk}" && test "$(id -u)" != 0; then
1212
echo "This script currently requires full root"; exit 1
1313
fi
@@ -40,7 +40,7 @@ just build-integration-test-image
4040
# for output artifacts
4141
mkdir -p target
4242

43-
DISK=target/integration-test.raw
43+
DISK=target/bootc-integration-test.raw
4444
SIZE=10G
4545
rm -vf "${DISK}"
4646
if test -n "${bcvk}"; then
@@ -62,4 +62,9 @@ else
6262
--generic-image \
6363
--via-loopback \
6464
/target/$(basename ${DISK})
65-
fi
65+
fi
66+
# testcloud barfs on .raw sadly; FIXME drop this once it's been changed.
67+
# Alternatively we could teach bcvk how to write qcow2 easily enough.
68+
qemu-img convert -f raw -O qcow2 ${DISK} target/bootc-integration-test.qcow2
69+
rm -f "${DISK}"
70+

tests/test.sh

Lines changed: 70 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -12,84 +12,89 @@ set -exuo pipefail
1212
# Ensure we're in the topdir canonically
1313
cd $(git rev-parse --show-toplevel)
1414

15-
DISK=target/integration-test.raw
16-
17-
# Generate a temporary key
18-
SSH_KEY=$(pwd)/target/id_rsa
19-
rm -vf "${SSH_KEY}"*
20-
ssh-keygen -f "${SSH_KEY}" -N "" -q -t rsa-sha2-256 -b 4096
21-
chmod 600 "${SSH_KEY}"
15+
DISK=$(pwd)/target/bootc-integration-test.qcow2
16+
test -f "${DISK}"
2217

2318
TMT_PLAN_NAME=$1
2419
shift
2520

26-
SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o PasswordAuthentication=no -o ConnectTimeout=5)
27-
pubkey=$(base64 -w 0 < target/id_rsa.pub)
28-
ssh_tmpfiles=$(printf "d /root/.ssh 0750 - - -\nf+~ /root/.ssh/authorized_keys 700 - - - ${pubkey}" | base64 -w 0)
29-
ssh_cred="io.systemd.credential.binary:tmpfiles.extra="${ssh_tmpfiles}
21+
# Generate a temporary key
22+
#SSH_KEY=$(pwd)/target/id_rsa
23+
#rm -vf "${SSH_KEY}"*
24+
#ssh-keygen -f "${SSH_KEY}" -N "" -q -t rsa-sha2-256 -b 4096
25+
#chmod 600 "${SSH_KEY}"
26+
27+
# SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o PasswordAuthentication=no -o ConnectTimeout=5)
28+
# pubkey=$(base64 -w 0 < target/id_rsa.pub)
29+
# ssh_tmpfiles=$(printf "d /root/.ssh 0750 - - -\nf+~ /root/.ssh/authorized_keys 700 - - - ${pubkey}" | base64 -w 0)
30+
# ssh_cred="io.systemd.credential.binary:tmpfiles.extra="${ssh_tmpfiles}
3031

31-
# TODO replace with tmt's virt provisioner
32-
ARCH=$(uname -m)
33-
qemu_args=()
34-
case "$ARCH" in
35-
"aarch64")
36-
qemu_args+=(qemu-system-aarch64
37-
-machine virt
38-
-bios /usr/share/AAVMF/AAVMF_CODE.fd)
39-
;;
40-
"x86_64")
41-
qemu_args+=(qemu-system-x86_64)
42-
;;
43-
*)
44-
echo "Unhandled architecture: $ARCH" >&2
45-
exit 1
46-
;;
47-
esac
48-
qemu_args+=(
49-
-name bootc-vm
50-
-enable-kvm
51-
-cpu host
52-
-m 2G
53-
-drive file="target/disk.raw",if=virtio,format=raw
54-
-snapshot
55-
-net nic,model=virtio
56-
-net user,hostfwd=tcp::2222-:22
57-
-display none
58-
-smbios type=11,value=${ssh_cred}
59-
)
32+
# # TODO replace with tmt's virt provisioner
33+
# ARCH=$(uname -m)
34+
# qemu_args=()
35+
# case "$ARCH" in
36+
# "aarch64")
37+
# qemu_args+=(qemu-system-aarch64
38+
# -machine virt
39+
# -bios /usr/share/AAVMF/AAVMF_CODE.fd)
40+
# ;;
41+
# "x86_64")
42+
# qemu_args+=(qemu-system-x86_64)
43+
# ;;
44+
# *)
45+
# echo "Unhandled architecture: $ARCH" >&2
46+
# exit 1
47+
# ;;
48+
# esac
49+
# qemu_args+=(
50+
# -name bootc-vm
51+
# -enable-kvm
52+
# -cpu host
53+
# -m 2G
54+
# -drive file="target/disk.raw",if=virtio,format=raw
55+
# -snapshot
56+
# -net nic,model=virtio
57+
# -net user,hostfwd=tcp::2222-:22
58+
# -display none
59+
# -smbios type=11,value=${ssh_cred}
60+
# )
6061

61-
# Kill qemu when the test exits by default
62-
setpriv --pdeathsig SIGTERM -- ${qemu_args[@]} &>/dev/null &
62+
# # Kill qemu when the test exits by default
63+
# setpriv --pdeathsig SIGTERM -- ${qemu_args[@]} &>/dev/null &
6364

64-
wait_for_ssh_up() {
65-
SSH_STATUS=$(ssh "${SSH_OPTIONS[@]}" -i "$SSH_KEY" -p 2222 root@"${1}" '/bin/bash -c "echo -n READY"')
66-
if [[ $SSH_STATUS == READY ]]; then
67-
echo 1
68-
else
69-
echo 0
70-
fi
71-
}
65+
# wait_for_ssh_up() {
66+
# SSH_STATUS=$(ssh "${SSH_OPTIONS[@]}" -i "$SSH_KEY" -p 2222 root@"${1}" '/bin/bash -c "echo -n READY"')
67+
# if [[ $SSH_STATUS == READY ]]; then
68+
# echo 1
69+
# else
70+
# echo 0
71+
# fi
72+
# }
7273

73-
for _ in $(seq 0 30); do
74-
RESULT=$(wait_for_ssh_up "localhost")
75-
if [[ $RESULT == 1 ]]; then
76-
echo "SSH is ready now! 🥳"
77-
break
78-
fi
79-
sleep 10
80-
done
74+
# for _ in $(seq 0 30); do
75+
# RESULT=$(wait_for_ssh_up "localhost")
76+
# if [[ $RESULT == 1 ]]; then
77+
# echo "SSH is ready now! 🥳"
78+
# break
79+
# fi
80+
# sleep 10
81+
# done
8182

82-
# Make sure VM is ready for testing
83-
ssh "${SSH_OPTIONS[@]}" \
84-
-i "$SSH_KEY" \
85-
-p 2222 \
86-
root@localhost \
87-
"bootc status"
83+
# # Make sure VM is ready for testing
84+
# ssh "${SSH_OPTIONS[@]}" \
85+
# -i "$SSH_KEY" \
86+
# -p 2222 \
87+
# root@localhost \
88+
# "bootc status"
8889

8990
# Move the tmt bits to a subdirectory to work around https://github.com/teemtee/tmt/issues/4062
9091
rm target/tmt-workdir -rf
9192
mkdir target/tmt-workdir
9293
cp -a .fmf tmt target/tmt-workdir/
94+
95+
# Hack around https://github.com/teemtee/testcloud/issues/17
96+
rm -vrf /var/tmp/tmt/testcloud/images/bootc-integration-test.qcow2
97+
9398
cd target/tmt-workdir
9499
# TMT will rsync tmt-* scripts to TMT_SCRIPTS_DIR=/var/lib/tmt/scripts
95-
tmt run --all --verbose -e TMT_SCRIPTS_DIR=/var/lib/tmt/scripts provision --how connect --guest localhost --port 2222 --user root --key "$SSH_KEY" plan --name "/tmt/plans/integration/${TMT_PLAN_NAME}"
100+
tmt --context "test_disk_image=${DISK}" run --all --verbose -e TMT_SCRIPTS_DIR=/var/lib/tmt/scripts plan --name "/tmt/plans/integration/${TMT_PLAN_NAME}"

tmt/plans/integration.fmf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
provision:
22
how: virtual
33
# Build via `./tests/build.sh`
4-
image: target/integration-disk.img
4+
image: $@{test_disk_image}
55
execute:
66
how: tmt
77

tmt/tests/bootc-install-provision.fmf

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)