Repository navigation
test: e2e for the four payload kinds that had never met an API server - #63
Merged
Merged
Conversation
job_runs, deployment_revisions, workload_policy and cluster_policy had unit tests and golden bytes and no contact with a real cluster. One suite covers all four, because they come from the same flush and the same fixtures. The workload-policy assertion is what earns the test. Those records can only be built if the ClusterRole actually grants the six resources ADR 0032 added — and since ADR 0033 a missing grant no longer stops the agent, so such a mistake would now be silent in every other test. Here it surfaces as an unavailable_sources line the test requires to be absent. Verified by removing the storageclasses rule from deploy/controller.yaml and running it: the suite fails with "unavailable sources = [storage_classes]; the deployed ClusterRole does not grant what ADR 0032 says it does". That run also confirmed ADR 0033 against a real API server — revisions and workload policy still arrived while one grant was missing, which is the whole point of the change. The first arrangement caught that too, but as a six-minute timeout waiting for the storage-class catalog. Awaiting the catalog is the wrong readiness condition: a missing grant is then reported as "something never showed up" rather than as the one-line cause it is. The wait is now on the fixture namespace and the grants are asserted where the failure can name itself. Fixtures live in their own namespace. A ResourceQuota or LimitRange in the controller's namespace would apply to the controller's own pod, and the test would be measuring its own interference. The first run also failed for a reason worth keeping: the inner metric struct had no JSON tags, and Go's case-insensitive matching does not reach target_type. Exactly the class of mismatch this suite exists to catch, even though it was in the test rather than in the agent. Job-run windows are decoded as a stream: a run near an hour boundary leaves two files, and `cat` over the glob concatenates them. Runs in 64 seconds. `make policy-e2e`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes finding 3 from the review.
job_runs,deployment_revisions,workload_policyandcluster_policyhad unit tests and golden bytes and no contact with a real cluster. One suite covers all four — they come from the same flush and the same fixtures. Runs in 64 seconds:make policy-e2e.The assertion that earns the test
workload_policyrecords can only be built if the ClusterRole actually grants the six resources ADR 0032 added. And since ADR 0033 a missing grant no longer stops the agent — so a mistake there would now be silent in every other test. Here it surfaces as anunavailable_sourcesline the test requires to be absent.Verified by breaking it. Removing the
storageclassesrule fromdeploy/controller.yamland running the suite:That run doubles as the first real-cluster confirmation of ADR 0033: revisions and workload policy still arrived while a grant was missing, and the agent kept running. That is the whole point of the change, and it had only ever been tested against a fake client.
Readiness conditions are part of the assertion
The first arrangement caught the missing grant too — as a six-minute timeout waiting for the storage-class catalog to appear. Awaiting the catalog is the wrong condition: a missing grant is then reported as "something never showed up" instead of the one-line cause it is. The wait is now on the fixture namespace, and the grants are asserted where the failure can name itself. Same detection, 64 seconds instead of 426, with a message that says what to fix.
Two details that turned into decisions
Fixtures live in their own namespace. A ResourceQuota or LimitRange in the controller's namespace would apply to the controller's own pod, and the test would be measuring its own interference.
Job-run windows decode as a stream. A run near an hour boundary leaves two files and
catover the glob concatenates them; a singleUnmarshalwould fail on the second document.The first run failed, usefully
The inner metric struct had no JSON tags, and Go's case-insensitive field matching does not reach
target_type— soTargetTypeandTargetValuecame back empty. Exactly the class of mismatch this suite exists to catch, even though it lived in the test rather than in the agent.What it asserts
deployment_revisions— revision 1 of the fixture Deployment with its image.workload_policy— the budget (minAvailable: 100%→disruptions_allowed: 0, the node cannot be drained) and the autoscaler, with the utilization target travelling beside its type.cluster_policy— the namespace's LimitRange default request, the quota's hard limit, and kind's ownstandardstorage class in the catalog.job_runs— a Job that finished on its own, with both instants read from the object rather than baselined (ADR 0029 §3).make test(16 packages) andmake lint(0 issues) green;make policy-e2egreen against kind.🤖 Generated with Claude Code