1
0
Fork 0
mirror of synced 2024-07-04 06:00:53 +12:00

addressing comments

This commit is contained in:
shimon 2023-02-02 15:43:19 +02:00
parent d33f8cc910
commit ff78bf8685
4 changed files with 36 additions and 16 deletions

@ -1 +1 @@
Subproject commit b1a81a390a05746701651fca49e0d853f430677c
Subproject commit fae048b91787d0b372c13caf27f14fc8b780ef60

View file

@ -111,14 +111,12 @@ class UsageTest extends Scope
$this->validateDates($res['users']);
$this->assertEquals($requestsCount, $res['requests'][array_key_last($res['requests'])]['value']);
$this->validateDates($res['requests']);
$requestsCount++;
$res = $this->client->call(Client::METHOD_GET, '/users/usage?range=30d', array_merge($headers, [
'x-appwrite-project' => $projectId,
'x-appwrite-mode' => 'admin'
]));
$requestsCount++;
$res = $res['body'];
@ -270,7 +268,7 @@ class UsageTest extends Scope
$filesCreate = $data['filesCreate'];
$filesDelete = $data['filesDelete'];
sleep(30);
sleep(20);
// console request
$headers = [
@ -390,7 +388,7 @@ class UsageTest extends Scope
for ($i = 0; $i < 10; $i++) {
$name = uniqid() . ' collection';
$res = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', array_merge($headers, ['content-type' => 'multipart/form-data']), [
$res = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $headers, [
'collectionId' => 'unique()',
'name' => $name,
'documentSecurity' => false,
@ -423,11 +421,12 @@ class UsageTest extends Scope
}
}
$res = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes' . '/string', array_merge($headers, ['content-type' => 'multipart/form-data']), [
$res = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes' . '/string', $headers, [
'key' => 'name',
'size' => 255,
'required' => true,
]);
$this->assertEquals('name', $res['body']['key']);
$collectionsUpdate++;
$requestsCount++;
@ -436,7 +435,7 @@ class UsageTest extends Scope
for ($i = 0; $i < 10; $i++) {
$name = uniqid() . ' collection';
$res = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collectionId . '/documents', array_merge($headers, ['content-type' => 'multipart/form-data']), [
$res = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collectionId . '/documents', $headers, [
'documentId' => 'unique()',
'data' => ['name' => $name]
]);
@ -514,7 +513,7 @@ class UsageTest extends Scope
$documentsRead = $data['documentsRead'];
$documentsDelete = $data['documentsDelete'];
sleep(30);
sleep(20);
// check datbase stats
$headers = [
@ -628,7 +627,7 @@ class UsageTest extends Scope
$executions = 0;
$failures = 0;
$response1 = $this->client->call(Client::METHOD_POST, '/functions', array_merge($headers, ['content-type' => 'multipart/form-data']), [
$response1 = $this->client->call(Client::METHOD_POST, '/functions', $headers, [
'functionId' => 'unique()',
'name' => 'Test',
'runtime' => 'php-8.0',
@ -653,7 +652,7 @@ class UsageTest extends Scope
$code = realpath(__DIR__ . '/../../resources/functions') . "/php/code.tar.gz";
$this->packageCode('php');
$deployment = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments', array_merge($headers, ['content-type' => 'multipart/form-data',]), [
$deployment = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments', $headers, [
'entrypoint' => 'index.php',
'code' => new CURLFile($code, 'application/x-gzip', \basename($code)),
'activate' => true
@ -677,7 +676,7 @@ class UsageTest extends Scope
$this->assertEquals(true, DateTime::isValid($response['body']['$updatedAt']));
$this->assertEquals($deploymentId, $response['body']['deployment']);
$execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge($headers, ['content-type' => 'multipart/form-data']), [
$execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', $headers, [
'async' => false,
]);
@ -744,7 +743,7 @@ class UsageTest extends Scope
$executions = $data['executions'];
$failures = $data['failures'];
sleep(30);
sleep(20);
$response = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/usage', $headers, [
'range' => '30d'

View file

@ -635,7 +635,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertStringContainsString('8.0', $execution['body']['response']);
$this->assertStringContainsString('êä', $execution['body']['response']); // tests unknown utf-8 chars
$this->assertEquals('', $execution['body']['stderr']);
$this->assertLessThan(3, $execution['body']['duration']);
$this->assertLessThan(1.500, $execution['body']['duration']);
/**
* Test for FAILURE
@ -915,6 +915,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals($executions['body']['executions'][0]['statusCode'], 500);
$this->assertGreaterThan(2, $executions['body']['executions'][0]['duration']);
$this->assertLessThan(6, $executions['body']['executions'][0]['duration']);
$this->assertLessThan(4, $executions['body']['executions'][0]['duration']);
$this->assertEquals($executions['body']['executions'][0]['response'], '');
$this->assertEquals($executions['body']['executions'][0]['stderr'], 'An internal curl error has occurred within the executor! Error Msg: Operation timed out');

View file

@ -211,6 +211,26 @@ class RealtimeCustomClientTest extends Scope
$this->assertEquals(1003, $response['data']['code']);
$this->assertEquals('Message format is not valid.', $response['data']['message']);
$client->close();
}
public function testConnectionPlatform()
{
/**
* Test for FAILURE
*/
$client = $this->getWebsocket(['documents'], ['origin' => 'http://appwrite.unknown']);
$payload = json_decode($client->receive(), true);
$this->assertArrayHasKey('type', $payload);
$this->assertArrayHasKey('data', $payload);
$this->assertEquals('error', $payload['type']);
$this->assertEquals(1008, $payload['data']['code']);
$this->assertEquals('Invalid Origin. Register your new client (appwrite.unknown) as a new Web platform on your project console dashboard', $payload['data']['message']);
\usleep(250000); // 250ms
$this->expectException(ConnectionException::class); // Check if server disconnnected client
$client->close();
}
@ -440,8 +460,8 @@ class RealtimeCustomClientTest extends Scope
$this->assertNotEmpty($response['data']['payload']);
/**
// * Test Account Session Create
// */
* Test Account Session Create
*/
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
@ -1229,7 +1249,7 @@ class RealtimeCustomClientTest extends Scope
$this->assertNotEmpty($deployment['body']['$id']);
// Wait for deployment to be built.
sleep(10);
sleep(5);
$response = $this->client->call(Client::METHOD_PATCH, '/functions/' . $functionId . '/deployments/' . $deploymentId, array_merge([
'content-type' => 'application/json',