Exemplo n.º 1
0
func registerAddr(reg *registry.RouteRegistry, path string, routeServiceUrl string, addr net.Addr, instanceId string) {
	host, portStr, err := net.SplitHostPort(addr.String())
	Expect(err).NotTo(HaveOccurred())

	port, err := strconv.Atoi(portStr)
	Expect(err).NotTo(HaveOccurred())

	reg.Register(route.Uri(path), route.NewEndpoint("", host, uint16(port), instanceId, nil, -1, routeServiceUrl))
}
Exemplo n.º 2
0
func registerAddr(r *registry.RouteRegistry, u string, a net.Addr, instanceId string) {
	h, p, err := net.SplitHostPort(a.String())
	Ω(err).NotTo(HaveOccurred())

	x, err := strconv.Atoi(p)
	Ω(err).NotTo(HaveOccurred())

	r.Register(route.Uri(u), route.NewEndpoint("", h, uint16(x), instanceId, nil))
}
Exemplo n.º 3
0
			proxyObj = proxy.NewProxy(proxy.ProxyArgs{
				EndpointTimeout:     conf.EndpointTimeout,
				Ip:                  conf.Ip,
				TraceKey:            conf.TraceKey,
				Registry:            r,
				Reporter:            nullVarz{},
				AccessLogger:        fakeAccessLogger,
				SecureCookies:       conf.SecureCookies,
				TLSConfig:           tlsConfig,
				RouteServiceEnabled: conf.RouteServiceEnabled,
				RouteServiceTimeout: conf.RouteServiceTimeout,
				Crypto:              crypto,
				CryptoPrev:          cryptoPrev,
			})

			r.Register(route.Uri("some-app"), &route.Endpoint{})
		})

		Context("Log response time", func() {
			It("logs response time for HTTP connections", func() {
				body := []byte("some body")
				req := test_util.NewRequest("GET", "some-app", "/", bytes.NewReader(body))
				resp := httptest.NewRecorder()

				proxyObj.ServeHTTP(resp, req)
				Expect(fakeAccessLogger.LogCallCount()).To(Equal(1))
				Expect(fakeAccessLogger.LogArgsForCall(0).FinishedAt).NotTo(Equal(time.Time{}))
			})

			It("logs response time for TCP connections", func() {
				req := test_util.NewRequest("UPGRADE", "some-app", "/", nil)
Exemplo n.º 4
0
		b, e := json.Marshal(v)
		Expect(e).ToNot(HaveOccurred())

		d := make(map[string]interface{})
		e = json.Unmarshal(b, &d)
		Expect(e).ToNot(HaveOccurred())

		for _, k := range members {
			_, ok := d[k]
			Expect(ok).To(BeTrue(), k)
		}
	})

	It("reports seconds since last registry update", func() {
		Registry.Register("foo", &route.Endpoint{})

		time.Sleep(10 * time.Millisecond)

		timeSince := findValue(Varz, "ms_since_last_registry_update").(float64)
		Expect(timeSince).To(BeNumerically("<", 1000))
		Expect(timeSince).To(BeNumerically(">=", 10))
	})

	It("has urls", func() {
		Expect(findValue(Varz, "urls")).To(Equal(float64(0)))

		var fooReg = route.NewEndpoint("12345", "192.168.1.1", 1234, "", map[string]string{}, -1, "")

		// Add a route
		Registry.Register("foo.vcap.me", fooReg)