func itValidatesAbsenceOfTheInstanceKey(lrp *models.ActualLRP) {
	Context("when the instance key is set", func() {
		BeforeEach(func() {
			lrp.ActualLRPInstanceKey = models.NewActualLRPInstanceKey("some-instance", "some-cell")
		})

		It("validate returns an error", func() {
			err := lrp.Validate()
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("instance key"))
		})
	})

	Context("when the instance key is not set", func() {
		BeforeEach(func() {
			lrp.ActualLRPInstanceKey = models.ActualLRPInstanceKey{}
		})

		It("validate does not return an error", func() {
			Expect(lrp.Validate()).NotTo(HaveOccurred())
		})
	})
}
예제 #2
0
		)

		BeforeEach(func() {
			oldDesiredLRP = oldmodels.DesiredLRP{
				ProcessGuid: processGuid,
				Domain:      domain,
				RootFS:      "some:rootfs",
				Instances:   1,
				Action: &oldmodels.RunAction{
					Path: "true",
					User: "******",
				},
			}

			legacyKey = oldmodels.NewActualLRPKey(processGuid, 0, domain)
			legacyOldInstanceKey = oldmodels.NewActualLRPInstanceKey("instance-guid", "cell-id")
			legacyNewInstanceKey = oldmodels.NewActualLRPInstanceKey("other-instance-guid", "other-cell-id")
			legacyNetInfo = oldmodels.NewActualLRPNetInfo("1.1.1.1", []oldmodels.PortMapping{})

			key = models.NewActualLRPKey(processGuid, 0, domain)
			oldInstanceKey = models.NewActualLRPInstanceKey("instance-guid", "cell-id")
			newInstanceKey = models.NewActualLRPInstanceKey("other-instance-guid", "other-cell-id")
			netInfo = models.NewActualLRPNetInfo("1.1.1.1")
		})

		It("receives events", func() {
			By("creating a ActualLRP")
			err := legacyBBS.DesireLRP(logger, oldDesiredLRP)
			Expect(err).NotTo(HaveOccurred())

			actualLRPGroup, err := bbsClient.ActualLRPGroupByProcessGuidAndIndex(oldDesiredLRP.ProcessGuid, 0)
예제 #3
0
		evacuatingLRP2 = actualLRP2
		evacuatingLRP2.State = proto.String(models.ActualLRPStateRunning)
		evacuatingLRP2.Since = proto.Int64(3417)
	})

	// old before each
	BeforeEach(func() {
		oldActualLRP1 = oldmodels.ActualLRP{
			ActualLRPKey: oldmodels.NewActualLRPKey(
				"process-guid-0",
				1,
				"domain-0",
			),
			ActualLRPInstanceKey: oldmodels.NewActualLRPInstanceKey(
				"instance-guid-0",
				"cell-id-0",
			),
			State: oldmodels.ActualLRPStateRunning,
			Since: 1138,
		}

		oldActualLRP2 = oldmodels.ActualLRP{
			ActualLRPKey: oldmodels.NewActualLRPKey(
				"process-guid-1",
				2,
				"domain-1",
			),
			ActualLRPInstanceKey: oldmodels.NewActualLRPInstanceKey(
				"instance-guid-1",
				"cell-id-1",
			),
예제 #4
0
		evacuatingLRPKey    models.ActualLRPKey
		oldEvacuatingLRPKey oldmodels.ActualLRPKey
	)

	BeforeEach(func() {
		receptorProcess = ginkgomon.Invoke(receptorRunner)

		for i := 0; i < lrpCount; i++ {
			index := strconv.Itoa(i)
			lrpKey := oldmodels.NewActualLRPKey(
				"process-guid-"+index,
				i,
				fmt.Sprintf("domain-%d", i/2),
			)
			instanceKey := oldmodels.NewActualLRPInstanceKey(
				"instance-guid-"+index,
				"cell-id",
			)
			netInfo := oldmodels.NewActualLRPNetInfo("the-host", []oldmodels.PortMapping{{ContainerPort: 80, HostPort: uint16(1000 + i)}})
			err := legacyBBS.StartActualLRP(logger, lrpKey, instanceKey, netInfo)
			Expect(err).NotTo(HaveOccurred())
		}

		desiredLRP := oldmodels.DesiredLRP{
			ProcessGuid: "process-guid-0",
			Domain:      "domain-0",
			Instances:   1,
			RootFS:      "some:rootfs",
			Ports:       []uint16{80},
			Action:      &oldmodels.RunAction{User: "******", Path: "/bin/true"},
		}
예제 #5
0
					event := hub.EmitArgsForCall(0)

					desiredLRPRemovedEvent, ok := event.(receptor.DesiredLRPRemovedEvent)
					Expect(ok).To(BeTrue())
					Expect(desiredLRPRemovedEvent.DesiredLRPResponse).To(Equal(serialization.DesiredLRPToResponse(desiredLRP)))
				})
			})
		})

		Describe("Actual LRP changes", func() {
			var actualLRP models.ActualLRP

			BeforeEach(func() {
				actualLRP = models.ActualLRP{
					ActualLRPKey:         models.NewActualLRPKey(expectedProcessGuid, 1, "domain"),
					ActualLRPInstanceKey: models.NewActualLRPInstanceKey(expectedInstanceGuid, "cell-id"),
				}
			})

			Context("when a non-evacuating create arrives", func() {
				BeforeEach(func() {
					actualCreateCB(actualLRP, false)
				})

				It("emits an ActualLRPCreatedEvent to the hub", func() {
					Expect(hub.EmitCallCount()).To(Equal(1))
					event := hub.EmitArgsForCall(0)
					Expect(event).To(BeAssignableToTypeOf(receptor.ActualLRPCreatedEvent{}))

					actualLRPCreatedEvent := event.(receptor.ActualLRPCreatedEvent)
					Expect(actualLRPCreatedEvent.ActualLRPResponse).To(Equal(serialization.ActualLRPToResponse(actualLRP, false)))
				})

				It("returns a validation error", func() {
					Expect(actualLRPKey.Validate()).To(ConsistOf(models.ErrInvalidField{"index"}))
				})
			})
		})
	})

	Describe("ActualLRPInstanceKey", func() {
		Describe("Validate", func() {
			var actualLRPInstanceKey models.ActualLRPInstanceKey

			Context("when both instance guid and cell id are specified", func() {
				It("returns nil", func() {
					actualLRPInstanceKey = models.NewActualLRPInstanceKey("instance-guid", "cell-id")
					Expect(actualLRPInstanceKey.Validate()).To(BeNil())
				})
			})

			Context("when both instance guid and cell id are empty", func() {
				It("returns a validation error", func() {
					actualLRPInstanceKey = models.NewActualLRPInstanceKey("", "")
					Expect(actualLRPInstanceKey.Validate()).To(ConsistOf(
						models.ErrInvalidField{"cell_id"},
						models.ErrInvalidField{"instance_guid"},
					))

				})
			})
예제 #7
0
			netInfo        models.ActualLRPNetInfo
		)

		BeforeEach(func() {
			desiredLRP = models.DesiredLRP{
				ProcessGuid: processGuid,
				Domain:      domain,
				RootFS:      "some:rootfs",
				Instances:   1,
				Action: &models.RunAction{
					Path: "true",
				},
			}

			key = models.NewActualLRPKey(processGuid, 0, domain)
			instanceKey = models.NewActualLRPInstanceKey("instance-guid", "cell-id")
			newInstanceKey = models.NewActualLRPInstanceKey("other-instance-guid", "other-cell-id")
			netInfo = models.NewActualLRPNetInfo("1.1.1.1", []models.PortMapping{})
		})

		It("receives events", func() {
			By("creating a ActualLRP")
			err := bbs.DesireLRP(logger, desiredLRP)
			Expect(err).NotTo(HaveOccurred())

			actualLRPGroup, err := bbs.ActualLRPGroupByProcessGuidAndIndex(logger, desiredLRP.ProcessGuid, 0)
			Expect(err).NotTo(HaveOccurred())
			actualLRP := *actualLRPGroup.Instance

			var event receptor.Event
			Eventually(func() receptor.Event {