本文整理匯總了Golang中code/cloudfoundry/org/clock/fakeclock.FakeClock.WaitForWatcherAndIncrement方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeClock.WaitForWatcherAndIncrement方法的具體用法?Golang FakeClock.WaitForWatcherAndIncrement怎麽用?Golang FakeClock.WaitForWatcherAndIncrement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/cloudfoundry/org/clock/fakeclock.FakeClock
的用法示例。
在下文中一共展示了FakeClock.WaitForWatcherAndIncrement方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
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:
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:
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:
})
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() {