예제 #1
0
	Describe("ValidateCreateTcpRouteMapping", func() {
		var (
			tcpMapping   models.TcpRouteMapping
			routerGroups models.RouterGroups
		)

		BeforeEach(func() {
			routerGroups = models.RouterGroups{
				{
					Guid:            DefaultRouterGroupGuid,
					Name:            "default-tcp",
					Type:            "tcp",
					ReservablePorts: "1024-65535",
				},
			}
			tcpMapping = models.NewTcpRouteMapping(DefaultRouterGroupGuid, 52000, "1.2.3.4", 60000, 60)
		})

		Context("when valid tcp mapping is passed", func() {
			It("does not return error", func() {
				err := validator.ValidateCreateTcpRouteMapping([]models.TcpRouteMapping{tcpMapping}, routerGroups, 120)
				Expect(err).To(BeNil())
			})
		})

		Context("when invalid tcp route mappings are passed", func() {

			It("blows up when a backend port is zero", func() {
				tcpMapping.HostPort = 0
				err := validator.ValidateCreateTcpRouteMapping([]models.TcpRouteMapping{tcpMapping}, routerGroups, 120)
				Expect(err).ToNot(BeNil())
예제 #2
0
		BeforeEach(func() {
			etcd, err = db.NewETCD(etcdRunner.NodeURLS())
			Expect(err).NotTo(HaveOccurred())
			route = models.Route{
				Route:           "post_here",
				Port:            7000,
				IP:              "1.2.3.4",
				TTL:             50,
				LogGuid:         "my-guid",
				RouteServiceUrl: "https://rs.com",
			}
			fakeKeysAPI = &fakes.FakeKeysAPI{}
			fakeEtcd = setupFakeEtcd(fakeKeysAPI)

			tcpRouteMapping1 = models.NewTcpRouteMapping("router-group-guid-002", 52002, "2.3.4.5", 60002, 50)
		})

		Describe("Http Routes", func() {
			Describe("ReadRoutes", func() {
				var routes []models.Route
				var err error

				JustBeforeEach(func() {
					routes, err = fakeEtcd.ReadRoutes()
					Expect(err).ToNot(HaveOccurred())
				})

				Context("when the route key is missing", func() {
					BeforeEach(func() {
						fakeKeysAPI.GetReturns(nil, errors.New("key missing error"))
예제 #3
0
			)

			BeforeEach(func() {
				routingAPIRunner := testrunner.New(routingAPIBinPath, routingAPIArgs)
				proc = ifrit.Invoke(routingAPIRunner)
				routerGroupGuid = getRouterGroupGuid()
			})

			AfterEach(func() {
				ginkgomon.Interrupt(proc)
			})

			It("allows to create given tcp route mappings", func() {
				client := routing_api.NewClient(fmt.Sprintf("http://127.0.0.1:%d", routingAPIPort))
				var err error
				tcpRouteMapping1 = models.NewTcpRouteMapping(routerGroupGuid, 52000, "1.2.3.4", 60000, 60)
				tcpRouteMapping2 = models.NewTcpRouteMapping(routerGroupGuid, 52001, "1.2.3.5", 60001, 1)

				tcpRouteMappings := []models.TcpRouteMapping{tcpRouteMapping1, tcpRouteMapping2}
				err = client.UpsertTcpRouteMappings(tcpRouteMappings)
				Expect(err).NotTo(HaveOccurred())
				tcpRouteMappingsResponse, err := client.TcpRouteMappings()
				Expect(err).NotTo(HaveOccurred())
				Expect(tcpRouteMappingsResponse).NotTo(BeNil())
				mappings := test_helpers.TcpRouteMappings(tcpRouteMappingsResponse)
				Expect(mappings.ContainsAll(tcpRouteMappings...)).To(BeTrue())

				By("letting route expire")
				Eventually(func() bool {
					tcpRouteMappingsResponse, err := client.TcpRouteMappings()
					Expect(err).NotTo(HaveOccurred())
예제 #4
0
				Expect(log).To(ContainSubstring("RESPONSE: "))
				Expect(log).To(ContainSubstring("HTTP/1.1 400 Bad Request"))
			})
		})
	})

	Context("UpsertTcpRouteMappings", func() {

		var (
			err              error
			tcpRouteMapping1 models.TcpRouteMapping
			tcpRouteMapping2 models.TcpRouteMapping
		)
		BeforeEach(func() {
			tcpRouteMapping1 = models.NewTcpRouteMapping("router-group-guid-001", 52000, "1.2.3.4", 60000, 60)
			tcpRouteMapping2 = models.NewTcpRouteMapping("router-group-guid-001", 52001, "1.2.3.5", 60001, 60)
		})

		JustBeforeEach(func() {
			err = client.UpsertTcpRouteMappings([]models.TcpRouteMapping{tcpRouteMapping1, tcpRouteMapping2})
		})

		Context("when the server returns a valid response", func() {
			BeforeEach(func() {
				server.AppendHandlers(
					ghttp.VerifyRequest("POST", TCP_CREATE_ROUTE_MAPPINGS_API_URL),
				)
			})

			It("sends an Upsert request to the server", func() {