Add some more fixes caught by race detector (#4488)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2024-03-07 14:46:10 -05:00
1 parent 39a0c0d833
commit 9408b2b299
23 files changed
+86 -51

No files matched your search

@@ -241,6 +241,7 @@ func TestReloadControllerDatabase_InvalidNewDatabaseState(t *testing.T) {
cfgHcl := fmt.Sprintf(dbSwapConfig, urlA, controllerKey, workerAuthKey, recoveryKey)
require.NoError(t, os.WriteFile(td+"/config.hcl", []byte(cfgHcl), 0o644))
errCh := make(chan error, 1)
wg := &sync.WaitGroup{}
wg.Add(1)
go func() {
@@ -250,12 +251,15 @@ func TestReloadControllerDatabase_InvalidNewDatabaseState(t *testing.T) {
exitCode := cmd.Run(args)
if exitCode != 0 {
output := cmd.UI.(*cli.MockUi).ErrorWriter.String() + cmd.UI.(*cli.MockUi).OutputWriter.String()
t.Errorf("got a non-zero exit status: %s", output)
errCh <- fmt.Errorf("got a non-zero exit status: %s", output)
close(errCh)
}
}()
// Wait until things are up and running (or timeout).
select {
case err := <-errCh:
t.Fatal(err)
case <-cmd.startedCh:
case <-time.After(15 * time.Second):
t.Fatal("timeout")