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

test adjustments

This commit is contained in:
shimon 2023-01-17 15:10:05 +02:00
parent 7d40488724
commit abf67f8469

View file

@ -85,7 +85,7 @@ class UsageTest extends Scope
#[Retry(count: 1)]
public function testUsersStats(array $data): array
{
sleep(20);
sleep(30);
$projectId = $data['projectId'];
$headers = $data['headers'];
@ -112,11 +112,15 @@ class UsageTest extends Scope
$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'];
$this->assertEquals(10, $res['usersCreate'][array_key_last($res['usersCreate'])]['value']);
$this->validateDates($res['usersCreate']);
@ -266,7 +270,7 @@ class UsageTest extends Scope
$filesCreate = $data['filesCreate'];
$filesDelete = $data['filesDelete'];
sleep(20);
sleep(30);
// console request
$headers = [
@ -279,7 +283,6 @@ class UsageTest extends Scope
$res = $this->client->call(Client::METHOD_GET, '/project/usage?range=30d', $headers);
$res = $res['body'];
$this->assertEquals(9, count($res));
$this->assertEquals(30, count($res['requests']));
$this->assertEquals(30, count($res['storage']));
@ -287,12 +290,13 @@ class UsageTest extends Scope
$this->validateDates($res['requests']);
$this->assertEquals($storageTotal, $res['storage'][array_key_last($res['storage'])]['value']);
$this->validateDates($res['storage']);
$requestsCount++;
$res = $this->client->call(Client::METHOD_GET, '/storage/usage?range=30d', array_merge($headers, [
'x-appwrite-project' => $projectId,
'x-appwrite-mode' => 'admin'
]));
$requestsCount++;
$res = $res['body'];
$this->assertEquals($storageTotal, $res['storage'][array_key_last($res['storage'])]['value']);
$this->validateDates($res['storage']);
@ -312,19 +316,20 @@ class UsageTest extends Scope
$this->validateDates($res['filesCreate']);
$this->assertEquals($filesDelete, $res['filesDelete'][array_key_last($res['filesDelete'])]['value']);
$this->validateDates($res['filesDelete']);
$requestsCount++;
$res = $this->client->call(Client::METHOD_GET, '/storage/' . $bucketId . '/usage?range=30d', array_merge($headers, [
'x-appwrite-project' => $projectId,
'x-appwrite-mode' => 'admin'
]));
$requestsCount++;
$res = $res['body'];
$this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesStorage'])]['value']);
$this->assertEquals($filesCount, $res['filesCount'][array_key_last($res['filesCount'])]['value']);
$this->assertEquals($filesRead, $res['filesRead'][array_key_last($res['filesRead'])]['value']);
$this->assertEquals($filesCreate, $res['filesCreate'][array_key_last($res['filesCreate'])]['value']);
$this->assertEquals($filesDelete, $res['filesDelete'][array_key_last($res['filesDelete'])]['value']);
$requestsCount++;
$data['requestsCount'] = $requestsCount;
return $data;
}
@ -361,6 +366,7 @@ class UsageTest extends Scope
'databaseId' => 'unique()',
'name' => $name,
]);
$this->assertEquals($name, $res['body']['name']);
$this->assertNotEmpty($res['body']['$id']);
$databaseId = $res['body']['$id'];
@ -382,7 +388,7 @@ class UsageTest extends Scope
$requestsCount += 2;
}
}
exit;
for ($i = 0; $i < 10; $i++) {
$name = uniqid() . ' collection';
$res = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $headers, [
@ -426,7 +432,8 @@ class UsageTest extends Scope
$this->assertEquals('name', $res['body']['key']);
$collectionsUpdate++;
$requestsCount++;
sleep(20);
sleep(30);
for ($i = 0; $i < 10; $i++) {
$name = uniqid() . ' collection';
@ -508,7 +515,7 @@ class UsageTest extends Scope
$documentsRead = $data['documentsRead'];
$documentsDelete = $data['documentsDelete'];
sleep(20);
sleep(30);
// check datbase stats
$headers = [
@ -738,7 +745,7 @@ class UsageTest extends Scope
$executions = $data['executions'];
$failures = $data['failures'];
sleep(20);
sleep(30);
$response = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/usage', $headers, [
'range' => '30d'