Exemple #1
0
						fakeBaggageclaimClient = new(bfakes.FakeClient)
						satisfyingWorker.VolumeManagerReturns(fakeBaggageclaimClient, true)
					})

					Context("when the cache is already present", func() {
						var foundVolume *bfakes.FakeVolume

						BeforeEach(func() {
							foundVolume = new(bfakes.FakeVolume)
							foundVolume.HandleReturns("found-volume-handle")
							cacheIdentifier.FindOnReturns(foundVolume, true, nil)

							cacheIdentifier.ResourceVersionReturns(atc.Version{"some": "theversion"})
							cacheIdentifier.ResourceHashReturns("hash")
							satisfyingWorker.NameReturns("myworker")
							foundVolume.ExpirationReturns(time.Hour, time.Now(), nil)
						})

						It("does not error and returns a resource", func() {
							Expect(initErr).NotTo(HaveOccurred())
							Expect(initResource).NotTo(BeNil())
						})

						It("chose the worker satisfying the resource type and tags", func() {
							Expect(workerClient.SatisfyingArgsForCall(0)).To(Equal(worker.WorkerSpec{
								ResourceType: "type1",
								Tags:         []string{"resource", "tags"},
							}))
						})

						It("located it on the correct worker", func() {
Exemple #2
0
			By("releasing the volume with a final ttl")
			vol.Release(worker.FinalTTL(2 * time.Second))
			Eventually(fakeVolume.SetTTLCallCount).Should(Equal(4))
			actualTTL = fakeVolume.SetTTLArgsForCall(3)
			Expect(actualTTL).To(Equal(2 * time.Second))

			Eventually(fakeDB.SetVolumeTTLCallCount).Should(Equal(4))
			actualHandle, actualTTL = fakeDB.SetVolumeTTLArgsForCall(3)
			Expect(actualHandle).To(Equal(vol.Handle()))
			Expect(actualTTL).To(Equal(2 * time.Second))
		})

		It("is resiliant to errors while heartbeating", func() {
			By("using the baggage claim volumes ttl if the initial db lookup fails")
			fakeVolume.ExpirationReturns(expectedTTL, time.Now(), nil)
			fakeDB.GetVolumeTTLReturns(0, errors.New("disaster"))
			_, err := volumeFactory.Build(logger, fakeVolume)
			Expect(err).ToNot(HaveOccurred())
			By("using that ttl to heartbeat the volume initially")
			Expect(fakeVolume.SetTTLCallCount()).To(Equal(1))
			actualTTL := fakeVolume.SetTTLArgsForCall(0)
			Expect(actualTTL).To(Equal(expectedTTL))

			By("continuing to use the same ttl if the db continues to error")
			fakeClock.Increment(30 * time.Second)
			Eventually(fakeVolume.SetTTLCallCount).Should(Equal(2))
			actualTTL = fakeVolume.SetTTLArgsForCall(1)
			Expect(actualTTL).To(Equal(expectedTTL))
		})