Skip to content

Commit 9be6b5a

Browse files
committed
tests: Drop internal-testing-api, move to tests-integration
Previous work started moving our tests into an external binary; this is just cleaner because it can test things how a user would test. Also, we started using `libtest-mimic` to have a "real" test scaffolding that e.g. allows selecting individual tests to run, etc. Complete the picture here by moving the remaining bits into the tests-integration binary. We now run the `tests-integration` binary in two ways in e.g. Github Actions: - It's compiled directly on the Ubuntu runner, and orchestrates things itself - It's built in our default container image (Fedora) but as an external `/usr/bin/bootc-integration-tests` binary Also while we're here, drop the kola tests. Signed-off-by: Colin Walters <[email protected]>
1 parent f152bfe commit 9be6b5a

File tree

16 files changed

+183
-371
lines changed

16 files changed

+183
-371
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ jobs:
5757
- name: Build container (fedora)
5858
run: sudo podman build --build-arg=base=quay.io/fedora/fedora-bootc:40 -t localhost/bootc -f hack/Containerfile .
5959
- name: Container integration
60-
run: sudo podman run --rm localhost/bootc bootc internal-tests run-container-integration
61-
- name: Privileged tests
62-
run: sudo podman run --rm --privileged -v /run/systemd:/run/systemd -v /:/run/host --pid=host localhost/bootc bootc internal-tests run-privileged-integration
60+
run: sudo podman run --rm localhost/bootc bootc-integration-tests container
6361
cargo-deny:
6462
runs-on: ubuntu-latest
6563
steps:
@@ -78,14 +76,22 @@ jobs:
7876
uses: actions/checkout@v4
7977
- name: Ensure host skopeo is disabled
8078
run: sudo rm -f /bin/skopeo /usr/bin/skopeo
79+
- name: Free up disk space on runner
80+
run: sudo ./ci/clean-gha-runner.sh
8181
- name: Integration tests
8282
run: |
8383
set -xeu
8484
sudo podman build -t localhost/bootc -f hack/Containerfile .
85+
export CARGO_INCREMENTAL=0 # because we aren't caching the test runner bits
86+
cargo build --release -p tests-integration
87+
df -h /
88+
sudo install -m 0755 target/release/tests-integration /usr/bin/bootc-integration-tests
89+
rm target -rf
90+
df -h /
8591
# Nondestructive but privileged tests
86-
cargo run -p tests-integration host-privileged localhost/bootc
92+
sudo bootc-integration-tests host-privileged localhost/bootc
8793
# Finally the install-alongside suite
88-
cargo run -p tests-integration install-alongside localhost/bootc
94+
sudo bootc-integration-tests install-alongside localhost/bootc
8995
docs:
9096
if: ${{ contains(github.event.pull_request.labels.*.name, 'documentation') }}
9197
runs-on: ubuntu-latest

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ prefix ?= /usr
33
all:
44
cargo build --release
55

