func itValidatesAbsenceOfNetInfo(lrp *models.ActualLRP) {
	Context("when net info is set", func() {
		BeforeEach(func() {
			lrp.ActualLRPNetInfo = models.NewActualLRPNetInfo("1.2.3.4", []models.PortMapping{})
		})

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

	Context("when net info is not set", func() {
		BeforeEach(func() {
			lrp.ActualLRPNetInfo = models.ActualLRPNetInfo{}
		})

		It("validate does not return an error", func() {
			Expect(lrp.Validate()).NotTo(HaveOccurred())
		})
	})
}
Beispiel #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)
			Expect(err).NotTo(HaveOccurred())
			actualLRP := actualLRPGroup.Instance
Beispiel #3
0
	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"},
		}

		err := legacyBBS.DesireLRP(logger, desiredLRP)
		Expect(err).NotTo(HaveOccurred())
    "state": "RUNNING",
    "since": 1138,
    "cell_id":"some-cell-id",
    "domain":"some-domain",
		"crash_count": 1,
		"modification_tag": {
			"epoch": "some-guid",
			"index": 50
		}
  }`

		BeforeEach(func() {
			lrpKey = models.NewActualLRPKey("some-guid", 2, "some-domain")
			instanceKey = models.NewActualLRPInstanceKey("some-instance-guid", "some-cell-id")
			netInfo = models.NewActualLRPNetInfo("1.2.3.4", []models.PortMapping{
				{ContainerPort: 8080},
				{ContainerPort: 8081, HostPort: 1234},
			})

			lrp = models.ActualLRP{
				ActualLRPKey:         lrpKey,
				ActualLRPInstanceKey: instanceKey,
				ActualLRPNetInfo:     netInfo,
				CrashCount:           1,
				State:                models.ActualLRPStateRunning,
				Since:                1138,
				ModificationTag: models.ModificationTag{
					Epoch: "some-guid",
					Index: 50,
				},
			}
		})
Beispiel #5
0
		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 {
				Eventually(events).Should(Receive(&event))
				return event
		BeforeEach(func() {
			actualLRP = models.ActualLRP{
				ActualLRPKey: models.NewActualLRPKey(
					"process-guid-0",
					3,
					"some-domain",
				),
				ActualLRPInstanceKey: models.NewActualLRPInstanceKey(
					"instance-guid-0",
					"cell-id-0",
				),
				ActualLRPNetInfo: models.NewActualLRPNetInfo(
					"address-0",
					[]models.PortMapping{
						{
							ContainerPort: 2345,
							HostPort:      9876,
						},
					},
				),
				State:      models.ActualLRPStateRunning,
				CrashCount: 42,
				Since:      99999999999,
				ModificationTag: models.ModificationTag{
					Epoch: "some-guid",
					Index: 50,
				},
			}
		})

		It("serializes all the fields", func() {