func (s *Simulator) emitHeartbeatFor(dea string) { hb := models.Heartbeat{ DeaGuid: dea, InstanceHeartbeats: make([]models.InstanceHeartbeat, len(s.DEAs[dea])), } for i, app := range s.DEAs[dea] { hb.InstanceHeartbeats[i] = app.InstanceAtIndex(0).Heartbeat() hb.InstanceHeartbeats[i].State = s.AppInstanceState[app.AppGuid] } s.messageBus.Publish("dea.heartbeat", hb.ToJSON()) }
var err error store, err = storecassandra.New([]string{"127.0.0.1:9042"}, gocql.One, conf, timeprovider.NewTimeProvider()) Ω(err).ShouldNot(HaveOccured()) justOnce = true } }) 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,
Ω(stopMessages()).Should(HaveLen(3)) expectedMessage := models.NewPendingStopMessage(clock.Now(), 0, conf.GracePeriod(), app.AppGuid, app.AppVersion, app.InstanceAtIndex(3).InstanceGuid, models.PendingStopMessageReasonExtra) Ω(stopMessages()).Should(ContainElement(EqualPendingStopMessage(expectedMessage))) expectedMessage = models.NewPendingStopMessage(clock.Now(), 0, conf.GracePeriod(), app.AppGuid, app.AppVersion, duplicateExtraInstance1.InstanceGuid, models.PendingStopMessageReasonExtra) Ω(stopMessages()).Should(ContainElement(EqualPendingStopMessage(expectedMessage))) expectedMessage = models.NewPendingStopMessage(clock.Now(), 0, conf.GracePeriod(), app.AppGuid, app.AppVersion, duplicateExtraInstance2.InstanceGuid, models.PendingStopMessageReasonExtra) Ω(stopMessages()).Should(ContainElement(EqualPendingStopMessage(expectedMessage))) }) }) }) Describe("Handling evacuating instances", func() { var heartbeat models.Heartbeat var evacuatingHeartbeat models.InstanceHeartbeat BeforeEach(func() { evacuatingHeartbeat = app.InstanceAtIndex(1).Heartbeat() evacuatingHeartbeat.State = models.InstanceStateEvacuating heartbeat = dea.HeartbeatWith( app.InstanceAtIndex(0).Heartbeat(), evacuatingHeartbeat, ) store.SyncHeartbeats(heartbeat) }) Context("when the app is no longer desired", func() { It("should send an immediate stop", func() { err := analyzer.Analyze() Ω(err).ShouldNot(HaveOccurred())