Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/e2e-docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@ jobs:

- name: Run tests
env:
NEXTEST_TEST_THREADS: "4"
OPENSHELL_MCP_CONFORMANCE_CLIENT_IMAGE: ${{ format('openshell-mcp-conformance-client:{0}', inputs.image-tag) }}
run: ${{ matrix.cmd }}
1 change: 1 addition & 0 deletions .github/workflows/e2e-kubernetes-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ jobs:

- name: Run Kubernetes E2E
env:
NEXTEST_TEST_THREADS: "4"
AGENT_SANDBOX_VERSION: ${{ inputs.agent-sandbox-version }}
OPENSHELL_E2E_KUBE_CONTEXT: kind-${{ env.KIND_CLUSTER_NAME }}
OPENSHELL_E2E_KUBE_EXTRA_VALUES: ${{ inputs.extra-helm-values }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/e2e-podman-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ jobs:
run: echo "${{ secrets.GITHUB_TOKEN }}" | podman login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin

- name: Run tests
env:
NEXTEST_TEST_THREADS: "4"
run: ${{ matrix.cmd }}

- name: Print AppArmor denials
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/e2e-suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ jobs:
# package runs every package in the workspace; each driver suite is a
# workspace of its own.
rows='[
{"environment":"ubuntu-docker-rootful","installer":"deb","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04"},
{"environment":"ubuntu-docker-rootful","installer":"deb-external-docker-driver","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04","external_driver":true},
{"environment":"fedora-podman-rootful","installer":"rpm","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04"},
{"environment":"fedora-podman-rootless","installer":"rpm","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04"},
{"environment":"ubuntu-k3s","installer":"k3s","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04"},
{"environment":"ubuntu-k3s","installer":"k3s-ha","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04"},
{"environment":"ubuntu-docker-rootful","installer":"deb","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04","test_threads":4},
{"environment":"ubuntu-docker-rootful","installer":"deb-external-docker-driver","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04","external_driver":true,"test_threads":4},
{"environment":"fedora-podman-rootful","installer":"rpm","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04","test_threads":4},
{"environment":"fedora-podman-rootless","installer":"rpm","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04","test_threads":4},
{"environment":"ubuntu-k3s","installer":"k3s","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":4},
{"environment":"ubuntu-k3s","installer":"k3s-ha","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":4},
{"environment":"ubuntu-docker-rootful-cdi","installer":"deb","family":"features","package":"cdi","gateway":"openshell","runner":"ubuntu-24.04"},
{"environment":"fedora-podman-rootful-cdi","installer":"rpm","family":"features","package":"cdi","gateway":"openshell","runner":"ubuntu-24.04"},
{"environment":"fedora-podman-rootless-cdi","installer":"rpm","family":"features","package":"cdi","gateway":"openshell","runner":"ubuntu-24.04"},
Expand Down Expand Up @@ -252,6 +252,7 @@ jobs:
PACKAGE: ${{ matrix.package }}
GATEWAY: ${{ matrix.gateway }}
DISRUPTION: ${{ matrix.disruption }}
TEST_THREADS: ${{ matrix.test_threads }}
run: |
# The tests this environment can't pass yet; the runner passes the
# variable on to the guest.
Expand Down Expand Up @@ -282,6 +283,9 @@ jobs:
selection+=(--package "${PACKAGE}")
fi
fi
if [ -n "${TEST_THREADS}" ]; then
selection+=(--test-threads "${TEST_THREADS}")
fi
# A continuity row seeds state, applies the disruption, and verifies.
if [ -n "${DISRUPTION}" ]; then
selection+=(--disruption "${DISRUPTION}")
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/e2e-vm-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ jobs:

- name: Run tests
env:
# Simultaneous VM launches crash on a fresh gateway (#5902).
NEXTEST_TEST_THREADS: "1"
E2E_TASK: ${{ inputs.e2e-task }}
OPENSHELL_E2E_VM_TEST: ${{ inputs.test-name }}
run: mise run --no-deps --skip-deps "$E2E_TASK"
18 changes: 15 additions & 3 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ re-locks a workspace from the root lockfile. Add new testkit workspaces to

#### What a conformance test may assert

Conformance tests must work concurrently on a shared gateway. Use
`Context::name` (or testkit's sandbox builder) for gateway resource names,
use test-unique selector values and host fixtures, and scope assertions and
cleanup to resources the test owns. Do not change gateway-wide settings or
routes.

Conformance tests run on every compute driver, so they check the public
contract and nothing a driver is free to change.

Expand Down Expand Up @@ -251,10 +257,13 @@ prebuilt testkit program, such as a static `openshell-conformance` for the
guest's architecture, instead of building the family's tests; it can't be
combined with `--package`. With it, `--filter` (repeatable) takes parts of test
names, as the program does, such as `--filter policy_advisor::`, rather than a
nextest filterset. The runner runs the program's `ready`
and `run` commands in the guest and still writes `junit.xml` and `nextest.log`
(the program's output) to the results directory. Branch E2E builds
nextest filterset. The runner runs the program's `ready` command in the
guest, then uses nextest to run the prebuilt binary. It writes `junit.xml`
and `nextest.log` to the results directory. Branch E2E builds
`openshell-conformance` once and passes it to every conformance row this way.
`--test-threads N` runs up to N tests concurrently in the guest, whether
the runner builds the suite or uses `--bundle` or `--program`. The default
is one. CI rows can opt in with `test_threads`.

`openshell-test-runner build --family <family> --out <dir>` builds a family's
test bundle for the guest without booting a VM, and `run --bundle <dir>` runs
Expand Down Expand Up @@ -514,6 +523,9 @@ feature variable (`OPENSHELL_E2E_DOCKER_FEATURES`, `OPENSHELL_E2E_PODMAN_FEATURE
`e2e-conformance-only` to skip the Rust tests; the runner logs a notice when
it skips them. Unset or empty values select the driver's default Rust
features. The selector is handled by the runner; it is not a Cargo feature.
The wrappers use nextest, which runs one test per CPU by default. Set
`NEXTEST_TEST_THREADS` to change the worker count. For a standalone run without nextest,
invoke `openshell-conformance run` directly.

```shell
OPENSHELL_E2E_KUBERNETES_FEATURES=e2e-conformance-only mise run e2e:kubernetes
Expand Down
3 changes: 2 additions & 1 deletion e2e/rust/e2e-kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ run_e2e() {
fi

# Pin `--target-dir` so the profile `junit.path` resolves regardless of `CARGO_TARGET_DIR`.
cargo nextest run --profile e2e-kubernetes \
# NEXTEST_TEST_THREADS sets conformance concurrency, not this suite's.
env -u NEXTEST_TEST_THREADS cargo nextest run --profile e2e-kubernetes \
--config-file "${ROOT}/.config/nextest.toml" \
--target-dir "${ROOT}/e2e/rust/target" \
--manifest-path "${ROOT}/e2e/rust/Cargo.toml" \
Expand Down
21 changes: 17 additions & 4 deletions e2e/support/conformance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ e2e_openshell_conformance_bin() {
echo "${program}"
}

# Run the conformance suite with openshell-conformance. The JUnit report goes
# Run the conformance suite with nextest. The JUnit report goes
# to OPENSHELL_CONFORMANCE_JUNIT, else results/conformance-<gateway>.xml.
e2e_run_openshell_conformance() {
e2e_run_openshell_conformance() (
local gateway_label=${1:-OpenShell}
local root program junit
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
Expand All @@ -84,8 +84,21 @@ e2e_run_openshell_conformance() {
# these for the gateway they started.
echo "==> Running conformance suites against the ${gateway_label} gateway"
"${program}" ready || return
"${program}" run --junit "${junit}"
}
local work status=0
work="$(mktemp -d)" || return
trap 'rm -rf "${work}"' EXIT
"${program}" nextest-metadata "${work}" || return
# The profile the runner also uses for prebuilt programs.
cargo-nextest nextest run \
--cargo-metadata "${work}/cargo-metadata.json" \
--binaries-metadata "${work}/binaries-metadata.json" \
--config-file "${root}/tests/runner/src/program-nextest.toml" \
--profile openshell --no-tests fail || status=$?
if [[ -f "${work}/target/nextest/openshell/junit.xml" ]]; then
mv "${work}/target/nextest/openshell/junit.xml" "${junit}" || return
fi
return "${status}"
)

if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
e2e_run_openshell_conformance
Expand Down
16 changes: 16 additions & 0 deletions tasks/scripts/check-conformance-program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ if [[ ! -s "${work}/nextest" ]] || ! diff -u "${work}/nextest" "${work}/program"
fi
echo "openshell-conformance lists the same $(wc -l < "${work}/program" | tr -d ' ') tests as nextest"

# Check the same inventory from a renamed prebuilt binary without Cargo on PATH.
messages="$(cargo build --locked --manifest-path "${conformance}" --bin openshell-conformance --message-format json)"
program="$(jq -r 'select(.reason == "compiler-artifact" and .executable != null) | .executable' <<< "${messages}")"
cp "${program}" "${work}/test-program"
"${work}/test-program" nextest-metadata "${work}/metadata"
nextest="$(command -v cargo-nextest)"
(
cd "${work}/metadata"
PATH=/usr/bin:/bin OPENSHELL_TEST_UNSUPPORTED="${unsupported}" \
"${nextest}" nextest list --color never --run-ignored all \
--cargo-metadata cargo-metadata.json --binaries-metadata binaries-metadata.json \
--message-format oneline
) > "${work}/prebuilt"
grep -q '^conformance::bin/openshell-conformance ' "${work}/prebuilt"
awk '{print $2}' "${work}/prebuilt" | sort | diff -u "${work}/program" -

if [[ -n "${unsupported}" ]]; then
for manifest in "${manifests[@]}"; do
OPENSHELL_TEST_UNSUPPORTED="${unsupported}" \
Expand Down
22 changes: 17 additions & 5 deletions tests/runner/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct Manifest {
pub enum Kind {
/// A nextest archive, run with `cargo-nextest`.
Nextest,
/// A prebuilt testkit program (`list`, `ready` and `run`), run directly.
/// A prebuilt testkit program, run by nextest without a Cargo build.
Program,
}

Expand All @@ -93,7 +93,7 @@ impl Bundle {
}
}

/// A bundle holding only `program`, a testkit program already built for the
/// A bundle holding `program`, a testkit program already built for the
/// guest target. `program` must be a static binary, as the guest's libc is
/// not known.
pub fn program(program: &Path) -> Result<Bundle> {
Expand All @@ -105,9 +105,14 @@ pub fn program(program: &Path) -> Result<Bundle> {
let dir = tempfile::tempdir().context("create bundle directory")?;
std::fs::copy(program, dir.path().join(PROGRAM_BINARY))
.with_context(|| format!("copy {}", program.display()))?;
std::fs::write(dir.path().join(CONFIG), PROGRAM_CONFIG)?;
Ok(Bundle(dir, Kind::Program))
}

/// The nextest configuration written into a program bundle, shared with the
/// host-lane wrapper (`e2e/support/conformance.sh`).
const PROGRAM_CONFIG: &str = include_str!("program-nextest.toml");

/// The Rust target for guests. tmachine only boots guests of the host's
/// architecture, and static musl binaries don't depend on the guest's libc.
fn guest_target() -> Result<&'static str> {
Expand Down Expand Up @@ -362,20 +367,27 @@ mod tests {
}

#[test]
fn program_bundle_holds_only_the_program() {
fn program_bundle_holds_the_program_and_nextest_config() {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("openshell-conformance");
std::fs::write(&path, b"binary").unwrap();
let bundle = program(&path).unwrap();
assert_eq!(bundle.kind(), Kind::Program);
let names: Vec<_> = std::fs::read_dir(bundle.path())
let mut names: Vec<_> = std::fs::read_dir(bundle.path())
.unwrap()
.map(|entry| entry.unwrap().file_name())
.collect();
assert_eq!(names, [PROGRAM_BINARY]);
names.sort();
assert_eq!(names, [CONFIG, PROGRAM_BINARY]);
assert!(program(&dir.path().join("missing")).is_err());
}

#[test]
fn program_config_defines_the_runner_profile() {
assert!(PROGRAM_CONFIG.contains(&format!("[profile.{PROFILE}]\n")));
assert!(PROGRAM_CONFIG.contains(&format!("[profile.{PROFILE}.junit]\n")));
}

fn write_bundle(dir: &Path, family: &str, packages: &[&str]) {
std::fs::create_dir_all(dir.join("host-gateway")).unwrap();
for name in [ARCHIVE, CONFIG, READY_BINARY, "Cargo.toml"] {
Expand Down
Loading
Loading