@@ -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