From 38b6271de1eb3344f365964be83239a93ea8f9ea Mon Sep 17 00:00:00 2001 From: Josh Black Date: Fri, 11 Jun 2021 09:08:19 -0700 Subject: [PATCH] OSS parts of sighup license reload test (#11816) --- command/server.go | 18 ++++++++++++------ command/server_test.go | 5 +++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/command/server.go b/command/server.go index cac839dc98..7669f2d8be 100644 --- a/command/server.go +++ b/command/server.go @@ -99,10 +99,11 @@ type ServerCommand struct { cleanupGuard sync.Once - reloadFuncsLock *sync.RWMutex - reloadFuncs *map[string][]reloadutil.ReloadFunc - startedCh chan (struct{}) // for tests - reloadedCh chan (struct{}) // for tests + reloadFuncsLock *sync.RWMutex + reloadFuncs *map[string][]reloadutil.ReloadFunc + startedCh chan (struct{}) // for tests + reloadedCh chan (struct{}) // for tests + licenseReloadedCh chan (error) // for tests allLoggers []log.Logger @@ -1564,8 +1565,13 @@ func (c *ServerCommand) Run(args []string) int { } // Reload license file - if err := vault.LicenseReload(core); err != nil { - c.UI.Error(fmt.Sprintf("Error reloading license: %v", err)) + if err = vault.LicenseReload(core); err != nil { + c.UI.Error(err.Error()) + } + + select { + case c.licenseReloadedCh <- err: + default: } case <-c.SigUSR2Ch: diff --git a/command/server_test.go b/command/server_test.go index e98ec3a772..143e27531b 100644 --- a/command/server_test.go +++ b/command/server_test.go @@ -96,8 +96,9 @@ func testServerCommand(tb testing.TB) (*cli.MockUi, *ServerCommand) { }, // These prevent us from random sleep guessing... - startedCh: make(chan struct{}, 5), - reloadedCh: make(chan struct{}, 5), + startedCh: make(chan struct{}, 5), + reloadedCh: make(chan struct{}, 5), + licenseReloadedCh: make(chan error), } }