var registrationError = errors.New("boom")
		BeforeEach(func() {
			agent.ServiceRegisterReturns(registrationError)
		})

		JustBeforeEach(func() {
			registrationProcess = ifrit.Background(registrationRunner)
		})

		AfterEach(func() {
			ginkgomon.Kill(registrationProcess)
		})

		It("retries", func() {
			Eventually(agent.ServiceRegisterCallCount).Should(Equal(1))
			clock.IncrementBySeconds(6)
			Eventually(agent.ServiceRegisterCallCount).Should(Equal(2))
		})

		It("does not become ready", func() {
			Consistently(registrationProcess.Ready()).ShouldNot(BeClosed())
		})
	})

	Context("when registering hangs forever", func() {
		var blockRegister chan struct{}
		var blockRegisterDone chan struct{}

		BeforeEach(func() {
			blockRegister = make(chan struct{})
			blockRegisterDone = make(chan struct{})
예제 #2
0
			It("acquires the lock", func() {
				lockProcess = ifrit.Background(lockRunner)
				Eventually(lockProcess.Ready()).Should(BeClosed())
				Expect(sender.GetValue(lockUptimeMetricName).Value).Should(Equal(float64(0)))
				Expect(getLockValue()).To(Equal(lockValue))
				Expect(sender.GetValue(lockHeldMetricName).Value).To(Equal(float64(1)))
			})

			Context("and we have acquired the lock", func() {
				JustBeforeEach(func() {
					lockProcess = ifrit.Background(lockRunner)
					Eventually(lockProcess.Ready()).Should(BeClosed())
				})

				It("continues to emit lock metric", func() {
					clock.IncrementBySeconds(30)
					Eventually(func() float64 {
						return sender.GetValue(lockUptimeMetricName).Value
					}, 2).Should(Equal(float64(30 * time.Second)))
					clock.IncrementBySeconds(30)
					Eventually(func() float64 {
						return sender.GetValue(lockUptimeMetricName).Value
					}, 2).Should(Equal(float64(60 * time.Second)))
					clock.IncrementBySeconds(30)
					Eventually(func() float64 {
						return sender.GetValue(lockUptimeMetricName).Value
					}, 2).Should(Equal(float64(90 * time.Second)))
				})

				Context("when consul shuts down", func() {
					JustBeforeEach(func() {