mirror of
https://github.com/hashicorp/vault.git
synced 2026-02-18 18:38:08 -05:00
identity: fix a race in invalidation testing (#29836)
This commit is contained in:
parent
e9fe1abd3e
commit
4cbdadffe2
2 changed files with 23 additions and 2 deletions
|
|
@ -1643,9 +1643,10 @@ func identityStoreLoadingIsDeterministic(t *testing.T, flags *determinismTestFla
|
|||
c.FeatureActivationFlags.ActivateInMem(activationflags.IdentityDeduplication, true)
|
||||
require.NoError(t, err)
|
||||
|
||||
c.identityStore.activateDeduplicationDone = make(chan struct{})
|
||||
c.identityStore.MakeDeduplicationDoneChan()
|
||||
err := c.systemBackend.activateIdentityDeduplication(ctx, nil)
|
||||
<-c.identityStore.activateDeduplicationDone
|
||||
require.NoError(t, err)
|
||||
err = c.identityStore.WaitForActivateDeduplicationDone(ctx)
|
||||
require.NoError(t, err)
|
||||
require.IsType(t, &renameResolver{}, c.identityStore.conflictResolver)
|
||||
require.False(t, c.identityStore.disableLowerCasedNames)
|
||||
|
|
|
|||
|
|
@ -2947,3 +2947,23 @@ func makeLocalAliasWithName(t *testing.T, name, entityID string, bucketKey strin
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
// MakeDeduplicationDoneChan creates a new done channel for synchronization
|
||||
// with tests outside of the vault package (e.g. in external_tests).
|
||||
func (i *IdentityStore) MakeDeduplicationDoneChan() {
|
||||
i.activateDeduplicationDone = make(chan struct{})
|
||||
}
|
||||
|
||||
// WaitForActivateDeduplicationDone is a test helper to wait for the identity
|
||||
// deduplication activation to finish.
|
||||
func (i *IdentityStore) WaitForActivateDeduplicationDone(ctx context.Context) error {
|
||||
timeoutCtx, cancel := context.WithTimeout(ctx, 90*time.Second)
|
||||
defer cancel()
|
||||
select {
|
||||
case <-i.activateDeduplicationDone:
|
||||
return nil
|
||||
case <-timeoutCtx.Done():
|
||||
return fmt.Errorf("timed out waiting for deduplication")
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue