本文整理汇总了Golang中github.com/cloudfoundry/gunk/timeprovider/faketimeprovider.FakeTimeProvider.Time方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeTimeProvider.Time方法的具体用法?Golang FakeTimeProvider.Time怎么用?Golang FakeTimeProvider.Time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/gunk/timeprovider/faketimeprovider.FakeTimeProvider
的用法示例。
在下文中一共展示了FakeTimeProvider.Time方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Ω(pendingStarts).Should(BeEmpty())
})
})
Context("when the reason is DEA_EVACUATION", func() {
BeforeEach(func() {
messageBus.SubjectCallbacks("droplet.exited")[0](&nats.Msg{
Data: app.InstanceAtIndex(1).DropletExited(models.DropletExitedReasonDEAEvacuation).ToJSON(),
})
})
It("should put a high priority pending start message (configured to skip verification) into the queue", func() {
pendingStarts, err := store.GetPendingStartMessages()
Ω(err).ShouldNot(HaveOccurred())
expectedStartMessage := models.NewPendingStartMessage(timeProvider.Time(), 0, conf.GracePeriod(), app.AppGuid, app.AppVersion, 1, 2.0, models.PendingStartMessageReasonEvacuating)
expectedStartMessage.SkipVerification = true
Ω(pendingStarts).Should(ContainElement(EqualPendingStartMessage(expectedStartMessage)))
})
})
Context("when the reason is DEA_SHUTDOWN", func() {
BeforeEach(func() {
messageBus.SubjectCallbacks("droplet.exited")[0](&nats.Msg{
Data: app.InstanceAtIndex(1).DropletExited(models.DropletExitedReasonDEAShutdown).ToJSON(),
})
})
It("should put a high priority pending start message (configured to skip verification) into the queue", func() {
pendingStarts, err := store.GetPendingStartMessages()
示例2:
})
It("should not error", func() {
Ω(err).ShouldNot(HaveOccurred())
})
Context("when the message should be kept alive", func() {
BeforeEach(func() {
keepAliveTime = 30
})
It("should update the sent on times", func() {
messages, _ := store.GetPendingStartMessages()
Ω(messages).Should(HaveLen(1))
for _, message := range messages {
Ω(message.SentOn).Should(Equal(timeProvider.Time().Unix()))
}
})
Context("when saving the start messages fails", func() {
BeforeEach(func() {
storeSetErrInjector = fakestoreadapter.NewFakeStoreAdapterErrorInjector("start", errors.New("oops"))
})
It("should return an error", func() {
Ω(err).Should(HaveOccurred())
})
})
})
Context("when the KeepAlive = 0", func() {
示例3:
messageBus.Subscriptions["dea.heartbeat"][0].Callback(&yagnats.Message{
Payload: app.Heartbeat(1).ToJSON(),
})
store.RevokeActualFreshness()
timeProvider.IncrementBySeconds(conf.ActualFreshnessTTL())
messageBus.Subscriptions["dea.advertise"][0].Callback(&yagnats.Message{
Payload: []byte("doesn't matter"),
})
})
It("Bumps the actual state freshness", func() {
timeProvider.IncrementBySeconds(conf.ActualFreshnessTTL())
isFresh, _ := store.IsActualStateFresh(timeProvider.Time())
Ω(isFresh).Should(BeTrue())
})
})
Context("and a heartbeat was received recently", func() {
BeforeEach(func() {
messageBus.Subscriptions["dea.heartbeat"][0].Callback(&yagnats.Message{
Payload: app.Heartbeat(1).ToJSON(),
})
store.RevokeActualFreshness()
timeProvider.IncrementBySeconds(conf.ActualFreshnessTTL() - 1)
messageBus.Subscriptions["dea.advertise"][0].Callback(&yagnats.Message{
示例4:
Describe("Starting missing instances", func() {
Context("where an app has desired instances", func() {
BeforeEach(func() {
store.SyncDesiredState(
app.DesiredState(2),
)
})
Context("and none of the instances are running", func() {
It("should send a start message for each of the missing instances", func() {
err := analyzer.Analyze()
Ω(err).ShouldNot(HaveOccurred())
Ω(stopMessages()).Should(BeEmpty())
Ω(startMessages()).Should(HaveLen(2))
expectedMessage := models.NewPendingStartMessage(timeProvider.Time(), conf.GracePeriod(), 0, app.AppGuid, app.AppVersion, 0, 1, models.PendingStartMessageReasonMissing)
Ω(startMessages()).Should(ContainElement(EqualPendingStartMessage(expectedMessage)))
expectedMessage = models.NewPendingStartMessage(timeProvider.Time(), conf.GracePeriod(), 0, app.AppGuid, app.AppVersion, 1, 1, models.PendingStartMessageReasonMissing)
Ω(startMessages()).Should(ContainElement(EqualPendingStartMessage(expectedMessage)))
})
It("should set the priority to 1", func() {
analyzer.Analyze()
for _, message := range startMessages() {
Ω(message.Priority).Should(Equal(1.0))
}
})
})
Context("when there is an existing start message", func() {