當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。