Skip to content

Commit bc8690f

Browse files
committed
Snapshot vds baseline before awaiting watcher start.
1 parent 9d4ed43 commit bc8690f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

test/integration/vaultdynamicsecret_integration_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,8 +1699,15 @@ func TestVaultDynamicSecret_InstantUpdates(t *testing.T) {
16991699
"ttl",
17001700
)
17011701

1702-
// Capture the VDS status before rotation so we can detect changes.
1702+
// Confirm the WebSocket subscription is active before snapshotting
1703+
// vdsBefore, so the baseline is taken as close to our own
1704+
// rotate-role call as possible.
17031705
objKey := ctrlclient.ObjectKeyFromObject(vdsObj)
1706+
awaitEventWatcherStarted(t, ctx, crdClient, vdsObj)
1707+
1708+
// Snapshot immediately before rotation to minimise the window where
1709+
// a concurrent subtest's rotate-role could have already updated
1710+
// LastVaultRotation and staled this baseline.
17041711
var vdsBefore secretsv1beta1.VaultDynamicSecret
17051712
require.NoError(t, backoff.Retry(func() error {
17061713
if err := crdClient.Get(ctx, objKey, &vdsBefore); err != nil {
@@ -1715,10 +1722,6 @@ func TestVaultDynamicSecret_InstantUpdates(t *testing.T) {
17151722
return nil
17161723
}, backoff.WithMaxRetries(backoff.NewConstantBackOff(time.Second), 60)))
17171724

1718-
// Wait for the EventWatcherStarted event, confirming the WebSocket
1719-
// subscription is active before triggering the rotation.
1720-
awaitEventWatcherStarted(t, ctx, crdClient, vdsObj)
1721-
17221725
// Force-rotate the static database role in Vault. This emits a
17231726
// database* event that the SharedWebSocket fans out to all N
17241727
// subscribed VDS CRs simultaneously.

0 commit comments

Comments
 (0)