6-
all-test:
7-
cargo build --release --all-features
8-
96
install:
107
install -D -m 0755 -t $(DESTDIR)$(prefix)/bin target/release/bootc
118
install -d -m 0755 $(DESTDIR)$(prefix)/lib/systemd/system-generators/
@@ -22,11 +19,14 @@ install:
2219
done
2320
install -D -m 0644 -t $(DESTDIR)/$(prefix)/lib/systemd/system systemd/*.service systemd/*.timer
2421

22+
install-with-tests: install
23+
install -D -m 0755 target/release/tests-integration $(DESTDIR)$(prefix)/bin/bootc-integration-tests
24+
2525
bin-archive: all
2626
$(MAKE) install DESTDIR=tmp-install && tar --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf
2727

28-
test-bin-archive: all-test
29-
$(MAKE) install DESTDIR=tmp-install && tar --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf
28+
test-bin-archive: all
29+
$(MAKE) install-with-tests DESTDIR=tmp-install && tar --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf
3030

3131
install-kola-tests:
3232
install -D -t $(DESTDIR)$(prefix)/lib/coreos-assembler/tests/kola/bootc tests/kolainst/*

ci/clean-gha-runner.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -xeuo pipefail
3+
df -h
4+
docker image prune --all --force > /dev/null
5+
rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android
6+
apt-get remove -y '^aspnetcore-.*' > /dev/null
7+
apt-get remove -y '^dotnet-.*' > /dev/null
8+
apt-get remove -y '^llvm-.*' > /dev/null
9+
apt-get remove -y 'php.*' > /dev/null
10+
apt-get remove -y '^mongodb-.*' > /dev/null
11+
apt-get remove -y '^mysql-.*' > /dev/null1
12+
apt-get remove -y azure-cli google-chrome-stable firefox mono-devel >/dev/null
13+
df -h

lib/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,4 @@ default = ["install"]
5454
install = []
5555
# Implementation detail of man page generation.
5656
docgen = ["clap_mangen"]
57-
# This feature should only be enabled in CI environments.
58-
internal-testing-api = ["xshell"]
57+

lib/src/cli.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -161,28 +161,6 @@ impl InternalsOpts {
161161
const GENERATOR_BIN: &'static str = "bootc-systemd-generator";
162162
}
163163

164-
/// Options for internal testing
165-
#[derive(Debug, clap::Subcommand, PartialEq, Eq)]
166-
pub(crate) enum TestingOpts {
167-
/// Execute integration tests that require a privileged container
168-
RunPrivilegedIntegration {},
169-
/// Execute integration tests that target a not-privileged ostree container
170-
RunContainerIntegration {},
171-
/// Block device setup for testing
172-
PrepTestInstallFilesystem { blockdev: Utf8PathBuf },
173-
/// e2e test of install to-filesystem
174-
TestInstallFilesystem {
175-
image: String,
176-
blockdev: Utf8PathBuf,
177-
},
178-
#[clap(name = "verify-selinux")]
179-
VerifySELinux {
180-
root: String,
181-
#[clap(long)]
182-
warn: bool,
183-
},
184-
}
185-
186164
/// Deploy and transactionally in-place with bootable container images.
187165
///
188166
/// The `bootc` project currently uses ostree-containers as a backend
@@ -302,10 +280,6 @@ pub(crate) enum Opt {
302280
#[clap(subcommand)]
303281
#[clap(hide = true)]
304282
Internals(InternalsOpts),
305-
/// Internal integration testing helpers.
306-
#[clap(hide(true), subcommand)]
307-
#[cfg(feature = "internal-testing-api")]
308-
InternalTests(TestingOpts),
309283
#[clap(hide(true))]
310284
#[cfg(feature = "docgen")]
311285
Man(ManOpts),
@@ -689,8 +663,6 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
689663
}
690664
InternalsOpts::FixupEtcFstab => crate::deploy::fixup_etc_fstab(&root),
691665
},
692-
#[cfg(feature = "internal-testing-api")]
693-
Opt::InternalTests(opts) => crate::privtests::run(opts).await,
694666
#[cfg(feature = "docgen")]
695667
Opt::Man(manopts) => crate::docgen::generate_manpages(&manopts.directory),
696668
}

lib/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ mod status;
2929
mod task;
3030
mod utils;
3131

32-
#[cfg(feature = "internal-testing-api")]
33-
mod privtests;
34-
3532
#[cfg(feature = "install")]
3633
mod blockdev;
3734
#[cfg(feature = "install")]

lib/src/privtests.rs

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

tests-integration/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ cap-std-ext = "4"
1717
clap = { version= "4.5.4", features = ["derive","cargo"] }
1818
fn-error-context = "0.2.1"
1919
libtest-mimic = "0.7.3"
20+
rustix = { "version" = "0.38.34", features = ["thread", "fs", "system", "process"] }
21+
serde = { features = ["derive"], version = "1.0.199" }
22+
serde_json = "1.0.116"
2023
tempfile = "3.10.1"
2124
xshell = { version = "0.2.6" }

0 commit comments

Comments
 (0)