Skip to content

A contract test of the Git and cluster adapters against the providers' published descriptions #200

Open

Description

@ephico2real2

Part of #18

What is wanted

A test of the service suite checks each HTTP call of the two adapters against the provider's own published description, with no server and no container. Spike #187 measured the method: 23 calls of core/git/github.py (22 operations) against GitHub's OpenAPI description, and 48 calls of core/clients/kube.py (40 operations) against the Kubernetes API description. Both comparisons found 0 differences, in 0.47 s and 0.16 s, and mutants of each comparison failed.

Where

  • New: cmapi/tests/service/test_adapter_contracts.py, and cmapi/tests/contracts/ with one pinned extract for each provider.
  • New: scripts/provider-contracts.py. It reads a provider's full description and writes the extract: only the operations that the adapters call, with each reference resolved, the source commit and the date.
  • The adapters: cmapi/src/cmapi/core/git/github.py, cmapi/src/cmapi/core/clients/kube.py.

Acceptance criteria

  1. The test records each request that the adapter sends, on a mock transport, for each method of the port. It does not read a hand-written list of calls. Proof: the test fails when a method of GitHubProvider or KubeClient has no recorded request.
  2. Each recorded request is valid for the extract: the path and method, each query parameter, each body field, each required body field, and the content type. Proof: a mutant of the adapter with a wrong field fails the test.
  3. Each answer of the mock transport that the tests give (test_github_check_runs.py and the new ones) is valid for the answer schema of the extract. Proof: a mutant answer with a wrong field fails.
  4. The extracts are small (under 300 KB each) and say their source: the repository, the commit and the date. scripts/provider-contracts.py --check <description> fails when the extract differs from a new description. Proof: its own test with a changed description.
  5. docs/08 says what the test covers and what it does not: the meaning of an answer, rate limits and server-side apply conflicts are not in a description.

Not in this task

A real API server for Kubernetes (envtest or kwok with its binary runtime) and recorded answers from a real run against GitHub (#61). The spike's record says when each one is the better tool.

Class

INV. The task adds a check and changes no behaviour.

Activity

  1. added
    task
    class:INV
    status:open
    Backlog
    on Nov 13, 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

    Backlogclass:INVstatus:opentask

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions