Skip to content

Commit

Permalink
Merge pull request #576 from cgwalters/testing
Browse files Browse the repository at this point in the history
tests: Drop `internal-testing-api`, move to tests-integration
  • Loading branch information
cgwalters committed Jun 4, 2024
2 parents e51bf9e + 9be6b5a commit 70edd01
Show file tree
Hide file tree
Showing 16 changed files with 183 additions and 371 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ jobs:
- name: Build container (fedora)
run: sudo podman build --build-arg=base=quay.io/fedora/fedora-bootc:40 -t localhost/bootc -f hack/Containerfile .
- name: Container integration
run: sudo podman run --rm localhost/bootc bootc internal-tests run-container-integration
- name: Privileged tests
run: sudo podman run --rm --privileged -v /run/systemd:/run/systemd -v /:/run/host --pid=host localhost/bootc bootc internal-tests run-privileged-integration
run: sudo podman run --rm localhost/bootc bootc-integration-tests container
cargo-deny:
runs-on: ubuntu-latest
steps:
Expand All @@ -78,14 +76,22 @@ jobs:
uses: actions/checkout@v4
- name: Ensure host skopeo is disabled
run: sudo rm -f /bin/skopeo /usr/bin/skopeo
- name: Free up disk space on runner
run: sudo ./ci/clean-gha-runner.sh
- name: Integration tests
run: |
set -xeu
sudo podman build -t localhost/bootc -f hack/Containerfile .
export CARGO_INCREMENTAL=0 # because we aren't caching the test runner bits
cargo build --release -p tests-integration
df -h /
sudo install -m 0755 target/release/tests-integration /usr/bin/bootc-integration-tests
rm target -rf
df -h /
# Nondestructive but privileged tests
cargo run -p tests-integration host-privileged localhost/bootc
sudo bootc-integration-tests host-privileged localhost/bootc
# Finally the install-alongside suite
cargo run -p tests-integration install-alongside localhost/bootc
sudo bootc-integration-tests install-alongside localhost/bootc
docs:
if: ${{ contains(github.event.pull_request.labels.*.name, 'documentation') }}
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ prefix ?= /usr
all:
cargo build --release

all-test:
cargo build --release --all-features

install:
install -D -m 0755 -t $(DESTDIR)$(prefix)/bin target/release/bootc
install -d -m 0755 $(DESTDIR)$(prefix)/lib/systemd/system-generators/
Expand All @@ -22,11 +19,14 @@ install:
done
install -D -m 0644 -t $(DESTDIR)/$(prefix)/lib/systemd/system systemd/*.service systemd/*.timer

install-with-tests: install
install -D -m 0755 target/release/tests-integration $(DESTDIR)$(prefix)/bin/bootc-integration-tests

bin-archive: all
$(MAKE) install DESTDIR=tmp-install && tar --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf

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

install-kola-tests:
install -D -t $(DESTDIR)$(prefix)/lib/coreos-assembler/tests/kola/bootc tests/kolainst/*
Expand Down
13 changes: 13 additions & 0 deletions ci/clean-gha-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -xeuo pipefail
df -h
docker image prune --all --force > /dev/null
rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android
apt-get remove -y '^aspnetcore-.*' > /dev/null
apt-get remove -y '^dotnet-.*' > /dev/null
apt-get remove -y '^llvm-.*' > /dev/null
apt-get remove -y 'php.*' > /dev/null
apt-get remove -y '^mongodb-.*' > /dev/null
apt-get remove -y '^mysql-.*' > /dev/null1
apt-get remove -y azure-cli google-chrome-stable firefox mono-devel >/dev/null
df -h
3 changes: 1 addition & 2 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ default = ["install"]
install = []
# Implementation detail of man page generation.
docgen = ["clap_mangen"]
# This feature should only be enabled in CI environments.
internal-testing-api = ["xshell"]

28 changes: 0 additions & 28 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,28 +170,6 @@ impl InternalsOpts {
const GENERATOR_BIN: &'static str = "bootc-systemd-generator";
}

/// Options for internal testing
#[derive(Debug, clap::Subcommand, PartialEq, Eq)]
pub(crate) enum TestingOpts {
/// Execute integration tests that require a privileged container
RunPrivilegedIntegration {},
/// Execute integration tests that target a not-privileged ostree container
RunContainerIntegration {},
/// Block device setup for testing
PrepTestInstallFilesystem { blockdev: Utf8PathBuf },
/// e2e test of install to-filesystem
TestInstallFilesystem {
image: String,
blockdev: Utf8PathBuf,
},
#[clap(name = "verify-selinux")]
VerifySELinux {
root: String,
#[clap(long)]
warn: bool,
},
}

/// Deploy and transactionally in-place with bootable container images.
///
/// The `bootc` project currently uses ostree-containers as a backend
Expand Down Expand Up @@ -314,10 +292,6 @@ pub(crate) enum Opt {
#[clap(subcommand)]
#[clap(hide = true)]
Internals(InternalsOpts),
/// Internal integration testing helpers.
#[clap(hide(true), subcommand)]
#[cfg(feature = "internal-testing-api")]
InternalTests(TestingOpts),
#[clap(hide(true))]
#[cfg(feature = "docgen")]
Man(ManOpts),
Expand Down Expand Up @@ -714,8 +688,6 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
}
InternalsOpts::FixupEtcFstab => crate::deploy::fixup_etc_fstab(&root),
},
#[cfg(feature = "internal-testing-api")]
Opt::InternalTests(opts) => crate::privtests::run(opts).await,
#[cfg(feature = "docgen")]
Opt::Man(manopts) => crate::docgen::generate_manpages(&manopts.directory),
}
Expand Down
3 changes: 0 additions & 3 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ mod status;
mod task;
mod utils;

#[cfg(feature = "internal-testing-api")]
mod privtests;

#[cfg(feature = "install")]
mod blockdev;
#[cfg(feature = "install")]
Expand Down
212 changes: 0 additions & 212 deletions lib/src/privtests.rs

This file was deleted.

3 changes: 3 additions & 0 deletions tests-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ cap-std-ext = "4"
clap = { version= "4.5.4", features = ["derive","cargo"] }
fn-error-context = "0.2.1"
libtest-mimic = "0.7.3"
rustix = { "version" = "0.38.34", features = ["thread", "fs", "system", "process"] }
serde = { features = ["derive"], version = "1.0.199" }
serde_json = "1.0.116"
tempfile = "3.10.1"
xshell = { version = "0.2.6" }
Loading

0 comments on commit 70edd01

Please sign in to comment.