fix: Fail in goroutine after tests have completed (#23158)

* fix panic: Fail in goroutine after TestProxy_Config_ReloadTls has completed

* fix proxy test

* feedback

* track the command output code and stdout/err
This commit is contained in:
Hamid Ghaf
2023-09-19 08:40:10 -07:00
committed by GitHub
parent 1e76ad42ef
commit d5f4243c9e
2 changed files with 38 additions and 19 deletions

View File

@@ -1171,12 +1171,13 @@ func TestProxy_Config_ReloadTls(t *testing.T) {
logger := logging.NewVaultLogger(hclog.Trace)
ui, cmd := testProxyCommand(t, logger)
var output string
var code int
wg.Add(1)
args := []string{"-config", configFile.Name()}
go func() {
if code := cmd.Run(args); code != 0 {
output := ui.ErrorWriter.String() + ui.OutputWriter.String()
t.Errorf("got a non-zero exit status: %s", output)
if code = cmd.Run(args); code != 0 {
output = ui.ErrorWriter.String() + ui.OutputWriter.String()
}
wg.Done()
}()
@@ -1243,6 +1244,9 @@ func TestProxy_Config_ReloadTls(t *testing.T) {
// Shut down
cmd.ShutdownCh <- struct{}{}
wg.Wait()
if code != 0 {
t.Fatalf("got a non-zero exit status: %d, stdout/stderr: %s", code, output)
}
}