|
| 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. |
0 commit comments