(t *testing.T)
| 1421 | } |
| 1422 | |
| 1423 | func TestPrometheusMetricsEndpoint(t *testing.T) { |
| 1424 | c := NewCommand(WithDialer(&spyDialer{})) |
| 1425 | // Keep the test output quiet |
| 1426 | c.SilenceUsage = true |
| 1427 | c.SilenceErrors = true |
| 1428 | c.SetArgs([]string{"--prometheus", "my-project:my-region:my-instance"}) |
| 1429 | |
| 1430 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) |
| 1431 | defer cancel() |
| 1432 | |
| 1433 | go c.ExecuteContext(ctx) |
| 1434 | |
| 1435 | // try to dial metrics server for a max of ~10s to give the proxy time to |
| 1436 | // start up. |
| 1437 | resp, err := tryDial("GET", "http://localhost:9090/metrics") // default port set by http-port flag |
| 1438 | if err != nil { |
| 1439 | t.Fatalf("failed to dial metrics endpoint: %v", err) |
| 1440 | } |
| 1441 | if resp.StatusCode != http.StatusOK { |
| 1442 | t.Fatalf("expected a 200 status, got = %v", resp.StatusCode) |
| 1443 | } |
| 1444 | } |
| 1445 | |
| 1446 | func TestPProfServer(t *testing.T) { |
| 1447 | c := NewCommand(WithDialer(&spyDialer{})) |
nothing calls this directly
no test coverage detected