diff --git a/agent/proxy/manager_test.go b/agent/proxy/manager_test.go index 0b5640241..3bf200805 100644 --- a/agent/proxy/manager_test.go +++ b/agent/proxy/manager_test.go @@ -203,7 +203,8 @@ func TestManagerRun_daemonLogs(t *testing.T) { m.LogDir = filepath.Join(td, "logs") // Create the service and calculate the log paths - id := testStateProxy(t, state, "web", helperProcess("output")) + path := filepath.Join(td, "notify") + id := testStateProxy(t, state, "web", helperProcess("output", path)) stdoutPath := logPath(m.LogDir, id, "stdout") stderrPath := logPath(m.LogDir, id, "stderr") @@ -212,13 +213,9 @@ func TestManagerRun_daemonLogs(t *testing.T) { // We should see the path appear shortly retry.Run(t, func(r *retry.R) { - if _, err := os.Stat(stdoutPath); err != nil { + if _, err := os.Stat(path); err != nil { r.Fatalf("error waiting for stdout path: %s", err) } - - if _, err := os.Stat(stderrPath); err != nil { - r.Fatalf("error waiting for stderr path: %s", err) - } }) expectedOut := "hello stdout\n" diff --git a/agent/proxy/proxy_test.go b/agent/proxy/proxy_test.go index d79ea5bc8..d0812fc07 100644 --- a/agent/proxy/proxy_test.go +++ b/agent/proxy/proxy_test.go @@ -141,6 +141,18 @@ func TestHelperProcess(t *testing.T) { case "output": fmt.Fprintf(os.Stdout, "hello stdout\n") fmt.Fprintf(os.Stderr, "hello stderr\n") + + // Sync to be sure it is written out of buffers + os.Stdout.Sync() + os.Stderr.Sync() + + // Output a file to signal we've written to stdout/err + path := args[0] + if err := ioutil.WriteFile(path, []byte("hello"), 0644); err != nil { + fmt.Fprintf(os.Stderr, "Error: %s\n", err) + os.Exit(1) + } + <-make(chan struct{}) default: