← Back to Pull requests

NO-JIRA: add Deployment manifest golden-file testing #53

Closed
unknown closed this pull request without merging on Oct 13, 2026 16:10 UTC
View on GitHub
unknown unknown commented on Oct 08, 2026 04:47 UTC
Author

Adds golden YAML fixture tests for HCP-reconciled Karpenter Deployments to catch unintended manifest changes.

- Checks rendered manifests and stability across repeated reconciliations.
- Replaces broad Deployment assertions with focused drift-correction checks.
- Documents the fixture workflow and UPDATE=true regeneration in a new TESTING.md markdown file which is referenced by AGENTS.md.

This is based on the workflow that exists in hypershift:
fixture test for control plane components deployed by hypershift-operator https://github.com/openshift/hypershift/blob/0f18311657aeef47627b621368c8cc8ce653564f/hypershift-operator/controllers/hostedcluster/hostedcluster_controller_test.go#L5592
where those golden files live in hypershift: https://github.com/openshift/hypershift/tree/main/hypershift-operator/controllers/hostedcluster/testdata

Here's a failing fixture test output when you change something in the operand configuration either intentionally or unintentionally:

$ make test
go test ./pkg/... -count=1
?       github.com/openshift/karpenter-operator/pkg/apis/autoscaling/v1alpha1 [no test files]
?       github.com/openshift/karpenter-operator/pkg/assets      [no test files]
?       github.com/openshift/karpenter-operator/pkg/cloudprovider       [no test files]
ok      github.com/openshift/karpenter-operator/pkg/cloudprovider/aws   0.038s
ok      github.com/openshift/karpenter-operator/pkg/cloudprovider/azure 0.040s
?       github.com/openshift/karpenter-operator/pkg/cloudprovider/common      [no test files]
ok      github.com/openshift/karpenter-operator/pkg/controllers 15.230s
ok      github.com/openshift/karpenter-operator/pkg/controllers/clusteroperator 0.168s
ok      github.com/openshift/karpenter-operator/pkg/controllers/crd     0.183s
--- FAIL: TestHCPDeploymentFixture (0.02s)
    --- FAIL: TestHCPDeploymentFixture/When_an_HCP_uses_Karpenter,_it_should_render_the_expected_deployment (0.01s)
        hcp_deployment_fixture_test.go:143: fixture testdata/zz_fixture_TestHCPDeploymentFixture_When_an_HCP_uses_Karpenter__it_should_render_the_expected_deployment.yaml differs (-want +got):
              (
                """
                ... // 29 identical lines
                    spec:
                      containers:
            -         - env:
            +         - args:
            +           - --log-level=debug
            +           env:
                        - name: SYSTEM_NAMESPACE
                          valueFrom:
                ... // 14 identical lines
                        - name: AWS_SDK_LOAD_CONFIG
                          value: "true"
            -           - name: LOG_LEVEL
            -             value: debug
                        - name: KUBECONFIG
                          value: /mnt/kubeconfig/target-kubeconfig
                ... // 93 identical lines
                """
              )
            
            If intentional, run UPDATE=true go test ./... -count=1 -run "TestHCPDeploymentFixture/When_an_HCP_uses_Karpenter,_it_should_render_the_expected_deployment" and review the fixture diff.
    --- FAIL: TestHCPDeploymentFixture/When_HCP_deployment_inputs_change,_it_should_render_the_updated_deployment (0.01s)
        hcp_deployment_fixture_test.go:143: fixture testdata/zz_fixture_TestHCPDeploymentFixture_When_HCP_deployment_inputs_change__it_should_render_the_updated_deployment.yaml differs (-want +got):
              (
                """
                ... // 29 identical lines
                    spec:
                      containers:
            -         - env:
            +         - args:
            +           - --log-level=debug
            +           env:
                        - name: SYSTEM_NAMESPACE
                          valueFrom:
                ... // 14 identical lines
                        - name: AWS_SDK_LOAD_CONFIG
                          value: "true"
            -           - name: LOG_LEVEL
            -             value: debug
                        - name: KUBECONFIG
                          value: /mnt/kubeconfig/target-kubeconfig
                ... // 93 identical lines
                """
              )
            
            If intentional, run UPDATE=true go test ./... -count=1 -run "TestHCPDeploymentFixture/When_HCP_deployment_inputs_change,_it_should_render_the_updated_deployment" and review the fixture diff.
FAIL
FAIL    github.com/openshift/karpenter-operator/pkg/controllers/karpenter       0.303s
ok      github.com/openshift/karpenter-operator/pkg/controllers/machineapprover 0.547s
ok      github.com/openshift/karpenter-operator/pkg/controllers/nodeclass/default0.210s
ok      github.com/openshift/karpenter-operator/pkg/controllers/nodeclass/ec2   0.306s
ok      github.com/openshift/karpenter-operator/pkg/hypershift  0.183s
ok      github.com/openshift/karpenter-operator/pkg/operator    0.144s
?       github.com/openshift/karpenter-operator/pkg/version     [no test files]
FAIL
make: *** [Makefile:138: test] Error 1

Diff: 639 lines (+479 / -160) across 7 files Reviewer: maxcao13 Review duration: 7882m
All Vouch review confidence checks passed
Residual risk 0.32 = Change Risk (0.74) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.74 · 639 lines diff across 7 files
0.74
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.387
Shallow Review Depth shallow_review_depth
0.289
Sensitive Paths sensitive_paths
0.074
Real PR Conversation Timeline
1 comments
"Review active on #53"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 73.6% (HIGH) · Higher = larger blast radius
73.6%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 31.8% · Safe to merge
31.8%