mirror of https://github.com/status-im/consul.git
WIP
This commit is contained in:
parent
8cf4b3a6eb
commit
a2fe604191
|
@ -121,12 +121,17 @@ func TestDaemonDetachesChild(t *testing.T) {
|
|||
proc.Kill()
|
||||
}()
|
||||
|
||||
time.Sleep(20 * time.Second)
|
||||
|
||||
// Now kill the parent and wait for it
|
||||
require.NoError(parentCmd.Process.Kill())
|
||||
|
||||
_, err := parentCmd.Process.Wait()
|
||||
require.NoError(err)
|
||||
|
||||
// The child should still be running so file should still be there
|
||||
time.Sleep(15 * time.Second)
|
||||
|
||||
// The child should still be running so file should still be there AND child processid should still be there
|
||||
_, err = os.Stat(path)
|
||||
require.NoError(err, "child should still be running")
|
||||
|
||||
|
|
|
@ -178,12 +178,13 @@ func TestHelperProcess(t *testing.T) {
|
|||
|
||||
<-make(chan struct{})
|
||||
|
||||
// Parent runs the given process in a Daemon and then exits. It exists to test
|
||||
// that the Daemon-managed child process survives it's parent exiting which we
|
||||
// can't test directly without exiting the test process so we need an extra
|
||||
// level of indirection. The caller must pass a file path as the first
|
||||
// argument for the child processes PID to be written and then must take care
|
||||
// to clean up that PID later or the child will be left running forever.
|
||||
// Parent runs the given process in a Daemon and then sleeps until the test
|
||||
// code kills it. It exists to test that the Daemon-managed child process
|
||||
// survives it's parent exiting which we can't test directly without exiting
|
||||
// the test process so we need an extra level of indirection. The test code
|
||||
// using this must pass a file path as the first argument for the child
|
||||
// processes PID to be written and then must take care to clean up that PID
|
||||
// later or the child will be left running forever.
|
||||
case "parent":
|
||||
// We will write the PID for the child to the file in the first argument
|
||||
// then pass rest of args through to command.
|
||||
|
@ -197,10 +198,11 @@ func TestHelperProcess(t *testing.T) {
|
|||
pidBs := []byte(strconv.Itoa(d.Process.Pid))
|
||||
if err := ioutil.WriteFile(pidFile, pidBs, 0644); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %s\n", err)
|
||||
// TODO: Also kill the detached process (once it is detached)
|
||||
os.Exit(1)
|
||||
}
|
||||
// Wait "forever" (calling test chooses when we exit with signal/Wait to
|
||||
// minimise coordination)
|
||||
// minimise coordination).
|
||||
for {
|
||||
time.Sleep(time.Hour)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue