buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Several tests can't run in hermetic build sandboxes (FHS paths, cleared environment, missing timeouts)

Open kleinbem opened this issue 1 month ago • 1 comments

Describe the bug Building Buzz from source with its test suites (nixpkgs, and other distributions that build in a sandbox) needs about 20 tests skipped. They fall into a few groups:

  1. FHS interpreters. 13 tests in desktop/src-tauri run /bin/bash or /usr/bin/true, write #!/usr/bin/env node scripts, or run env/true with PATH cleared, and the process-group tests start /bin/sleep; 5 in crates/buzz-acp run fake agents from #!/bin/bash and #!/usr/bin/env scripts. The Nix build sandbox has only /bin/sh, and NixOS itself adds only /usr/bin/env. I know the absolute paths are deliberate in places (managed_agents/runtime/tests.rs: parallel tests swap PATH, so a lookup during the swap flakes).
  2. Cleared environment, then TLS. buzz-agent's cli_signin_aliases_reuse_legacy_cache_without_runtime_configuration (tests/databricks_cli_auth.rs) and buzz-acp's task_native_git_and_startup_shutdown_cleanup (tests/git_bootstrap.rs) start the binary with env_clear(). That drops SSL_CERT_FILE, so building the HTTP client fails where there is no system CA store.
  3. Hangs instead of failures. metadata_command_cancellation_drops_an_in_flight_response and metadata_pipeline_remains_pending_beyond_former_aggregate_deadline (desktop/src-tauri/src/commands/link_preview_tests.rs:72, :119) await request_started_rx without a timeout. When the spawned fetch task panics (here: reqwest::Client::new() couldn't load CA certificates), the test never finishes; my build ran for hours.
  4. A flaky test. provider_deploy_refuses_mismatch_before_sending_agent_secret (desktop/src-tauri/src/managed_agents/backend_tests.rs:276) runs a provider script it has just written while a parallel test may still hold the file open ("Text file busy").
  5. macOS sandbox. buzz-agent's Databricks OAuth tests (9) bind the mock server to 127.0.0.1 but point the client at https://localhost:<port> (src/databricks_test_support.rs); the macOS sandbox can't resolve localhost. buzz-acp's keepalive_resets_idle_past_deadline (src/acp.rs:3639) and idle_resets_on_stdout_activity assert timing and fail on slower runners ("elapsed only 112ms").

Steps to reproduce Run the suites without /bin/bash, /usr/bin/env and a system CA store, e.g. in the nixpkgs build (nix-build -A buzz-acp with the skips removed), or in a minimal container with only SSL_CERT_FILE pointing at a CA bundle.

Expected behavior The tests resolve each interpreter once, before any test swaps PATH (for example into a OnceLock at first use), or skip when it is missing; pass SSL_CERT_FILE/SSL_CERT_DIR through after env_clear(), time out instead of hanging, and connect to the address they bound (or use ClientBuilder::resolve("localhost", addr), which keeps the certificate name).

Version and platform

  • Buzz version: 0.5.28 (code as of main 347ce88d5)
  • OS: NixOS (x86_64-linux, aarch64-linux) and macOS (aarch64-darwin), all in the Nix build sandbox

Logs / additional context The nixpkgs packages list every skipped test with a comment (NixOS/nixpkgs#570552, #571723). I'm happy to send PRs group by group if that's welcome.

kleinbem avatar Oct 22 '26 15:10 kleinbem

Closing: I'm focusing on Buzz 1.0 (block/buzz-app), which doesn't use this code.

kleinbem avatar Oct 23 '26 12:10 kleinbem