test: poll scheduled function
This commit is contained in:
parent
dff9bed882
commit
6f38ef3a18
1 changed files with 17 additions and 6 deletions
|
@ -260,13 +260,24 @@ class FunctionsCustomClientTest extends Scope
|
||||||
|
|
||||||
$executionId = $execution['body']['$id'];
|
$executionId = $execution['body']['$id'];
|
||||||
|
|
||||||
\sleep(20);
|
while (true) {
|
||||||
|
|
||||||
|
$execution = $this->client->call(Client::METHOD_GET, '/functions/' . $function['body']['$id'] . '/executions/' . $executionId, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (
|
||||||
|
$execution['headers']['status-code'] >= 400
|
||||||
|
|| \in_array($execution['body']['status'], ['completed', 'failed'])
|
||||||
|
) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
\sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
$execution = $this->client->call(Client::METHOD_GET, '/functions/' . $function['body']['$id'] . '/executions/' . $executionId, [
|
|
||||||
'content-type' => 'application/json',
|
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
|
||||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
|
||||||
]);
|
|
||||||
$this->assertEquals('completed', $execution['body']['status'], \json_encode($execution['body']));
|
$this->assertEquals('completed', $execution['body']['status'], \json_encode($execution['body']));
|
||||||
|
|
||||||
// Cleanup : Delete function
|
// Cleanup : Delete function
|
||||||
|
|
Loading…
Reference in a new issue