MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cloud-sql-proxy / TestPrometheusMetricsEndpoint

Function TestPrometheusMetricsEndpoint

cmd/root_test.go:1423–1444  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1421}
1422
1423func 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
1446func TestPProfServer(t *testing.T) {
1447 c := NewCommand(WithDialer(&spyDialer{}))

Callers

nothing calls this directly

Calls 3

NewCommandFunction · 0.85
WithDialerFunction · 0.85
tryDialFunction · 0.85

Tested by

no test coverage detected