Skip to content

Commit 88364c0

Browse files
authored
Merge pull request #1607 from cgwalters/testing-cleanups-p1
ci: Unify more of hack/ and tests/
2 parents 8aff03a + 6c415c5 commit 88364c0

24 files changed

+244
-618
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ jobs:
5454
run: sudo apt update && sudo apt install just
5555
- uses: actions/checkout@v4
5656
- name: Build and run container integration tests
57-
run: sudo just run-container-integration run-container-external-tests
57+
run: |
58+
sudo just build
59+
sudo just run-container-integration run-container-external-tests
5860
container-continuous:
5961
runs-on: ubuntu-24.04
6062
steps:
@@ -101,7 +103,8 @@ jobs:
101103
set -xeu
102104
# Build images to test; TODO investigate doing single container builds
103105
# via GHA and pushing to a temporary registry to share among workflows?
104-
sudo just build-integration-test-image
106+
sudo just build
107+
sudo just build-install-test-image
105108
sudo podman build -t localhost/bootc-fsverity -f ci/Containerfile.install-fsverity
106109
107110
# TODO move into a container, and then have this tool run other containers
@@ -116,9 +119,9 @@ jobs:
116119
sudo podman run --privileged --pid=host -v /:/run/host -v $(pwd):/src:ro -v /var/tmp:/var/tmp \
117120
-v /run/dbus:/run/dbus -v /run/systemd:/run/systemd localhost/bootc /src/crates/ostree-ext/ci/priv-integration.sh
118121
# Nondestructive but privileged tests
119-
sudo bootc-integration-tests host-privileged localhost/bootc-integration
122+
sudo bootc-integration-tests host-privileged localhost/bootc-integration-install
120123
# Install tests
121-
sudo bootc-integration-tests install-alongside localhost/bootc-integration
124+
sudo bootc-integration-tests install-alongside localhost/bootc-integration-install
122125
123126
# system-reinstall-bootc tests
124127
cargo build --release -p system-reinstall-bootc

.github/workflows/integration.yml

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,81 @@
1-
name: bootc integration test
1+
# This workflow builds a container across a matrix of OSes,
2+
# generates a disk image from that, and runs integration tests
3+
# using tmt + libvirt (using nested virt support in the default GHA runners).
4+
name: Build+TMT
25
on:
36
pull_request:
4-
branches: [main]
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
513

614
jobs:
715
build:
816
strategy:
17+
fail-fast: false
918
matrix:
10-
test_os: [fedora-41, fedora-42, fedora-43, centos-9]
11-
test_runner: [ubuntu-latest, ubuntu-24.04-arm]
19+
test_os: [fedora-42, fedora-43, centos-9, centos-10]
1220

13-
runs-on: ${{ matrix.test_runner }}
21+
runs-on: ubuntu-24.04
1422

1523
steps:
16-
- name: Install podman for heredoc support
24+
- name: Install dependencies
1725
run: |
1826
set -eux
1927
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
2028
sudo apt update
21-
sudo apt install -y crun/testing podman/testing
29+
sudo apt install -y crun/testing podman/testing just qemu-utils
2230
2331
- uses: actions/checkout@v4
2432

25-
- name: Build bootc and bootc image
26-
env:
27-
TEST_OS: ${{ matrix.test_os }}
28-
run: sudo -E TEST_OS=$TEST_OS tests/build.sh
33+
- name: Set architecture variable
34+
id: set_arch
35+
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
2936

30-
- name: Grant sudo user permission to archive files
37+
- name: Build container and disk image
3138
run: |
32-
sudo chmod 0755 /tmp/tmp-bootc-build/id_rsa
33-
34-
- name: Archive bootc disk image - disk.raw
35-
if: matrix.test_runner == 'ubuntu-latest'
36-
uses: actions/upload-artifact@v4
37-
with:
38-
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-disk
39-
path: /tmp/tmp-bootc-build/disk.raw
40-
retention-days: 1
39+
sudo tests/build.sh ${{ matrix.test_os }}
4140
42-
- name: Archive SSH private key - id_rsa
43-
if: matrix.test_runner == 'ubuntu-latest'
41+
- name: Archive disk image
4442
uses: actions/upload-artifact@v4
4543
with:
46-
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-id_rsa
47-
path: /tmp/tmp-bootc-build/id_rsa
44+
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-disk
45+
path: target/bootc-integration-test.qcow2
4846
retention-days: 1
4947

5048
test:
5149
needs: build
5250
strategy:
51+
fail-fast: false
5352
matrix:
54-
test_os: [fedora-41, fedora-42, fedora-43, centos-9]
55-
tmt_plan: [test-01-readonly, test-20-local-upgrade, test-21-logically-bound-switch, test-22-logically-bound-install, test-23-install-outside-container, test-24-local-upgrade-reboot]
53+
test_os: [fedora-42, fedora-43, centos-9, centos-10]
5654

5755
runs-on: ubuntu-latest
5856

5957
steps:
6058
- uses: actions/checkout@v4
6159

