Skip to content

Commit a9c7999

Browse files
chore(internal): update retry delay tests
1 parent 16ab425 commit a9c7999

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

langsmith-java-core/src/test/kotlin/com/langchain/smith/core/http/RetryingHttpClientTest.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,14 @@ internal class RetryingHttpClientTest {
395395
// All retries exhausted; the last 503 response is returned.
396396
assertThat(response.statusCode()).isEqualTo(503)
397397
verify(4, postRequestedFor(urlPathEqualTo("/something")))
398-
// Exponential backoff with jitter: backoff = min(0.5 * 2^(retries-1), 8) * jitter where
398+
// Exponential backoff with jitter: backoff = min(0.5 * 2^(retries-1), 16) * jitter where
399399
// jitter is in [0.75, 1.0].
400400
assertThat(sleeper.durations).hasSize(3)
401401
// retries=1: 0.5s * [0.75, 1.0]
402402
assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500))
403-
// retries=2: 1.0s * [0.75, 1.0]
403+
// retries=2: 1s * [0.75, 1.0]
404404
assertThat(sleeper.durations[1]).isBetween(Duration.ofMillis(750), Duration.ofMillis(1000))
405-
// retries=3: 2.0s * [0.75, 1.0]
405+
// retries=3: 2s * [0.75, 1.0]
406406
assertThat(sleeper.durations[2]).isBetween(Duration.ofMillis(1500), Duration.ofMillis(2000))
407407
assertNoResponseLeaks()
408408
}
@@ -412,7 +412,7 @@ internal class RetryingHttpClientTest {
412412
fun execute_withExponentialBackoffCap(async: Boolean) {
413413
stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable()))
414414
val sleeper = RecordingSleeper()
415-
val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(6).build()
415+
val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(7).build()
416416

417417
val response =
418418
retryingClient.execute(
@@ -425,12 +425,14 @@ internal class RetryingHttpClientTest {
425425
)
426426

427427
assertThat(response.statusCode()).isEqualTo(503)
428-
verify(7, postRequestedFor(urlPathEqualTo("/something")))
429-
assertThat(sleeper.durations).hasSize(6)
430-
// retries=5: min(0.5 * 2^4, 8) = 8.0s * [0.75, 1.0]
431-
assertThat(sleeper.durations[4]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000))
432-
// retries=6: min(0.5 * 2^5, 8) = min(16, 8) = 8.0s * [0.75, 1.0] (capped)
433-
assertThat(sleeper.durations[5]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000))
428+
verify(8, postRequestedFor(urlPathEqualTo("/something")))
429+
assertThat(sleeper.durations).hasSize(7)
430+
// retries=6: backoff hits the 16s cap * [0.75, 1.0]
431+
assertThat(sleeper.durations[5])
432+
.isBetween(Duration.ofMillis(12000), Duration.ofMillis(16000))
433+
// retries=7: still capped at 16s * [0.75, 1.0]
434+
assertThat(sleeper.durations[6])
435+
.isBetween(Duration.ofMillis(12000), Duration.ofMillis(16000))
434436
assertNoResponseLeaks()
435437
}
436438

0 commit comments

Comments
 (0)