Skip to content

test(k8s): test the product contracts on a fixture tree #5298

Closed as not planned

Description

@dan-petty

Problem or Motivation

The product contracts of devops-cli are tested against the environment files under k8s/. #5134 step 6 (plan step 17 on #5120) deletes the environment files from devops-cli. After that step, these tests have no input. The tests check product behaviour, so they must stay in devops-cli and must not read the environment tree.

This item was item 4 of #5131. One issue gets one pull request, so it has its own issue now. #5131 builds PR 1 (the environment root and the foreign-source support).

Proposed Solution & Architectural Design

Product contracts stay in devops-cli and test a fixture tree with no private data:

  • the Job label (tests/invariants/test_k8s_mcp_server_policies.py),
  • job_admission_policy.py, runner.py and devops_runtime.py of the gate checks,
  • the deploy paths of tests/invariants/test_architectural_invariants.py,
  • render_active_devops_configmap with k8s/devops/configmap.example.yaml,
  • the product dashboards and the alert rules that watch the Service (after refactor(k8s): split the product dashboards and rules in place #5292 moves them to k8s/devops/).

Make each fixture from the devops-cli history only, never from homelab, because homelab holds the real hosts after #5134 step 5b. tests/support/k8s_tree.py takes a root parameter, so a test can read the fixture tree in place of k8s/.

Target Subsystem

Kubernetes & Minikube Automation

Existing Tool Considered

pytest fixtures and the test helpers of tests/support/ cover the need. No new tool is necessary. Cost: about 2M model input to build, 0.2M a quarter to keep, 3 hours.

Acceptance Criteria

  • The product-contract tests pass against a fixture tree, with the k8s/ environment folders hidden.
  • No fixture holds a host, an address or a name from homelab.
  • uv run devops ci passes.

Dependencies

#5131 (PR 1: the environment root and tests/support/k8s_tree.py with a ref name other than $values). #5292 (the product dashboards and rules in k8s/devops/). This item blocks #5134 step 6 (plan step 17).

Source: #5120

Alternatives check of 2026-11-16: not-applicable.
Class: test, no search.
Tool: none found.

Proposed design

Problem statement

The product contracts of devops-cli test the environment files under k8s/. #5134 step 6 deletes those files, so the tests lose their input. This item moves the product-contract tests to a fixture Kubernetes tree with no private data. The tests stay in devops-cli and do not read the environment tree.

Acceptance criteria

Requirement: Product contracts read the fixture tree

The product-contract tests MUST read the fixture Kubernetes tree in place of the k8s/ environment folders.

Scenario: Fixture root replaces the environment tree

  • WHEN uv run pytest tests/invariants/test_k8s_mcp_server_policies.py tests/invariants/test_architectural_invariants.py tests/k8s/test_k8s_configmap.py runs with the k8s/ environment folders hidden
  • THEN the tests pass and no test reads a path under the hidden k8s/ environment folders

Requirement: Fixture tree holds the product contract inputs

The fixture tree SHALL hold the Job label, the gate-check inputs, the deploy paths, the ConfigMap example and the product dashboards and alert rules.

Scenario: Each product contract reads its fixture input

  • WHEN uv run pytest tests/invariants/test_k8s_mcp_server_policies.py tests/invariants/test_architectural_invariants.py tests/k8s/test_k8s_configmap.py runs
  • THEN each test reads its input from tests/fixtures/k8s/ and passes

Requirement: Fixtures hold no homelab data

Each fixture file MUST come from the devops-cli history and MUST NOT contain a host, address or name from homelab.

Scenario: Fixture provenance and private data check

  • WHEN uv run pytest tests/invariants/test_architectural_invariants.py -k fixture_k8s_tree_provenance runs
  • THEN the test passes and each fixture file names a devops-cli commit and no homelab host, address or name

Requirement: CI passes

The full CI MUST pass with the fixture-tree tests.

Scenario: CI check passes

  • WHEN uv run devops ci runs
  • THEN the command exits 0

Existing Tool Considered

pytest with the tests/support/ helpers covers the need. It lacks nothing for this item. The alternatives check is not-applicable for a test item and found no tool. Cost of the fixture tests: about 2M model input to build, 0.2M a quarter to keep, 3 hours.

Key questions

  • How should a product-contract test select the fixture Kubernetes tree?: Pass the fixture root to tests/support/k8s_tree.py after refactor(k8s): read the environment tree from the infra repo #5131. Do not use a global setting or copy the fixture over k8s/. (best practice) [sources: tests/support/k8s_tree.py]
    • Chosen: Root parameter of tests/support/k8s_tree.py. The helper takes a root, so each test gives its own tree and parallel tests do not interfere.
    • Rejected: Environment variable. It hides the input from the test and makes parallel tests interfere.
    • Rejected: Copy the fixture over k8s/. It changes the working tree and defeats the check that k8s/ is hidden.
  • Where should the fixture Kubernetes tree live?: Under tests/fixtures/k8s/, read through the FIXTURES path in tests/support/paths.py. (best practice) [sources: tests/support/paths.py]
    • Chosen: tests/fixtures/k8s/. FIXTURES already points at the test data directory and keeps fixture data apart from test modules.
    • Rejected: tests/k8s/fixtures/. It puts test data beside test modules and gives no shared root.
    • Rejected: k8s/devops/. That is the product base, not test data, and it holds no environment input.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#5131, #5292

Activity

  1. added
    source/agent
    on Nov 13, 2026
  2. added
    type/test
    scope/k8s
    status/new
    value/medium
    effort/medium
    on Nov 13, 2026
  3. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 13, 2026
  5. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: test. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-16. A person decides what this means for the item. The check changes no label and closes no issue.

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

    @devops-cli-service
    Contributor

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

  8. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 23, 2026
  9. dan-petty commented on Nov 23, 2026

    @dan-petty
    OwnerAuthor

    Closing as not planned per AGENTS.md rule 2 (Check the premise first): newer issues and commits replaced this item.

    Evidence:

    1. tests/invariants/test_k8s_mcp_server_policies.py: PR fix(k8s): Drop the tests that assert values of manifests and config #6075 (test(k8s): Drop the tests that repeat third-party version pins #6060) and PR fix(k8s): Take the k8s area of the config-read list to zero #6124 (test(k8s): Take the k8s area of the config-read allow list to zero #6119, commit 0857ee5fb) dropped all tests that assert values of manifests or config files, and removed test_k8s_mcp_server_policies.py. Its specification (openspec/specs/mcp-server-network-policies/spec.md) was updated to specify live cluster validator checks. Adding new tests that assert manifest values is forbidden by tests/gate/tree_checks/config_values.py.
    2. Gate checks job_admission_policy.py and runner.py: Read REPO_ROOT / "k8s" / "devops" (the product base), not the environment tree. The product base remains in devops-cli.
    3. ConfigMap rendering: render_active_devops_configmap reads k8s/devops/configmap.example.yaml (product base), which remains in devops-cli.
    4. Product dashboards and alert rules: PR refactor(k8s): split the product dashboards and rules in place #5292 already moved them to k8s/devops/dashboards/.
    5. Environment checks: Issue feat(k8s): run the environment checks in homelab CI #5296 (feat(k8s): run the environment checks in homelab CI) moves the environment checks to homelab CI.
  10. removed
    status/in-progress
    owner/agent
    on Nov 23, 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/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