Skip to content

Commit

Permalink
Updated manager tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi Constantin committed Nov 26, 2019
1 parent 4051d08 commit bab76de
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func TestOverseerSignalStopRestart(t *testing.T) {

id := "ping"
opts := cmd.Options{RetryTimes: 3}
c := ovr.Add(id, "ping", []string{"localhost"}, opts)
ovr.Add(id, "ping", []string{"localhost"}, opts)

stat := ovr.Status(id)
assert.Equal("initial", stat.State)
Expand All @@ -193,18 +193,26 @@ func TestOverseerSignalStopRestart(t *testing.T) {
go ovr.Supervise(id)
time.Sleep(timeUnit)

// Signal() doesn't reset retry times
assert.Nil(ovr.Signal(id, syscall.SIGTERM))
stat = ovr.Status(id)
assert.Equal("stopping", stat.State)

time.Sleep(timeUnit)
stat = ovr.Status(id)
assert.NotZero(stat.RetryTimes)
assert.Equal("running", stat.State)

// Stop() resets retry times
assert.Nil(ovr.Stop(id))
stat = ovr.Status(id)
assert.Equal("stopping", stat.State)

time.Sleep(timeUnit)
stat = ovr.Status(id)
assert.Zero(stat.RetryTimes)
assert.Equal("interrupted", stat.State)

c.Lock()
assert.Zero(c.RetryTimes)
c.Unlock()

ovr.StopAll(true)

time.Sleep(timeUnit)
Expand Down

0 comments on commit bab76de

Please # to comment.