Exemplo n.º 1
0
		etcdStoreAdapter.Set([]storeadapter.StoreNode{node})
	}

	Context("When /desired and /actual are missing", func() {
		It("Should not send any start or stop messages", func() {
			startMessages, stopMessages, err := analyzer.Analyze()
			Ω(err).ShouldNot(HaveOccured())
			Ω(startMessages).Should(BeEmpty())
			Ω(stopMessages).Should(BeEmpty())
		})
	})

	Context("When /desired and /actual are empty", func() {
		BeforeEach(func() {
			desired := a1.DesiredState(42)
			actual := a2.GetInstance(0).Heartbeat(30)

			insertDesiredIntoStore(desired)
			insertActualIntoStore(actual)

			etcdStoreAdapter.Delete("/desired/" + desired.StoreKey())
			etcdStoreAdapter.Delete("/actual/" + actual.StoreKey())
		})

		It("Should not send any start or stop messages", func() {
			startMessages, stopMessages, err := analyzer.Analyze()
			Ω(err).ShouldNot(HaveOccured())
			Ω(startMessages).Should(BeEmpty())
			Ω(stopMessages).Should(BeEmpty())
		})
	})
Exemplo n.º 2
0
			store.GetDesiredStateError = errIn
			desired, err := store.GetDesiredState()
			Ω(desired).Should(BeEmpty())
			Ω(err).Should(Equal(errIn))

			store.Reset()
			err = store.SaveDesiredState([]models.DesiredAppState{desired1})
			Ω(err).ShouldNot(HaveOccured())
			_, err = store.GetDesiredState()
			Ω(err).ShouldNot(HaveOccured())
		})
	})

	Describe("Setting, getting, and deleting actual state", func() {
		It("should set, get, and delete the actual state", func() {
			heartbeat1 := app1.GetInstance(0).Heartbeat(12)
			heartbeat2 := app2.GetInstance(0).Heartbeat(10)

			err := store.SaveActualState([]models.InstanceHeartbeat{heartbeat1, heartbeat1, heartbeat2})
			Ω(err).ShouldNot(HaveOccured())

			actual, err := store.GetActualState()
			Ω(err).ShouldNot(HaveOccured())
			Ω(actual).Should(HaveLen(2))
			Ω(actual).Should(ContainElement(heartbeat1))
			Ω(actual).Should(ContainElement(heartbeat2))

			heartbeat2.State = models.InstanceStateCrashed
			heartbeat3 := app1.GetInstance(1).Heartbeat(12)

			err = store.SaveActualState([]models.InstanceHeartbeat{heartbeat2, heartbeat3})