1
0
Fork 0
mirror of synced 2024-06-14 00:34:51 +12:00

feat: update test message

This commit is contained in:
Christy Jacob 2022-03-15 18:51:32 +04:00
parent ee056e582f
commit 13b28e0051
5 changed files with 11 additions and 7 deletions

View file

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

View file

@ -457,7 +457,8 @@ App::post('/v1/execution')
switch (true) {
/** No Error. */
case $errNo === 0: break;
case $errNo === 0:
break;
/** Runtime not ready for requests yet. 111 is the swoole error code for Connection Refused - see https://openswoole.com/docs/swoole-error-code */
case $errNo === 111:
throw new Exception('An internal curl error has occurred within the executor! Error Msg: ' . $error, 406);

View file

@ -287,6 +287,7 @@ class FunctionsV1 extends Worker
$vars = \array_merge($function->getAttribute('vars', []), $vars);
/** Execute function */
$startTime = microtime(true);
try {
$executionResponse = $this->executor->createExecution(
projectId: $projectId,
@ -307,7 +308,7 @@ class FunctionsV1 extends Worker
$execution->setAttribute('stderr', $executionResponse['stderr']);
$execution->setAttribute('time', $executionResponse['time']);
} catch (\Throwable $th) {
$endtime = \time();
$endtime = \microtime(true);
$time = $endtime - $execution->getAttribute('dateCreated');
$execution->setAttribute('time', $time);
$execution->setAttribute('status', 'failed');

View file

@ -161,12 +161,14 @@ class Executor
'timeout' => $timeout,
];
/* Add 2 seconds as a buffer to the actual timeout value since there can be a slight variance*/
$requestTimeout = $timeout + 2;
/* Add 1 second as a buffer to the actual timeout value since there can be a slight variance*/
$requestTimeout = $timeout + 1;
$response = $this->call(self::METHOD_POST, $route, $headers, $params, true, $requestTimeout);
$status = $response['headers']['status-code'];
var_dump($response);
var_dump($status);
for ($attempts = 0; $attempts < 10; $attempts++) {
try {
switch (true) {

View file

@ -763,9 +763,9 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals($executions['body']['executions'][0]['status'], 'failed');
$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->assertLessThan(6, $executions['body']['executions'][0]['time']);
$this->assertEquals($executions['body']['executions'][0]['stdout'], '');
$this->assertEquals($executions['body']['executions'][0]['stderr'], 'Execution timed out.');
$this->assertEquals($executions['body']['executions'][0]['stderr'], 'An internal curl error has occurred within the executor! Error Msg: Operation timed out');
// Cleanup : Delete function
$response = $this->client->call(Client::METHOD_DELETE, '/functions/'. $functionId, [