diff --git a/internals/daemon/daemon_test.go b/internals/daemon/daemon_test.go index 8bd62478..a73cceb0 100644 --- a/internals/daemon/daemon_test.go +++ b/internals/daemon/daemon_test.go @@ -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") @@ -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() diff --git a/internals/overlord/servstate/manager_test.go b/internals/overlord/servstate/manager_test.go index 98fbf85c..2f95ae37 100644 --- a/internals/overlord/servstate/manager_test.go +++ b/internals/overlord/servstate/manager_test.go @@ -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: @@ -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) }