Skip to content

Commit 10b9d71

Browse files
perf(e2e): run conformance in parallel with nextest (#5865)
* perf(testkit): run conformance tests concurrently within each CI row Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * perf(e2e): schedule prebuilt conformance with nextest Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * refactor(testkit): share E2E runner configuration across suites Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * refactor(e2e): always use nextest in conformance wrappers Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * perf(e2e): bundle nextest in openshell-conformance Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * refactor(conformance): pass scheduler options directly to nextest Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * refactor(testkit): use a shared nextest args namespace Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * ci(e2e): simplify bundled conformance smoke check Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * refactor(e2e): run conformance with external nextest Revert the bundled-nextest packaging. openshell-conformance only writes the metadata nextest needs (nextest-metadata DIR), and callers run cargo-nextest themselves, so every nextest option works unchanged. Replace OPENSHELL_TESTKIT_THREADS with nextest's own NEXTEST_TEST_THREADS. The wrapper's profile defaults to one thread because tests share a gateway. This reverts commits 7dc9bb5, fc3d032, c56037e and d942fbf. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * refactor(e2e): use nextest's default conformance concurrency Drop the wrapper profile's test-threads = 1 so local runs use nextest's default of one test per CPU. CI sets NEXTEST_TEST_THREADS explicitly. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * ci(e2e): run VM conformance with one worker Simultaneous VM launches on a fresh gateway crash with a vCPU "Bad address" error (#5902), so keep the VM lanes serial until the driver handles concurrent first launches. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * fix(e2e): keep conformance worker count out of Kubernetes Rust e2e NEXTEST_TEST_THREADS is set for the whole CI step, so the legacy Kubernetes nextest run inherited it. Unset it there to keep that suite on its own profile's concurrency. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * refactor(e2e): share the prebuilt-program nextest profile The runner and the host-lane wrapper wrote the same nextest profile and passed the same output flags. Keep them in one checked-in file that the runner embeds and the wrapper passes by path. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * docs(testing): link conformance shared-gateway rules to TESTING.md Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * chore(e2e): add SPDX header to the program nextest profile Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> --------- Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
1 parent 8dd34ff commit 10b9d71

19 files changed

Lines changed: 307 additions & 91 deletions

File tree

‎.github/workflows/e2e-docker-test.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,6 @@ jobs:
107107

108108
- name: Run tests
109109
env:
110+
NEXTEST_TEST_THREADS: "4"
110111
OPENSHELL_MCP_CONFORMANCE_CLIENT_IMAGE: ${{ format('openshell-mcp-conformance-client:{0}', inputs.image-tag) }}
111112
run: ${{ matrix.cmd }}

‎.github/workflows/e2e-kubernetes-test.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ jobs:
163163
164164
- name: Run Kubernetes E2E
165165
env:
166+
NEXTEST_TEST_THREADS: "4"
166167
AGENT_SANDBOX_VERSION: ${{ inputs.agent-sandbox-version }}
167168
OPENSHELL_E2E_KUBE_CONTEXT: kind-${{ env.KIND_CLUSTER_NAME }}
168169
OPENSHELL_E2E_KUBE_EXTRA_VALUES: ${{ inputs.extra-helm-values }}

‎.github/workflows/e2e-podman-test.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ jobs:
8383
run: echo "${{ secrets.GITHUB_TOKEN }}" | podman login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin
8484

8585
- name: Run tests
86+
env:
87+
NEXTEST_TEST_THREADS: "4"
8688
run: ${{ matrix.cmd }}
8789

8890
- name: Print AppArmor denials

‎.github/workflows/e2e-suites.yml‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ jobs:
9393
# package runs every package in the workspace; each driver suite is a
9494
# workspace of its own.
9595
rows='[
96-
{"environment":"ubuntu-docker-rootful","installer":"deb","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04"},
97-
{"environment":"ubuntu-docker-rootful","installer":"deb-external-docker-driver","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04","external_driver":true},
98-
{"environment":"fedora-podman-rootful","installer":"rpm","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04"},
99-
{"environment":"fedora-podman-rootless","installer":"rpm","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04"},
100-
{"environment":"ubuntu-k3s","installer":"k3s","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04"},
101-
{"environment":"ubuntu-k3s","installer":"k3s-ha","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04"},
96+
{"environment":"ubuntu-docker-rootful","installer":"deb","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04","test_threads":4},
97+
{"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},
98+
{"environment":"fedora-podman-rootful","installer":"rpm","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04","test_threads":4},
99+
{"environment":"fedora-podman-rootless","installer":"rpm","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04","test_threads":4},
100+
{"environment":"ubuntu-k3s","installer":"k3s","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":4},
101+
{"environment":"ubuntu-k3s","installer":"k3s-ha","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":4},
102102
{"environment":"ubuntu-docker-rootful-cdi","installer":"deb","family":"features","package":"cdi","gateway":"openshell","runner":"ubuntu-24.04"},
103103
{"environment":"fedora-podman-rootful-cdi","installer":"rpm","family":"features","package":"cdi","gateway":"openshell","runner":"ubuntu-24.04"},
104104
{"environment":"fedora-podman-rootless-cdi","installer":"rpm","family":"features","package":"cdi","gateway":"openshell","runner":"ubuntu-24.04"},
@@ -256,6 +256,7 @@ jobs:
256256
PACKAGE: ${{ matrix.package }}
257257
GATEWAY: ${{ matrix.gateway }}
258258
DISRUPTION: ${{ matrix.disruption }}
259+
TEST_THREADS: ${{ matrix.test_threads }}
259260
run: |
260261
# The tests this environment can't pass yet; the runner passes the
261262
# variable on to the guest.
@@ -286,6 +287,9 @@ jobs:
286287
selection+=(--package "${PACKAGE}")
287288
fi
288289
fi
290+
if [ -n "${TEST_THREADS}" ]; then
291+
selection+=(--test-threads "${TEST_THREADS}")
292+
fi
289293
# A continuity row seeds state, applies the disruption, and verifies.
290294
if [ -n "${DISRUPTION}" ]; then
291295
selection+=(--disruption "${DISRUPTION}")

‎.github/workflows/e2e-vm-test.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ jobs:
6464

6565
- name: Run tests
6666
env:
67+
# Simultaneous VM launches crash on a fresh gateway (#5902).
68+
NEXTEST_TEST_THREADS: "1"
6769
E2E_TASK: ${{ inputs.e2e-task }}
6870
OPENSHELL_E2E_VM_TEST: ${{ inputs.test-name }}
6971
run: mise run --no-deps --skip-deps "$E2E_TASK"

‎TESTING.md‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ re-locks a workspace from the root lockfile. Add new testkit workspaces to
203203

204204
#### What a conformance test may assert
205205

206+
Conformance tests must work concurrently on a shared gateway. Use
207+
`Context::name` (or testkit's sandbox builder) for gateway resource names,
208+
use test-unique selector values and host fixtures, and scope assertions and
209+
cleanup to resources the test owns. Do not change gateway-wide settings or
210+
routes.
211+
206212
Conformance tests run on every compute driver, so they check the public
207213
contract and nothing a driver is free to change.
208214

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

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

518530
```shell
519531
OPENSHELL_E2E_KUBERNETES_FEATURES=e2e-conformance-only mise run e2e:kubernetes

‎e2e/rust/e2e-kubernetes.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ run_e2e() {
121121
fi
122122

123123
# Pin `--target-dir` so the profile `junit.path` resolves regardless of `CARGO_TARGET_DIR`.
124-
cargo nextest run --profile e2e-kubernetes \
124+
# NEXTEST_TEST_THREADS sets conformance concurrency, not this suite's.
125+
env -u NEXTEST_TEST_THREADS cargo nextest run --profile e2e-kubernetes \
125126
--config-file "${ROOT}/.config/nextest.toml" \
126127
--target-dir "${ROOT}/e2e/rust/target" \
127128
--manifest-path "${ROOT}/e2e/rust/Cargo.toml" \

‎e2e/support/conformance.sh‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ e2e_openshell_conformance_bin() {
6060
echo "${program}"
6161
}
6262

63-
# Run the conformance suite with openshell-conformance. The JUnit report goes
63+
# Run the conformance suite with nextest. The JUnit report goes
6464
# to OPENSHELL_CONFORMANCE_JUNIT, else results/conformance-<gateway>.xml.
65-
e2e_run_openshell_conformance() {
65+
e2e_run_openshell_conformance() (
6666
local gateway_label=${1:-OpenShell}
6767
local root program junit
6868
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
@@ -84,8 +84,21 @@ e2e_run_openshell_conformance() {
8484
# these for the gateway they started.
8585
echo "==> Running conformance suites against the ${gateway_label} gateway"
8686
"${program}" ready || return
87-
"${program}" run --junit "${junit}"
88-
}
87+
local work status=0
88+
work="$(mktemp -d)" || return
89+
trap 'rm -rf "${work}"' EXIT
90+
"${program}" nextest-metadata "${work}" || return
91+
# The profile the runner also uses for prebuilt programs.
92+
cargo-nextest nextest run \
93+
--cargo-metadata "${work}/cargo-metadata.json" \
94+
--binaries-metadata "${work}/binaries-metadata.json" \
95+
--config-file "${root}/tests/runner/src/program-nextest.toml" \
96+
--profile openshell --no-tests fail || status=$?
97+
if [[ -f "${work}/target/nextest/openshell/junit.xml" ]]; then
98+
mv "${work}/target/nextest/openshell/junit.xml" "${junit}" || return
99+
fi
100+
return "${status}"
101+
)
89102

90103
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
91104
e2e_run_openshell_conformance

‎tasks/scripts/check-conformance-program.sh‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ if [[ ! -s "${work}/nextest" ]] || ! diff -u "${work}/nextest" "${work}/program"
9696
fi
9797
echo "openshell-conformance lists the same $(wc -l < "${work}/program" | tr -d ' ') tests as nextest"
9898

99+
# Check the same inventory from a renamed prebuilt binary without Cargo on PATH.
100+
messages="$(cargo build --locked --manifest-path "${conformance}" --bin openshell-conformance --message-format json)"
101+
program="$(jq -r 'select(.reason == "compiler-artifact" and .executable != null) | .executable' <<< "${messages}")"
102+
cp "${program}" "${work}/test-program"
103+
"${work}/test-program" nextest-metadata "${work}/metadata"
104+
nextest="$(command -v cargo-nextest)"
105+
(
106+
cd "${work}/metadata"
107+
PATH=/usr/bin:/bin OPENSHELL_TEST_UNSUPPORTED="${unsupported}" \
108+
"${nextest}" nextest list --color never --run-ignored all \
109+
--cargo-metadata cargo-metadata.json --binaries-metadata binaries-metadata.json \
110+
--message-format oneline
111+
) > "${work}/prebuilt"
112+
grep -q '^conformance::bin/openshell-conformance ' "${work}/prebuilt"
113+
awk '{print $2}' "${work}/prebuilt" | sort | diff -u "${work}/program" -
114+
99115
if [[ -n "${unsupported}" ]]; then
100116
for manifest in "${manifests[@]}"; do
101117
OPENSHELL_TEST_UNSUPPORTED="${unsupported}" \

‎tests/runner/src/bundle.rs‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct Manifest {
7676
pub enum Kind {
7777
/// A nextest archive, run with `cargo-nextest`.
7878
Nextest,
79-
/// A prebuilt testkit program (`list`, `ready` and `run`), run directly.
79+
/// A prebuilt testkit program, run by nextest without a Cargo build.
8080
Program,
8181
}
8282

@@ -93,7 +93,7 @@ impl Bundle {
9393
}
9494
}
9595

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

112+
/// The nextest configuration written into a program bundle, shared with the
113+
/// host-lane wrapper (`e2e/support/conformance.sh`).
114+
const PROGRAM_CONFIG: &str = include_str!("program-nextest.toml");
115+
111116
/// The Rust target for guests. tmachine only boots guests of the host's
112117
/// architecture, and static musl binaries don't depend on the guest's libc.
113118
fn guest_target() -> Result<&'static str> {
@@ -362,20 +367,27 @@ mod tests {
362367
}
363368

364369
#[test]
365-
fn program_bundle_holds_only_the_program() {
370+
fn program_bundle_holds_the_program_and_nextest_config() {
366371
let dir = tempfile::tempdir().unwrap();
367372
let path = dir.path().join("openshell-conformance");
368373
std::fs::write(&path, b"binary").unwrap();
369374
let bundle = program(&path).unwrap();
370375
assert_eq!(bundle.kind(), Kind::Program);
371-
let names: Vec<_> = std::fs::read_dir(bundle.path())
376+
let mut names: Vec<_> = std::fs::read_dir(bundle.path())
372377
.unwrap()
373378
.map(|entry| entry.unwrap().file_name())
374379
.collect();
375-
assert_eq!(names, [PROGRAM_BINARY]);
380+
names.sort();
381+
assert_eq!(names, [CONFIG, PROGRAM_BINARY]);
376382
assert!(program(&dir.path().join("missing")).is_err());
377383
}
378384

385+
#[test]
386+
fn program_config_defines_the_runner_profile() {
387+
assert!(PROGRAM_CONFIG.contains(&format!("[profile.{PROFILE}]\n")));
388+
assert!(PROGRAM_CONFIG.contains(&format!("[profile.{PROFILE}.junit]\n")));
389+
}
390+
379391
fn write_bundle(dir: &Path, family: &str, packages: &[&str]) {
380392
std::fs::create_dir_all(dir.join("host-gateway")).unwrap();
381393
for name in [ARCHIVE, CONFIG, READY_BINARY, "Cargo.toml"] {

0 commit comments

Comments
 (0)