From e5815b40146332531eb4c0dad1f5c7440b0212f1 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Tue, 1 Dec 2026 12:43:50 -0800 Subject: [PATCH 1/5] chore(tests): include every tests/support directory as a workspace member Signed-off-by: Matthew Grossman --- TESTING.md | 3 ++- tests/support/Cargo.toml | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/TESTING.md b/TESTING.md index cefa946ff5..b6d16b71eb 100644 --- a/TESTING.md +++ b/TESTING.md @@ -388,7 +388,8 @@ service. without quoting. - **Fixture.** Put the service's fixture in a support crate under `tests/support/`, named `-support`, so any suite can - depend on it, or reuse the existing one. It defines the variable names as constants and a + depend on it, or reuse the existing one. The `tests/support` workspace picks + up every directory, so the crate needs no `members` entry. It defines the variable names as constants and a `Context::new(cx)` that reads them, waits for the service, and wraps the testkit `Context`. Each test calls it on its first line. Nextest runs each test in its own process, so the fixture builds its diff --git a/tests/support/Cargo.toml b/tests/support/Cargo.toml index ad39c93144..c9faf9e530 100644 --- a/tests/support/Cargo.toml +++ b/tests/support/Cargo.toml @@ -2,7 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 # Support crates for test suites, one per concern, such as a service the -# environment runs. Suites depend on them by path. +# environment runs. Suites depend on them by path. Every directory here is a +# member, so a new crate needs no entry. [workspace] resolver = "2" -members = ["container-engine", "corporate-proxy", "host-server", "keycloak", "otlp", "podman", "sandbox-clients", "spiffe"] +members = ["*"] +exclude = ["target"] From 579fea0e08dccd7682f04d65c60d0be27b7ae29b Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Tue, 1 Dec 2026 12:45:59 -0800 Subject: [PATCH 2/5] refactor(tmachine): define each feature environment in its own file Signed-off-by: Matthew Grossman --- TESTING.md | 11 ++-- tests/tmachine/config.nix | 63 ++++----------------- tests/tmachine/features/cdi.nix | 9 +++ tests/tmachine/features/corporate-proxy.nix | 10 ++++ tests/tmachine/features/ipv6.nix | 9 +++ tests/tmachine/features/keycloak.nix | 12 ++++ tests/tmachine/features/oidc.nix | 16 ++++++ tests/tmachine/features/otlp.nix | 10 ++++ tests/tmachine/features/spiffe.nix | 11 ++++ 9 files changed, 95 insertions(+), 56 deletions(-) create mode 100644 tests/tmachine/features/cdi.nix create mode 100644 tests/tmachine/features/corporate-proxy.nix create mode 100644 tests/tmachine/features/ipv6.nix create mode 100644 tests/tmachine/features/keycloak.nix create mode 100644 tests/tmachine/features/oidc.nix create mode 100644 tests/tmachine/features/otlp.nix create mode 100644 tests/tmachine/features/spiffe.nix diff --git a/TESTING.md b/TESTING.md index b6d16b71eb..29416f385d 100644 --- a/TESTING.md +++ b/TESTING.md @@ -377,7 +377,7 @@ it. The environment and the suite share a contract: a set of `OPENSHELL_TEST__*` environment variables that say how to reach the service. -- **Environment.** Add an environment to `tests/tmachine/config.nix` whose +- **Environment.** Add a feature environment, described below, whose setup playbook starts the service (with a restart policy, since setup is cached as a disk) and writes the variables as `KEY=VALUE` lines to `/etc/openshell-test/env.d/.env`. Pass files the playbook needs @@ -420,10 +420,11 @@ nix run .#openshell-test-runner -- run \ A suite that needs setup beyond a container engine runs in a feature environment, named `-`, such as `ubuntu-docker-rootful-keycloak` -or `ubuntu-docker-rootful-cdi`. `features` in `tests/tmachine/config.nix` lists -each feature's setup playbooks, the inputs they read, and the bases it supports. -To add one, add an entry there and use the generated environment name in the -suite's row in `.github/workflows/e2e-suites.yml`. The CDI suite +or `ubuntu-docker-rootful-cdi`. Each feature is a file, +`tests/tmachine/features/.nix`, that lists the feature's setup +playbooks, the inputs they read, and the bases it supports. To add one, add a +file there (`git add` it, since the flake only sees tracked files) and use the +generated environment name in the suite's row in `.github/workflows/e2e-suites.yml`. The CDI suite (`tests/suites/features/cdi`) runs in `ubuntu-docker-rootful-cdi`, which creates hardware-free CDI devices and the host files they reference. The environment tells the suite where its scenarios are with `OPENSHELL_TEST_CDI_SCENARIOS`, the diff --git a/tests/tmachine/config.nix b/tests/tmachine/config.nix index 9123c2a1c3..c6194b0b77 100644 --- a/tests/tmachine/config.nix +++ b/tests/tmachine/config.nix @@ -157,57 +157,18 @@ let }; # Feature environments, -, one per base the feature supports. # A suite that needs a feature's setup runs in that environment, so the setup - # lands in a cached layer and other suites don't carry it. - features = { - # Keycloak, for the keycloak-provider-refresh suite. - keycloak = { - bases = dockerBases ++ podmanBases; - setup = { - playbooks = [ "ansible/playbooks/keycloak.yaml" ]; - inputs.keycloak_realm_file = "../../scripts/keycloak-realm.json"; - }; - }; - # Keycloak plus a gateway that signs users in with it, for the oidc-auth - # suite. Needs the deb or rpm installer, whose gateway runs mTLS. - oidc = { - bases = dockerBases; - setup = { - playbooks = [ - "ansible/playbooks/keycloak.yaml" - "ansible/playbooks/oidc.yaml" - ]; - inputs.keycloak_realm_file = "../../scripts/keycloak-realm.json"; - }; - }; - ipv6 = { - bases = [ "ubuntu-k3s" ]; - setup.playbooks = [ "ansible/playbooks/k3s-ipv6.yaml" ]; - }; - # Hardware-free CDI fixtures, for the cdi suite. - cdi = { - bases = dockerBases ++ podmanBases; - setup.playbooks = [ "ansible/playbooks/cdi.yaml" ]; - }; - # An OTLP collector for the gateway and the agent trace relay, for the - # otlp-relay suite. Its endpoint names Podman's host alias. - otlp = { - bases = podmanBases; - setup.playbooks = [ "ansible/playbooks/otlp.yaml" ]; - }; - # SPIFFE Workload APIs for the gateway and supervisors, for the - # provider-token-exchange suite. Supervisors reach theirs over loopback, - # which needs Podman's host-network supervisors. - spiffe = { - bases = podmanBases; - setup.playbooks = [ "ansible/playbooks/spiffe.yaml" ]; - }; - # A TLS-intercepting corporate proxy with Basic auth that the gateway's - # driver sends sandbox egress through, for the corporate-proxy suite. - corporate-proxy = { - bases = dockerBases ++ podmanBases; - setup.playbooks = [ "ansible/playbooks/corporate-proxy.yaml" ]; - }; - }; + # lands in a cached layer and other suites don't carry it. Each feature is a + # file, features/.nix, that takes the base lists and returns the + # bases it supports and its setup. + featureFiles = pkgs.lib.filterAttrs ( + file: type: type == "regular" && pkgs.lib.hasSuffix ".nix" file + ) (builtins.readDir ./features); + features = pkgs.lib.mapAttrs' ( + file: _: + pkgs.lib.nameValuePair (pkgs.lib.removeSuffix ".nix" file) ( + import (./features + "/${file}") { inherit dockerBases podmanBases; } + ) + ) featureFiles; featureEnvironments = pkgs.lib.concatMap ( feature: map (base: withSetup base feature features.${feature}.setup) features.${feature}.bases ) (builtins.attrNames features); diff --git a/tests/tmachine/features/cdi.nix b/tests/tmachine/features/cdi.nix new file mode 100644 index 0000000000..cea19bee0e --- /dev/null +++ b/tests/tmachine/features/cdi.nix @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Hardware-free CDI fixtures, for the cdi suite. +{ dockerBases, podmanBases, ... }: +{ + bases = dockerBases ++ podmanBases; + setup.playbooks = [ "ansible/playbooks/cdi.yaml" ]; +} diff --git a/tests/tmachine/features/corporate-proxy.nix b/tests/tmachine/features/corporate-proxy.nix new file mode 100644 index 0000000000..e61a77abee --- /dev/null +++ b/tests/tmachine/features/corporate-proxy.nix @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# A TLS-intercepting corporate proxy with Basic auth that the gateway's +# driver sends sandbox egress through, for the corporate-proxy suite. +{ dockerBases, podmanBases, ... }: +{ + bases = dockerBases ++ podmanBases; + setup.playbooks = [ "ansible/playbooks/corporate-proxy.yaml" ]; +} diff --git a/tests/tmachine/features/ipv6.nix b/tests/tmachine/features/ipv6.nix new file mode 100644 index 0000000000..f6638915e4 --- /dev/null +++ b/tests/tmachine/features/ipv6.nix @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# An IPv6-only k3s cluster, for the conformance and policy-dns-ipv6 suites. +{ ... }: +{ + bases = [ "ubuntu-k3s" ]; + setup.playbooks = [ "ansible/playbooks/k3s-ipv6.yaml" ]; +} diff --git a/tests/tmachine/features/keycloak.nix b/tests/tmachine/features/keycloak.nix new file mode 100644 index 0000000000..b0fc23f0ed --- /dev/null +++ b/tests/tmachine/features/keycloak.nix @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Keycloak, for the keycloak-provider-refresh suite. +{ dockerBases, podmanBases, ... }: +{ + bases = dockerBases ++ podmanBases; + setup = { + playbooks = [ "ansible/playbooks/keycloak.yaml" ]; + inputs.keycloak_realm_file = "../../scripts/keycloak-realm.json"; + }; +} diff --git a/tests/tmachine/features/oidc.nix b/tests/tmachine/features/oidc.nix new file mode 100644 index 0000000000..0344f97a41 --- /dev/null +++ b/tests/tmachine/features/oidc.nix @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Keycloak plus a gateway that signs users in with it, for the oidc-auth +# suite. Needs the deb or rpm installer, whose gateway runs mTLS. +{ dockerBases, ... }: +{ + bases = dockerBases; + setup = { + playbooks = [ + "ansible/playbooks/keycloak.yaml" + "ansible/playbooks/oidc.yaml" + ]; + inputs.keycloak_realm_file = "../../scripts/keycloak-realm.json"; + }; +} diff --git a/tests/tmachine/features/otlp.nix b/tests/tmachine/features/otlp.nix new file mode 100644 index 0000000000..6eea437e99 --- /dev/null +++ b/tests/tmachine/features/otlp.nix @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# An OTLP collector for the gateway and the agent trace relay, for the +# otlp-relay suite. Its endpoint names Podman's host alias. +{ podmanBases, ... }: +{ + bases = podmanBases; + setup.playbooks = [ "ansible/playbooks/otlp.yaml" ]; +} diff --git a/tests/tmachine/features/spiffe.nix b/tests/tmachine/features/spiffe.nix new file mode 100644 index 0000000000..9325710cb1 --- /dev/null +++ b/tests/tmachine/features/spiffe.nix @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# SPIFFE Workload APIs for the gateway and supervisors, for the +# provider-token-exchange suite. Supervisors reach theirs over loopback, +# which needs Podman's host-network supervisors. +{ podmanBases, ... }: +{ + bases = podmanBases; + setup.playbooks = [ "ansible/playbooks/spiffe.yaml" ]; +} From 7a18c0ad9d9d7d6f65494f1a6f19cd3de501710e Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Tue, 1 Dec 2026 12:48:18 -0800 Subject: [PATCH 3/5] docs(tests): document environment variables only in the crate that reads them Signed-off-by: Matthew Grossman --- TESTING.md | 8 +++--- tests/support/README.md | 31 ++++++----------------- tests/support/container-engine/src/lib.rs | 6 +++-- tests/support/keycloak/src/lib.rs | 2 +- 4 files changed, 17 insertions(+), 30 deletions(-) diff --git a/TESTING.md b/TESTING.md index 29416f385d..72c3e6d265 100644 --- a/TESTING.md +++ b/TESTING.md @@ -395,10 +395,10 @@ service. Nextest runs each test in its own process, so the fixture builds its clients there from the variables. A missing variable fails the test; it never skips it. -- **Documentation.** Document the variables in the fixture's module docs, so - anyone can run the suite against their own deployment by setting them, and - add a row for each to the - [environment contract table](tests/support/README.md#environment-contract). +- **Documentation.** Document the variables, and the environment that sets + them, in the fixture's module docs, so anyone can run the suite against + their own deployment by setting them. Don't add them to a shared list; see + the [environment contract](tests/support/README.md#environment-contract). The Keycloak fixture is `tests/support/keycloak`. Run the suite that uses it with: diff --git a/tests/support/README.md b/tests/support/README.md index d734833f77..02e39603e6 100644 --- a/tests/support/README.md +++ b/tests/support/README.md @@ -7,37 +7,22 @@ environment and a fixture share a contract. ## Environment contract -These are the variables that an environment, the test runner or CI sets for -tests to read. A tmachine environment publishes its variables with +An environment, the test runner or CI sets variables for tests to read. A +tmachine environment publishes its variables with `tests/tmachine/ansible/playbooks/test-env.yaml`, and `openshell-test-runner` passes them to the tests. To run a suite against your own deployment, set them yourself. A fixture fails the test when a variable it needs is missing; it -never skips it. Add a row when you add a variable. The runner also sets +never skips it. + +Each support crate, and each suite that reads a variable of its own, +documents its variables and the environment that sets them in its crate docs, +and a missing one is named in the test failure. The table below lists only +the variables that testkit, the runner and CI own. The runner also sets `OPENSHELL_GATEWAY` and `OPENSHELL_BIN`, which testkit reads; see [Running against a gateway](../testkit/README.md#running-against-a-gateway). | Variable | Set by | Read by | Meaning | |---|---|---|---| -| `OPENSHELL_TEST_CONTAINER_ENGINE` | Every Docker and Podman base environment (`playbooks/docker.yaml`, `podman-rootful.yaml`, `podman-rootless.yaml`); `e2e:oci-image` tasks | `container-engine-support` | The command that reaches the gateway's container engine, split on whitespace, such as `docker` or `sudo -n podman`. | -| `OPENSHELL_TEST_PODMAN_USERNS` | `-userns-` (`playbooks/drivers/podman/userns.yaml`) | `podman-support` | The gateway's Podman user-namespace mode: `default`, `auto`, `keep-id` or `private`. | -| `OPENSHELL_TEST_CDI_SCENARIOS` | `-cdi` (`playbooks/cdi.yaml`) | `tests/suites/features/cdi` | The path of the document that names the CDI device kind, each scenario and the checks it expects. | -| `OPENSHELL_TEST_KEYCLOAK_ISSUER` | `-keycloak` (`playbooks/keycloak.yaml`) | `keycloak-support` | The OIDC issuer URL of the test realm, reachable from the test process. | -| `OPENSHELL_TEST_KEYCLOAK_CLIENT_ID` | `-keycloak` | `keycloak-support` | A client in that realm that allows password grants. | -| `OPENSHELL_TEST_KEYCLOAK_USERNAME` | `-keycloak` | `keycloak-support` | The realm user that tests sign in as. | -| `OPENSHELL_TEST_KEYCLOAK_PASSWORD` | `-keycloak` | `keycloak-support` | That user's password. | -| `OPENSHELL_TEST_KEYCLOAK_USER_USERNAME` | `-oidc` (`playbooks/oidc.yaml`) | `keycloak-support` (`User::User`) | A realm user with no platform admin role, which the gateway signs in. | -| `OPENSHELL_TEST_KEYCLOAK_USER_PASSWORD` | `-oidc` | `keycloak-support` | That user's password. | -| `OPENSHELL_TEST_KEYCLOAK_USER_B_USERNAME` | `-oidc` | `keycloak-support` (`User::UserB`) | A second such user, for tests across two users' workspaces. | -| `OPENSHELL_TEST_KEYCLOAK_USER_B_PASSWORD` | `-oidc` | `keycloak-support` | That user's password. | -| `OPENSHELL_TEST_OTLP_LOG` | `-otlp` (`playbooks/otlp.yaml`) | `otlp-support` | The JSONL file where the environment's OTLP collector appends every trace export it receives, readable by the test user. Tests read only spans they named. | -| `OPENSHELL_TEST_OTLP_ENDPOINT` | `-otlp` | `otlp-support` | The collector endpoint in the gateway's `[openshell.gateway.otlp]`, which also enables the agent trace relay. Tests check that sandboxes never see it. | -| `OPENSHELL_TEST_SPIFFE_JWKS` | `-spiffe` (`playbooks/spiffe.yaml`) | `spiffe-support` | The JWKS that verifies the JWT-SVIDs the environment's gateway and supervisor Workload APIs issue. | -| `OPENSHELL_TEST_CORPORATE_PROXY_URL` | `-corporate-proxy` (`playbooks/corporate-proxy.yaml`) | `corporate-proxy-support` | The corporate proxy URL that the gateway's driver sends sandbox egress through, such as `https://host.openshell.internal:3128`. | -| `OPENSHELL_TEST_CORPORATE_PROXY_CA_CERT` | `-corporate-proxy` | `corporate-proxy-support` | The path of the proxy's CA certificate, in PEM. It signs the proxy's listener certificate and the certificates it re-signs tunnels with. | -| `OPENSHELL_TEST_CORPORATE_PROXY_BYPASS_PORT` | `-corporate-proxy` | `corporate-proxy-support` | The port a test listens on for a destination that the gateway's `no_proxy` sends direct. | -| `OPENSHELL_TEST_CORPORATE_PROXY_LOG` | `-corporate-proxy` | `corporate-proxy-support` | The path of the proxy's log, one JSON line per CONNECT, readable by the test user. | -| `OPENSHELL_TEST_ADDITIONAL_CA_CERT` | The additional-CA environment, which sets `openshell.supervisor.network.additional_ca_bundle` (added by #5729) | `host-server-support` (`TestCa::from_env`) | The path of the CA certificate, in PEM, that the supervisor trusts for sandbox egress. | -| `OPENSHELL_TEST_ADDITIONAL_CA_KEY` | The additional-CA environment | `host-server-support` (`TestCa::from_env`) | The path of that CA's private key, in PEM, readable by the test user. Tests sign server certificates with it. | | `OPENSHELL_TEST_BASE_IMAGE` | Optional; you, for example to use a mirror | `testkit::base_image()` | The default sandbox image. Unset, it is `nvcr.io/nvidia/base/ubuntu:24.04`. | | `OPENSHELL_TEST_PYTHON_IMAGE` | Optional; `e2e/rust/e2e-kubernetes.sh` and `e2e-vm.sh` set a pullable image | `testkit::python_image()` | The workload image for tests that run `python3`, curl, git or openssl. Unset, it is `openshell/e2e-python:dev`, which the tmachine installers load. | | `OPENSHELL_TEST_UNSUPPORTED` | CI and `e2e/support/conformance.sh` derive it from `tests/suites/unsupported.yaml` with `tasks/scripts/suite-unsupported.sh` | testkit programs | Tests the environment can't pass yet, as `=` entries. See [Unsupported tests](../testkit/README.md#unsupported-tests). | diff --git a/tests/support/container-engine/src/lib.rs b/tests/support/container-engine/src/lib.rs index d3cc525fa9..bd7a63b453 100644 --- a/tests/support/container-engine/src/lib.rs +++ b/tests/support/container-engine/src/lib.rs @@ -15,8 +15,10 @@ //! | Rootful Podman | `sudo -n podman` | //! //! The value is split on whitespace, so it can't hold arguments with spaces. -//! Under `openshell-test-runner`, the tmachine environment's setup publishes -//! it. A missing variable fails the test; it never skips it. +//! Under `openshell-test-runner`, every tmachine Docker and Podman base +//! environment publishes it (`tests/tmachine/ansible/playbooks/docker.yaml`, +//! `podman-rootful.yaml` and `podman-rootless.yaml`), and the `e2e:oci-image` +//! tasks set it. A missing variable fails the test; it never skips it. use std::path::Path; diff --git a/tests/support/keycloak/src/lib.rs b/tests/support/keycloak/src/lib.rs index c4b70c9215..a2e8951044 100644 --- a/tests/support/keycloak/src/lib.rs +++ b/tests/support/keycloak/src/lib.rs @@ -5,7 +5,7 @@ //! //! The environment runs Keycloak and publishes how to reach it in //! `OPENSHELL_TEST_KEYCLOAK_*` variables. Under `openshell-test-runner`, the -//! tmachine `ubuntu-docker-rootful-keycloak` environment does that +//! tmachine `-keycloak` environments do that //! (`tests/tmachine/ansible/playbooks/keycloak.yaml`); against your own //! deployment, set them yourself: //! From 36a816bf7d0d38f0637214db5a9eb3c5ccee5f2e Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Tue, 1 Dec 2026 12:53:11 -0800 Subject: [PATCH 4/5] ci(e2e): list the E2E suites each environment runs in tests/suites/ci-matrix.yaml The matrix is keyed by environment and installer, with sorted suite lists, so the file shows what each environment runs and changes that add different suites edit different lines. tasks/scripts/e2e-suite-rows.sh expands it into the rows e2e-suites.yml and check-conformance-program.sh read. Signed-off-by: Matthew Grossman --- .github/workflows/branch-e2e.yml | 4 +- .github/workflows/e2e-suites.yml | 86 +++-------- CI.md | 6 +- TESTING.md | 19 ++- tasks/scripts/check-conformance-program.sh | 5 +- tasks/scripts/e2e-suite-rows.jq | 70 +++++++++ tasks/scripts/e2e-suite-rows.sh | 32 ++++ tests/suites/ci-matrix.yaml | 161 +++++++++++++++++++++ tests/testkit/README.md | 6 +- 9 files changed, 305 insertions(+), 84 deletions(-) create mode 100644 tasks/scripts/e2e-suite-rows.jq create mode 100755 tasks/scripts/e2e-suite-rows.sh create mode 100644 tests/suites/ci-matrix.yaml diff --git a/.github/workflows/branch-e2e.yml b/.github/workflows/branch-e2e.yml index d09430cf56..ed89371fe0 100644 --- a/.github/workflows/branch-e2e.yml +++ b/.github/workflows/branch-e2e.yml @@ -465,7 +465,7 @@ jobs: CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} # Run the testkit feature suites (tests/suites/features) on tmachine. The - # environments and suites are listed in e2e-suites.yml. + # environments and suites are listed in tests/suites/ci-matrix.yaml. feature-specific-integration: needs: [prepare-integration, build-e2e-bundles] permissions: @@ -482,7 +482,7 @@ jobs: CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} # Run the testkit driver suites (tests/suites/drivers) on tmachine. The - # environments and suites are listed in e2e-suites.yml. + # environments and suites are listed in tests/suites/ci-matrix.yaml. driver-specific-integration: needs: [prepare-integration, build-e2e-bundles] permissions: diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index 0beea45fda..62d81df830 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -1,11 +1,13 @@ # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -# Runs testkit suites in tmachine environments on CI. Each row of `ROWS` below +# Runs testkit suites in tmachine environments on CI. Each row, from +# tests/suites/ci-matrix.yaml (expanded by tasks/scripts/e2e-suite-rows.sh), # names a tmachine environment and installer, the family (the path of a # workspace under tests/suites/, such as conformance or drivers/podman) and, -# optionally, the package in it, the gateway name the installer registers, and -# the runner label for the environment's architecture. `openshell-test-runner` +# optionally, the package in it and the gateway name the installer registers. +# A row without a package runs every package in the workspace; each driver +# suite is a workspace of its own. `openshell-test-runner` # builds the tests, boots the environment, runs them inside it and checks the # results. With `prebuilt`, the rows run what the caller built once for the # run instead: conformance rows the static `openshell-conformance`, the other @@ -68,8 +70,8 @@ concurrency: cancel-in-progress: ${{ inputs['cancel-in-progress'] }} jobs: - # The rows live here, in one place. Add an environment or a suite by adding a - # row; the runner needs no list of its own. + # The rows come from tests/suites/ci-matrix.yaml. Add an environment or a + # suite there; the runner needs no list of its own. select: name: Select E2E suites runs-on: ubuntu-24.04 @@ -78,6 +80,12 @@ jobs: matrix: ${{ steps.rows.outputs.matrix }} upgrade_source_tag: ${{ steps.baseline.outputs.tag }} steps: + # The matrix of the revision under test, which the suites job runs. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ inputs['source-sha'] }} + persist-credentials: false + - name: Select the rows to run id: rows env: @@ -86,71 +94,17 @@ jobs: UPGRADE_SOURCE: ${{ inputs.upgrade-source }} run: | set -euo pipefail - # Only amd64 for now: CI has no arm64 runner with KVM for tmachine, - # and the caller only builds amd64 inputs. The gateway is the name the - # installer registers with the CLI: `openshell` for the packages, - # `tmachine` for the k3s and binaries installers. A row without a - # 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","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-k3s-ipv6","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"}, - {"environment":"ubuntu-docker-rootful-corporate-proxy","installer":"deb","family":"features","package":"corporate-proxy","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootful-corporate-proxy","installer":"rpm","family":"features","package":"corporate-proxy","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootless-corporate-proxy","installer":"rpm","family":"features","package":"corporate-proxy","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-docker-rootful-keycloak","installer":"deb","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-docker-rootful-oidc","installer":"deb","family":"features","package":"oidc-auth","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-docker-rootful","installer":"deb","family":"features","package":"oci-image","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootful","installer":"rpm","family":"features","package":"oci-image","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootless","installer":"rpm","family":"features","package":"oci-image","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-docker-rootful","installer":"deb","family":"features","package":"host-gateway","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootful","installer":"rpm","family":"features","package":"host-gateway","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootless","installer":"rpm","family":"features","package":"host-gateway","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-k3s","installer":"k3s","family":"features","package":"host-gateway","gateway":"tmachine","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"features","package":"host-gateway","gateway":"tmachine","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-docker-rootful","installer":"deb","family":"features","package":"routable-host-ip","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootful","installer":"rpm","family":"features","package":"routable-host-ip","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-k3s","installer":"k3s","family":"features","package":"routable-host-ip","gateway":"tmachine","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"features","package":"routable-host-ip","gateway":"tmachine","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-k3s-ipv6","installer":"k3s-ha","family":"features","package":"policy-dns-ipv6","gateway":"tmachine","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-docker-rootful","installer":"deb","family":"features","package":"connect-ssh-supervision","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootless-otlp","installer":"rpm","family":"features","package":"otlp-relay","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-docker-rootful","installer":"deb","family":"features","package":"otlp-relay-inactive","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootless-spiffe","installer":"rpm","family":"features","package":"provider-token-exchange","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-docker-rootful","installer":"deb","family":"features","package":"service-exposure","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootful","installer":"rpm","family":"features","package":"service-exposure","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootless","installer":"rpm","family":"features","package":"service-exposure","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootful-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootless-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootful-userns-default","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootful-userns-auto","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootful-userns-keep-id","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootful-userns-private","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootless-userns-default","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootless-userns-auto","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootless-userns-keep-id","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"fedora-podman-rootless-userns-private","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-docker-rootful","installer":"deb","family":"continuity","disruption":"gateway-restart","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-docker-rootful","installer":"deb-upgrade-source","family":"continuity","disruption":"upgrade","gateway":"openshell","runner":"ubuntu-24.04","upgrade_source":true,"upgrade_package":"deb"} - ]' - # `suite` names the row's tests in the job and artifact names. + rows="$(tasks/scripts/e2e-suite-rows.sh)" + # The workflow picks the runner, and the bundle target to match, so a + # matrix change can't choose one. Only amd64 for now: CI has no arm64 + # runner with KVM for tmachine, and the caller only builds amd64 inputs. matrix=$(jq -c --arg family "${FAMILY}" --arg external "${EXTERNAL_DRIVERS}" --arg upgrade "${UPGRADE_SOURCE}" '{include: map( select($family == "" or .family == $family or (.family | startswith($family + "/"))) | select((.external_driver // false) == false or $external == "true") | select((.upgrade_source // false) == false or $upgrade == "true") - | .package //= "" - | .disruption //= "" - | .suite = ([.family, .package, .disruption] | map(select(. != "")) | join("/")) - | .artifact = ([.suite, .environment, .installer] | join("-") | gsub("/"; "-")) - | .bundle = "openshell-e2e-bundle-\(.family | gsub("/"; "-"))-x86_64-unknown-linux-musl" + | .runner = "ubuntu-24.04" + | .bundle = "openshell-e2e-bundle-\(.bundle_family)-x86_64-unknown-linux-musl" + | del(.bundle_family) )}' <<< "$rows") if [ "$(jq '.include | length' <<< "$matrix")" -eq 0 ]; then echo "::error::No E2E suites match family '${FAMILY}'" diff --git a/CI.md b/CI.md index 6e1e964d05..3d444c529b 100644 --- a/CI.md +++ b/CI.md @@ -242,7 +242,7 @@ When multiple labels are present, `Branch E2E Checks` builds each generic multi- The `OpenShell / E2E` required status is evaluated from the `Core E2E result` job inside that workflow. `test:e2e-kubernetes` is optional while Kubernetes HA and credential-driver behavior are under active iteration: failures are visible in the workflow run but do not publish a required CI gate status. `test:e2e:continuity` is optional too. The continuity suites (`tests/suites/continuity`) check that state created before -a disruption survives it. Each row of `e2e-suites.yml` names one disruption: +a disruption survives it. Each continuity suite in `tests/suites/ci-matrix.yaml` names one disruption: `gateway-restart` restarts the gateway, and `upgrade` installs the candidate package over the latest published release. Each upgrade row downloads that release's package and runtime images itself, with the `prepare-upgrade-source` action and a tag @@ -276,8 +276,8 @@ JUnit report, nextest log and, after a failure, the guest's diagnostics as an ### Run a subset of the conformance tests The conformance lanes run the `conformance` crate in `tests/suites/conformance` -through `.github/workflows/e2e-suites.yml`, which keeps the list of -environments. To run one suite in one environment from a checkout, build the +through `.github/workflows/e2e-suites.yml`, in the environments that +`tests/suites/ci-matrix.yaml` lists. To run one suite in one environment from a checkout, build the candidate inputs (see [TESTING.md](TESTING.md)) and narrow the tests with a nextest filterset: diff --git a/TESTING.md b/TESTING.md index 72c3e6d265..154607b484 100644 --- a/TESTING.md +++ b/TESTING.md @@ -56,8 +56,8 @@ find the gateway and CLI. **tmachine** boots a VM, sets up the engine and any add-ons, and installs OpenShell. **`openshell-test-runner`** runs your selected suite in that VM -using nextest. A [CI matrix row](.github/workflows/e2e-suites.yml) pairs -the environment and installer with the family and, for features, the package. +using nextest. The [CI matrix](tests/suites/ci-matrix.yaml) lists the suites +that each environment and installer runs. On a host with virtualization support, build the installer inputs once with `nix run .#build-artifacts`. Then run a feature or driver suite: @@ -343,11 +343,15 @@ built by `nix run .#build-artifacts` or downloaded by CI. A flaky or broken test is marked `#[ignore = ""]`, which takes it out of every environment until it's fixed. -**CI.** `.github/workflows/e2e-suites.yml` lists the environments and suites as -an explicit matrix and runs the runner once per row. Branch E2E calls it once +**CI.** `tests/suites/ci-matrix.yaml` lists, for each environment and +installer, the suites CI runs there. `.github/workflows/e2e-suites.yml` runs the +runner once per suite, environment and installer (a row), and picks the runner +itself. Keep each list sorted; `tasks/scripts/e2e-suite-rows.sh` expands the file +and rejects unsorted lists and unknown suites or installers. Branch E2E calls it once per family when the `test:e2e` label is set, and a failure fails the Core E2E result. Release Dev and Release Qualification run the conformance and feature -families. To run a suite in another environment on CI, add a row. +families. To run a suite in another environment on CI, add it to that +environment's list. ### Adding a feature suite @@ -365,7 +369,8 @@ suite, with a name that says what the suite tests. tests/suites/features/Cargo.toml`, then `uv run tasks/scripts/check_cargo_lockfile_alignment.py --fix`. `cargo fmt` and `cargo clippy` already cover every package in the workspace. -4. Add a row for the suite to the matrix in `.github/workflows/e2e-suites.yml`. +4. Add `features/` to the lists of the environments it runs in, in + `tests/suites/ci-matrix.yaml`. If the feature only needs the gateway, run the suite in an existing environment such as `ubuntu-docker-rootful`, and skip the rest of this @@ -424,7 +429,7 @@ or `ubuntu-docker-rootful-cdi`. Each feature is a file, `tests/tmachine/features/.nix`, that lists the feature's setup playbooks, the inputs they read, and the bases it supports. To add one, add a file there (`git add` it, since the flake only sees tracked files) and use the -generated environment name in the suite's row in `.github/workflows/e2e-suites.yml`. The CDI suite +generated environment name in `tests/suites/ci-matrix.yaml`. The CDI suite (`tests/suites/features/cdi`) runs in `ubuntu-docker-rootful-cdi`, which creates hardware-free CDI devices and the host files they reference. The environment tells the suite where its scenarios are with `OPENSHELL_TEST_CDI_SCENARIOS`, the diff --git a/tasks/scripts/check-conformance-program.sh b/tasks/scripts/check-conformance-program.sh index ca8edaa8f6..13aa14e625 100755 --- a/tasks/scripts/check-conformance-program.sh +++ b/tasks/scripts/check-conformance-program.sh @@ -55,9 +55,8 @@ while IFS= read -r test_name; do done < "${work}/entries" # Accept tmachine rows of every family and the host lanes. -known="$(yq '.jobs.select.steps[] | select(.id == "rows") | .run' "${root}/.github/workflows/e2e-suites.yml" \ - | sed -n "/rows='\[/,/^ *\]'/p" | sed "1s/.*rows='//; \$s/'.*//" \ - | yq -o=json -I=0 'map(.environment + "/" + .installer) + ["docker", "podman", "kubernetes", "vm"]')" +known="$("${root}/tasks/scripts/e2e-suite-rows.sh" \ + | jq -c 'map(.environment + "/" + .installer) + ["docker", "podman", "kubernetes", "vm"]')" # shellcheck disable=SC2016 # $name is a yq variable. unknown="$(known="${known}" yq -r '[.[].environments[]] | unique | .[] | select(. as $name | env(known) | any_c(. == $name) | not)' "${unsupported_file}")" diff --git a/tasks/scripts/e2e-suite-rows.jq b/tasks/scripts/e2e-suite-rows.jq new file mode 100644 index 0000000000..34f3cba431 --- /dev/null +++ b/tasks/scripts/e2e-suite-rows.jq @@ -0,0 +1,70 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Expands one E2E matrix file (see tests/suites/ci-matrix.yaml), as JSON, into +# the rows e2e-suites.yml runs. Called by e2e-suite-rows.sh with: +# $file the matrix file's path, for error messages; +# $crates every crate under tests/suites/ as {dir, workspace, package}, where +# package is the Cargo package name, or null for a virtual workspace. + +def fail($msg): error("\($file): \($msg)"); + +def workspaces: $crates | map(select(.workspace) | .dir); + +def check_keys($allowed; $what): + (keys - $allowed) as $extra + | if $extra == [] then . else fail("\($what) cannot set \($extra | join(", "))") end; + +def check_installer($name): + check_keys(["gateway", "external_driver", "upgrade_source", "upgrade_package"]; "installer \($name)") + | if .gateway == null then fail("installer \($name) needs a gateway") else . end; + +def check_suite($name): + check_keys(["family", "package", "disruption", "test_threads"]; "suite \($name)") + | .family as $family + | if workspaces | index($family) then . else fail("suite \($name): \($family) is not a workspace under tests/suites") end; + +def check_list($where): + if . == unique then . else fail("\($where): sort the suites and list each once") end; + +def check_matrix: + .installers = ((.installers // {}) | with_entries(.key as $name | .value |= check_installer($name))) + | .suites = ((.suites // {}) | with_entries(.key as $name | .value |= check_suite($name))) + | .environments = ((.environments // fail("no environments")) + | with_entries(.key as $env | .value |= with_entries(.key as $installer | .value |= check_list("\($env) \($installer)")))); + +# A suite under `suites` is used as written, and named after its family, +# package and disruption. Any other suite is a workspace under tests/suites/ +# (the whole workspace), or a crate directory in one (that crate's package), +# and is named as written. +def resolve_suite($suite; $defined; $where): + if $defined[$suite] then + $defined[$suite] | .suite = ([.family, .package, .disruption] | map(select(. != null)) | join("/")) + else + ([workspaces[] | . as $w | select($suite == $w or ($suite | startswith($w + "/")))] | max_by(length) + // fail("\($where): \($suite) is not a workspace under tests/suites")) as $family + | if $suite == $family then + {family: $family, suite: $suite} + else + (first($crates[] | select(.dir == $suite and (.workspace | not)) | .package) + // fail("\($where): \($suite) is not a package under tests/suites")) as $package + | {family: $family, package: $package, suite: $suite} + end + end; + +# `suite` names the row in its check and artifact names, `artifact` names its +# results, and `bundle_family` its family's test bundle; the workflow adds the +# bundle's target architecture. +def row($env; $installer; $settings; $resolved): + {environment: $env, installer: $installer, package: "", disruption: ""} + $resolved + $settings + | .artifact = ([.suite, .environment, .installer] | join("-") | gsub("/"; "-")) + | .bundle_family = (.family | gsub("/"; "-")); + +check_matrix +| .installers as $installers +| .suites as $defined +| [.environments | to_entries[] | .key as $env + | .value | to_entries[] | .key as $installer + | ($installers[$installer] // fail("\($env): installer \($installer) is not under installers")) as $settings + | .value[] + | row($env; $installer; $settings; resolve_suite(.; $defined; "\($env) \($installer)"))] diff --git a/tasks/scripts/e2e-suite-rows.sh b/tasks/scripts/e2e-suite-rows.sh new file mode 100755 index 0000000000..d4f35c65a4 --- /dev/null +++ b/tasks/scripts/e2e-suite-rows.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Print the rows that .github/workflows/e2e-suites.yml runs, as one JSON array +# with one row per environment, installer and suite. The rows come from the +# matrix files given as arguments, tests/suites/ci-matrix.yaml by default; see +# that file for the format and e2e-suite-rows.jq for the expansion. + +set -euo pipefail + +root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +suites="${root}/tests/suites" +if [[ $# -eq 0 ]]; then + set -- "${suites}/ci-matrix.yaml" +fi + +# Every crate under tests/suites/: its directory, whether it is a workspace, +# and its Cargo package name. +crates="$(cd "${suites}" && find . -name target -prune -o -name Cargo.toml -print \ + | sed 's|^\./||' | LC_ALL=C sort \ + | while IFS= read -r manifest; do + dir="$(dirname "${manifest}")" yq -p toml -o=json -I=0 \ + '{"dir": strenv(dir), "workspace": has("workspace"), "package": (.package.name // null)}' "${manifest}" + done | jq -cs .)" + +rows="$(for file in "$@"; do + yq -o=json -I=0 . "${file}" \ + | jq -c --arg file "${file#"${root}/"}" --argjson crates "${crates}" -f "${root}/tasks/scripts/e2e-suite-rows.jq" +done)" +jq -cs 'add' <<< "${rows}" diff --git a/tests/suites/ci-matrix.yaml b/tests/suites/ci-matrix.yaml new file mode 100644 index 0000000000..69ffac72ec --- /dev/null +++ b/tests/suites/ci-matrix.yaml @@ -0,0 +1,161 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# The E2E suites CI runs in each tmachine environment. Under `environments`, +# each environment lists its installers, and each installer the suites to run +# with it. .github/workflows/e2e-suites.yml runs one job per suite, and +# tasks/scripts/e2e-suite-rows.sh expands this file into those jobs. +# +# A suite is the path of a workspace under tests/suites/, or of a crate +# directory in one: `drivers/podman` runs the whole workspace and +# `features/cdi` the package in features/cdi, whatever its Cargo name. The +# path also names the suite's checks. `suites` names the others and sets +# options for a suite wherever it runs. `installers` sets the gateway name each +# installer registers with the CLI, plus its options. The workflow, not this +# file, picks the runner. +# +# Installers and environments are grouped by compute driver. Keep the suite +# lists sorted, so changes that add different suites edit different lines. + +installers: + # Docker. + deb: + gateway: openshell + deb-external-docker-driver: + gateway: openshell + external_driver: true + deb-upgrade-source: + gateway: openshell + upgrade_source: true + upgrade_package: deb + + # Podman. + rpm: + gateway: openshell + + # Kubernetes (k3s). + k3s: + gateway: tmachine + k3s-ha: + gateway: tmachine + +# Only for suites that need options, or that aren't a workspace or package +# path: the continuity entries are names for disruptions, not paths. +suites: + conformance: + family: conformance + package: conformance + test_threads: 4 + continuity/gateway-restart: + family: continuity + disruption: gateway-restart + continuity/upgrade: + family: continuity + disruption: upgrade + +environments: + # Docker. + ubuntu-docker-rootful: + deb: + - conformance + - continuity/gateway-restart + - features/connect-ssh-supervision + - features/host-gateway + - features/oci-image + - features/otlp-relay-inactive + - features/routable-host-ip + - features/service-exposure + deb-external-docker-driver: + - conformance + deb-upgrade-source: + - continuity/upgrade + ubuntu-docker-rootful-cdi: + deb: + - features/cdi + ubuntu-docker-rootful-corporate-proxy: + deb: + - features/corporate-proxy + ubuntu-docker-rootful-keycloak: + deb: + - features/keycloak-provider-refresh + ubuntu-docker-rootful-oidc: + deb: + - features/oidc-auth + + # Podman. + fedora-podman-rootful: + rpm: + - conformance + - features/host-gateway + - features/oci-image + - features/routable-host-ip + - features/service-exposure + fedora-podman-rootful-cdi: + rpm: + - features/cdi + fedora-podman-rootful-corporate-proxy: + rpm: + - features/corporate-proxy + fedora-podman-rootful-keycloak: + rpm: + - features/keycloak-provider-refresh + fedora-podman-rootful-userns-auto: + rpm: + - drivers/podman + fedora-podman-rootful-userns-default: + rpm: + - drivers/podman + fedora-podman-rootful-userns-keep-id: + rpm: + - drivers/podman + fedora-podman-rootful-userns-private: + rpm: + - drivers/podman + fedora-podman-rootless: + rpm: + - conformance + - features/host-gateway + - features/oci-image + - features/service-exposure + fedora-podman-rootless-cdi: + rpm: + - features/cdi + fedora-podman-rootless-corporate-proxy: + rpm: + - features/corporate-proxy + fedora-podman-rootless-keycloak: + rpm: + - features/keycloak-provider-refresh + fedora-podman-rootless-otlp: + rpm: + - features/otlp-relay + fedora-podman-rootless-spiffe: + rpm: + - features/provider-token-exchange + fedora-podman-rootless-userns-auto: + rpm: + - drivers/podman + fedora-podman-rootless-userns-default: + rpm: + - drivers/podman + fedora-podman-rootless-userns-keep-id: + rpm: + - drivers/podman + fedora-podman-rootless-userns-private: + rpm: + - drivers/podman + + # Kubernetes (k3s). + ubuntu-k3s: + k3s: + - conformance + - features/host-gateway + - features/routable-host-ip + k3s-ha: + - conformance + - features/host-gateway + - features/routable-host-ip + ubuntu-k3s-ipv6: + k3s-ha: + - conformance + - features/policy-dns-ipv6 diff --git a/tests/testkit/README.md b/tests/testkit/README.md index 40c28b6152..7471abfd63 100644 --- a/tests/testkit/README.md +++ b/tests/testkit/README.md @@ -315,9 +315,9 @@ keep it in the row and skip it there instead of using `#[ignore]` everywhere: 1. File an issue for the bug. 2. Add the test, issue URL and affected environments to the shared [`unsupported.yaml`](../suites/unsupported.yaml). Each environment is an - [E2E matrix row](../../.github/workflows/e2e-suites.yml) - (`/`, such as `ubuntu-k3s/k3s-ha`) or a host lane - (`docker`, `podman`, `kubernetes` or `vm`). + `/` pair from the + [E2E matrix](../suites/ci-matrix.yaml), such as `ubuntu-k3s/k3s-ha`, or a + host lane (`docker`, `podman`, `kubernetes` or `vm`). 3. Delete the entry in the PR that fixes the bug. CI validates the entries and passes those for each row as From 81a0c98b8be3c701e729a8cd58259bd246fb8ef5 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Tue, 1 Dec 2026 15:16:07 -0800 Subject: [PATCH 5/5] refactor(ci): expand the E2E matrix in Python tasks/scripts/e2e_suite_rows.py replaces the shell and jq expansion of tests/suites/ci-matrix.yaml. The rows are unchanged. Signed-off-by: Matthew Grossman --- .github/workflows/e2e-suites.yml | 9 +- TESTING.md | 2 +- tasks/scripts/check-conformance-program.sh | 2 +- tasks/scripts/e2e-suite-rows.jq | 70 -------------- tasks/scripts/e2e-suite-rows.sh | 32 ------- tasks/scripts/e2e_suite_rows.py | 104 +++++++++++++++++++++ tests/suites/ci-matrix.yaml | 2 +- 7 files changed, 114 insertions(+), 107 deletions(-) delete mode 100644 tasks/scripts/e2e-suite-rows.jq delete mode 100755 tasks/scripts/e2e-suite-rows.sh create mode 100755 tasks/scripts/e2e_suite_rows.py diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index 62d81df830..fa8a66b5c2 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 # Runs testkit suites in tmachine environments on CI. Each row, from -# tests/suites/ci-matrix.yaml (expanded by tasks/scripts/e2e-suite-rows.sh), +# tests/suites/ci-matrix.yaml (expanded by tasks/scripts/e2e_suite_rows.py), # names a tmachine environment and installer, the family (the path of a # workspace under tests/suites/, such as conformance or drivers/podman) and, # optionally, the package in it and the gateway name the installer registers. @@ -86,6 +86,11 @@ jobs: ref: ${{ inputs['source-sha'] }} persist-credentials: false + - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 + with: + version: "0.10.12" + python-version: "3.13" + - name: Select the rows to run id: rows env: @@ -94,7 +99,7 @@ jobs: UPGRADE_SOURCE: ${{ inputs.upgrade-source }} run: | set -euo pipefail - rows="$(tasks/scripts/e2e-suite-rows.sh)" + rows="$(uv run -q tasks/scripts/e2e_suite_rows.py)" # The workflow picks the runner, and the bundle target to match, so a # matrix change can't choose one. Only amd64 for now: CI has no arm64 # runner with KVM for tmachine, and the caller only builds amd64 inputs. diff --git a/TESTING.md b/TESTING.md index 666243d002..a11403d57e 100644 --- a/TESTING.md +++ b/TESTING.md @@ -346,7 +346,7 @@ out of every environment until it's fixed. **CI.** `tests/suites/ci-matrix.yaml` lists, for each environment and installer, the suites CI runs there. `.github/workflows/e2e-suites.yml` runs the runner once per suite, environment and installer (a row), and picks the runner -itself. Keep each list sorted; `tasks/scripts/e2e-suite-rows.sh` expands the file +itself. Keep each list sorted; `tasks/scripts/e2e_suite_rows.py` expands the file and rejects unsorted lists and unknown suites or installers. Branch E2E calls it once per family when the `test:e2e` label is set, and a failure fails the Core E2E result. Release Dev and Release Qualification run the conformance and feature diff --git a/tasks/scripts/check-conformance-program.sh b/tasks/scripts/check-conformance-program.sh index 13aa14e625..97cf73b7a4 100755 --- a/tasks/scripts/check-conformance-program.sh +++ b/tasks/scripts/check-conformance-program.sh @@ -55,7 +55,7 @@ while IFS= read -r test_name; do done < "${work}/entries" # Accept tmachine rows of every family and the host lanes. -known="$("${root}/tasks/scripts/e2e-suite-rows.sh" \ +known="$(uv run -q "${root}/tasks/scripts/e2e_suite_rows.py" \ | jq -c 'map(.environment + "/" + .installer) + ["docker", "podman", "kubernetes", "vm"]')" # shellcheck disable=SC2016 # $name is a yq variable. unknown="$(known="${known}" yq -r '[.[].environments[]] | unique | .[] diff --git a/tasks/scripts/e2e-suite-rows.jq b/tasks/scripts/e2e-suite-rows.jq deleted file mode 100644 index 34f3cba431..0000000000 --- a/tasks/scripts/e2e-suite-rows.jq +++ /dev/null @@ -1,70 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -# Expands one E2E matrix file (see tests/suites/ci-matrix.yaml), as JSON, into -# the rows e2e-suites.yml runs. Called by e2e-suite-rows.sh with: -# $file the matrix file's path, for error messages; -# $crates every crate under tests/suites/ as {dir, workspace, package}, where -# package is the Cargo package name, or null for a virtual workspace. - -def fail($msg): error("\($file): \($msg)"); - -def workspaces: $crates | map(select(.workspace) | .dir); - -def check_keys($allowed; $what): - (keys - $allowed) as $extra - | if $extra == [] then . else fail("\($what) cannot set \($extra | join(", "))") end; - -def check_installer($name): - check_keys(["gateway", "external_driver", "upgrade_source", "upgrade_package"]; "installer \($name)") - | if .gateway == null then fail("installer \($name) needs a gateway") else . end; - -def check_suite($name): - check_keys(["family", "package", "disruption", "test_threads"]; "suite \($name)") - | .family as $family - | if workspaces | index($family) then . else fail("suite \($name): \($family) is not a workspace under tests/suites") end; - -def check_list($where): - if . == unique then . else fail("\($where): sort the suites and list each once") end; - -def check_matrix: - .installers = ((.installers // {}) | with_entries(.key as $name | .value |= check_installer($name))) - | .suites = ((.suites // {}) | with_entries(.key as $name | .value |= check_suite($name))) - | .environments = ((.environments // fail("no environments")) - | with_entries(.key as $env | .value |= with_entries(.key as $installer | .value |= check_list("\($env) \($installer)")))); - -# A suite under `suites` is used as written, and named after its family, -# package and disruption. Any other suite is a workspace under tests/suites/ -# (the whole workspace), or a crate directory in one (that crate's package), -# and is named as written. -def resolve_suite($suite; $defined; $where): - if $defined[$suite] then - $defined[$suite] | .suite = ([.family, .package, .disruption] | map(select(. != null)) | join("/")) - else - ([workspaces[] | . as $w | select($suite == $w or ($suite | startswith($w + "/")))] | max_by(length) - // fail("\($where): \($suite) is not a workspace under tests/suites")) as $family - | if $suite == $family then - {family: $family, suite: $suite} - else - (first($crates[] | select(.dir == $suite and (.workspace | not)) | .package) - // fail("\($where): \($suite) is not a package under tests/suites")) as $package - | {family: $family, package: $package, suite: $suite} - end - end; - -# `suite` names the row in its check and artifact names, `artifact` names its -# results, and `bundle_family` its family's test bundle; the workflow adds the -# bundle's target architecture. -def row($env; $installer; $settings; $resolved): - {environment: $env, installer: $installer, package: "", disruption: ""} + $resolved + $settings - | .artifact = ([.suite, .environment, .installer] | join("-") | gsub("/"; "-")) - | .bundle_family = (.family | gsub("/"; "-")); - -check_matrix -| .installers as $installers -| .suites as $defined -| [.environments | to_entries[] | .key as $env - | .value | to_entries[] | .key as $installer - | ($installers[$installer] // fail("\($env): installer \($installer) is not under installers")) as $settings - | .value[] - | row($env; $installer; $settings; resolve_suite(.; $defined; "\($env) \($installer)"))] diff --git a/tasks/scripts/e2e-suite-rows.sh b/tasks/scripts/e2e-suite-rows.sh deleted file mode 100755 index d4f35c65a4..0000000000 --- a/tasks/scripts/e2e-suite-rows.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -# Print the rows that .github/workflows/e2e-suites.yml runs, as one JSON array -# with one row per environment, installer and suite. The rows come from the -# matrix files given as arguments, tests/suites/ci-matrix.yaml by default; see -# that file for the format and e2e-suite-rows.jq for the expansion. - -set -euo pipefail - -root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" -suites="${root}/tests/suites" -if [[ $# -eq 0 ]]; then - set -- "${suites}/ci-matrix.yaml" -fi - -# Every crate under tests/suites/: its directory, whether it is a workspace, -# and its Cargo package name. -crates="$(cd "${suites}" && find . -name target -prune -o -name Cargo.toml -print \ - | sed 's|^\./||' | LC_ALL=C sort \ - | while IFS= read -r manifest; do - dir="$(dirname "${manifest}")" yq -p toml -o=json -I=0 \ - '{"dir": strenv(dir), "workspace": has("workspace"), "package": (.package.name // null)}' "${manifest}" - done | jq -cs .)" - -rows="$(for file in "$@"; do - yq -o=json -I=0 . "${file}" \ - | jq -c --arg file "${file#"${root}/"}" --argjson crates "${crates}" -f "${root}/tasks/scripts/e2e-suite-rows.jq" -done)" -jq -cs 'add' <<< "${rows}" diff --git a/tasks/scripts/e2e_suite_rows.py b/tasks/scripts/e2e_suite_rows.py new file mode 100755 index 0000000000..044945399a --- /dev/null +++ b/tasks/scripts/e2e_suite_rows.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# /// script +# requires-python = ">=3.11" +# dependencies = [ +# "PyYAML==6.0.2", +# ] +# /// + +"""Print the rows .github/workflows/e2e-suites.yml runs, as a JSON array. + +The rows come from the matrix files given as arguments, +tests/suites/ci-matrix.yaml by default; see that file for the format. +""" + +import json +import sys +import tomllib +from pathlib import Path + +import yaml + +SUITES = Path(__file__).resolve().parents[2] / "tests" / "suites" +INSTALLER_KEYS = {"gateway", "external_driver", "upgrade_source", "upgrade_package"} +SUITE_KEYS = {"family", "package", "disruption", "test_threads"} + +# Workspace directories, and the Cargo package name of every other crate. +workspaces, packages = set(), {} +for manifest in SUITES.rglob("Cargo.toml"): + path = manifest.parent.relative_to(SUITES) + if "target" not in path.parts: + cargo = tomllib.loads(manifest.read_text()) + if "workspace" in cargo: + workspaces.add(path.as_posix()) + else: + packages[path.as_posix()] = cargo["package"]["name"] + + +def check_keys(entry, allowed, what): + if extra := sorted(set(entry) - allowed): + sys.exit(f"{what} cannot set {', '.join(extra)}") + return entry + + +def resolve(suite, defined, where): + """A suite under `suites` is named after its family, package and + disruption. Any other is a workspace (all of it) or a crate directory in + one (its package), and is named as written.""" + if suite in defined: + parts = (defined[suite].get(k) for k in ("family", "package", "disruption")) + return defined[suite] | {"suite": "/".join(p for p in parts if p)} + family = max( + (w for w in workspaces if suite == w or suite.startswith(w + "/")), + key=len, + default=None, + ) + if family is None: + sys.exit(f"{where}: {suite} is not a workspace under tests/suites") + if suite == family: + return {"family": family, "suite": suite} + if suite not in packages: + sys.exit(f"{where}: {suite} is not a package under tests/suites") + return {"family": family, "package": packages[suite], "suite": suite} + + +def expand(path): + matrix = check_keys( + yaml.safe_load(path.read_text()), + {"installers", "suites", "environments"}, + f"{path}: the matrix", + ) + installers = matrix.get("installers") or {} + defined = matrix.get("suites") or {} + for name, installer in installers.items(): + check_keys(installer, INSTALLER_KEYS, f"{path}: installer {name}") + if "gateway" not in installer: + sys.exit(f"{path}: installer {name} needs a gateway") + for name, suite in defined.items(): + check_keys(suite, SUITE_KEYS, f"{path}: suite {name}") + if suite.get("family") not in workspaces: + sys.exit(f"{path}: suite {name}: {suite.get('family')} is not a workspace") + if not matrix.get("environments"): + sys.exit(f"{path}: no environments") + for env, by_installer in matrix["environments"].items(): + for installer, suites in by_installer.items(): + where = f"{path}: {env} {installer}" + if suites != sorted(set(suites)): + sys.exit(f"{where}: sort the suites and list each once") + if installer not in installers: + sys.exit(f"{where}: {installer} is not under installers") + for suite in suites: + row = {"environment": env, "installer": installer} + row |= {"package": "", "disruption": ""} + row |= resolve(suite, defined, where) | installers[installer] + # The workflow adds the bundle's target architecture. + row["artifact"] = f"{row['suite']}-{env}-{installer}".replace("/", "-") + row["bundle_family"] = row["family"].replace("/", "-") + yield row + + +files = [Path(a) for a in sys.argv[1:]] or [SUITES / "ci-matrix.yaml"] +print(json.dumps([row for path in files for row in expand(path)])) diff --git a/tests/suites/ci-matrix.yaml b/tests/suites/ci-matrix.yaml index 69ffac72ec..04a54396a0 100644 --- a/tests/suites/ci-matrix.yaml +++ b/tests/suites/ci-matrix.yaml @@ -4,7 +4,7 @@ # The E2E suites CI runs in each tmachine environment. Under `environments`, # each environment lists its installers, and each installer the suites to run # with it. .github/workflows/e2e-suites.yml runs one job per suite, and -# tasks/scripts/e2e-suite-rows.sh expands this file into those jobs. +# tasks/scripts/e2e_suite_rows.py expands this file into those jobs. # # A suite is the path of a workspace under tests/suites/, or of a crate # directory in one: `drivers/podman` runs the whole workspace and