Esempio n. 1
0
								defer req.Body.Close()

								protoMessage := &models.UpdateDesiredLRPRequest{}

								err = proto.Unmarshal(body, protoMessage)
								Expect(err).ToNot(HaveOccurred(), "Failed to unmarshal protobuf")

								Expect(*protoMessage.Update.Annotation).To(Equal("2.1"))
								Expect(protoMessage.ProcessGuid).To(Equal("process-guid-2"))
							},
						),
					)

					expectedLRPDeleteRequest := &models.RemoveDesiredLRPRequest{ProcessGuid: "process-guid-4"}
					fakeBBS.RouteToHandler("POST", "/v1/desired_lrp/remove",
						ghttp.VerifyProtoRepresenting(expectedLRPDeleteRequest),
					)

					fakeCC.RouteToHandler("GET", "/internal/v3/bulk/task_states",
						ghttp.RespondWith(200, `{"token": {},"task_states": []}`),
					)

					fakeBBS.RouteToHandler("POST", "/v1/tasks/list.r1",
						ghttp.RespondWith(200, `{"error": {},"tasks": []}`),
					)
				})

				It("it (adds), (updates), and (removes extra) LRPs", func() {
					Eventually(func() bool {
						for _, r := range fakeBBS.ReceivedRequests() {
							if r.URL.Path == "/v1/desired_lrp/desire" {
Esempio n. 2
0
		It("forwards an index kill to the BBS", func() {
			actualLRPKey := models.ActualLRPKey{ProcessGuid: "the-guid", Index: 7}

			fakeBBS.RouteToHandler("POST", "/v1/actual_lrp_groups/get_by_process_guid_and_index",
				ghttp.RespondWithProto(200, &models.ActualLRPGroupResponse{
					ActualLrpGroup: &models.ActualLRPGroup{
						Instance: &models.ActualLRP{ActualLRPKey: actualLRPKey},
					},
				}),
			)

			fakeBBS.RouteToHandler("POST", "/v1/actual_lrps/retire",
				ghttp.CombineHandlers(
					ghttp.VerifyContentType("application/x-protobuf"),
					ghttp.VerifyProtoRepresenting(&models.RetireActualLRPRequest{
						ActualLrpKey: &actualLRPKey,
					}),
				),
			)

			resp, err := killIndex("the-guid", 7)
			Expect(err).NotTo(HaveOccurred())
			Expect(resp.StatusCode).To(Equal(http.StatusAccepted))

			Expect(fakeBBS).To(HaveReceivedRequest("/v1/actual_lrps/retire"))
		})
	})

	Describe("Desire a task", func() {
		It("forwards the desire request to the BBS", func() {
			desiredTheTask := false