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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,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
69 changes: 69 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,60 @@ 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/podman`.

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 conformance with nextest:

```shell
cargo nextest run --locked --manifest-path tests/suites/conformance/Cargo.toml --test-threads 1
```

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 fedora-podman-rootful-userns-default --installer rpm \
--family drivers/podman
```

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.

## Rust Tests

Unit tests live inline with `#[cfg(test)] mod tests` blocks. Integration tests
Expand Down Expand Up @@ -472,8 +526,23 @@ 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/<driver>`; use the Podman suite as a model. |
| State that must survive a restart or upgrade | [Continuity suites](#continuity-suites-testssuitescontinuity) if the runner can apply the disruption between test phases. |

If your test needs an environment or suite that doesn't exist yet, ask a
maintainer where to add it.

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

Do not add new tests to `e2e/rust/`. You can edit or remove 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
8 changes: 8 additions & 0 deletions e2e/rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Legacy Rust E2E tests

Do not add new tests to `e2e/rust/`, including in existing files. This suite
is being retired. You can update or remove existing tests.

Add new E2E coverage with testkit under `tests/suites/`. See
[Where a new test goes](../../TESTING.md#where-a-new-test-goes) and the
[E2E suite quickstart](../../TESTING.md#e2e-suite-quickstart).
Loading