Skip to content

test(e2e): port CLI exec, attach, and SSH host identity tests to testkit - #5442

Merged
elezar merged 28 commits into
mainfrom
test/5426-port-cli-attach-exec/matthewgrossman
Nov 18, 2026
Merged

elezar merged 28 commits into
mainfrom
test/5426-port-cli-attach-exec/matthewgrossman

Conversation

@matthewgrossman

@matthewgrossman matthewgrossman commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Port the e2e/rust tests that drive a long-running openshell CLI process (exec streaming, attached create, --no-keep, attach/reconnect, and SSH host identity) to testkit, and delete the legacy tests.

Related Issue

Closes #5426
Part of #5281.

Changes

  • testkit: CliChild (Cli::spawn/spawn_with_stdin, cx.cli_spawn/cx.cli_spawn_with_stdin): a long-running CLI process with stdin, a line reader, its pid, signal/kill and wait. kill closes stdin first, as tokio's Child::kill does, so the ssh child of sandbox connect exits and releases the attachment's input. Also Cli::gateway() and Cli::apply_env(), which export the CLI environment for a plain ssh client.
  • Conformance (runs on every conformance row):
    • exec_cli.rs: cli_exec_large_output_is_complete, cli_exec_piped_stdin_crosses_grpc_message_limit
    • cli.rs: cli_attached_create_streams_main_and_reports_exit, cli_no_keep_removes_sandbox_after_main_exit
    • attach.rs: attach_reconnect_replays_history_for_the_same_main_process (it also stops and starts the sandbox while a connect session is open), attach_main_exit_255_is_not_retried_as_transport_failure
    • ssh.rs: ssh_host_identity_stable_across_stop_start_and_new_on_recreate
  • New tests/suites/features/connect-ssh-supervision with one Linux row (ubuntu-docker-rootful, deb) in .github/workflows/e2e-suites.yml: connect_recovers_its_ssh_transport, connect_forwards_pid_targeted_termination_and_reaps_ssh. It reads host procfs directly, matching only processes started by the CLI under test, and fails with a clear message off Linux. The row isn't on k3s, because of Investigate delayed SSH input-owner release through kubectl port-forward #4445.
  • Deleted e2e/rust/tests/ssh_host_identity.rs, and the tests this PR ports from e2e/rust/tests/sandbox_lifecycle.rs. That file stays, holding only on_failure_policy_replaces_runtime_and_preserves_workspace until bug(vm): on-failure restart never completes because the preserved overlay fails e2fsck #5507 (a VM driver bug) is fixed, so its follow-up entry in tests/tmachine/artifacts.nix stays too, with an updated comment. Also removed:
    • the stale [profile.e2e-kubernetes] waiver for canonical_main_connect_recovers_its_ssh_transport in .config/nextest.toml;
    • the now-unused openshell_tty_cmd, shell_escape and nix dependency in e2e/rust.
  • Docs: tests/testkit/README.md, tests/suites/conformance/README.md, and TESTING.md.

Legacy test → new test

Legacy test New test
sandbox_lifecycle::sandbox_exec_large_output_is_complete exec_cli::cli_exec_large_output_is_complete
sandbox_lifecycle::piped_exec_stdin_crosses_grpc_message_limit exec_cli::cli_exec_piped_stdin_crosses_grpc_message_limit
canonical_main_exit_zero_completes_persistent_sandbox + canonical_main_nonzero_exit_preserves_status merged into cli::cli_attached_create_streams_main_and_reports_exit
sandbox_create_with_no_keep_cleans_up_after_tty_command + …_preserves_failure_then_cleans_up merged into cli::cli_no_keep_removes_sandbox_after_main_exit
canonical_main_disconnect_reconnect_replays_history_for_same_process attach::attach_reconnect_replays_history_for_the_same_main_process
canonical_main_exit_255_is_not_retried_as_transport_failure attach::attach_main_exit_255_is_not_retried_as_transport_failure
canonical_main_connect_recovers_its_ssh_transport features/connect-ssh-supervision::connect_recovers_its_ssh_transport
canonical_main_connect_forwards_pid_targeted_termination_and_reaps_ssh features/connect-ssh-supervision::connect_forwards_pid_targeted_termination_and_reaps_ssh
ssh_host_identity::ssh_host_identity_survives_restarts_and_changes_after_recreation split: ssh::ssh_host_identity_stable_across_stop_start_and_new_on_recreate; the gateway-restart part is tracked in #5652