62-
- name: Install dependence
60+
- name: Set architecture variable
61+
id: set_arch
62+
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
63+
64+
- name: Install deps
6365
run: |
6466
sudo apt-get update
65-
sudo apt install -y qemu-kvm qemu-system
66-
pip install --user tmt
67+
# see https://tmt.readthedocs.io/en/stable/overview.html#install
68+
sudo apt install -y libkrb5-dev pkg-config libvirt-dev genisoimage qemu-kvm qemu-utils libvirt-daemon-system
69+
pip install --user "tmt[provision-virtual]"
6770
6871
- name: Create folder to save disk image
69-
run: mkdir -p /tmp/tmp-bootc-build
72+
run: mkdir -p target
7073

7174
- name: Download disk.raw
7275
uses: actions/download-artifact@v4
7376
with:
74-
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-disk
75-
path: /tmp/tmp-bootc-build
76-
77-
- name: Download id_rsa
78-
uses: actions/download-artifact@v4
79-
with:
80-
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-id_rsa
81-
path: /tmp/tmp-bootc-build
77+
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-disk
78+
path: target
8279

8380
- name: Enable KVM group perms
8481
run: |
@@ -87,14 +84,16 @@ jobs:
8784
sudo udevadm trigger --name-match=kvm
8885
ls -l /dev/kvm
8986
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+
9090
- name: Run test
91-
env:
92-
TMT_PLAN_NAME: ${{ matrix.tmt_plan }}
93-
run: chmod 600 /tmp/tmp-bootc-build/id_rsa && tests/test.sh
91+
run: |
92+
tests/run-tmt.sh
9493
9594
- name: Archive TMT logs
9695
if: always()
9796
uses: actions/upload-artifact@v4
9897
with:
99-
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ matrix.tmt_plan }}
98+
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-${{ matrix.tmt_plan }}
10099
path: /var/tmp/tmt

.packit.yaml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,26 @@ jobs:
5959
owner: rhcontainerbot
6060
project: bootc
6161
enable_net: true
62+
# TODO
6263
notifications:
6364
failure_comment:
6465
message: "bootc Copr build failed for {commit_sha}. @admin check logs {logs_url} and packit dashboard {packit_dashboard_url}"
6566

66-
- job: tests
67-
trigger: pull_request
68-
targets:
69-
- centos-stream-9-x86_64
70-
- centos-stream-9-aarch64
71-
- centos-stream-10-x86_64
72-
- centos-stream-10-aarch64
73-
- fedora-42-x86_64
74-
- fedora-42-aarch64
75-
- fedora-rawhide-x86_64
76-
- fedora-rawhide-aarch64
77-
tmt_plan: /integration
78-
skip_build: true
79-
identifier: integration-test
67+
# TODO: Readd some tmt tests that install the built RPM and e.g. test out system-reinstall-bootc
68+
# - job: tests
69+
# trigger: pull_request
70+
# targets:
71+
# - centos-stream-9-x86_64
72+
# - centos-stream-9-aarch64
73+
# - centos-stream-10-x86_64
74+
# - centos-stream-10-aarch64
75+
# - fedora-42-x86_64
76+
# - fedora-42-aarch64
77+
# - fedora-rawhide-x86_64
78+
# - fedora-rawhide-aarch64
79+
# tmt_plan: /integration
80+
# skip_build: true
81+
# identifier: integration-test
8082

8183
- job: propose_downstream
8284
trigger: release

Justfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ 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}} .
8+
# Keep these in sync with what's used in hack/lbi
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
10+
11+
# Only used by ci.yml right now
12+
build-install-test-image: build-integration-test-image
13+
cd hack && podman build -t localhost/bootc-integration-install -f Containerfile.drop-lbis
814

915
# Run container integration tests
1016
run-container-integration: build-integration-test-image

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ bin-archive: all
7979
test-bin-archive: all
8080
$(MAKE) install-all DESTDIR=tmp-install && $(TAR_REPRODUCIBLE) --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf
8181

82-
test-tmt:
83-
cargo xtask test-tmt
84-
8582
test:
8683
tests/build.sh && tests/test.sh
8784

crates/tests-integration/src/install.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ pub(crate) fn delete_ostree(sh: &Shell) -> Result<(), anyhow::Error> {
2626
if !Path::new("/ostree/").exists() {
2727
return Ok(());
2828
}
29+
// TODO: This shouldn't be leaking out of installs
30+
cmd!(sh, "sudo umount -Rl /ostree/bootc/storage/overlay")
31+
.ignore_status()
32+
.run()?;
2933
cmd!(sh, "sudo /bin/sh -c 'rm -rf /ostree/'").run()?;
3034
Ok(())
3135
}

crates/tests-integration/src/system_reinstall.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ use rustix::fs::statfs;
66
use std::{
77
fs::{self},
88
path::Path,
9+
time::Duration,
910
};
1011

1112
use crate::install;
1213

13-
const TIMEOUT: u64 = 60000;
14+
/// A generous timeout since some CI runs may be slower
15+
const TIMEOUT: Duration = std::time::Duration::from_secs(5 * 60);
1416

