Make manualStepDownCh a 1-buffered channel to ensure StepDown actually steps down in tests. (#9622)

This commit is contained in:
ncabatoff 2020-07-31 10:01:51 -04:00 committed by GitHub
parent fbe2a86693
commit b6fd378ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -1494,7 +1494,7 @@ func (c *Core) unsealInternal(ctx context.Context, masterKey []byte) (bool, erro
} else {
// Go to standby mode, wait until we are active to unseal
c.standbyDoneCh = make(chan struct{})
c.manualStepDownCh = make(chan struct{})
c.manualStepDownCh = make(chan struct{}, 1)
c.standbyStopCh.Store(make(chan struct{}))
go c.runStandby(c.standbyDoneCh, c.manualStepDownCh, c.standbyStopCh.Load().(chan struct{}))
}

View File

@ -1250,7 +1250,7 @@ func TestCore_Standby_Seal(t *testing.T) {
func TestCore_StepDown(t *testing.T) {
// Create the first core and initialize it
logger = logging.NewVaultLogger(log.Trace)
logger = logging.NewVaultLogger(log.Trace).Named(t.Name())
inm, err := inmem.NewInmemHA(nil, logger)
if err != nil {
@ -1267,6 +1267,7 @@ func TestCore_StepDown(t *testing.T) {
HAPhysical: inmha.(physical.HABackend),
RedirectAddr: redirectOriginal,
DisableMlock: true,
Logger: logger.Named("core1"),
})
if err != nil {
t.Fatalf("err: %v", err)
@ -1305,6 +1306,7 @@ func TestCore_StepDown(t *testing.T) {
HAPhysical: inmha.(physical.HABackend),
RedirectAddr: redirectOriginal2,
DisableMlock: true,
Logger: logger.Named("core2"),
})
if err != nil {
t.Fatalf("err: %v", err)