Truncate logs to a limit

This commit is contained in:
Khushboo Verma
2025-08-20 17:28:35 +05:30
parent 7eaecd896e
commit 343ded16a8
6 changed files with 79 additions and 3 deletions
@@ -2282,4 +2282,34 @@ class FunctionsCustomServerTest extends Scope
$this->cleanupFunction($functionId);
}
public function testLogTruncation(): void
{
$functionId = $this->setupFunction([
'functionId' => ID::unique(),
'name' => 'Test Log Truncation',
'runtime' => 'node-22',
'entrypoint' => 'index.js',
'timeout' => 15,
]);
$this->setupDeployment($functionId, [
'code' => $this->packageFunction('log-truncation'),
'activate' => true
]);
$execution = $this->createExecution($functionId, [
'async' => 'false'
]);
$this->assertEquals(201, $execution['headers']['status-code']);
$this->assertEquals(200, $execution['body']['responseStatusCode']);
// Verify logs are truncated and warning message is present
$logs = $execution['body']['logs'];
$this->assertLessThanOrEqual(APP_FUNCTION_LOG_LENGTH_LIMIT, strlen($logs));
$this->assertStringContainsString('[WARNING] Logs truncated', $logs);
$this->cleanupFunction($functionId);
}
}