Skip to content

Commit 2081449

Browse files
committed
test(podman): run namespace stories against a shared gateway
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent f703015 commit 2081449

25 files changed

Lines changed: 757 additions & 408 deletions

‎.github/workflows/branch-checks.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ jobs:
143143
cargo fmt --all -- --check
144144
cargo fmt --manifest-path e2e/support/rust/Cargo.toml --all -- --check
145145
cargo fmt --manifest-path e2e/suites/conformance/Cargo.toml --all -- --check
146+
cargo fmt --manifest-path e2e/suites/drivers/Cargo.toml --all -- --check
146147
cargo fmt --manifest-path e2e/rust/Cargo.toml --all -- --check
147148
cargo fmt --manifest-path examples/governance-interceptor/Cargo.toml --all -- --check
148149
cargo fmt --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml --all -- --check
@@ -200,6 +201,7 @@ jobs:
200201
cargo clippy --locked --workspace --all-targets -- -D warnings
201202
cargo clippy --locked --manifest-path e2e/support/rust/Cargo.toml --workspace --all-targets -- -D warnings
202203
cargo clippy --locked --manifest-path e2e/suites/conformance/Cargo.toml --workspace --all-targets -- -D warnings
204+
cargo clippy --locked --manifest-path e2e/suites/drivers/Cargo.toml --workspace --all-targets -- -D warnings
203205
cargo clippy --locked --manifest-path e2e/rust/Cargo.toml --all-targets -- -D warnings
204206
cargo clippy --locked --manifest-path examples/governance-interceptor/Cargo.toml --all-targets -- -D warnings
205207
cargo clippy --locked --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml --all-targets -- -D warnings
@@ -241,6 +243,7 @@ jobs:
241243
cargo nextest run --locked --profile ci --workspace --features openshell-server/test-support
242244
cargo nextest run --locked --config-file .config/nextest.toml --profile ci --manifest-path e2e/support/rust/Cargo.toml
243245
cargo nextest run --locked --config-file .config/nextest.toml --profile ci --manifest-path e2e/suites/conformance/Cargo.toml --package openshell-test-conformance-cli -E 'binary(policy_advisor) & test(draft_assertion::tests::)'
246+
cargo nextest run --locked --config-file .config/nextest.toml --profile ci --manifest-path e2e/suites/drivers/Cargo.toml --package openshell-test-suite-podman -E 'test(::tests::)'
244247
cargo nextest run --locked --config-file .config/nextest.toml --profile ci --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml
245248
246249
rust-build-modes:

‎TESTING.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,14 @@ The `e2e-podman` testsuite runs a nextest archive built with the corresponding
336336
Rust feature and preloads its Python workload image into the rootless Podman
337337
store. The separate `driver-podman` testsuite compares OpenShell and direct
338338
Podman user-namespace mappings for the default, `auto`, `keep-id`, and private
339-
profiles. The E2E archive excludes binaries that still depend on wrapper-owned
339+
profiles. Each profile is a named Rust test. The suite runs serially against
340+
the shared gateway; a guest-side file lock also protects separate invocations.
341+
The Rust fixture restores the original gateway configuration, restarts and
342+
checks gateway health, and verifies sandbox cleanup after each test, including
343+
assertion failures. A dirty marker stops later tests after interruption or failed
344+
restoration; start a fresh tmachine invocation to recover.
345+
346+
The E2E archive excludes binaries that still depend on wrapper-owned
340347
gateway controls, host fixtures, missing guest tools, or nondeterministic relay
341348
setup. The `driver-podman` suite replaces the removed `podman_userns` E2E
342349
binary. `tests/artifacts.nix` keeps the follow-up exclusions explicit and uses

‎e2e/suites/drivers/Cargo.lock‎

Lines changed: 87 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎e2e/suites/drivers/podman/Cargo.toml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ repository = "https://github.com/NVIDIA/OpenShell"
1212
[dependencies]
1313
openshell-e2e-support = { path = "../../../support/rust" }
1414
serde = { version = "1", features = ["derive"] }
15-
tokio = { version = "1.43", features = ["macros", "rt"] }
15+
tokio = { version = "1.43", features = ["macros", "rt", "process", "time", "io-util"] }
16+
17+
[dev-dependencies]
18+
futures-util = { version = "0.3", default-features = false, features = ["std"] }
19+
toml_edit = "0.22"
20+
21+
[features]
22+
fixture-validation = []
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Podman driver tests
2+
3+
These tests run inside a disposable tmachine guest against its shared Podman
4+
gateway. Rootful and rootless Podman are separate tmachine environments.
5+
6+
The `user_namespaces` Cargo test target contains four story modules: `default`,
7+
`auto`, `keep_id`, and `private`. Each compares OpenShell's UID mapping with a
8+
direct Podman container in the gateway service user's execution context, and
9+
checks that the non-root workload owns and can write to its managed workspace.
10+
Both commands use the same workload image.
11+
12+
## Gateway fixture
13+
14+
The Rust fixture requires `/etc/openshell/gateway.toml`, the
15+
`openshell-gateway.service` systemd unit, a registered candidate CLI, and
16+
passwordless sudo in the guest. tmachine prepares the writable fixture directory
17+
at `/var/lib/openshell-driver-tests/podman`. This is a dedicated test gateway:
18+
its baseline must omit `userns`, `uidmap`, and `gidmap` and contain no sandboxes.
19+
20+
Ansible installs the archive and invokes nextest once with `--test-threads 1`.
21+
A guest-side file lock also serializes separate Cargo or nextest invocations.
22+
Under the lock, Rust captures the original config, applies the selected profile,
23+
and restarts and checks gateway readiness. After success, an error, or an
24+
assertion panic, it deletes tracked sandboxes, restores the exact original
25+
configuration, restarts the gateway, and verifies health and sandbox absence.
26+
Scenario failures and restoration failures remain test failures.
27+
28+
Before changing the gateway, the fixture writes a dirty marker. It removes that
29+
marker only after successful restoration. An interrupted process or failed
30+
restoration therefore prevents subsequent stories from treating modified state
31+
as their baseline. Start a fresh tmachine invocation to recover; each invocation
32+
uses a disposable overlay over the cached installed guest image.
33+
34+
## Run
35+
36+
Build the candidate runtime inputs and driver archive, then run either environment:
37+
38+
```shell
39+
nix run .#build-podman-driver-test-archive
40+
nix run .#tmachine -- test fedora-podman-rootful binaries driver-podman
41+
nix run .#tmachine -- test fedora-podman-rootless binaries driver-podman
42+
```
43+
44+
The tests may restart the gateway and require guest privileges. Run the pure
45+
configuration and UID-map assertions on the development host with:
46+
47+
```shell
48+
cargo test --locked --manifest-path e2e/suites/drivers/Cargo.toml \
49+
--package openshell-test-suite-podman --test user_namespaces ::tests::
50+
```
51+
52+
Inside a prepared guest, a nextest test-name filter selects one profile. The
53+
`fixture-validation` Cargo feature adds a deliberately failing panic scenario
54+
for validating cleanup; it is excluded from normal archives. Execute that
55+
scenario explicitly, require failure and successful restoration, then run a
56+
normal profile in the same guest to verify recovery.

‎e2e/suites/drivers/podman/fixtures/userns-auto.toml‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎e2e/suites/drivers/podman/fixtures/userns-keep-id.toml‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎e2e/suites/drivers/podman/fixtures/userns-private.toml‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)