예제 #1
0
func newHealthCheck(
	network, uri, port string,
	timeout time.Duration,
) healthcheck.HealthCheck {
	jsonPortMappings := os.Getenv("CF_INSTANCE_PORTS")
	var portMappings []PortMapping
	json.Unmarshal([]byte(jsonPortMappings), &portMappings)
	for _, mapping := range portMappings {
		if strconv.Itoa(mapping.Internal) == port {
			port = strconv.Itoa(mapping.External)
		}
	}
	return healthcheck.NewHealthCheck(network, uri, port, timeout)
}
예제 #2
0
func newHealthCheck(
	network, uri, port string,
	timeout time.Duration,
) healthcheck.HealthCheck {
	return healthcheck.NewHealthCheck(network, uri, port, timeout)
}
예제 #3
0
		serverDelay = 0

		server.HTTPTestServer.Listener = listener
		serverAddr = listener.Addr().String()
		_, port, err = net.SplitHostPort(serverAddr)
		Expect(err).NotTo(HaveOccurred())
	})

	JustBeforeEach(func() {
		server.RouteToHandler("GET", "/api/_ping",
			func(http.ResponseWriter, *http.Request) {
				time.Sleep(serverDelay)
			})
		server.Start()

		hc = healthcheck.NewHealthCheck("tcp", uri, port, timeout)
	})

	AfterEach(func() {
		if server != nil {
			server.CloseClientConnections()
			server.Close()
		}
	})

	Describe("check interfaces", func() {
		It("succeeds when there are healthy interfaces", func() {
			interfaces, err := net.Interfaces()
			Expect(err).NotTo(HaveOccurred())

			err = hc.CheckInterfaces(interfaces)