diff --git a/tests/e2e/Services/Functions/FunctionsLoadTest.php b/tests/e2e/Services/Functions/FunctionsLoadTest.php deleted file mode 100644 index 81d861fc6b..0000000000 --- a/tests/e2e/Services/Functions/FunctionsLoadTest.php +++ /dev/null @@ -1,126 +0,0 @@ -setupFunction([ - 'functionId' => ID::unique(), - 'name' => 'Load Test Sleep', - 'runtime' => 'node-22', - 'entrypoint' => 'index.js', - // Must exceed worst-case queue drain time: executions waiting in the - // queue longer than the function timeout are reported as failed. - 'timeout' => 300, - ]); - - $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('sleep'), - 'activate' => true, - ]); - - // Warm up the runtime so cold start does not skew the measurement. - $execution = $this->createExecution($functionId, ['async' => false]); - $this->assertEquals(201, $execution['headers']['status-code']); - $this->assertEquals('completed', $execution['body']['status']); - - // Fire N async executions. - $start = \microtime(true); - - for ($i = 0; $i < self::EXECUTIONS; $i++) { - $execution = $this->createExecution($functionId, ['async' => true]); - $this->assertEquals(202, $execution['headers']['status-code']); - } - - $enqueued = \microtime(true) - $start; - - // Poll until all executions reach a terminal state. - // The warmup execution is already completed, so expect N + 1. - $expected = self::EXECUTIONS + 1; - $completed = 0; - $failed = 0; - $drained = null; - - while (\microtime(true) - $start < self::DRAIN_TIMEOUT_SECONDS) { - $completed = $this->countExecutions($functionId, 'completed'); - $failed = $this->countExecutions($functionId, 'failed'); - - if ($completed + $failed >= $expected) { - $drained = \microtime(true) - $start; - break; - } - - \usleep(250_000); - } - - $this->assertNotNull($drained, "Queue did not drain in " . self::DRAIN_TIMEOUT_SECONDS . "s ({$completed} completed, {$failed} failed)"); - - if ($failed > 0) { - $samples = $this->listExecutions($functionId, [ - 'queries' => [ - Query::equal('status', ['failed'])->toString(), - Query::limit(3)->toString(), - ], - ]); - - $details = \array_map(fn ($e) => [ - 'responseStatusCode' => $e['responseStatusCode'] ?? null, - 'errors' => $e['errors'] ?? null, - 'logs' => $e['logs'] ?? null, - 'duration' => $e['duration'] ?? null, - ], $samples['body']['executions'] ?? []); - - $this->fail("{$failed} executions failed. Samples: " . \json_encode($details, JSON_PRETTY_PRINT)); - } - $this->assertEquals($expected, $completed); - - $throughput = self::EXECUTIONS / $drained; - - \fwrite(STDERR, \sprintf( - "\n[load] executions=%d enqueue=%.2fs drain=%.2fs throughput=%.2f exec/s\n", - self::EXECUTIONS, - $enqueued, - $drained, - $throughput, - )); - - $this->cleanupFunction($functionId); - } - - private function countExecutions(string $functionId, string $status): int - { - $executions = $this->listExecutions($functionId, [ - 'queries' => [ - Query::equal('status', [$status])->toString(), - Query::limit(1)->toString(), - ], - ]); - - $this->assertEquals(200, $executions['headers']['status-code']); - - return $executions['body']['total']; - } -} diff --git a/tests/resources/functions/sleep/index.js b/tests/resources/functions/sleep/index.js deleted file mode 100644 index 416bb512ec..0000000000 --- a/tests/resources/functions/sleep/index.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = async (context) => { - await new Promise((resolve) => setTimeout(resolve, 1000)); - return context.res.send('OK'); -};