...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package tests
17
18 import (
19 "context"
20 "fmt"
21 "net/http"
22 "testing"
23 )
24
25 const (
26 readinessPath = "/readiness"
27 testPort = "8090"
28 )
29
30
31
32 func singleInstanceDial(t *testing.T, connName string, port int) {
33 ctx := context.Background()
34
35 var args []string
36 args = append(args, fmt.Sprintf("-instances=%s=tcp:%d", connName, port), "-use_http_health_check")
37
38
39 p, err := StartProxy(ctx, args...)
40 if err != nil {
41 t.Fatalf("unable to start proxy: %v", err)
42 }
43 defer p.Close()
44 output, err := p.WaitForServe(ctx)
45 if err != nil {
46 t.Fatalf("unable to verify proxy was serving: %s \n %s", err, output)
47 }
48
49 resp, err := http.Get("http://localhost:" + testPort + readinessPath)
50 if err != nil {
51 t.Fatalf("HTTP GET failed: %v", err)
52 }
53 if resp.StatusCode != http.StatusOK {
54 t.Errorf("want %v, got %v", http.StatusOK, resp.StatusCode)
55 }
56 }
57
View as plain text