1
0
Fork 0
mirror of synced 2024-06-13 16:24:47 +12:00

feat: function execution time for failed executions

This commit is contained in:
Christy Jacob 2022-03-15 17:06:05 +04:00
parent 1728833307
commit ee056e582f
4 changed files with 8 additions and 2 deletions

View file

@ -960,6 +960,9 @@ App::post('/v1/functions/:functionId/executions')
$execution->setAttribute('stderr', $executionResponse['stderr']);
$execution->setAttribute('time', $executionResponse['time']);
} catch (\Throwable $th) {
$endtime = \time();
$time = $endtime - $execution->getAttribute('dateCreated');
$execution->setAttribute('time', $time);
$execution->setAttribute('status', 'failed');
$execution->setAttribute('statusCode', $th->getCode());
$execution->setAttribute('stderr', $th->getMessage());

View file

@ -470,7 +470,7 @@ App::post('/v1/execution')
case $statusCode >= 500:
$stderr = $executorResponse ?? 'Internal Runtime error.';
break;
case $statusCode >= 200:
case $statusCode >= 100:
$stdout = $executorResponse;
break;
default:

View file

@ -307,6 +307,9 @@ class FunctionsV1 extends Worker
$execution->setAttribute('stderr', $executionResponse['stderr']);
$execution->setAttribute('time', $executionResponse['time']);
} catch (\Throwable $th) {
$endtime = \time();
$time = $endtime - $execution->getAttribute('dateCreated');
$execution->setAttribute('time', $time);
$execution->setAttribute('status', 'failed');
$execution->setAttribute('statusCode', $th->getCode());
$execution->setAttribute('stderr', $th->getMessage());

View file

@ -761,7 +761,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals($executions['body']['executions'][0]['$id'], $executionId);
$this->assertEquals($executions['body']['executions'][0]['trigger'], 'http');
$this->assertEquals($executions['body']['executions'][0]['status'], 'failed');
$this->assertEquals($executions['body']['executions'][0]['statusCode'], 124);
$this->assertEquals($executions['body']['executions'][0]['statusCode'], 500);
$this->assertGreaterThan(2, $executions['body']['executions'][0]['time']);
$this->assertLessThan(3, $executions['body']['executions'][0]['time']);
$this->assertEquals($executions['body']['executions'][0]['stdout'], '');