Defaults applied

  • No cli_pty. The legacy attached-create and --no-keep tests ran under script to get a terminal. The ports run each case with --no-tty and with --tty, which gives the main a PTY and makes the CLI attach with ssh -tt, through plain Cli::run. Only connect_forwards_pid_targeted_termination_and_reaps_ssh needs one; it passes an openpty follower as the CliChild's stdin.
  • Split of the attach tests: reconnect/replay and exit 255 are in conformance; SSH transport recovery and pid-targeted termination are in features/connect-ssh-supervision on one Linux row.
  • Named gateway: the ssh host identity test needs one, because sandbox ssh-config writes it into its ProxyCommand. Without one, the test fails with a clear message. It reads the fingerprint through the SDK and keeps the "auth.json unreadable" check.

Testing

  • cargo fmt and cargo clippy --all-targets are clean for testkit, conformance and features, on macOS and in Linux (Docker, rust:1.95-bookworm) for the Linux-only connect-ssh-supervision code
  • cargo test -p openshell-testkit --lib passes, including the new CliChild unit tests
  • cargo check --features e2e,e2e-host-gateway --tests passes in e2e/rust
  • Lockfile alignment check passes
  • E2E tests added/updated (to be validated by Branch E2E on this PR)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

@matthewgrossman matthewgrossman added the test:e2e Requires end-to-end coverage label Nov 10, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown

Label test:e2e applied, but pull-request/5442 does not exist yet. A maintainer needs to comment /ok to test bbbe0433ccf56073b6d28ed92514f2630ce16ba4 to mirror this PR. Once the mirror exists, re-apply the label or re-run Branch E2E Checks from the Actions tab.

@matthewgrossman

Copy link
Copy Markdown
Member Author

/ok to test bbbe043

@elezar
elezar force-pushed the test/5425-port-sandbox-lifecycle/matthewgrossman branch from 1ce77a5 to f8b1ced Compare November 10, 2026 10:44
Move the driver-agnostic sandbox lifecycle, labels, templates, settings,
image, process, Landlock and upload tests from e2e/rust to the conformance
suite, the Podman OCI identity test to the podman driver suite, and the
doctor, proxy-preflight and WebSocket tunnel checks to crate tests. Move the
live-Internet benchmark to mise run perf:live-internet. Delete the legacy
files and their references.

Signed-off-by: Matthew Grossman <[email protected]>
…d test image helpers

Add cx.cli_sandbox (with policy files), ExecOutput::success, cx.sandbox_details, cx.wait_absent and Engine::build_test_image, use them in the ported lifecycle tests, and replace the duplicate policy file, sandbox get and test image code in the host-gateway, oci-image and podman suites.

Signed-off-by: Matthew Grossman <[email protected]>
Replace hand-written exit-code checks in the smoke, lifecycle, persistent_workspace, file_transfer and policy_advisor suites. Polls and checks that expect a failure keep reading the exit code.

Signed-off-by: Matthew Grossman <[email protected]>
…e helpers

Add SandboxBuilder::create_ready, ExecOutput::expect_stdout, Sandbox::poll_exec, Context::delete_and_expect_absent and testkit::with_deadline, and convert std::io::Error into testkit::Error so I/O results take .context directly. Use them across the conformance suite, which also gets shared template, global-setting and label-list helpers and a split on-failure restart poll. Make Engine::build_image private so callers go through build_test_image, which removes the image.

Signed-off-by: Matthew Grossman <[email protected]>
…proxy

Replace the hand-written WebSocket bridge with openshell_sdk::edge_tunnel::start_tunnel_proxy, so the test covers the client half of the tunnel and its edge-token headers as well as the router.

Signed-off-by: Matthew Grossman <[email protected]>
Move expect_listed, expect_absent, wait_absent and the CLI's sandbox get JSON (now get_json) from Context onto Sandbox, and drop delete_and_expect_absent. Give ExecOutput failure() and CliOutput expect_stdout(), so both outputs offer the same checks. Put with_deadline's description first, like poll_until. Make CliSandboxBuilder::run consume the builder like create, and rename its policy setter to policy_yaml. Update the testkit README's list of what a test can do.

