Exemplo n.º 1
0
				calc := models.NewDefaultRestartCalculator()
				for _, state := range models.ActualLRPStates {
					actual.State = state
					if state == models.ActualLRPStateCrashed {
						Expect(actual.ShouldRestartCrash(now, calc)).To(BeTrue(), "should restart CRASHED lrp")
					} else {
						Expect(actual.ShouldRestartCrash(now, calc)).To(BeFalse(), fmt.Sprintf("should not restart %s lrp", state))
					}
				}
			})
		})
	})

	Describe("StartActualLRPRequest", func() {
		Describe("Validate", func() {
			var request models.StartActualLRPRequest

			BeforeEach(func() {
				request = models.StartActualLRPRequest{
					ActualLrpKey:         &models.ActualLRPKey{ProcessGuid: "p-guid", Index: 2, Domain: "domain"},
					ActualLrpInstanceKey: &models.ActualLRPInstanceKey{InstanceGuid: "i-guid", CellId: "c-id"},
					ActualLrpNetInfo:     &models.ActualLRPNetInfo{Address: "addr"},
				}
			})

			Context("when valid", func() {
				It("returns nil", func() {
					Expect(request.Validate()).To(BeNil())
				})
			})
Exemplo n.º 2
0
				Expect(claimErr).To(Equal(models.ErrResourceNotFound))
			})

			It("does not create an actual LRP", func() {
				_, err := etcdDB.ActualLRPGroupByProcessGuidAndIndex(logger, "process-guid", 1)
				Expect(err).To(HaveOccurred())
			})
		})
	})

	Describe("StartActualLRP", func() {
		var (
			startErr         *models.Error
			request          models.StartActualLRPRequest
			startedActualLRP *models.ActualLRP

			lrpKey      models.ActualLRPKey
			instanceKey models.ActualLRPInstanceKey
			netInfo     models.ActualLRPNetInfo
		)

		JustBeforeEach(func() {
			request.ActualLrpKey = &lrpKey
			request.ActualLrpInstanceKey = &instanceKey
			request.ActualLrpNetInfo = &netInfo
			startedActualLRP, startErr = etcdDB.StartActualLRP(logger, &request)
		})

		Context("when the actual LRP exists", func() {
			var (
				processGuid string