Skip to content

test(infra): docker, tf, watchers and Argo CRD tests run on edge fakes #3751

Closed

Description

@dan-petty

Problem or Motivation

Part 5 of 6 of #1335. It needs no other part.

Seven test files of the docker, tf, watchers and Argo CRD code reach their edges through patches. Measured at origin/main 29309f0, with the counting rules of #1335:

File Lines Tests Patch sites Private imports
tests/ai/mcp/test_docker_cosign.py 599 30 35 1
tests/core/test_docker_engine.py 1,385 81 12 0
tests/commands/test_workload_sandbox.py 332 12 3 0
tests/argo/test_argo_crd.py 519 32 1 1
tests/tf/test_tf_analysis.py 824 45 0 0
tests/tf/test_tf_cost.py 300 20 9 0
tests/watchers/test_watchers.py 191 8 2 0
Total 4,150 228 62 2

None of the 62 sites is a seam site.

What each file patches:

Two rules still sit in commands/ (Q19). Both are domain logic, and the CLI tests of #1327 reach them through patches:

  • Argo workflow waiting. _await_workflow (commands/argo.py:134) polls a Workflow until a terminal phase or a timeout. It uses time.monotonic and time.sleep. It also calls print_error and typer.Exit.
  • Cloudflare DNS record matching and deletion. _resolve_dns_target_names, _record_matches_filter, _find_matching_records and _execute_dns_deletions (commands/cloudflare.py:438-505) decide which records match a target, a type and the managed comment. They then delete them through CloudflareClient.

Proposed Solution & Architectural Design

  1. Replace each patch by the fake or the real object that owns the edge. For the two vet_addresses sites in test_docker_engine.py, take the answers from public_dns. refactor(cli): Unify HTTP and DNS seams with shared fakes #1314 replaces that fixture later.
  2. Move the waiting loop into argo/ as a public function. It takes the ArgoCRDService, the name, the namespace and the timeout. It returns the state or raises a DevOpsCLIError subclass. commands/argo.py catches the error and prints. Tests use FakeCluster and the clock fixture. A test that waits in real time is not allowed.
  3. Move the four Cloudflare helpers into cloudflare/ as public functions. commands/cloudflare.py keeps the rendering and the call. The cases of tests/commands/test_cloudflare_commands.py that test the matching rule move to tests/cloudflare/. The command keeps tests for its wiring only. Do not move other cases of that file. Its other patch sites belong to the finish of test(cli): the infra commands are thin adapters tested over edge fakes, with no internal patches or private imports #1327.
  4. Replace each private import by a test of the public behaviour. If no public path reaches a private function, delete it as dead code.
  5. Use the cli fixture. Split test_docker_engine.py (1,385 lines) by behaviour as a separate commit.

Why _resolve_client of Cloudflare and Valkey does not move: each one turns settings and a keyring secret into a client. That is wiring. The Valkey fake (#1317) and, later, the HTTP fake (#1314) reach the client behind it. The old body asked for the move. This is the reason to drop it.

Why docker/cosign.py needs no new seam: it starts cosign through run_subprocess, the seam of the process edge.

Acceptance criteria

  • A test first for the moved waiting function. It returns at once on a terminal phase. It polls on the clock fake until the phase turns terminal. It raises the timeout error when the budget ends. The test takes no real time.
  • A test first for each moved Cloudflare function. The cases are matching by name, by id and by type, and the force flag that ignores the managed comment.
  • The seven files hold no patch site and no private import. The pull request comment gives the counts before (62 and 2) and after.
  • commands/argo.py holds no time.sleep call. commands/cloudflare.py holds no matching rule.
  • The seven files hold no module-level CliRunner().
  • uv run devops ci passes. The changed lines are covered at 90 percent.

Target Subsystem

SDLC, Git & PR Governance

Existing Tool Considered

The fakes exist: ProcessFake, FakeKeyring, DockerEngineFake, FakeCluster and ClockFake (tests/support/fakes/). For the waiting loop, tenacity is in the project (pyproject.toml pins 9.1.4, and TESTING.md names it for retries). Use it only if the loop shrinks. Do not add a new library. The cost to build is about 350,000 tokens. It costs about 15,000 tokens a year to keep. The work takes about 2 days.

Strategic alignment: child of #1335. Parent #1307. Related: #1327 (closed, its files still hold patch sites), #1314, #1336.

Activity

  1. added
    source/agent
    type/test
    scope/infra
    status/new
    value/medium
    effort/high
    on Nov 6, 2026
  2. dan-petty commented on Nov 6, 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/test. The test prefix of the title gives the type.
    • Scope: scope/infra. The (infra) scope of the title gives the scope.
    • Priority: P2-Medium. It improves test maintainability for 7 files but does not fix a user-facing defect or block a release.
    • Value: Medium. Replacing 62 patch sites with fakes reduces brittleness and private-import coupling for 228 tests, but the change is internal to the test suite.
    • Effort: High. Seven files, 4,150 lines, 62 patch sites, two rule moves from commands/ to their packages, and private-import removals are all in scope.
    • Related: test(sandbox): sandbox tests run on edge fakes #3749, which asks for a different change. Both are parts of #1335 that replace test patches with edge fakes, but #3749 covers sandbox test files while the candidate covers docker, tf, watchers, and Argo CRD test files.
  3. added
    priority/p2-medium
    on Nov 6, 2026
  4. added
    status/in-review
    and removed
    status/new
    on Nov 6, 2026
  5. removed
    status/in-review
    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/highpriority/p2-mediumscope/infrasource/agenttype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions