Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions .github/workflows/branch-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ jobs:
cargo fmt --manifest-path tests/suites/conformance/Cargo.toml --all -- --check
cargo fmt --manifest-path tests/suites/continuity/Cargo.toml --all -- --check
cargo fmt --manifest-path tests/suites/drivers/podman/Cargo.toml --all -- --check
cargo fmt --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --all -- --check
cargo fmt --manifest-path tests/suites/drivers/vm/Cargo.toml --all -- --check
cargo fmt --manifest-path tests/suites/features/Cargo.toml --all -- --check
cargo fmt --manifest-path tests/support/Cargo.toml --all -- --check

Expand Down Expand Up @@ -329,6 +331,8 @@ jobs:
cargo clippy --locked --manifest-path tests/suites/conformance/Cargo.toml --workspace --all-targets -- -D warnings
cargo clippy --locked --manifest-path tests/suites/continuity/Cargo.toml --workspace --all-targets -- -D warnings
cargo clippy --locked --manifest-path tests/suites/drivers/podman/Cargo.toml --workspace --all-targets -- -D warnings
cargo clippy --locked --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --workspace --all-targets -- -D warnings
cargo clippy --locked --manifest-path tests/suites/drivers/vm/Cargo.toml --workspace --all-targets -- -D warnings
cargo clippy --locked --manifest-path tests/suites/features/Cargo.toml --workspace --all-targets -- -D warnings
cargo clippy --locked --manifest-path tests/support/Cargo.toml --all-targets -- -D warnings

Expand Down Expand Up @@ -626,6 +630,37 @@ jobs:

- name: Test accepted-work library, review-readiness, and issue labeling
run: "mise run test:accepted-work ::: test:review-readiness ::: test:label-issue"
e2e-rust-freeze:
name: Rust E2E Freeze
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- name: Reject new Rust E2E tests
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
# Read current labels so a rerun picks up a maintainer's decision.
exception=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" \
--jq 'any(.labels[]; .name == "test:e2e-rust-exception")')
if [[ "$exception" == true ]]; then
echo "Maintainer exception: test:e2e-rust-exception"
exit 0
fi
bash tasks/scripts/check-e2e-rust-freeze.sh "$BASE_SHA" "$HEAD_SHA"

python-sdk-freeze:
# The Python SDK moved to ai-openshell/sdk-python (#5287), which imported it
# at v0.1.7. Its files stay only until core removes them, so PRs must not
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/branch-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ jobs:
set -euo pipefail
# Retry dependency preparation, then build once.
nix build --no-link .#openshell-test-runner || nix build --no-link .#openshell-test-runner
for family in features drivers/podman; do
for family in features drivers/podman drivers/kubernetes; do
nix run .#openshell-test-runner -- build \
--family "$family" --out "artifacts/e2e-bundles/${family//\//-}"
done
Expand All @@ -285,6 +285,12 @@ jobs:
path: artifacts/e2e-bundles/drivers-podman
retention-days: 5
if-no-files-found: error
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: openshell-e2e-bundle-drivers-kubernetes-x86_64-unknown-linux-musl
path: artifacts/e2e-bundles/drivers-kubernetes
retention-days: 5
if-no-files-found: error

build-external-drivers:
name: ${{ matrix.binary }} (${{ matrix.triple }})
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/e2e-suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ jobs:
{"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-k3s","installer":"k3s","family":"drivers/kubernetes","gateway":"tmachine","runner":"ubuntu-24.04"},
{"environment":"ubuntu-k3s","installer":"k3s-ha","family":"drivers/kubernetes","gateway":"tmachine","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"}
]'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
run: |
set -euo pipefail
nix build --no-link .#openshell-test-runner || nix build --no-link .#openshell-test-runner
for family in features drivers/podman; do
for family in features drivers/podman drivers/kubernetes; do
nix run .#openshell-test-runner -- build \
--family "$family" --out "$RUNNER_TEMP/e2e-bundles/${family//\//-}"
done
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ ocsf_emit!(event);
## Sandbox Infra Changes

