test: Write URL after signal listen to fix flake (#2456)

The URL could be read before the signal was listening, causing
this test to flake: https://github.com/coder/coder/runs/6936820170?check_suite_focus=true
This commit is contained in:
Kyle Carberry
2022-06-17 09:16:45 -05:00
committed by GitHub
parent f09ab03baf
commit 7cce7a9c69
2 changed files with 7 additions and 6 deletions

View File

@ -408,11 +408,6 @@ func server() *cobra.Command {
errCh <- wg.Wait()
}()
// This is helpful for tests, but can be silently ignored.
// Coder may be ran as users that don't have permission to write in the homedir,
// such as via the systemd service.
_ = config.URL().Write(client.URL.String())
hasFirstUser, err := client.HasFirstUser(cmd.Context())
if !hasFirstUser && err == nil {
cmd.Println()
@ -442,6 +437,12 @@ func server() *cobra.Command {
stopChan := make(chan os.Signal, 1)
defer signal.Stop(stopChan)
signal.Notify(stopChan, os.Interrupt)
// This is helpful for tests, but can be silently ignored.
// Coder may be ran as users that don't have permission to write in the homedir,
// such as via the systemd service.
_ = config.URL().Write(client.URL.String())
select {
case <-cmd.Context().Done():
coderAPI.Close()

View File

@ -96,7 +96,7 @@ func (api *API) ListenProvisionerDaemon(ctx context.Context) (client proto.DRPCP
},
})
go func() {
err = server.Serve(ctx, serverSession)
err := server.Serve(ctx, serverSession)
if err != nil && !xerrors.Is(err, io.EOF) {
api.Logger.Debug(ctx, "provisioner daemon disconnected", slog.Error(err))
}