Exemplo n.º 1
0
		Context("when the actual lrp data is the same", func() {
			It("does nothing", func() {
				_, err := etcdDBWithFakeStore.EvacuateActualLRP(logger, &actualLRP.ActualLRPKey, &actualLRP.ActualLRPInstanceKey, &actualLRP.ActualLRPNetInfo, ttl)
				Expect(err).NotTo(HaveOccurred())

				Expect(fakeStoreClient.CompareAndSwapCallCount()).To(Equal(0))
			})
		})

		Context("when the evacuating actual lrp does not exist", func() {
			BeforeEach(func() {
				_, err := storeClient.Delete(etcd.EvacuatingActualLRPSchemaPath(guid, index), false)
				Expect(err).NotTo(HaveOccurred())

				actualLRP.CrashCount = 0
				actualLRP.CrashReason = ""
				actualLRP.Since = clock.Now().UnixNano()
			})

			It("creates the evacuating actual lrp", func() {
				group, err := etcdDB.EvacuateActualLRP(logger, &actualLRP.ActualLRPKey, &actualLRP.ActualLRPInstanceKey, &actualLRP.ActualLRPNetInfo, ttl)
				Expect(err).NotTo(HaveOccurred())

				actualLRPGroup, err := etcdDB.ActualLRPGroupByProcessGuidAndIndex(logger, guid, index)
				Expect(err).NotTo(HaveOccurred())
				Expect(group).To(Equal(actualLRPGroup))

				Expect(actualLRPGroup.Evacuating.ModificationTag.Epoch).NotTo(BeNil())
				Expect(actualLRPGroup.Evacuating.ModificationTag.Index).To(BeEquivalentTo((1)))
				actualLRPGroup.Evacuating.ModificationTag = actualLRP.ModificationTag