1517
fn get_deployment_dir() -> Result<std::path::PathBuf> {
1618
let base_path = Path::new("/ostree/deploy/default/deploy");
@@ -58,7 +60,7 @@ pub(crate) fn run(image: &str, testargs: libtest_mimic::Arguments) -> Result<()>
5860

5961
let mut p: PtySession = rexpect::spawn(
6062
format!("/usr/bin/system-reinstall-bootc {image}").as_str(),
61-
Some(TIMEOUT),
63+
Some(TIMEOUT.as_millis().try_into().unwrap()),
6264
)?;
6365

6466
// Basic flow stdout verification
@@ -132,7 +134,7 @@ pub(crate) fn run(image: &str, testargs: libtest_mimic::Arguments) -> Result<()>
132134
// Run system-reinstall-bootc
133135
let mut p: PtySession = rexpect::spawn(
134136
format!("/usr/bin/system-reinstall-bootc {image}").as_str(),
135-
Some(TIMEOUT),
137+
Some(TIMEOUT.as_millis().try_into().unwrap()),
136138
)?;
137139

138140
p.exp_regex("Found only one user ([^:]+) with ([\\d]+) SSH authorized keys.")?;

crates/xtask/src/xtask.rs

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ use xshell::{cmd, Shell};
1313
mod man;
1414

1515
const NAME: &str = "bootc";
16-
const TEST_IMAGES: &[&str] = &[
17-
"quay.io/curl/curl-base:latest",
18-
"quay.io/curl/curl:latest",
19-
"registry.access.redhat.com/ubi9/podman:latest",
20-
];
2116
const TAR_REPRODUCIBLE_OPTS: &[&str] = &[
2217
"--sort=name",
2318
"--owner=0",
@@ -45,7 +40,6 @@ const TASKS: &[(&str, fn(&Shell) -> Result<()>)] = &[
4540
("package", package),
4641
("package-srpm", package_srpm),
4742
("spec", spec),
48-
("test-tmt", test_tmt),
4943
];
5044

5145
fn try_main() -> Result<()> {
@@ -109,78 +103,6 @@ fn gitrev(sh: &Shell) -> Result<String> {
109103
}
110104
}
111105

112-
#[context("test-integration")]
113-
fn all_plan_files(sh: &Shell) -> Result<Vec<(u32, String)>> {
114-
// We need to split most of our tests into separate plans because tmt doesn't
115-
// support automatic isolation. (xref)
116-
let mut all_plan_files =
117-
sh.read_dir("plans")?
118-
.into_iter()
119-
.try_fold(Vec::new(), |mut acc, ent| -> Result<_> {
120-
let path = Utf8PathBuf::try_from(ent)?;
121-
let Some(ext) = path.extension() else {
122-
return Ok(acc);
123-
};
124-
if ext != "fmf" {
125-
return Ok(acc);
126-
}
127-
let stem = path.file_stem().expect("file stem");
128-
let Some((prefix, suffix)) = stem.split_once('-') else {
129-
return Ok(acc);
130-
};
131-
if prefix != "test" {
132-
return Ok(acc);
133-
}
134-
let Some((priority, _)) = suffix.split_once('-') else {
135-
anyhow::bail!("Invalid test {path}");
136-
};
137-
let priority: u32 = priority
138-
.parse()
139-
.with_context(|| format!("Parsing {path}"))?;
140-
acc.push((priority, stem.to_string()));
141-
Ok(acc)
142-
})?;
143-
all_plan_files.sort_by_key(|v| v.0);
144-
println!("Discovered plans: {all_plan_files:?}");
145-
Ok(all_plan_files)
146-
}
147-
148-
#[context("test-integration")]
149-
fn test_tmt(sh: &Shell) -> Result<()> {
150-
let mut tests = all_plan_files(sh)?;
151-
if let Ok(name) = std::env::var("TMT_TEST") {
152-
tests.retain(|x| x.1.as_str() == name);
153-
if tests.is_empty() {
154-
anyhow::bail!("Failed to match test: {name}");
155-
}
156-
}
157-
158-
// pull some small images that are used for LBI installation tests
159-
cmd!(sh, "podman pull {TEST_IMAGES...}").run()?;
160-
161-
for (_prio, name) in tests {
162-
// cc https://pagure.io/testcloud/pull-request/174
163-
cmd!(sh, "rm -vf /var/tmp/tmt/testcloud/images/disk.qcow2").run()?;
164-
let verbose_enabled = std::env::var("TMT_VERBOSE")
165-
.ok()
166-
.and_then(|s| s.parse::<u32>().ok())
167-
.unwrap_or(0);
168-
169-
let verbose = if verbose_enabled == 1 {
170-
Some("-vvvvv".to_string())
171-
} else {
172-
None
173-
};
174-
175-
if let Err(e) = cmd!(sh, "tmt {verbose...} run plans -n {name}").run() {
176-
// tmt annoyingly does not output errors by default
177-
let _ = cmd!(sh, "tmt run -l report -vvv").run();
178-
return Err(e.into());
179-
}
180-
}
181-
Ok(())
182-
}
183-
184106
/// Return a string formatted version of the git commit timestamp, up to the minute
185107
/// but not second because, well, we're not going to build more than once a second.
186108
#[context("Finding git timestamp")]

0 commit comments

Comments
 (0)