host: change-index pass tests arm the policy cache as RunAgent does (#328)
ciReconcileConfig handed Reconcile a nil Policies, so every pass built a throwaway PolicyCache whose backstop was due, and the quiet floor in TestInstancesLoopFloorIsRefreshWhenArmed listed control/app-policy/ on every pass. A box never does that: RunAgent calls armPolicyCache after armChangeIndex and both provisioning loops pass the one cache (boxProvisionConfig). The helper now arms it the same way, over the watch armView or disarmView left, and restores the previous cache after the test. The test's request-count assertion is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+13
−1
internal/host/changeindex_test.go+13 −1
diff --git a/internal/host/changeindex_test.go b/internal/host/changeindex_test.go| index 8070a1da7..06086694e 100644 |
| --- a/internal/host/changeindex_test.go |
| +++ b/internal/host/changeindex_test.go |
| @@ -205,8 +205,20 @@ func disarmView(t *testing.T) { |
| armedRecordView.Store(nil) |
| } |
| +// ciReconcileConfig is a pass config as the box's provisioning loops build |
| +// it, with the process's one app policy cache (#328, #329): armPolicyCache |
| +// over the watch armView or disarmView just left, as RunAgent arms it after |
| +// armChangeIndex, and the same cache in every pass that reuses the config. |
| +// Without it each pass would build a throwaway cache, whose backstop is due |
| +// every pass (one ListETags of control/app-policy/), which no box does |
| +// (spec §3a). Call it after armView or disarmView; the previous cache is |
| +// restored after t. |
| func ciReconcileConfig(t *testing.T) provision.ReconcileConfig { |
| - return provision.ReconcileConfig{DataDir: t.TempDir(), Layout: flatLayout} |
| + t.Helper() |
| + prev := armedPolicyCache.Load() |
| + t.Cleanup(func() { armedPolicyCache.Store(prev) }) |
| + armPolicyCache() |
| + return provision.ReconcileConfig{DataDir: t.TempDir(), Layout: flatLayout, Policies: armedPolicyCache.Load()} |
| } |
| // recordFamilyLists counts listings under the record families. |