Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions jobsupervisor/monit_job_supervisor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ var _ = Describe("monitJobSupervisor", func() {

failureMessage := "Timed out waiting for services 'foo' to no longer be pending after 5 minutes"

advanceTime(timeService, 10*time.Minute, 2)
timeService.WaitForNWatchersAndIncrement(10*time.Minute, 2)
Eventually(timeService.WatcherCount).Should(Equal(0))
Eventually(errchan).Should(Receive(Equal(errors.New(failureMessage))))
Expect(len(runner.RunCommands)).To(Equal(0)) // never called 'monit stop'
Expand All @@ -371,18 +371,16 @@ var _ = Describe("monitJobSupervisor", func() {
errchan <- monit.StopAndWait()
}()

Eventually(timeService.WatcherCount).Should(Equal(2)) // we hit the pending sleep
Eventually(timeService.WatcherCount).Should(Equal(2)) // wait for pending sleep

client.StatusStatus = fakemonit.FakeMonitStatus{
Services: []boshmonit.Service{
{Monitored: true, Name: "foo", Status: "unknown", Pending: false},
},
}
timeService.Increment(3 * time.Minute)

Eventually(timeService.WatcherCount).Should(Equal(2)) // we hit the stop sleep

timeService.Increment(3 * time.Minute)
timeService.WaitForNWatchersAndIncrement(3*time.Minute, 2) // wait for stop sleep, then advance

Eventually(errchan).Should(Receive(Equal(errors.New("Timed out waiting for services 'foo' to stop after 5 minutes"))))
})
Expand Down Expand Up @@ -555,7 +553,7 @@ var _ = Describe("monitJobSupervisor", func() {

failureMessage := "Timed out waiting for services 'unmonitored-start-pending, initializing, running, running-stop-pending, unmonitored-stop-pending, failing' to stop after 5 minutes"

advanceTime(timeService, 5*time.Minute, 2)
timeService.WaitForNWatchersAndIncrement(5*time.Minute, 2)
Eventually(timeService.WatcherCount).Should(Equal(0))
Eventually(errchan).Should(Receive(Equal(errors.New(failureMessage))))
Expect(statusRequests).To(Equal(3))
Expand Down Expand Up @@ -894,8 +892,3 @@ var _ = Describe("monitJobSupervisor", func() {
})
})
})

func advanceTime(timeService *fakeclock.FakeClock, duration time.Duration, watcherCount int) {
Eventually(timeService.WatcherCount).Should(Equal(watcherCount))
timeService.Increment(duration)
}
10 changes: 6 additions & 4 deletions jobsupervisor/windows_job_supervisor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ var (
)

var _ = AfterSuite(func() {
err := os.RemoveAll(TempDir)
Expect(err).NotTo(HaveOccurred())
Eventually(func() error { return os.RemoveAll(TempDir) }, 2*time.Minute, time.Second).Should(Succeed())
gexec.CleanupBuildArtifacts()

match := func(s string) bool {
Expand Down Expand Up @@ -486,8 +485,11 @@ var _ = Describe("WindowsJobSupervisor", func() {
AfterEach(func() {
Expect(jobSupervisor.Stop()).To(Succeed())
Expect(jobSupervisor.RemoveAllJobs()).To(Succeed())
Eventually(func() error { return fs.RemoveAll(jobDir) }, 60*time.Second).Should(Succeed())
Expect(fs.RemoveAll(logDir)).To(Succeed())
// Windows releases file handles on the service wrapper exe and log
// files asynchronously after the SCM reports services as deleted.
// Use a long timeout with a slow poll to avoid spinning on busy CI.
Eventually(func() error { return fs.RemoveAll(jobDir) }, 2*time.Minute, time.Second).Should(Succeed())
Eventually(func() error { return fs.RemoveAll(logDir) }, 2*time.Minute, time.Second).Should(Succeed())
})

Describe("AddJob", func() {
Expand Down
Loading