Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

test: functional coverage for WatchCRDsAndInvalidate + envtest CI - #28

Closed
braghettos wants to merge 1 commit into
mainfrom
test/cache-staleness-envtest
Closed

test: functional coverage for WatchCRDsAndInvalidate + envtest CI#28
braghettos wants to merge 1 commit into
mainfrom
test/cache-staleness-envtest

Conversation

@braghettos

Copy link
Copy Markdown
Collaborator

What

Functional coverage for WatchCRDsAndInvalidate — the cdc's discovery-cache staleness fix — which previously had only TestWatchCRDsAndInvalidate_NoResetIsNoop.

Tests

  • internal/tools/dynamic/crdwatch_envtest_test.go (-tags envtest) — one real apiserver, two production NewRESTMapper mappers: one guarded by WatchCRDsAndInvalidate, one bare. A CRD is registered mid-run; the watched mapper resolves the new kind on its own within the coalescing window (no restart), while the unwatched control stays stale until an explicit Reset() (reproducing the old "restart required" behavior).
  • internal/tools/dynamic/crdwatch_test.go — adds the resettable-mapper active-setup case alongside the existing no-op case.

CI

  • Makefile: test, test-race, test-envtest.
  • .github/workflows/test.yaml: runs both on PR/push to main.

Context

Building this envtest layer corrected an earlier misdiagnosis: the umbrella inst.crdExists gate renders on a fresh-per-reconcile helm client (proven separately in krateo-platformops/plumbing), so it is not the stale path. The only long-lived cache is this mapper, which WatchCRDsAndInvalidate already keeps fresh — verified live (every cdc controller holds the CRD get;list;watch RBAC). This PR makes that shipped fix properly tested.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LJsLqtryCgWwEt8FnPE1se

WatchCRDsAndInvalidate (the RESTMapper discovery-cache refresh) had only a
no-op unit test. Add a build-tagged (envtest) functional test that stands up a
real apiserver, registers a CRD mid-run, and proves the watched production
mapper self-heals with no restart while an unwatched control stays stale until
an explicit Reset() (the manual-restart equivalent); plus a resettable-mapper
active-setup unit test.

Adds a Makefile (test / test-race / test-envtest via setup-envtest) and a test
GitHub Actions workflow running both on PR/push to main (the repo had
release/security CI but no test job).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LJsLqtryCgWwEt8FnPE1se
@braghettos

Copy link
Copy Markdown
Collaborator Author

Superseded: the deployed cdc image is built by the core-provider monorepo (go/composition-dynamic-controller); these cache-staleness tests were re-targeted there in core-provider#62. This standalone repo is legacy and being archived.

@braghettos braghettos closed this Aug 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant