Esempio n. 1
0
				aVolume = new(bfakes.FakeVolume)
				aVolume.HandleReturns("a")
				bVolume = new(bfakes.FakeVolume)
				bVolume.HandleReturns("b")
			})

			Context("with a, b order", func() {
				BeforeEach(func() {
					fakeBaggageclaimClient.ListVolumesReturns([]baggageclaim.Volume{aVolume, bVolume}, nil)
				})

				It("selects the volume based on the lowest alphabetical name", func() {
					Expect(foundVolume).To(Equal(aVolume))
					Expect(found).To(BeTrue())

					Expect(aVolume.SetTTLCallCount()).To(Equal(0))
					Expect(bVolume.ReleaseCallCount()).To(Equal(1))
					Expect(bVolume.ReleaseArgsForCall(0)).To(Equal(worker.FinalTTL(time.Minute)))
				})
			})

			Context("with b, a order", func() {
				BeforeEach(func() {
					fakeBaggageclaimClient.ListVolumesReturns([]baggageclaim.Volume{bVolume, aVolume}, nil)
				})

				It("selects the volume based on the lowest alphabetical name", func() {
					Expect(foundVolume).To(Equal(aVolume))
					Expect(found).To(BeTrue())

					Expect(aVolume.SetTTLCallCount()).To(Equal(0))
Esempio n. 2
0
			expectedTTL2 = 5 * time.Second
			fakeVolume.HandleReturns("some-handle")
			fakeDB.GetVolumeTTLReturns(expectedTTL, nil)
		})

		It("heartbeats", func() {
			vol, err := volumeFactory.Build(logger, fakeVolume)
			Expect(err).ToNot(HaveOccurred())

			By("looking up the initial ttl in the database")
			Expect(fakeDB.GetVolumeTTLCallCount()).To(Equal(1))
			actualHandle := fakeDB.GetVolumeTTLArgsForCall(0)
			Expect(actualHandle).To(Equal("some-handle"))

			By("using that ttl to heartbeat the volume initially")
			Expect(fakeVolume.SetTTLCallCount()).To(Equal(1))
			actualTTL := fakeVolume.SetTTLArgsForCall(0)
			Expect(actualTTL).To(Equal(expectedTTL))

			Expect(fakeDB.SetVolumeTTLCallCount()).To(Equal(1))
			actualHandle, actualTTL = fakeDB.SetVolumeTTLArgsForCall(0)
			Expect(actualHandle).To(Equal(vol.Handle()))
			Expect(actualTTL).To(Equal(expectedTTL))

			By("using the ttl from the database each tick")
			fakeDB.GetVolumeTTLReturns(expectedTTL2, nil)
			fakeClock.Increment(30 * time.Second)

			Eventually(fakeVolume.SetTTLCallCount).Should(Equal(2))
			actualTTL = fakeVolume.SetTTLArgsForCall(1)
			Expect(actualTTL).To(Equal(expectedTTL2))