Example #1
0
			From: fmt.Sprintf("http://%s/v1/static/%s", componentMaker.Addresses.FileServer, "lrp.zip"),
			To:   "/tmp",
			User: "******",
		}
		lrp.Action = &models.RunAction{
			User: "******",
			Path: "/tmp/go-server",
			Env:  []models.EnvironmentVariable{{"PORT", "8080"}},
		}

		err := receptorClient.CreateDesiredLRP(lrp)
		Expect(err).NotTo(HaveOccurred())

		By("running an actual LRP instance")
		Eventually(helpers.LRPStatePoller(receptorClient, processGuid, nil)).Should(Equal(receptor.ActualLRPStateRunning))
		Eventually(helpers.ResponseCodeFromHostPoller(componentMaker.Addresses.Router, helpers.DefaultHost)).Should(Equal(http.StatusOK))

		actualLRP, err := receptorClient.ActualLRPByProcessGuidAndIndex(processGuid, 0)
		Expect(err).NotTo(HaveOccurred())

		var evacuatingRepAddr string
		var evacutaingRepRunner *ginkgomon.Runner

		switch actualLRP.CellID {
		case cellAID:
			evacuatingRepAddr = cellARepAddr
			evacutaingRepRunner = cellARepRunner
		case cellBID:
			evacuatingRepAddr = cellBRepAddr
			evacutaingRepRunner = cellBRepRunner
		default:
Example #2
0
	Describe("Start an application", func() {
		guid := "process-guid"

		Context("when the running message contains a start_command", func() {
			It("runs the app on the executor, registers routes, and shows that they are running via the tps", func() {
				// desire the app
				resp, err := desireApp(guid, `["route-1", "route-2"]`, 2)
				Expect(err).NotTo(HaveOccurred())
				Expect(resp.StatusCode).To(Equal(http.StatusAccepted))

				// check lrp instance statuses
				Eventually(helpers.RunningLRPInstancesPoller(componentMaker.Addresses.TPSListener, guid)).Should(HaveLen(2))

				//both routes should be routable
				Eventually(helpers.ResponseCodeFromHostPoller(componentMaker.Addresses.Router, "route-1")).Should(Equal(http.StatusOK))
				Eventually(helpers.ResponseCodeFromHostPoller(componentMaker.Addresses.Router, "route-2")).Should(Equal(http.StatusOK))

				//a given route should route to all three running instances
				poller := helpers.HelloWorldInstancePoller(componentMaker.Addresses.Router, "route-1")
				Eventually(poller).Should(Equal([]string{"0", "1"}))
			})
		})

		Context("when the start message does not include a start_command", func() {
			It("runs the app, registers a route, and shows running via tps", func() {
				// desire the app
				resp, err := desireApp(guid, `["route-1"]`, 1)
				Expect(err).NotTo(HaveOccurred())
				Expect(resp.StatusCode).To(Equal(http.StatusAccepted))
Example #3
0
		BeforeEach(func() {
			lrpRequest = helpers.PrivilegedLRPCreateRequest(helpers.GenerateGuid())
		})

		JustBeforeEach(func() {
			err := receptorClient.CreateDesiredLRP(lrpRequest)
			Expect(err).NotTo(HaveOccurred())
		})

		Context("when the LRP is privileged", func() {
			BeforeEach(func() {
				lrpRequest.Privileged = true
			})

			It("succeeds", func() {
				Eventually(helpers.ResponseCodeFromHostPoller(componentMaker.Addresses.Router, helpers.DefaultHost)).Should(Equal(http.StatusOK))
			})
		})

		Context("when the LRP is not privileged", func() {
			BeforeEach(func() {
				lrpRequest.Privileged = false
			})

			It("fails", func() {
				Eventually(helpers.ResponseCodeFromHostPoller(componentMaker.Addresses.Router, helpers.DefaultHost)).Should(Equal(http.StatusInternalServerError))
			})
		})
	})
})
Example #4
0
		})

		Describe("updating routes", func() {
			BeforeEach(func() {
				lrp.Ports = []uint16{8080, 9080}
				lrp.Routes = cfroutes.CFRoutes{{Port: 8080, Hostnames: []string{"lrp-route-8080"}}}.RoutingInfo()

				lrp.Action = &models.RunAction{
					User: "******",
					Path: "/tmp/go-server",
					Env:  []models.EnvironmentVariable{{"PORT", "8080 9080"}},
				}
			})

			It("can not access container ports without routes", func() {
				Eventually(helpers.ResponseCodeFromHostPoller(componentMaker.Addresses.Router, "lrp-route-8080")).Should(Equal(http.StatusOK))
				Consistently(helpers.ResponseCodeFromHostPoller(componentMaker.Addresses.Router, "lrp-route-8080")).Should(Equal(http.StatusOK))
				Consistently(helpers.ResponseCodeFromHostPoller(componentMaker.Addresses.Router, "lrp-route-9080")).Should(Equal(http.StatusNotFound))
			})

			Context("when adding a route", func() {
				logger := lagertest.NewTestLogger("test")

				JustBeforeEach(func() {
					logger.Info("just-before-each", lager.Data{
						"processGuid": processGuid,
						"updateRequest": receptor.DesiredLRPUpdateRequest{
							Routes: cfroutes.CFRoutes{
								{Port: 8080, Hostnames: []string{"lrp-route-8080"}},
								{Port: 9080, Hostnames: []string{"lrp-route-9080"}},
							}.RoutingInfo(),