fix: keep the bootstrap 403 visible to heartbeats in rds-agent test

The fake control plane returned the scripted 403 once, then failed every
retry with "returned no config", overwriting the failure the heartbeat
reports. The test only passed if a beat landed within one 1ms retry
interval. A persistent fake error keeps the 403 on every retry.
This commit is contained in:
Julian Sommer
2026-10-15 09:00:04 +10:00
parent 29aef59dae
commit 838de354c2
+8 -1
View File
@@ -35,6 +35,8 @@ type fakeControlPlane struct {
bootstrapOut *handlers_rds.GetDBBootstrapConfigOutput
bootstrapErrs []error
// Returned once bootstrapErrs is drained, for a failure no retry heals.
bootstrapErr error
bootstrapReqs []identity
// Scripted responses ahead of bootstrapOut, so a test can answer the first
// fetch differently from the ones the agent retries with.
@@ -105,6 +107,9 @@ func (f *fakeControlPlane) GetBootstrapConfig(_ context.Context, id identity) (*
if err := nextErr(&f.bootstrapErrs); err != nil {
return nil, err
}
if f.bootstrapErr != nil {
return nil, f.bootstrapErr
}
if len(f.bootstrapQueue) > 0 {
out := f.bootstrapQueue[0]
f.bootstrapQueue = f.bootstrapQueue[1:]
@@ -639,7 +644,9 @@ func TestMountTableContains(t *testing.T) {
func TestRun_HeartbeatIncludesBootstrapFailure(t *testing.T) {
cp := newFakeControlPlane()
cp.bootstrapErrs = []error{errors.New("403 AccessDenied: instance profile is not authorised")}
// Persistent, so every retry republishes the 403 rather than leaving it
// visible to a heartbeat for a single retry interval.
cp.bootstrapErr = errors.New("403 AccessDenied: instance profile is not authorised")
cp.registerOut.HeartbeatIntervalSeconds = 0
cfg := testConfig(t)