Skip to content

Commit c4f092c

Browse files
committed
More unification of tmt flow
Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 7eab41e commit c4f092c

File tree

10 files changed

+73
-305
lines changed

10 files changed

+73
-305
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: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,50 @@ on:
44
branches: [main]
55
workflow_dispatch:
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
711
jobs:
812
build:
913
strategy:
14+
fail-fast: false
1015
matrix:
1116
#test_os: [fedora-42, fedora-43, centos-9, centos-10]
1217
test_os: [centos-10]
13-
test_runner: [ubuntu-24.04, ubuntu-24.04-arm]
18+
test_runner: [ubuntu-24.04]
1419

1520
runs-on: ${{ matrix.test_runner }}
1621

1722
steps:
18-
- name: Install podman for heredoc support
23+
- name: Install dependencies
1924
run: |
2025
set -eux
2126
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
2227
sudo apt update
23-
sudo apt install -y crun/testing podman/testing just
28+
sudo apt install -y crun/testing podman/testing just qemu-utils
2429
2530
- uses: actions/checkout@v4
2631

2732
- name: Set architecture variable
2833
id: set_arch
2934
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
3035

31-
- name: Build bootc and bootc image
36+
- name: Build container and disk image
3237
run: |
3338
sudo tests/build.sh ${{ matrix.test_os }}
3439
35-
- name: Archive bootc disk image - disk.raw
40+
- name: Archive disk image
3641
uses: actions/upload-artifact@v4
3742
with:
3843
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-disk
39-
path: target/disk.raw
44+
path: target/bootc-integration-test.qcow2
4045
retention-days: 1
4146

4247
test:
4348
needs: build
4449
strategy:
50+
fail-fast: false
4551
matrix:
4652
#test_os: [fedora-42, fedora-43, centos-9, centos-10]
4753
test_os: [centos-10]
@@ -59,7 +65,7 @@ jobs:
5965
- name: Install deps
6066
run: |
6167
sudo apt-get update
62-
sudo apt install -y qemu-kvm qemu-system just
68+
sudo apt install -y qemu-kvm qemu-system qemu-utils just
6369
pip install --user tmt
6470
6571
- name: Create folder to save disk image
@@ -78,6 +84,9 @@ jobs:
7884
sudo udevadm trigger --name-match=kvm
7985
ls -l /dev/kvm
8086
87+
- name: Workaround https://github.com/teemtee/testcloud/issues/18
88+
run: sudo rm -f /usr/bin/chcon && sudo ln -sr /usr/bin/true /usr/bin/chcon
89+
8190
- name: Run test
8291
run: |
8392
ls -al target

Justfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ 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 -q --retry 5 --retry-delay 5s quay.io/curl/curl:latest quay.io/curl/curl-base:latest registry.access.redhat.com/ubi9/podman:latest
1210

1311
# Run container integration tests
1412
run-container-integration: build-integration-test-image

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: 34 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,23 @@ if ! grep -q -r sudo /usr/lib/sysusers.d; then
6680
g sudo 16
6781
EOF
6882
fi
83+
84+
# dhcpcd
85+
if rpm -q dhcpcd &>/dev/null; then
86+
if ! grep -q -r dhcpcd /usr/lib/sysusers.d; then
87+
cat >/usr/lib/sysusers.d/bootc-dhcpcd-workaround.conf <<'EOF'
88+
u dhcpcd - 'Minimalistic DHCP client' /var/lib/dhcpcd
89+
EOF
90+
fi
91+
cat >/usr/lib/tmpfiles.d/bootc-dhcpd.conf <<'EOF'
92+
d /var/lib/dhcpcd 0755 root dhcpcd - -
93+
EOF
94+
rm -rf /var/lib/dhcpcd
95+
fi
96+
# dhclient
97+
if test -d /var/lib/dhclient; then
98+
cat >/usr/lib/tmpfiles.d/bootc-dhclient.conf <<'EOF'
99+
d /var/lib/dhclient 0755 root root - -
100+
EOF
101+
rm -rf /var/lib/dhclient
102+
fi

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: 7 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -12,84 +12,20 @@ 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}
30-
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-
)
60-
61-
# Kill qemu when the test exits by default
62-
setpriv --pdeathsig SIGTERM -- ${qemu_args[@]} &>/dev/null &
63-
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-
}
72-
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
81-
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"
88-
8921
# Move the tmt bits to a subdirectory to work around https://github.com/teemtee/tmt/issues/4062
9022
rm target/tmt-workdir -rf
9123
mkdir target/tmt-workdir
9224
cp -a .fmf tmt target/tmt-workdir/
25+
26+
# Hack around https://github.com/teemtee/testcloud/issues/17
27+
rm -vrf /var/tmp/tmt/testcloud/images/bootc-integration-test.qcow2
28+
9329
cd target/tmt-workdir
9430
# 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}"
31+
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)