expectedJSON, _ := json.Marshal(serialization.DesiredLRPProtoToResponse(desiredLRP)) Expect(actualJSON).To(MatchJSON(expectedJSON)) By("updating an existing DesiredLRP") routeMessage := json.RawMessage([]byte(`[{"port":8080,"hostnames":["new-route"]}]`)) newRoutes := map[string]*json.RawMessage{ "cf-router": &routeMessage, } err = legacyBBS.UpdateDesiredLRP(logger, oldDesiredLRP.ProcessGuid, oldmodels.DesiredLRPUpdate{Routes: newRoutes}) Expect(err).NotTo(HaveOccurred()) Eventually(events).Should(Receive(&event)) desiredLRPChangedEvent, ok := event.(receptor.DesiredLRPChangedEvent) Expect(ok).To(BeTrue()) Expect(desiredLRPChangedEvent.After.Routes).To(Equal(receptor.RoutingInfo(newRoutes))) By("removing the DesiredLRP") err = legacyBBS.RemoveDesiredLRPByProcessGuid(logger, oldDesiredLRP.ProcessGuid) Expect(err).NotTo(HaveOccurred()) Eventually(events).Should(Receive(&event)) desiredLRPRemovedEvent, ok := event.(receptor.DesiredLRPRemovedEvent) Expect(ok).To(BeTrue()) Expect(desiredLRPRemovedEvent.DesiredLRPResponse.ProcessGuid).To(Equal(desiredLRP.ProcessGuid)) }) }) Describe("Actual LRPs", func() { const (
"github.com/cloudfoundry-incubator/runtime-schema/models" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("DesiredLRP Serialization", func() { var routes map[string]*json.RawMessage var routingInfo receptor.RoutingInfo BeforeEach(func() { raw := json.RawMessage([]byte(`[{"port":1,"hostnames":["route-1","route-2"]}]`)) routes = map[string]*json.RawMessage{ "cf-router": &raw, } routingInfo = receptor.RoutingInfo(routes) }) Describe("DesiredLRPFromRequest", func() { var request receptor.DesiredLRPCreateRequest var desiredLRP models.DesiredLRP var securityRule models.SecurityGroupRule BeforeEach(func() { securityRule = models.SecurityGroupRule{ Protocol: "tcp", Destinations: []string{"0.0.0.0/0"}, PortRange: &models.PortRange{ Start: 1, End: 1024, },