waitForPrometheus waits for Prometheus to be ready.
(t *testing.T)
| 69 | |
| 70 | // waitForPrometheus waits for Prometheus to be ready. |
| 71 | func (p *queryLogTest) waitForPrometheus(t *testing.T) { |
| 72 | t.Helper() |
| 73 | require.Eventually(t, func() bool { |
| 74 | r, err := http.Get(fmt.Sprintf("http://%s:%d%s/-/ready", p.host, p.port, p.prefix)) |
| 75 | if err != nil { |
| 76 | return false |
| 77 | } |
| 78 | r.Body.Close() |
| 79 | return r.StatusCode == http.StatusOK |
| 80 | }, 20*time.Second, 500*time.Millisecond, "prometheus at %s:%d did not become ready in time", p.host, p.port) |
| 81 | } |
| 82 | |
| 83 | // setQueryLog alters the configuration file to enable or disable the query log, |
| 84 | // then reloads the configuration if needed. |