From f42232a6134fa9609f0e441b94de76c7fac1fa15 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 16 Apr 2026 04:51:33 +0000 Subject: [PATCH] fix: add polling loop for /logs-action execution log query in testSSRLogs The test was querying execution logs for /logs-action immediately without waiting for the async log write to complete, causing a race condition. The preceding /logs-inline test correctly used a 120-second polling loop. Apply the same pattern to /logs-action to prevent intermittent CI failures. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Services/Sites/SitesCustomServerTest.php | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 69dbd7fdf0..2f29f849f6 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2214,11 +2214,22 @@ class SitesCustomServerTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertStringContainsString("Action logs printed.", $response['body']); - $logs = $this->listLogs($siteId, [ - Query::orderDesc('$createdAt')->toString(), - Query::equal('requestPath', ['/logs-action'])->toString(), - Query::limit(1)->toString(), - ]); + // Poll for execution logs to be written (async) + $logs = null; + $timeout = 120; + $start = \time(); + while (\time() - $start < $timeout) { + $logs = $this->listLogs($siteId, [ + Query::orderDesc('$createdAt')->toString(), + Query::equal('requestPath', ['/logs-action'])->toString(), + Query::limit(1)->toString(), + ]); + if (!empty($logs['body']['executions'])) { + break; + } + \usleep(500000); + } + $this->assertNotEmpty($logs['body']['executions'], 'Execution logs for /logs-action were not available within timeout'); $this->assertEquals(200, $logs['headers']['status-code']); $this->assertStringContainsString($deploymentId, $logs['body']['executions'][0]['deploymentId']); $this->assertStringContainsString("GET", $logs['body']['executions'][0]['requestMethod']);