mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user