mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
remote-write: TestClientRetryAfter status code 500
and compare the retryAfter values. Signed-off-by: William Dumont <william.dumont@grafana.com>
This commit is contained in:
parent
febd62a23e
commit
ce6ad15422
|
@ -88,6 +88,7 @@ func TestClientRetryAfter(t *testing.T) {
|
||||||
setupServer := func(statusCode int) *httptest.Server {
|
setupServer := func(statusCode int) *httptest.Server {
|
||||||
return httptest.NewServer(
|
return httptest.NewServer(
|
||||||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Retry-After", "5")
|
||||||
http.Error(w, longErrMessage, statusCode)
|
http.Error(w, longErrMessage, statusCode)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
@ -114,9 +115,11 @@ func TestClientRetryAfter(t *testing.T) {
|
||||||
statusCode int
|
statusCode int
|
||||||
retryOnRateLimit bool
|
retryOnRateLimit bool
|
||||||
expectedRecoverable bool
|
expectedRecoverable bool
|
||||||
|
expectedRetryAfter model.Duration
|
||||||
}{
|
}{
|
||||||
{"TooManyRequests - No Retry", http.StatusTooManyRequests, false, false},
|
{"TooManyRequests - No Retry", http.StatusTooManyRequests, false, false, 0},
|
||||||
{"TooManyRequests - With Retry", http.StatusTooManyRequests, true, true},
|
{"TooManyRequests - With Retry", http.StatusTooManyRequests, true, true, 5 * model.Duration(time.Second)},
|
||||||
|
{"InternalServerError", http.StatusInternalServerError, false, true, 5 * model.Duration(time.Second)}, // HTTP 5xx errors do not depend on retryOnRateLimit.
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
@ -132,6 +135,9 @@ func TestClientRetryAfter(t *testing.T) {
|
||||||
var recErr RecoverableError
|
var recErr RecoverableError
|
||||||
err = c.Store(context.Background(), []byte{}, 0)
|
err = c.Store(context.Background(), []byte{}, 0)
|
||||||
require.Equal(t, tc.expectedRecoverable, errors.As(err, &recErr), "Mismatch in expected recoverable error status.")
|
require.Equal(t, tc.expectedRecoverable, errors.As(err, &recErr), "Mismatch in expected recoverable error status.")
|
||||||
|
if tc.expectedRecoverable {
|
||||||
|
require.Equal(t, tc.expectedRetryAfter, err.(RecoverableError).retryAfter)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue