for _, numApps := range numberOfApps {
		numApps := numApps
		iteration := 1
		Context(fmt.Sprintf("With %d apps", numApps), func() {
			Measure("Read/Write/Delete Performance", func(b Benchmarker) {
				fmt.Printf("%d apps iteration %d\n", numApps, iteration)
				iteration += 1
				heartbeat := models.Heartbeat{
					DeaGuid:            models.Guid(),
					InstanceHeartbeats: []models.InstanceHeartbeat{},
				}
				n := 0
				for i := 0; i < numApps; i++ {
					app := appfixture.NewAppFixture()
					for j := 0; j < numberOfInstancesPerApp; j++ {
						heartbeat.InstanceHeartbeats = append(heartbeat.InstanceHeartbeats, app.InstanceAtIndex(j).Heartbeat())
						n += 1
					}
				}

				b.Time("WRITE", func() {
					err := store.SyncHeartbeats(heartbeat)
					Ω(err).ShouldNot(HaveOccured())
				}, StorePerformanceReport{
					NumApps: numApps,
					Subject: "write",
				})

				b.Time("READ", func() {
					nodes, err := store.GetInstanceHeartbeats()
					Ω(err).ShouldNot(HaveOccured())
Esempio n. 2
0
					Ω(err).ShouldNot(HaveOccurred())

					Ω(stopMessages()).Should(BeEmpty())

					Ω(startMessages()).Should(HaveLen(1))

					expectedMessageForIndex1 := models.NewPendingStartMessage(clock.Now(), 0, conf.GracePeriod(), app.AppGuid, app.AppVersion, 1, 2.0, models.PendingStartMessageReasonEvacuating)
					Ω(startMessages()).Should(ContainElement(EqualPendingStartMessage(expectedMessageForIndex1)))
				})
			})

			Context("when there is a RUNNING instance on the evacuating index", func() {
				BeforeEach(func() {
					runningInstanceHeartbeat := app.InstanceAtIndex(1).Heartbeat()
					runningInstanceHeartbeat.InstanceGuid = models.Guid()
					heartbeat.InstanceHeartbeats = append(heartbeat.InstanceHeartbeats, runningInstanceHeartbeat)
					store.SyncHeartbeats(heartbeat)
				})

				It("should schedule an immediate stop for the EVACUATING instance", func() {
					err := analyzer.Analyze()
					Ω(err).ShouldNot(HaveOccurred())

					Ω(startMessages()).Should(BeEmpty())

					Ω(stopMessages()).Should(HaveLen(1))

					expectedMessageForEvacuatingInstance := models.NewPendingStopMessage(clock.Now(), 0, conf.GracePeriod(), app.AppGuid, app.AppVersion, evacuatingHeartbeat.InstanceGuid, models.PendingStopMessageReasonEvacuationComplete)
					Ω(stopMessages()).Should(ContainElement(EqualPendingStopMessage(expectedMessageForEvacuatingInstance)))
				})