Signed-off-by: Matthew Grossman <[email protected]>
Replace CliSandboxBuilder's private PolicyFile with testkit::YamlFile, and drop YamlFile's map_err calls now that I/O errors convert into testkit::Error. CliOutput::success now includes stdout in its failure message, like ExecOutput::success, since many commands report errors there.

Signed-off-by: Matthew Grossman <[email protected]>
…ting changes

Add SandboxBuilder::image and CliSandboxBuilder::create_ready, so both builders set an image and wait for Ready the same way. Convert tonic::Status into testkit::Error, keeping its code, so gRPC results take .context() directly, and drop Error::from_status. Create the host-gateway sandbox with cx.sandbox(..).image(..).policy(..) instead of a hand-written CLI create. In credential gating, use create_ready and poll_exec. Drop the remaining map_err calls on I/O results in host-server-support.

Signed-off-by: Matthew Grossman <[email protected]>
@matthewgrossman
matthewgrossman force-pushed the test/5425-port-sandbox-lifecycle/matthewgrossman branch from f8b1ced to a96df3a Compare November 10, 2026 17:40
@matthewgrossman
matthewgrossman force-pushed the test/5426-port-cli-attach-exec/matthewgrossman branch from bbbe043 to 1b45c0b Compare November 10, 2026 18:19
@matthewgrossman

Copy link
Copy Markdown
Member Author

/ok to test 1b45c0b

…ble driver

The gateway feature matrix builds without Docker, Podman or the VM driver, where the test file has no drivers to check.

Signed-off-by: Matthew Grossman <[email protected]>
…ure restart

Deleting a Docker sandbox that is still starting fails with a 409 because its supervisor volume is in use, so the labels test now waits for Ready before cleanup. The VM driver needs more than 45s to report an on-failure restart; the original e2e test allowed 60s.

Signed-off-by: Matthew Grossman <[email protected]>
…lders

Context, SandboxBuilder, Sandbox and CliSandboxBuilder now share one Handles value (clients, CLI, cleanup), so CliSandboxBuilder owns its state like SandboxBuilder instead of borrowing the context. Both builders are #[must_use] at the type level, and CliSandboxBuilder::image and policy_yaml take impl Into<String> like SandboxBuilder::image.

ExecOutput and CliOutput run success, failure and expect_stdout through one shared check, so their messages match and failure() also reports stderr. ExecOutput.command is renamed description, since it names the exec and its sandbox. CliOutput::message is renamed report_text.

serde_json and serde_yml errors convert into testkit::Error, which removes the last map_err(Error::from_error) calls. expect_listed uses let-else instead of ensure plus expect. kubernetes-updates uses create_ready.

Signed-off-by: Matthew Grossman <[email protected]>
@matthewgrossman

Copy link
Copy Markdown
Member Author

/ok to test d20313c

@matthewgrossman
matthewgrossman force-pushed the test/5426-port-cli-attach-exec/matthewgrossman branch from 1b45c0b to d20313c Compare November 10, 2026 19:07
matthewgrossman and others added 6 commits November 10, 2026 13:26
Read errors in gateway.rs and the image test use .context(..) now that the error types convert. Error::from_error and from_display are crate-private. Document why the global-setting helpers take &Cli, why the template test names and adopts its sandbox by hand, SandboxBuilder::restart_policy, and that the --no-keep test checks only gateway-visible removal.

Signed-off-by: Matthew Grossman <[email protected]>
Restore edge_tunnel_e2e with the --enable-websocket-tunnel flag in the Docker and Podman gateway wrappers, and ephemeral_cleanup with its Podman and VM lane entries. Both check what conformance cannot: the tunnel flag's wiring through a real gateway, and that drivers remove their resources. They move in later batches.

Remove the in-process WebSocket tunnel server test and its openshell-sdk dev-dependency, which checked the listener but not the flag wiring. The --no-keep conformance test now says the driver-resource check stays in ephemeral_cleanup.

Signed-off-by: Matthew Grossman <[email protected]>
The two live-Internet benchmarks were manual, needed the live Internet, and nothing referenced them. Remove the Python port and its perf:live-internet task instead of keeping it. #5472 tracks whether to bring one back.

Signed-off-by: Matthew Grossman <[email protected]>
proxy_settings_are_inserted_before_nested_driver_tables covers insert_docker_driver_settings, which the remaining corporate proxy tests still use. It was removed with the incoherent-configuration test by mistake.

