(method, addr string)
| 1394 | } |
| 1395 | |
| 1396 | func tryDial(method, addr string) (*http.Response, error) { |
| 1397 | var ( |
| 1398 | resp *http.Response |
| 1399 | attempts int |
| 1400 | err error |
| 1401 | ) |
| 1402 | u, err := url.Parse(addr) |
| 1403 | if err != nil { |
| 1404 | return nil, err |
| 1405 | } |
| 1406 | req := &http.Request{Method: method, URL: u} |
| 1407 | // Never wait longer than 30 seconds for an HTTP response. |
| 1408 | cl := &http.Client{Timeout: 30 * time.Second} |
| 1409 | for { |
| 1410 | if attempts > 10 { |
| 1411 | return resp, err |
| 1412 | } |
| 1413 | resp, err = cl.Do(req) |
| 1414 | if err != nil { |
| 1415 | attempts++ |
| 1416 | time.Sleep(time.Second) |
| 1417 | continue |
| 1418 | } |
| 1419 | return resp, err |
| 1420 | } |
| 1421 | } |
| 1422 | |
| 1423 | func TestPrometheusMetricsEndpoint(t *testing.T) { |
| 1424 | c := NewCommand(WithDialer(&spyDialer{})) |
no outgoing calls
no test coverage detected