From 7af560235fb32b89317c6378003cb88b39ff9483 Mon Sep 17 00:00:00 2001 From: Nick Ficano Date: Thu, 11 Jun 2026 22:56:35 -0400 Subject: [PATCH] test: make lease-expiry integration test deterministic The 50ms expiry window raced against submit-time validation on slow CI runners (lease already expired at submit -> INVALID_REQUEST instead of job.accepted). Widen the window to 1s and poll ValidateOpAsync until expiry instead of racing a fixed 150ms delay. Co-Authored-By: Claude Fable 5 --- tests/Arcp.IntegrationTests/LeaseExpiryTests.fs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/Arcp.IntegrationTests/LeaseExpiryTests.fs b/tests/Arcp.IntegrationTests/LeaseExpiryTests.fs index 6570840..213898c 100644 --- a/tests/Arcp.IntegrationTests/LeaseExpiryTests.fs +++ b/tests/Arcp.IntegrationTests/LeaseExpiryTests.fs @@ -54,8 +54,13 @@ let ``ValidateOpAsync after expires_at raises LEASE_EXPIRED`` () = "indexer", fun ctx -> task { - do! Task.Delay(150) - do! ctx.ValidateOpAsync(Capabilities.FsRead, "/data/file", ctx.CancellationToken) + // Poll until expires_at passes; the first post-expiry + // call raises LEASE_EXPIRED and fails the job. Avoids + // racing a fixed delay against the expiry window. + while true do + do! ctx.ValidateOpAsync(Capabilities.FsRead, "/data/file", ctx.CancellationToken) + do! Task.Delay(25) + return Json.serializeToElement 0 } )) @@ -67,7 +72,9 @@ let ``ValidateOpAsync after expires_at raises LEASE_EXPIRED`` () = LeaseConstraints = Some { - ExpiresAt = DateTimeOffset.UtcNow.AddMilliseconds(50.0) + // Far enough out that submit-time validation can't see an + // already-expired lease on a slow CI runner. + ExpiresAt = DateTimeOffset.UtcNow.AddSeconds(1.0) } }