当前位置: 首页>>代码示例>>Golang>>正文


Golang FakeTimeProvider.Time方法代码示例

本文整理汇总了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()
开发者ID:cgrotz,项目名称:hm9000,代码行数:31,代码来源:evacuator_test.go

示例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() {
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:31,代码来源:sender_test.go

示例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{
开发者ID:KeyOfSpectator,项目名称:hm9000,代码行数:31,代码来源:actual_state_listener_test.go

示例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() {
开发者ID:KeyOfSpectator,项目名称:hm9000,代码行数:31,代码来源:analyzer_test.go


注:本文中的github.com/cloudfoundry/gunk/timeprovider/faketimeprovider.FakeTimeProvider.Time方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。