Skip to content

Commit

Permalink
chore: update test cases with comments
Browse files Browse the repository at this point in the history
  • Loading branch information
IronCore864 committed Sep 29, 2024
1 parent 28d94de commit b46ca80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 3 additions & 4 deletions internals/daemon/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ services:
rsp.ServeHTTP(rec, req)
c.Check(rec.Result().StatusCode, Equals, 202)

// Wait for the change to be in doing state.
// Wait for the change to be in doing state so that the service is in starting state.
for i := 0; ; i++ {
if i >= 10 {
c.Fatalf("timed out waiting for change")
Expand All @@ -1354,12 +1354,11 @@ services:
time.Sleep(20 * time.Millisecond)
}

// Stop the daemon within the okayDelay,
// which should stop services in running state.
// Stop the daemon within the okayDelay, which should stop services in starting state.
err = d.Stop(nil)
c.Assert(err, IsNil)

// Ensure the "stop" change was created, along with its "stop" tasks.
// Ensure a "stop" change is created, along with its "stop" tasks.
d.state.Lock()
defer d.state.Unlock()
changes := d.state.Changes()
Expand Down
5 changes: 3 additions & 2 deletions internals/overlord/servstate/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,13 @@ services:
}

func (s *S) TestStopServiceWithinOkayDelay(c *C) {
// A longer okayDelay is used so that the change for starting the services won't
// A longer okayDelay is used so that the change for starting the service won't
// quickly transition into the running state.
fakeOkayDelay := 5 * shortOkayDelay
servstate.FakeOkayWait(fakeOkayDelay)

s.newServiceManager(c)
// The service sleeps for fakeOkayDelay second then creates a side effect (a file at donePath).
layer := `
services:
%s:
Expand Down Expand Up @@ -337,7 +338,7 @@ services:
s.st.Unlock()

donePath := filepath.Join(s.dir, serviceName)
// DonePath not created means the service is terminated within the okayWait.
// If the service is stopped within okayDelay and is indeed terminated, donePath should not exist.
if _, err := os.Stat(donePath); err == nil {
c.Fatalf("service %s waiting for service output", serviceName)
}
Expand Down

0 comments on commit b46ca80

Please sign in to comment.