Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions pkg/kncloudevents/message_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,14 @@ func newRetryAfterValidationServer(t *testing.T, statusCode int, retryAfterForma

// Determine Time Of Current Request
currentReqTime := time.Now()

// Adjust Expected Min Request Duration To Account For RFC850 Date Format Milliseconds Truncation
// TODO - Remove this check when experimental-feature moves to Stable/GA to convert behavior from opt-in to opt-out
if server.minRequestDuration > retryBackoffDuration {
// TODO - Keep this logic as is (no change required) when experimental-feature moves to Stable/GA
if retryAfterFormat == Date && retryAfterDuration > 0 {
currentReqTime = currentReqTime.Round(time.Second) // Round When Using Date Format To Account For RFC850 Precision
if retryAfterFormat == Date {
truncatedDuration := currentReqTime.Sub(currentReqTime.Truncate(time.Second))
server.minRequestDuration = server.minRequestDuration - truncatedDuration
}
}

Expand Down Expand Up @@ -264,7 +267,7 @@ func newRetryAfterValidationServer(t *testing.T, statusCode int, retryAfterForma
actualRequestDuration := currentReqTime.Sub(server.previousReqTime)
assert.GreaterOrEqual(t, actualRequestDuration, server.minRequestDuration, "previousReqTime =", server.previousReqTime.String(), "currentReqTime =", currentReqTime.String())
assert.LessOrEqual(t, actualRequestDuration, server.maxRequestDuration, "previousReqTime =", server.previousReqTime.String(), "currentReqTime =", currentReqTime.String())
t.Logf("Validated Request Duration %s between expected range %s - %s",
t.Logf("Request Duration %s should be within expected range %s - %s",
actualRequestDuration.String(),
server.minRequestDuration.String(),
server.maxRequestDuration.String())
Expand Down Expand Up @@ -379,9 +382,9 @@ func TestHTTPMessageSenderSendWithRetriesWithRetryAfter(t *testing.T) {
name: "large max 429 with Retry-After date",
statusCode: http.StatusTooManyRequests,
retryAfterFormat: Date,
retryAfterDuration: 1 * time.Second,
retryAfterDuration: 2 * time.Second,
retryAfterMaxDuration: &largeRetryAfterMaxDuration,
wantRequestDuration: 1 * time.Second,
wantRequestDuration: 2 * time.Second,
},
{
name: "large max 429 with invalid Retry-After",
Expand Down