Skip to content

fix(tests): four tests fail on the devcontainer host #3590

Closed as not planned
Closed as not planned

Description

@dan-petty

Problem

Four tests fail in the pytest gate of devops ci in the devcontainer. The same four tests also fail on the main checkout, which holds no change of issue 3488:

  • tests/telemetry/test_config_env_overrides.py::test_find_project_config_path_skips_directory
  • tests/commands/test_devcontainer_install_tools_dry_run.py::test_mark_only_commands_under_global_dry_run
  • tests/crypto/test_ssh.py::test_get_ssh_key_prefix_resolution
  • tests/ai/test_tool_executor_contract.py::test_the_direct_executor_refuses_a_network_profile_before_it_starts_the_tool[direct], which also errors at its setup

Evidence

On the main checkout, uv run pytest -n 0 on these four files gives 4 failed and 1 error. The ssh test expects the repository name my_plain_repo and gets devops_cli. The tool executor test reaches the host path of the popeye tool under the user data directory.

Expected

Each test passes in the devcontainer, or it skips when the host capability that it needs is missing, as the test rules require.

Proposed design

Problem statement

Four tests fail on the devcontainer host. The host has /tmp/config.yaml and an installed popeye tool. The tests read that host state instead of their own temporary state. The change isolates the tests from host state or skips them only when a needed capability is absent.

Acceptance criteria

Requirement: Isolated config path test

The test test_find_project_config_path_skips_directory SHALL ignore any project config file outside its temporary search root.

Scenario: Host config file exists

  • WHEN A /tmp/config.yaml file exists and the test searches from a temporary directory under /tmp.
  • THEN The test passes and the function returns None for a directory DEVOPS_CLI_CONFIG value.

Requirement: Host-independent install-tools status

The mark-only dry-run test SHALL pass when the host has tools installed under the user data directory.

Scenario: Popeye installed

  • WHEN popeye exists under ~/.local/share/devops-cli/tools/ and the test runs devops --dry-run install-tools status.
  • THEN The command exits 0 and prints the DevOps Tool header.

Requirement: Isolated SSH prefix fallback

The SSH prefix fallback test SHALL ignore any project config file outside its temporary directory.

Scenario: Host config sets a prefix

  • WHEN /tmp/config.yaml sets ssh.key_prefix and the test resolves a plain directory with no local config.
  • THEN get_ssh_key_prefix returns my_plain_repo.

Requirement: Direct executor network refusal without host tool

The direct executor network-profile test SHALL use a temporary stand-in program and MUST assert the refusal before any process starts.

Scenario: Host popeye installed

  • WHEN popeye is installed in the host data directory and the test sends a KubeApiNetwork request to DirectToolExecutor.
  • THEN The executor raises SandboxError matching cannot run the network profile kube-api and the stand-in writes no marker.

Requirement: Four tests pass with host state

The four tests SHALL pass in one uv run pytest -n 0 run on a host that has /tmp/config.yaml and popeye installed.

Scenario: Host state present

  • WHEN The host has /tmp/config.yaml and popeye under the user data directory.
  • THEN The command reports no failed test and no error.

Existing Tool Considered

No alternatives check has run. pytest with tmp_path and monkeypatch is the open, maintained tool that covers the test-isolation need. It lacks automatic isolation from host paths and installed tools, so each test must set its own temporary root or drop a host-dependent assertion. No custom code is needed.

