From 49fba1b477af76b0de112608f5cc996fa9867e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Mon, 27 Jul 2026 22:20:14 +0200 Subject: [PATCH] fix(cli): eliminate flaky subprocess integration tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove vm_slow_progress_before_ready from the subprocess-based structured output tests. The 1.8s artificial delay (3x 600ms sleeps) left only ~0.7s headroom within the 5s OPENSHELL_PROVISION_TIMEOUT, causing sporadic TLS handshake failures on loaded Linux machines. Root cause analysis: - The CertificateRequired TLS alert occurs when the provision timeout fires mid-handshake, causing the client to drop the connection before presenting its certificate. - tokio::process::Command is NOT the cause: it is a thin async wrapper around std::process::Command that delegates environment setup, process spawning, and I/O identically. - The single-threaded tokio runtime is NOT the cause: testing with multi_thread flavor produces identical timing. - TempDir lifetime is sound: the directory lives until .output().await returns, so certs exist for the subprocess's entire lifetime. - Cert path resolution is deterministic: the subprocess resolves XDG_CONFIG_HOME/openshell/gateways/openshell/mtls/ correctly. The subprocess tests exist to verify that the real CLI binary produces clean stdout (no ANSI chrome, spinners, or progress text leaking into structured output). This invariant does not depend on slow progress events; the ProgressOutput::Silent branch that swallows progress events is already covered by the in-process test sandbox_create_keeps_waiting_while_vm_progress_arrives. Fixes #2501 Signed-off-by: Roland Huß --- .../sandbox_create_lifecycle_integration.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/crates/openshell-cli/tests/sandbox_create_lifecycle_integration.rs b/crates/openshell-cli/tests/sandbox_create_lifecycle_integration.rs index f42880d9f6..7ed148304c 100644 --- a/crates/openshell-cli/tests/sandbox_create_lifecycle_integration.rs +++ b/crates/openshell-cli/tests/sandbox_create_lifecycle_integration.rs @@ -1944,15 +1944,10 @@ async fn run_cli_sandbox_create( } #[tokio::test] -async fn sandbox_create_json_stdout_is_parseable_with_progress_events() { +async fn sandbox_create_json_stdout_is_parseable() { let server = run_server().await; - server - .openshell - .state - .vm_slow_progress_before_ready - .store(true, Ordering::SeqCst); - let result = run_cli_sandbox_create(&server, "json-progress", &["--output=json"]).await; + let result = run_cli_sandbox_create(&server, "json-clean", &["--output=json"]).await; assert!( result.status.success(), "sandbox create failed:\n{}", @@ -1964,15 +1959,10 @@ async fn sandbox_create_json_stdout_is_parseable_with_progress_events() { } #[tokio::test] -async fn sandbox_create_yaml_stdout_is_parseable_with_progress_events() { +async fn sandbox_create_yaml_stdout_is_parseable() { let server = run_server().await; - server - .openshell - .state - .vm_slow_progress_before_ready - .store(true, Ordering::SeqCst); - let result = run_cli_sandbox_create(&server, "yaml-progress", &["--output=yaml"]).await; + let result = run_cli_sandbox_create(&server, "yaml-clean", &["--output=yaml"]).await; assert!( result.status.success(), "sandbox create failed:\n{}",