コード例 #1
0
ファイル: worker_test.go プロジェクト: ACPK/atc
					Describe("the created container", func() {
						It("can be destroyed", func() {
							err := createdContainer.Destroy()
							Expect(err).NotTo(HaveOccurred())

							By("destroying via garden")
							Expect(fakeGardenClient.DestroyCallCount()).To(Equal(1))
							Expect(fakeGardenClient.DestroyArgsForCall(0)).To(Equal("some-handle"))

							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))