Fix execution duration and add test
This commit is contained in:
parent
d2c5e55ca7
commit
4ef42c9cf8
3 changed files with 8 additions and 2 deletions
|
@ -225,8 +225,8 @@ class Executor
|
||||||
|
|
||||||
$response['body']['headers'] = \json_decode($response['body']['headers'] ?? '{}', true);
|
$response['body']['headers'] = \json_decode($response['body']['headers'] ?? '{}', true);
|
||||||
$response['body']['statusCode'] = \intval($response['body']['statusCode'] ?? 500);
|
$response['body']['statusCode'] = \intval($response['body']['statusCode'] ?? 500);
|
||||||
$response['body']['duration'] = \intval($response['body']['duration'] ?? 0);
|
$response['body']['duration'] = \floatval($response['body']['duration'] ?? 0);
|
||||||
$response['body']['startTime'] = \intval($response['body']['startTime'] ?? \microtime(true));
|
$response['body']['startTime'] = \floatval($response['body']['startTime'] ?? \microtime(true));
|
||||||
|
|
||||||
return $response['body'];
|
return $response['body'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,6 +182,7 @@ class FunctionsCustomClientTest extends Scope
|
||||||
$this->assertEquals($executions['body']['executions'][1]['responseStatusCode'], 200);
|
$this->assertEquals($executions['body']['executions'][1]['responseStatusCode'], 200);
|
||||||
$this->assertEquals($executions['body']['executions'][1]['responseBody'], '');
|
$this->assertEquals($executions['body']['executions'][1]['responseBody'], '');
|
||||||
$this->assertEquals($executions['body']['executions'][1]['logs'], '');
|
$this->assertEquals($executions['body']['executions'][1]['logs'], '');
|
||||||
|
$this->assertGreaterThan(0, $executions['body']['executions'][1]['duration']);
|
||||||
|
|
||||||
// Cleanup : Delete function
|
// Cleanup : Delete function
|
||||||
$response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $function['body']['$id'], [
|
$response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $function['body']['$id'], [
|
||||||
|
@ -285,6 +286,7 @@ class FunctionsCustomClientTest extends Scope
|
||||||
|
|
||||||
$this->assertEquals(202, $execution['headers']['status-code']);
|
$this->assertEquals(202, $execution['headers']['status-code']);
|
||||||
$this->assertEquals('scheduled', $execution['body']['status']);
|
$this->assertEquals('scheduled', $execution['body']['status']);
|
||||||
|
$this->assertGreaterThan(0, $execution['body']['duration']);
|
||||||
|
|
||||||
$executionId = $execution['body']['$id'];
|
$executionId = $execution['body']['$id'];
|
||||||
|
|
||||||
|
@ -301,6 +303,7 @@ class FunctionsCustomClientTest extends Scope
|
||||||
$this->assertEquals('completed', $execution['body']['status']);
|
$this->assertEquals('completed', $execution['body']['status']);
|
||||||
$this->assertEquals('/custom', $execution['body']['requestPath']);
|
$this->assertEquals('/custom', $execution['body']['requestPath']);
|
||||||
$this->assertEquals('GET', $execution['body']['requestMethod']);
|
$this->assertEquals('GET', $execution['body']['requestMethod']);
|
||||||
|
$this->assertGreaterThan(0, $execution['body']['duration']);
|
||||||
|
|
||||||
/* Test for FAILURE */
|
/* Test for FAILURE */
|
||||||
|
|
||||||
|
@ -438,6 +441,7 @@ class FunctionsCustomClientTest extends Scope
|
||||||
$output = json_decode($execution['body']['responseBody'], true);
|
$output = json_decode($execution['body']['responseBody'], true);
|
||||||
$this->assertEquals(201, $execution['headers']['status-code']);
|
$this->assertEquals(201, $execution['headers']['status-code']);
|
||||||
$this->assertEquals(200, $execution['body']['responseStatusCode']);
|
$this->assertEquals(200, $execution['body']['responseStatusCode']);
|
||||||
|
$this->assertGreaterThan(0, $execution['body']['duration']);
|
||||||
$this->assertEquals('completed', $execution['body']['status']);
|
$this->assertEquals('completed', $execution['body']['status']);
|
||||||
$this->assertEquals($functionId, $output['APPWRITE_FUNCTION_ID']);
|
$this->assertEquals($functionId, $output['APPWRITE_FUNCTION_ID']);
|
||||||
$this->assertEquals('Test', $output['APPWRITE_FUNCTION_NAME']);
|
$this->assertEquals('Test', $output['APPWRITE_FUNCTION_NAME']);
|
||||||
|
|
|
@ -1693,6 +1693,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
$this->assertEquals('completed', $execution['body']['status']);
|
$this->assertEquals('completed', $execution['body']['status']);
|
||||||
$this->assertEquals(200, $execution['body']['responseStatusCode']);
|
$this->assertEquals(200, $execution['body']['responseStatusCode']);
|
||||||
$this->assertNotEmpty($execution['body']['responseBody']);
|
$this->assertNotEmpty($execution['body']['responseBody']);
|
||||||
|
$this->assertGreaterThan(0, $execution['body']['duration']);
|
||||||
|
|
||||||
// Cleanup : Delete function
|
// Cleanup : Delete function
|
||||||
$response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [
|
$response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [
|
||||||
|
@ -1781,6 +1782,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
$this->assertEquals('completed', $execution['body']['status']);
|
$this->assertEquals('completed', $execution['body']['status']);
|
||||||
$this->assertEquals(200, $execution['body']['responseStatusCode']);
|
$this->assertEquals(200, $execution['body']['responseStatusCode']);
|
||||||
$this->assertEquals($cookie, $execution['body']['responseBody']);
|
$this->assertEquals($cookie, $execution['body']['responseBody']);
|
||||||
|
$this->assertGreaterThan(0, $execution['body']['duration']);
|
||||||
|
|
||||||
// Cleanup : Delete function
|
// Cleanup : Delete function
|
||||||
$response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [
|
$response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [
|
||||||
|
|
Loading…
Reference in a new issue