Skip to content

test(k8s): k8s command tests patch no devops_cli names #4086

Closed

Description

@dan-petty

Problem or Motivation

Group 1 of #3769. The tests of tests/commands/k8s/ still patch names inside devops_cli. At origin/main 74ba76b, git grep finds 245 string patches of a devops_cli name in 10 of the 25 test files of that directory. test_k8s.py holds 135 of them. test_k8s_bootstrap.py holds 29, test_k8s_context.py 26, test_k8s_logging_stack.py 22 and test_k8s_networking.py 12.

The patches target the private helpers _run_cmd, _cluster_reachable, _minikube_running, _is_cluster_argo_managed and _verify_url_reachability, the imported names run_subprocess, load_settings and save_settings, and the security scanners. commands/k8s/__init__.py holds a module class, _K8sModule, that exists only to forward such a patch to the submodule that uses the name. Product code must not be shaped so that a test can patch it (docs/TESTING.md).

Issue #1336 turns the ratchets into bans and fails on these patches.

Proposed Solution & Architectural Design

Replace each patch with the fake of the edge that the command reaches: process_fake for kubectl, helm and minikube, the cluster fixture for the Kubernetes API, the config fixture for settings, the dial and web fakes for the URL probes, and the scanner fakes for the scanners. A test keeps its name and the behavior that it checks. Delete _K8sModule and the private re-exports that only the old patches used.

Acceptance criteria:

  • git grep finds no string patch of a devops_cli name in tests/commands/k8s, or the pull request lists each remaining patch with its reason.
  • The node ids that pytest collects in tests/commands/k8s are the same before and after, except for a rename whose old name was wrong.
  • Mutations of the product code in a scratch copy make the migrated tests fail.
  • _K8sModule, _forward_submodule_attr and _PATCH_TARGET_MAP are gone from src/.
  • The pull request states the count of patches before and after.

Target Subsystem

Kubernetes & Minikube Automation

Existing Tool Considered

No new tool is needed. The fakes of tests/support/fakes/ (process, Kubernetes, dial, web, scanners) and the config and cli fixtures already cover every edge. The cost of the fakes is already paid by #1313 to #1325.

Related: #3769 (parent), #1307, #1336.

Activity

  1. added
    source/agent
    type/test
    scope/k8s
    status/new
    value/medium
    effort/high
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 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/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. Test refactoring that improves maintainability but does not fix a defect or block a release.
    • Value: Medium. Removes a testing anti-pattern and reduces coupling to internal product names.
    • Effort: High. 245 patches across 10 files must be replaced with edge fakes and _K8sModule must be deleted.
    • Related: test(cli): command tests patch no devops_cli names #3769, which asks for a different change. Both remove devops_cli name patches from command tests; the candidate covers only tests/commands/k8s (245 patches) while #3769 is the umbrella for all 869 patches across 129 files.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 8, 2026
  5. removed
    status/in-review
    on Nov 8, 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/k8ssource/agenttype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions