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

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

		It("should become ready", func() {
			Eventually(registrationProcess.Ready()).Should(BeClosed())
		})

		It("updates the health status after TTL/2", func() {
			Eventually(agent.PassTTLCallCount).Should(Equal(1))
			clock.WaitForWatcherAndIncrement(5 * time.Second)
			Eventually(agent.PassTTLCallCount).Should(Equal(2))
		})

		It("when the passTTL fails we should try and reregister", func() {
			Eventually(agent.ServiceRegisterCallCount()).Should(Equal(1))
			Eventually(agent.PassTTLCallCount).Should(Equal(1))
			agent.PassTTLReturns(fmt.Errorf("Invalid status: failed"))
			clock.WaitForWatcherAndIncrement(5 * time.Second)
			Eventually(agent.PassTTLCallCount).Should(Equal(2))
			Eventually(agent.ServiceRegisterCallCount()).Should(Equal(2))
		})

		Context("deregistering the service", func() {
			It("deregisters the service after being signalled", func() {
				Expect(agent.ServiceDeregisterCallCount()).Should(Equal(0))
예제 #2
0
				convergeRepeatInterval,
				kickTaskDuration,
				expirePendingTaskDuration,
				expireCompletedTaskDuration,
			),
		)
	})

	AfterEach(func() {
		ginkgomon.Interrupt(process)
		Eventually(process.Wait()).Should(Receive())
	})

	Describe("converging over time", func() {
		It("converges tasks, LRPs, and auctions when the lock is periodically reestablished", func() {
			fakeClock.WaitForWatcherAndIncrement(convergeRepeatInterval + aBit)

			Eventually(fakeTaskController.ConvergeTasksCallCount).Should(Equal(1))
			Eventually(fakeLrpConvergenceController.ConvergeLRPsCallCount).Should(Equal(1))

			_, actualKickTaskDuration, actualExpirePendingTaskDuration, actualExpireCompletedTaskDuration := fakeTaskController.ConvergeTasksArgsForCall(0)
			Expect(actualKickTaskDuration).To(Equal(kickTaskDuration))
			Expect(actualExpirePendingTaskDuration).To(Equal(expirePendingTaskDuration))
			Expect(actualExpireCompletedTaskDuration).To(Equal(expireCompletedTaskDuration))

			fakeClock.WaitForWatcherAndIncrement(convergeRepeatInterval + aBit)

			Eventually(fakeTaskController.ConvergeTasksCallCount).Should(Equal(2))
			Eventually(fakeLrpConvergenceController.ConvergeLRPsCallCount).Should(Equal(2))

			_, actualKickTaskDuration, actualExpirePendingTaskDuration, actualExpireCompletedTaskDuration = fakeTaskController.ConvergeTasksArgsForCall(1)
예제 #3
0
			consulRunner.Stop()
		})

		AfterEach(func() {
			consulRunner.Start()
			consulRunner.WaitUntilReady()
		})

		It("continues to retry acquiring the lock", func() {
			lockProcess = ifrit.Background(lockRunner)

			Consistently(lockProcess.Ready()).ShouldNot(BeClosed())
			Consistently(lockProcess.Wait()).ShouldNot(Receive())

			Eventually(logger).Should(Say("acquire-lock-failed"))
			clock.WaitForWatcherAndIncrement(retryInterval)
			Eventually(logger).Should(Say("retrying-acquiring-lock"))
			clock.WaitForWatcherAndIncrement(retryInterval)
			Eventually(logger).Should(Say("retrying-acquiring-lock"))
		})

		Context("when consul starts up", func() {
			It("acquires the lock", func() {
				lockProcess = ifrit.Background(lockRunner)

				Eventually(logger).Should(Say("acquire-lock-failed"))
				clock.Increment(retryInterval)
				Eventually(logger).Should(Say("retrying-acquiring-lock"))
				Consistently(lockProcess.Ready()).ShouldNot(BeClosed())
				Consistently(lockProcess.Wait()).ShouldNot(Receive())
예제 #4
0
	})

	Describe("Run", func() {
		var schedDone chan struct{}

		BeforeEach(func() {
			schedDone = make(chan struct{})
		})

		JustBeforeEach(func() {
			go func(sched *scheduler.Scheduler, c chan struct{}) {
				defer GinkgoRecover()
				Expect(sched.Run).NotTo(Panic())
				close(c)
			}(sched, schedDone)
			clk.WaitForWatcherAndIncrement(csSleep)
		})

		AfterEach(func() {
			Expect(sched.Stop()).To(Succeed())
			clk.Increment(csSleep)
			Eventually(schedDone).Should(BeClosed())
		})

		Context("when there are no tasks", func() {
			It("should not call the task selector", func() {
				Expect(taskSelector.SelectTaskCallCount()).To(Equal(0))
			})
		})

		Context("when there are tasks", func() {