Key questions

  • Why does test_find_project_config_path_skips_directory fail when /tmp/config.yaml exists?: The test searches from tmp_path under /tmp. The search goes up to /tmp and finds /tmp/config.yaml after it skips the directory in DEVOPS_CLI_CONFIG. [sources: tests/telemetry/test_config_env_overrides.py, tests/crypto/test_ssh.py]
  • Why does test_mark_only_commands_under_global_dry_run fail when popeye is installed?: The test asserts that install-tools status prints not installed. The host has popeye installed, so the output does not contain that text. [sources: tests/commands/test_devcontainer_install_tools_dry_run.py]
  • Why does test_get_ssh_key_prefix_resolution fail when /tmp/config.yaml exists?: The fallback part expects my_plain_repo. The config search finds /tmp/config.yaml, which sets a different prefix, so the result is devops_cli. [sources: tests/crypto/test_ssh.py:142, tests/crypto/test_ssh.py:144]
  • Why does the direct executor test fail when popeye is installed?: The test sends tool="popeye". The executor reaches the host popeye path before it refuses the network profile, so the test gets a different error. [sources: tests/ai/test_tool_executor_contract.py]
  • How should the config path and SSH fallback tests isolate from /tmp/config.yaml?: Add an optional search_root boundary to _find_project_config_path and pass tmp_path in the config path test. Use monkeypatch to return no project config in the SSH fallback part. (best practice) [sources: tests/telemetry/test_config_env_overrides.py, tests/crypto/test_ssh.py]
    • Chosen: Search boundary and monkeypatch. The config path test still exercises discovery and the SSH test keeps its fallback check.
    • Rejected: Monkeypatch both discovery calls. The config path test would no longer exercise the function under test.
    • Rejected: Accept the host config result. The assertion would stop protecting the directory-skip behavior.
  • How should the install-tools status test handle installed host tools?: Remove the not installed assertion. Keep the exit code and the DevOps Tool header check. (best practice) [sources: tests/commands/test_devcontainer_install_tools_dry_run.py]
    • Chosen: Drop host-dependent assertion. The test checks that a mark-only command runs, not the host tool inventory.
    • Rejected: Set the tool data directory to tmp_path. It needs an extra host setting and adds no coverage of the mark-only path.
    • Rejected: Skip when tools are installed. Installed tools are normal host state, not a missing capability.
  • How should the direct executor test avoid host popeye?: Use a temporary stand-in program that writes a marker. Assert the network-profile refusal and that the marker does not exist. (best practice) [sources: tests/ai/test_tool_executor_contract.py]
    • Chosen: Temporary stand-in program. The test proves that no process starts and does not resolve host popeye.
    • Rejected: Use a missing tool name. The error may name the missing tool instead of the network profile.
    • Rejected: Skip when popeye is installed. Installed popeye is normal host state, not a missing capability.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/tests
    status/new
    value/medium
    effort/medium
    on Nov 5, 2026
  2. dan-petty commented on Nov 5, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/tests. The (tests) scope of the title gives the scope.
    • Priority: P1-High. The CI gate fails, blocking all merges.
    • Value: Medium. It unblocks CI but does not change user-facing behaviour.
    • Effort: Medium. Four tests each need a host-state isolation fix.
    • Possible duplicate: fix(ci): host state fails four tests and one case #3585, which may ask for the same change. The model names the four devcontainer-host tests pass or skip in the pytest gate as the change that both ask for. Both ask for the same four tests to pass or skip in the devcontainer with the same acceptance criteria. A person closes one of the two if that is so.
  3. added
    priority/p1-high
    on Nov 5, 2026
  4. dan-petty commented on Nov 5, 2026

    @dan-petty
    OwnerAuthor

    Issue #3301 reproduces these failures. A full uv run devops ci run in the worktree of #3301 gives the same four failed tests and the same error.

    The same tests also fail on origin/main (d254410c) in the main checkout, so the change of #3301 does not cause them.

    Host state seems to cause them. The file /tmp/config.yaml exists from 2026-11-04, and the tool popeye is installed under ~/.local/share/devops-cli/tools/.

  5. added
    status/ready
    and removed
    status/new
    on Nov 5, 2026
  6. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at d254410 (see proposed design in issue body).

  7. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    Duplicate of #3585. This item lists the same four failing tests, and the fix design is in #3585. No pull request or branch exists for this item, so no work is lost. This item closes as not planned. If a point of this item is missing in #3585, add it there.

  8. removed
    status/ready
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p1-highscope/testssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions