예제 #1
0
파일: worker_test.go 프로젝트: ACPK/atc
							By("no longer heartbeating")
							fakeClock.Increment(30 * time.Second)
							Consistently(fakeContainer.SetGraceTimeCallCount).Should(Equal(1))
						})

						It("performs an initial heartbeat synchronously", func() {
							Expect(fakeContainer.SetGraceTimeCallCount()).To(Equal(1))
							Expect(fakeGardenWorkerDB.UpdateExpiresAtOnContainerCallCount()).To(Equal(1))
						})

						Describe("every 30 seconds", func() {
							It("heartbeats to the database and the container", func() {
								fakeClock.Increment(30 * time.Second)

								Eventually(fakeContainer.SetGraceTimeCallCount).Should(Equal(2))
								Expect(fakeContainer.SetGraceTimeArgsForCall(1)).To(Equal(5 * time.Minute))

								Eventually(fakeGardenWorkerDB.UpdateExpiresAtOnContainerCallCount).Should(Equal(2))
								handle, interval := fakeGardenWorkerDB.UpdateExpiresAtOnContainerArgsForCall(1)
								Expect(handle).To(Equal("some-handle"))
								Expect(interval).To(Equal(5 * time.Minute))

								fakeClock.Increment(30 * time.Second)

								Eventually(fakeContainer.SetGraceTimeCallCount).Should(Equal(3))
								Expect(fakeContainer.SetGraceTimeArgsForCall(2)).To(Equal(5 * time.Minute))

								Eventually(fakeGardenWorkerDB.UpdateExpiresAtOnContainerCallCount).Should(Equal(3))
								handle, interval = fakeGardenWorkerDB.UpdateExpiresAtOnContainerArgsForCall(2)
								Expect(handle).To(Equal("some-handle"))
								Expect(interval).To(Equal(5 * time.Minute))