- If you change sandbox infrastructure, ensure the relevant sandbox e2e path succeeds.
- For new E2E tests, see [Where a new test goes](TESTING.md#where-a-new-test-goes).

## Network Sockets

Expand Down
82 changes: 80 additions & 2 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,67 @@ tests/tmachine/ # QEMU test machines, Ansible playbooks, and the Session
tests/runner/ # openshell-test-runner: runs a test family in a tmachine environment
```

## E2E suite quickstart

The suites in `tests/suites/` run against a real OpenShell gateway. Tests use
`#[testkit::test]` to get a gateway client, run CLI commands, and clean up
sandboxes. Testkit doesn't install the gateway or its dependencies.

- **Conformance** checks public behavior that must work on every driver.
Tests [share a gateway](#what-a-conformance-test-may-assert) and run with
four nextest workers in CI, except on the VM host lane.
- **Feature suites** check behavior that needs a service or gateway setting,
such as Keycloak. Each feature is a package in the `features` workspace.
- **Driver suites** check behavior specific to one compute driver. Each driver
suite is its own workspace, such as `drivers/kubernetes`.

See [Where a new test goes](#where-a-new-test-goes) before adding coverage.

### Run against a local gateway

With Docker available, `mise run e2e:testkit` starts a gateway and runs
conformance. To use a gateway you've already set up, select it with
`OPENSHELL_GATEWAY` (or use the active gateway) and run the suite with Cargo.
For example, against a Kubernetes gateway:

```shell
cargo test --locked --manifest-path tests/suites/drivers/kubernetes/Cargo.toml
```

For a feature with extra dependencies, you must also provide its settings and
fixtures. The [testkit README](tests/testkit/README.md) explains how tests
find the gateway and CLI.

### Run in the same environment as CI

**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.

On a host with virtualization support, build the installer inputs once with
`nix run .#build-artifacts`. Then run a feature or driver suite:

```shell
nix run .#openshell-test-runner -- run \
--environment ubuntu-docker-rootful-keycloak --installer deb \
--family features --package keycloak-provider-refresh

nix run .#openshell-test-runner -- run \
--environment ubuntu-k3s --installer k3s \
--family drivers/kubernetes --gateway tmachine
```

Use `--installer k3s-ha` for the Kubernetes HA row. For a single test, add
`--filter 'test(kubernetes_sandbox_runs_a_command)'`. Results and logs go to
`artifacts/test-results/` by default. See
[Running suites in a tmachine environment](#running-suites-in-a-tmachine-environment-testsrunner)
for prerequisites and options.

The **VM driver** doesn't run nested inside tmachine. Run `mise run e2e:vm`
on a supported VM host; it starts the VM-backed gateway and runs conformance
and the VM driver suite with one worker each in CI.

## Rust Tests

Unit tests live inline with `#[cfg(test)] mod tests` blocks. Integration tests
Expand Down Expand Up @@ -268,8 +329,8 @@ 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
it instead of building one. `--package` then selects the tests to run from the
bundle, which must hold those packages. Branch E2E builds the `features` and
`drivers/podman` bundles once and passes them to their rows this way. Two runs on one host
bundle, which must hold those packages. Branch E2E builds the feature and driver
bundles once and passes them to their rows this way. Two runs on one host
need different `TMACHINE_SSH_PORT` values (default 2222). The installer
inputs, such as the Debian package and the images, come from `artifacts/`,
built by `nix run .#build-artifacts` or downloaded by CI.
Expand Down Expand Up @@ -458,8 +519,25 @@ def test_multiply(sandbox):
| `sandbox_client` | session | gRPC client connected to the active gateway |
| `sandbox` | function | Factory returning a `Sandbox` context manager |

### Where a new test goes

| If the test needs… | Put it here |
|---|---|
| A public contract that applies to every driver | `tests/suites/conformance` |
| A service or fixed gateway setting | `tests/suites/features/<name>`; add a tmachine add-on if the setup is missing (see [Adding a feature suite](#adding-a-feature-suite)) |
| Driver-specific behavior | `tests/suites/drivers/{docker,podman,kubernetes,vm}`. Kubernetes runs on `k3s` and `k3s-ha`; VM runs on the existing VM host lane. |
| A GPU or a gateway restart or reconfiguration during the test | No home yet. Use [continuity suites](#continuity-suites-testssuitescontinuity) if the runner can apply the disruption between test phases. |

For a GPU or mid-test restart or reconfiguration case that cannot move yet,
link a porting issue under [#5281](https://github.com/ai-openshell/openshell/issues/5281)
and ask a maintainer for `test:e2e-rust-exception`. After a label change, rerun
the Rust E2E Freeze job so it reads the current labels.

### Rust CLI E2E (`e2e/rust/`)

This tree is frozen to new tests. You can edit or delete existing tests.
See [Where a new test goes](#where-a-new-test-goes) for alternatives.

Rust-based e2e tests that exercise the `openshell` CLI binary as a subprocess.
They live in the `openshell-e2e` crate and use a shared harness for sandbox
lifecycle management, output parsing, and cleanup.
Expand Down
10 changes: 10 additions & 0 deletions e2e/rust/e2e-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,16 @@ if [ "${E2E_FEATURES}" = "e2e-conformance-only" ]; then
exit 0
fi

if [ -z "${E2E_TEST_OVERRIDE}" ]; then
echo "==> Running the VM driver suite"
# Conformance reads this list in its own subshell.
vm_unsupported="${OPENSHELL_TEST_UNSUPPORTED:-$("${ROOT}/tasks/scripts/suite-unsupported.sh" vm)}"
OPENSHELL_TEST_UNSUPPORTED="${vm_unsupported}" \
OPENSHELL_TEST_PYTHON_IMAGE="${OPENSHELL_TEST_PYTHON_IMAGE:-${E2E_PULLABLE_PYTHON_IMAGE}}" \
cargo nextest run --locked --manifest-path "${ROOT}/tests/suites/drivers/vm/Cargo.toml" \
--test-threads 1 --no-tests fail
fi

# Seed the catalog once for the whole lane. The profiles live in the gateway
# for as long as it runs, and the import is create-only: a second import of
# the same directory fails with "custom provider profile '<id>' already
Expand Down
6 changes: 6 additions & 0 deletions tasks/rust.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ run = [
"cargo clippy --manifest-path tests/suites/conformance/Cargo.toml --workspace --all-targets -- -D warnings",
"cargo clippy --manifest-path tests/suites/continuity/Cargo.toml --workspace --all-targets -- -D warnings",
"cargo clippy --manifest-path tests/suites/drivers/podman/Cargo.toml --workspace --all-targets -- -D warnings",
"cargo clippy --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --workspace --all-targets -- -D warnings",
"cargo clippy --manifest-path tests/suites/drivers/vm/Cargo.toml --workspace --all-targets -- -D warnings",
"cargo clippy --manifest-path tests/suites/features/Cargo.toml --workspace --all-targets -- -D warnings",
"cargo clippy --manifest-path tests/support/Cargo.toml --all-targets -- -D warnings",
]
Expand All @@ -62,6 +64,8 @@ run = [
"cargo fmt --manifest-path tests/suites/conformance/Cargo.toml --all",
"cargo fmt --manifest-path tests/suites/continuity/Cargo.toml --all",
"cargo fmt --manifest-path tests/suites/drivers/podman/Cargo.toml --all",
"cargo fmt --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --all",
"cargo fmt --manifest-path tests/suites/drivers/vm/Cargo.toml --all",
"cargo fmt --manifest-path tests/suites/features/Cargo.toml --all",
"cargo fmt --manifest-path tests/support/Cargo.toml --all",
]
Expand All @@ -81,6 +85,8 @@ run = [
"cargo fmt --manifest-path tests/suites/conformance/Cargo.toml --all -- --check",
"cargo fmt --manifest-path tests/suites/continuity/Cargo.toml --all -- --check",
"cargo fmt --manifest-path tests/suites/drivers/podman/Cargo.toml --all -- --check",
"cargo fmt --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --all -- --check",
"cargo fmt --manifest-path tests/suites/drivers/vm/Cargo.toml --all -- --check",
"cargo fmt --manifest-path tests/suites/features/Cargo.toml --all -- --check",
"cargo fmt --manifest-path tests/support/Cargo.toml --all -- --check",
]
Expand Down
39 changes: 39 additions & 0 deletions tasks/scripts/check-e2e-rust-freeze.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

base=$(git merge-base "$1" "$2")
head=$2

# Treat a move into the frozen tree like any other new file.
new_files=$(git diff --no-renames --name-only --diff-filter=A "$base" "$head" -- e2e/rust/tests/)

# Scan added lines only; hunk headers and context must not count. Match
# parameterized Tokio attributes too, including when their arguments wrap.
new_attributes=$(git diff --no-renames --no-ext-diff --no-textconv --no-color --no-prefix --text \
--unified=0 "$base" "$head" -- e2e/rust/ |
awk '
/^diff --git / { path = ""; in_hunk = 0 }
/^\+\+\+ / && !in_hunk { path = substr($0, 5) }
/^@@ / { in_hunk = 1 }
in_hunk && /^\+[[:space:]]*#[[:space:]]*\[[[:space:]]*(test[[:space:]]*\]|tokio[[:space:]]*::[[:space:]]*test[[:space:]]*(\]|\())/ {
print " " path ": " substr($0, 2)
}
')

if [[ -z "$new_files" && -z "$new_attributes" ]]; then
exit 0
fi

echo "::error title=Rust E2E Freeze::e2e/rust is frozen to new tests. See TESTING.md: Where a new test goes." >&2
if [[ -n "$new_files" ]]; then
echo "New files under e2e/rust/tests:" >&2
printf ' %s\n' "${new_files//$'\n'/$'\n '}" >&2
fi
if [[ -n "$new_attributes" ]]; then
echo "New test attributes under e2e/rust:" >&2
echo "$new_attributes" >&2
fi
exit 1
2 changes: 2 additions & 0 deletions tasks/scripts/check_cargo_lockfile_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"tests/testkit",
"tests/suites/conformance",
"tests/suites/continuity",
"tests/suites/drivers/kubernetes",
"tests/suites/drivers/podman",
"tests/suites/drivers/vm",
"tests/suites/features",
)

Expand Down
Loading
Loading