Signed-off-by: Matthew Grossman <[email protected]>
On the VM driver the replacement sandbox never starts: the preserved overlay disk fails e2fsck, and the sandbox stays in Starting. The test fails on every VM lane. Ignore it with a link to #5507, which also tracks removing the ignore.

Signed-off-by: Matthew Grossman <[email protected]>
…2e/rust

Restore `on_failure_policy_replaces_runtime_and_preserves_workspace` in
`sandbox_lifecycle.rs` and `settings_management.rs` as they were, and drop
their conformance counterparts.

The on-failure restart test ran on the Docker and Kubernetes lanes but never
on VM or Podman. Ported to conformance it fails on every VM row (#5507), and
an `#[ignore]` there removes the coverage it gave Docker and Kubernetes.

The global settings test changes a setting for the whole gateway, so it can't
share a conformance run with other tests until the runner has a test group
for it (#5295). `sandbox_setting_round_trip` stays in conformance.

Signed-off-by: Evan Lezar <[email protected]>
@matthewgrossman
matthewgrossman force-pushed the test/5426-port-cli-attach-exec/matthewgrossman branch from d20313c to 77794c7 Compare November 12, 2026 15:37
@matthewgrossman

Copy link
Copy Markdown
Member Author

/ok to test 77794c7

@matthewgrossman

Copy link
Copy Markdown
Member Author

/ok to test eedd41f

@matthewgrossman
matthewgrossman marked this pull request as ready for review November 16, 2026 21:19
On a multi-replica gateway, attaching to a sandbox whose main already
exited fails unless the request reaches the replica holding the
supervisor session (#4949). Delay the main's output and exit so the CLI
attaches while the sandbox is Ready.

Signed-off-by: Matthew Grossman <[email protected]>
@matthewgrossman

Copy link
Copy Markdown
Member Author

/ok to test f394ed8

@elezar elezar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the port. The conformance/feature split makes sense, and CliChild.kill() closing stdin first is a good catch (the unit test for it is helpful). I read the testkit, CI and attach changes closely and skimmed the rest; I haven't run the tests, so I'm relying on Branch E2E.

One thing I'd like resolved before merge, and one small coverage gap:

  1. Track the gateway-restart host-identity check. The legacy ssh_host_identity_survives_restarts… also checked that the identity survives a gateway restart. That part is deferred to "PR6", but I couldn't find an issue for it. Could you link or open one and add it to the gateway-control row of #5281? (inline comment on ssh.rs)
  2. --no-keep under a PTY. The legacy tests ran under a PTY, and the new one only covers the pipe path. (inline comment on cli.rs)

Also noted, not blocking:

  • Transport recovery and SIGTERM forwarding now run on ubuntu-docker-rootful only. I think that's fine. Both are client-side, the gateway-to-sandbox hop is covered by conformance, and the one driver-specific gap is #4445.
  • Suite naming (inline comment on Cargo.toml).

No issues with crypto boundaries or docs/skills drift.

Comment thread tests/suites/conformance/src/ssh.rs Resolved
Comment thread tests/suites/conformance/src/cli.rs Resolved
…rminal

The legacy tests ran under script, so the main got a PTY and the CLI
attached with ssh -tt. Run each case with --no-tty and with --tty.

Signed-off-by: Matthew Grossman <[email protected]>
Match only processes the CLI under test started.

Signed-off-by: Matthew Grossman <[email protected]>
@matthewgrossman

Copy link
Copy Markdown
Member Author

/ok to test f90a4cc

@elezar elezar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround. The tracking issue (#5652), the --tty/--no-tty modes in conformance, the rename and the descendant-scoped process lookup all address my comments. The --tty approach is better than the openpty stdin I suggested. Branch E2E passes on f90a4cc. I haven't run the tests locally.

@elezar
elezar added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit dc236df Nov 18, 2026
263 of 270 checks passed
@elezar
elezar deleted the test/5426-port-cli-attach-exec/matthewgrossman branch November 18, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:build CI/CD workflows, releases, build targets, packaging, and artifact publication. test:e2e Requires end-to-end coverage topic:dx Making OpenShell easy to contribute to for humans and agents. topic:testing Unit, integration, regression, conformance, E2E tests, coverage, flakes, and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(e2e): port CLI-driven exec, attach and SSH host identity tests from e2e/rust

3 participants