2022-06-30 16:27:11 +12:00
|
|
|
<?php
|
|
|
|
|
2022-07-04 21:31:14 +12:00
|
|
|
namespace Tests\E2E\General;
|
|
|
|
|
2022-06-30 16:27:11 +12:00
|
|
|
use Tests\E2E\Client;
|
|
|
|
use Tests\E2E\Scopes\ProjectCustom;
|
|
|
|
use Tests\E2E\Scopes\Scope;
|
|
|
|
use Tests\E2E\Scopes\SideServer;
|
2022-07-05 18:53:57 +12:00
|
|
|
use CURLFile;
|
2022-07-10 14:12:49 +12:00
|
|
|
use Tests\E2E\Services\Functions\FunctionsBase;
|
2022-08-26 10:10:52 +12:00
|
|
|
use Utopia\Database\DateTime;
|
2022-12-15 05:04:06 +13:00
|
|
|
use Utopia\Database\Helpers\Permission;
|
|
|
|
use Utopia\Database\Helpers\Role;
|
2023-03-02 01:00:36 +13:00
|
|
|
use Utopia\Database\Validator\Datetime as DatetimeValidator;
|
2022-06-30 16:27:11 +12:00
|
|
|
|
2022-06-30 21:40:27 +12:00
|
|
|
class UsageTest extends Scope
|
|
|
|
{
|
2022-06-30 16:27:11 +12:00
|
|
|
use ProjectCustom;
|
|
|
|
use SideServer;
|
2022-07-10 14:12:49 +12:00
|
|
|
use FunctionsBase;
|
2022-06-30 16:27:11 +12:00
|
|
|
|
2023-01-13 06:41:14 +13:00
|
|
|
private const WAIT = 35;
|
2022-12-19 21:25:49 +13:00
|
|
|
private const CREATE = 20;
|
2022-12-14 20:34:04 +13:00
|
|
|
|
2022-06-30 21:33:40 +12:00
|
|
|
protected string $projectId;
|
2022-06-30 21:40:27 +12:00
|
|
|
|
2022-12-19 21:30:32 +13:00
|
|
|
public function setUp(): void
|
2022-06-30 21:40:27 +12:00
|
|
|
{
|
2022-07-27 20:28:23 +12:00
|
|
|
parent::setUp();
|
|
|
|
}
|
2022-06-30 16:27:11 +12:00
|
|
|
|
2022-09-16 11:48:09 +12:00
|
|
|
protected static string $formatTz = 'Y-m-d\TH:i:s.vP';
|
|
|
|
|
|
|
|
protected function validateDates(array $metrics): void
|
|
|
|
{
|
|
|
|
foreach ($metrics as $metric) {
|
|
|
|
$this->assertIsObject(\DateTime::createFromFormat("Y-m-d\TH:i:s.vP", $metric['date']));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-10 05:16:22 +12:00
|
|
|
public function testPrepareUsersStats(): array
|
2022-07-27 20:28:23 +12:00
|
|
|
{
|
2022-07-28 19:28:00 +12:00
|
|
|
$project = $this->getProject(true);
|
|
|
|
$projectId = $project['$id'];
|
|
|
|
$headers['x-appwrite-project'] = $project['$id'];
|
|
|
|
$headers['x-appwrite-key'] = $project['apiKey'];
|
|
|
|
$headers['content-type'] = 'application/json';
|
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$usersTotal = 0;
|
|
|
|
$requestsTotal = 0;
|
2022-12-16 06:00:05 +13:00
|
|
|
for ($i = 0; $i < self::CREATE; $i++) {
|
2022-06-30 16:27:11 +12:00
|
|
|
$email = uniqid() . 'user@usage.test';
|
|
|
|
$password = 'password';
|
|
|
|
$name = uniqid() . 'User';
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/users',
|
|
|
|
$headers,
|
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'userId' => 'unique()',
|
|
|
|
'email' => $email,
|
|
|
|
'password' => $password,
|
|
|
|
'name' => $name,
|
2022-12-16 06:00:05 +13:00
|
|
|
]
|
|
|
|
);
|
2022-12-14 20:34:04 +13:00
|
|
|
|
2022-06-30 21:33:40 +12:00
|
|
|
$this->assertEquals($email, $res['body']['email']);
|
|
|
|
$this->assertNotEmpty($res['body']['$id']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$usersTotal++;
|
|
|
|
$requestsTotal++;
|
2022-07-03 14:42:13 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
if ($i < (self::CREATE / 2)) {
|
2022-07-03 14:42:13 +12:00
|
|
|
$userId = $res['body']['$id'];
|
2022-07-28 19:28:00 +12:00
|
|
|
$res = $this->client->call(Client::METHOD_DELETE, '/users/' . $userId, $headers);
|
2022-07-03 14:42:13 +12:00
|
|
|
$this->assertEmpty($res['body']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$requestsTotal++;
|
|
|
|
$usersTotal--;
|
2022-07-03 14:42:13 +12:00
|
|
|
}
|
2022-06-30 16:27:11 +12:00
|
|
|
}
|
2022-07-03 14:42:13 +12:00
|
|
|
|
2022-09-10 05:16:22 +12:00
|
|
|
return [
|
2022-12-15 20:56:06 +13:00
|
|
|
'projectId' => $projectId,
|
|
|
|
'headers' => $headers,
|
2023-02-06 09:07:46 +13:00
|
|
|
'usersTotal' => $usersTotal,
|
|
|
|
'requestsTotal' => $requestsTotal
|
2022-09-10 05:16:22 +12:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testPrepareUsersStats
|
|
|
|
*/
|
|
|
|
public function testUsersStats(array $data): array
|
|
|
|
{
|
2022-12-14 20:34:04 +13:00
|
|
|
sleep(self::WAIT);
|
2022-06-30 21:33:40 +12:00
|
|
|
|
2022-12-15 20:56:06 +13:00
|
|
|
$projectId = $data['projectId'];
|
|
|
|
$headers = $data['headers'];
|
2023-02-06 09:07:46 +13:00
|
|
|
$usersTotal = $data['usersTotal'];
|
|
|
|
$requestsTotal = $data['requestsTotal'];
|
2022-09-10 05:16:22 +12:00
|
|
|
|
2022-12-15 20:56:06 +13:00
|
|
|
$consoleHeaders = [
|
2022-06-30 21:33:40 +12:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'x-appwrite-project' => 'console',
|
|
|
|
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
|
2022-11-19 02:13:33 +13:00
|
|
|
'x-appwrite-project' => $projectId,
|
|
|
|
'x-appwrite-mode' => 'admin',
|
2022-06-30 21:33:40 +12:00
|
|
|
];
|
2022-06-30 21:40:27 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_GET,
|
|
|
|
'/project/usage?range=24h',
|
|
|
|
$consoleHeaders
|
|
|
|
);
|
2022-06-30 21:33:40 +12:00
|
|
|
$res = $res['body'];
|
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$this->assertEquals('24h', $res['range']);
|
2022-11-09 02:38:43 +13:00
|
|
|
$this->assertEquals(9, count($res));
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertEquals(24, count($res['requestsTotal']));
|
|
|
|
$this->assertEquals(24, count($res['usersTotal']));
|
|
|
|
$this->assertEquals($usersTotal, $res['usersTotal'][array_key_last($res['usersTotal'])]['value']);
|
|
|
|
$this->validateDates($res['usersTotal']);
|
|
|
|
$this->assertEquals($requestsTotal, $res['requestsTotal'][array_key_last($res['requestsTotal'])]['value']);
|
|
|
|
$this->validateDates($res['requestsTotal']);
|
2022-07-04 01:10:26 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_GET,
|
|
|
|
'/users/usage?range=90d',
|
|
|
|
$consoleHeaders
|
|
|
|
);
|
2022-12-15 20:56:06 +13:00
|
|
|
|
2022-07-04 01:10:26 +12:00
|
|
|
$res = $res['body'];
|
2022-12-14 20:34:04 +13:00
|
|
|
$this->assertEquals('90d', $res['range']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertEquals(90, count($res['usersTotal']));
|
|
|
|
$this->assertEquals(90, count($res['sessionsTotal']));
|
|
|
|
$this->assertEquals((self::CREATE / 2), $res['usersTotal'][array_key_last($res['usersTotal'])]['value']);
|
2022-12-15 20:56:06 +13:00
|
|
|
|
2022-12-14 20:34:04 +13:00
|
|
|
return [
|
|
|
|
'projectId' => $projectId,
|
|
|
|
'headers' => $headers,
|
2022-12-15 20:56:06 +13:00
|
|
|
'consoleHeaders' => $consoleHeaders,
|
2023-02-06 09:07:46 +13:00
|
|
|
'requestsTotal' => $requestsTotal,
|
2022-12-14 20:34:04 +13:00
|
|
|
];
|
2022-07-04 01:10:26 +12:00
|
|
|
}
|
|
|
|
|
2022-07-28 19:28:00 +12:00
|
|
|
/** @depends testUsersStats */
|
2022-09-10 05:16:22 +12:00
|
|
|
public function testPrepareStorageStats(array $data): array
|
2022-07-04 21:00:07 +12:00
|
|
|
{
|
2022-07-28 19:28:00 +12:00
|
|
|
$headers = $data['headers'];
|
2023-02-06 09:07:46 +13:00
|
|
|
$bucketsTotal = 0;
|
|
|
|
$requestsTotal = $data['requestsTotal'];
|
2022-07-04 01:10:26 +12:00
|
|
|
$storageTotal = 0;
|
2023-02-06 09:07:46 +13:00
|
|
|
$filesTotal = 0;
|
2022-07-04 01:10:26 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
|
|
|
|
for ($i = 0; $i < self::CREATE; $i++) {
|
2022-07-04 01:10:26 +12:00
|
|
|
$name = uniqid() . ' bucket';
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/storage/buckets',
|
2023-08-05 07:15:32 +12:00
|
|
|
$headers,
|
2022-12-16 06:00:05 +13:00
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'bucketId' => 'unique()',
|
|
|
|
'name' => $name,
|
|
|
|
'fileSecurity' => false,
|
|
|
|
'permissions' => [
|
|
|
|
Permission::read(Role::any()),
|
|
|
|
Permission::create(Role::any()),
|
|
|
|
Permission::update(Role::any()),
|
|
|
|
Permission::delete(Role::any()),
|
|
|
|
],
|
|
|
|
]
|
2022-12-16 06:00:05 +13:00
|
|
|
);
|
2022-07-04 01:10:26 +12:00
|
|
|
$this->assertEquals($name, $res['body']['name']);
|
|
|
|
$this->assertNotEmpty($res['body']['$id']);
|
|
|
|
$bucketId = $res['body']['$id'];
|
2023-02-06 09:07:46 +13:00
|
|
|
$bucketsTotal++;
|
|
|
|
$requestsTotal++;
|
2022-07-04 01:10:26 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
if ($i < (self::CREATE / 2)) {
|
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_DELETE,
|
|
|
|
'/storage/buckets/' . $bucketId,
|
|
|
|
$headers
|
|
|
|
);
|
2022-07-04 01:10:26 +12:00
|
|
|
$this->assertEmpty($res['body']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$requestsTotal++;
|
|
|
|
$bucketsTotal--;
|
2022-07-04 01:10:26 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// upload some files
|
2022-07-04 21:00:07 +12:00
|
|
|
$files = [
|
|
|
|
[
|
|
|
|
'path' => realpath(__DIR__ . '/../../resources/logo.png'),
|
|
|
|
'name' => 'logo.png',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'path' => realpath(__DIR__ . '/../../resources/file.png'),
|
|
|
|
'name' => 'file.png',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'path' => realpath(__DIR__ . '/../../resources/disk-a/kitten-3.gif'),
|
|
|
|
'name' => 'kitten-3.gif',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'path' => realpath(__DIR__ . '/../../resources/disk-a/kitten-1.jpg'),
|
|
|
|
'name' => 'kitten-1.jpg',
|
|
|
|
],
|
2022-09-16 11:48:09 +12:00
|
|
|
];
|
2022-07-04 21:00:07 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
for ($i = 0; $i < self::CREATE; $i++) {
|
2022-07-04 21:00:07 +12:00
|
|
|
$file = $files[$i % count($files)];
|
2022-12-15 20:56:06 +13:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/storage/buckets/' . $bucketId . '/files',
|
|
|
|
array_merge($headers, ['content-type' => 'multipart/form-data']),
|
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'fileId' => 'unique()',
|
|
|
|
'file' => new CURLFile($file['path'], '', $file['name']),
|
2022-12-16 06:00:05 +13:00
|
|
|
]
|
|
|
|
);
|
2022-12-15 20:56:06 +13:00
|
|
|
|
2022-07-04 01:10:26 +12:00
|
|
|
$this->assertNotEmpty($res['body']['$id']);
|
|
|
|
|
2022-07-04 21:00:07 +12:00
|
|
|
$fileSize = $res['body']['sizeOriginal'];
|
|
|
|
$storageTotal += $fileSize;
|
2023-02-06 09:07:46 +13:00
|
|
|
$filesTotal++;
|
|
|
|
$requestsTotal++;
|
2022-07-04 21:00:07 +12:00
|
|
|
|
|
|
|
$fileId = $res['body']['$id'];
|
2022-12-16 06:00:05 +13:00
|
|
|
if ($i < (self::CREATE / 2)) {
|
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_DELETE,
|
|
|
|
'/storage/buckets/' . $bucketId . '/files/' . $fileId,
|
|
|
|
$headers
|
|
|
|
);
|
2022-07-04 01:10:26 +12:00
|
|
|
$this->assertEmpty($res['body']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$requestsTotal++;
|
|
|
|
$filesTotal--;
|
2022-07-04 21:00:07 +12:00
|
|
|
$storageTotal -= $fileSize;
|
2022-07-04 01:10:26 +12:00
|
|
|
}
|
|
|
|
}
|
2022-07-04 21:00:07 +12:00
|
|
|
|
2022-09-10 05:16:22 +12:00
|
|
|
return array_merge($data, [
|
|
|
|
'bucketId' => $bucketId,
|
2023-02-06 09:07:46 +13:00
|
|
|
'bucketsTotal' => $bucketsTotal,
|
|
|
|
'requestsTotal' => $requestsTotal,
|
2022-09-10 05:16:22 +12:00
|
|
|
'storageTotal' => $storageTotal,
|
2023-02-06 09:07:46 +13:00
|
|
|
'filesTotal' => $filesTotal,
|
2022-09-10 05:16:22 +12:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testPrepareStorageStats
|
|
|
|
*/
|
|
|
|
public function testStorageStats(array $data): array
|
|
|
|
{
|
2022-12-14 20:34:04 +13:00
|
|
|
$bucketId = $data['bucketId'];
|
2023-02-06 09:07:46 +13:00
|
|
|
$bucketsTotal = $data['bucketsTotal'];
|
|
|
|
$requestsTotal = $data['requestsTotal'];
|
2022-12-14 20:34:04 +13:00
|
|
|
$storageTotal = $data['storageTotal'];
|
2023-02-06 09:07:46 +13:00
|
|
|
$filesTotal = $data['filesTotal'];
|
2022-09-10 05:16:22 +12:00
|
|
|
|
2022-12-14 20:34:04 +13:00
|
|
|
sleep(self::WAIT);
|
2022-07-04 01:10:26 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_GET,
|
|
|
|
'/project/usage?range=30d',
|
|
|
|
array_merge(
|
|
|
|
$data['headers'],
|
|
|
|
$data['consoleHeaders']
|
|
|
|
)
|
|
|
|
);
|
2022-07-04 01:10:26 +12:00
|
|
|
$res = $res['body'];
|
|
|
|
|
2022-11-09 03:16:10 +13:00
|
|
|
$this->assertEquals(9, count($res));
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertEquals(30, count($res['requestsTotal']));
|
|
|
|
$this->assertEquals(30, count($res['filesStorage']));
|
|
|
|
$this->assertEquals($requestsTotal, $res['requestsTotal'][array_key_last($res['requestsTotal'])]['value']);
|
|
|
|
$this->validateDates($res['requestsTotal']);
|
|
|
|
$this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesStorage'])]['value']);
|
|
|
|
$this->validateDates($res['filesStorage']);
|
2022-07-03 14:42:13 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_GET,
|
|
|
|
'/storage/usage?range=30d',
|
|
|
|
array_merge(
|
|
|
|
$data['headers'],
|
|
|
|
$data['consoleHeaders']
|
|
|
|
)
|
|
|
|
);
|
2022-12-15 20:56:06 +13:00
|
|
|
|
2022-07-03 14:42:13 +12:00
|
|
|
$res = $res['body'];
|
2023-02-15 06:40:21 +13:00
|
|
|
$this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesStorage'])]['value']);
|
2022-12-15 20:56:06 +13:00
|
|
|
$this->validateDates($res['filesStorage']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertEquals($bucketsTotal, $res['bucketsTotal'][array_key_last($res['bucketsTotal'])]['value']);
|
|
|
|
$this->validateDates($res['bucketsTotal']);
|
|
|
|
$this->assertEquals($filesTotal, $res['filesTotal'][array_key_last($res['filesTotal'])]['value']);
|
|
|
|
$this->validateDates($res['filesTotal']);
|
2022-07-04 21:00:07 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_GET,
|
|
|
|
'/storage/' . $bucketId . '/usage?range=30d',
|
|
|
|
array_merge(
|
|
|
|
$data['headers'],
|
|
|
|
$data['consoleHeaders']
|
|
|
|
)
|
|
|
|
);
|
2022-12-15 20:56:06 +13:00
|
|
|
|
2022-07-04 21:00:07 +12:00
|
|
|
$res = $res['body'];
|
|
|
|
$this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesStorage'])]['value']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertEquals($filesTotal, $res['filesTotal'][array_key_last($res['filesTotal'])]['value']);
|
2022-07-28 19:28:00 +12:00
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$data['requestsTotal'] = $requestsTotal;
|
2022-07-28 19:28:00 +12:00
|
|
|
|
|
|
|
return $data;
|
2022-06-30 16:27:11 +12:00
|
|
|
}
|
|
|
|
|
2022-07-28 21:01:03 +12:00
|
|
|
/** @depends testStorageStats */
|
2022-09-10 05:16:22 +12:00
|
|
|
public function testPrepareDatabaseStats(array $data): array
|
2022-07-05 18:53:57 +12:00
|
|
|
{
|
2022-07-28 19:28:00 +12:00
|
|
|
$headers = $data['headers'];
|
2022-07-05 19:11:27 +12:00
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$requestsTotal = $data['requestsTotal'];
|
|
|
|
$databasesTotal = 0;
|
|
|
|
$collectionsTotal = 0;
|
|
|
|
$documentsTotal = 0;
|
2022-07-05 18:53:57 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
for ($i = 0; $i < self::CREATE; $i++) {
|
2022-07-05 18:53:57 +12:00
|
|
|
$name = uniqid() . ' database';
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/databases',
|
2023-08-05 07:15:32 +12:00
|
|
|
$headers,
|
2022-12-16 06:00:05 +13:00
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'databaseId' => 'unique()',
|
|
|
|
'name' => $name,
|
2022-12-16 06:00:05 +13:00
|
|
|
]
|
|
|
|
);
|
2022-12-15 20:56:06 +13:00
|
|
|
|
|
|
|
|
2022-07-05 18:53:57 +12:00
|
|
|
$this->assertEquals($name, $res['body']['name']);
|
|
|
|
$this->assertNotEmpty($res['body']['$id']);
|
|
|
|
$databaseId = $res['body']['$id'];
|
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$requestsTotal++;
|
|
|
|
$databasesTotal++;
|
2022-07-05 18:53:57 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
if ($i < (self::CREATE / 2)) {
|
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_DELETE,
|
|
|
|
'/databases/' . $databaseId,
|
|
|
|
$headers
|
|
|
|
);
|
2022-07-05 18:53:57 +12:00
|
|
|
$this->assertEmpty($res['body']);
|
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$databasesTotal--;
|
|
|
|
$requestsTotal++;
|
2022-07-05 18:53:57 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
for ($i = 0; $i < self::CREATE; $i++) {
|
2022-07-05 18:53:57 +12:00
|
|
|
$name = uniqid() . ' collection';
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/databases/' . $databaseId . '/collections',
|
2023-08-05 07:15:32 +12:00
|
|
|
$headers,
|
2022-12-16 06:00:05 +13:00
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'collectionId' => 'unique()',
|
|
|
|
'name' => $name,
|
|
|
|
'documentSecurity' => false,
|
|
|
|
'permissions' => [
|
|
|
|
Permission::read(Role::any()),
|
|
|
|
Permission::create(Role::any()),
|
|
|
|
Permission::update(Role::any()),
|
|
|
|
Permission::delete(Role::any()),
|
|
|
|
],
|
2022-12-16 06:00:05 +13:00
|
|
|
]
|
|
|
|
);
|
2022-12-15 20:56:06 +13:00
|
|
|
|
2022-07-05 18:53:57 +12:00
|
|
|
$this->assertEquals($name, $res['body']['name']);
|
|
|
|
$this->assertNotEmpty($res['body']['$id']);
|
|
|
|
$collectionId = $res['body']['$id'];
|
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$requestsTotal++;
|
|
|
|
$collectionsTotal++;
|
2022-07-05 18:53:57 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
if ($i < (self::CREATE / 2)) {
|
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_DELETE,
|
|
|
|
'/databases/' . $databaseId . '/collections/' . $collectionId,
|
|
|
|
$headers
|
|
|
|
);
|
2022-07-05 18:53:57 +12:00
|
|
|
$this->assertEmpty($res['body']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$collectionsTotal--;
|
|
|
|
$requestsTotal++;
|
2022-07-05 18:53:57 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes' . '/string',
|
2023-02-06 20:20:03 +13:00
|
|
|
$headers,
|
2022-12-16 06:00:05 +13:00
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'key' => 'name',
|
|
|
|
'size' => 255,
|
|
|
|
'required' => true,
|
2022-12-16 06:00:05 +13:00
|
|
|
]
|
|
|
|
);
|
2022-12-15 20:56:06 +13:00
|
|
|
|
2022-07-05 18:53:57 +12:00
|
|
|
$this->assertEquals('name', $res['body']['key']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$requestsTotal++;
|
2022-07-05 18:53:57 +12:00
|
|
|
|
2022-12-15 20:56:06 +13:00
|
|
|
sleep(self::WAIT);
|
2022-07-05 18:53:57 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
for ($i = 0; $i < self::CREATE; $i++) {
|
2022-07-05 18:53:57 +12:00
|
|
|
$name = uniqid() . ' collection';
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/databases/' . $databaseId . '/collections/' . $collectionId . '/documents',
|
2023-08-05 07:15:32 +12:00
|
|
|
$headers,
|
2022-12-16 06:00:05 +13:00
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'documentId' => 'unique()',
|
|
|
|
'data' => ['name' => $name]
|
2022-12-16 06:00:05 +13:00
|
|
|
]
|
|
|
|
);
|
2022-07-05 18:53:57 +12:00
|
|
|
$this->assertEquals($name, $res['body']['name']);
|
|
|
|
$this->assertNotEmpty($res['body']['$id']);
|
|
|
|
$documentId = $res['body']['$id'];
|
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$requestsTotal++;
|
|
|
|
$documentsTotal++;
|
2022-07-05 18:53:57 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
if ($i < (self::CREATE / 2)) {
|
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_DELETE,
|
|
|
|
'/databases/' . $databaseId . '/collections/' . $collectionId . '/documents/' . $documentId,
|
|
|
|
$headers
|
|
|
|
);
|
2022-07-05 18:53:57 +12:00
|
|
|
$this->assertEmpty($res['body']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$documentsTotal--;
|
|
|
|
$requestsTotal++;
|
2022-07-05 18:53:57 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
return array_merge($data, [
|
2022-09-10 05:16:22 +12:00
|
|
|
'databaseId' => $databaseId,
|
|
|
|
'collectionId' => $collectionId,
|
2023-02-06 09:07:46 +13:00
|
|
|
'requestsTotal' => $requestsTotal,
|
|
|
|
'databasesTotal' => $databasesTotal,
|
|
|
|
'collectionsTotal' => $collectionsTotal,
|
|
|
|
'documentsTotal' => $documentsTotal,
|
2022-09-10 05:16:22 +12:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @depends testPrepareDatabaseStats */
|
2022-12-15 20:56:06 +13:00
|
|
|
|
2022-09-10 05:16:22 +12:00
|
|
|
public function testDatabaseStats(array $data): array
|
|
|
|
{
|
|
|
|
|
2022-12-15 20:56:06 +13:00
|
|
|
$projectId = $data['projectId'];
|
2022-09-10 05:16:22 +12:00
|
|
|
$databaseId = $data['databaseId'];
|
|
|
|
$collectionId = $data['collectionId'];
|
2023-02-06 09:07:46 +13:00
|
|
|
$requestsTotal = $data['requestsTotal'];
|
|
|
|
$databasesTotal = $data['databasesTotal'];
|
|
|
|
$collectionsTotal = $data['collectionsTotal'];
|
|
|
|
$documentsTotal = $data['documentsTotal'];
|
2022-09-10 05:16:22 +12:00
|
|
|
|
2022-12-15 20:56:06 +13:00
|
|
|
sleep(self::WAIT);
|
2022-11-19 02:13:33 +13:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_GET,
|
|
|
|
'/project/usage?range=30d',
|
|
|
|
$data['consoleHeaders']
|
|
|
|
);
|
2022-07-05 18:53:57 +12:00
|
|
|
$res = $res['body'];
|
2022-09-10 05:16:22 +12:00
|
|
|
|
2022-11-09 03:16:10 +13:00
|
|
|
$this->assertEquals(9, count($res));
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertEquals(30, count($res['requestsTotal']));
|
|
|
|
$this->assertEquals(30, count($res['filesStorage']));
|
|
|
|
$this->assertEquals($requestsTotal, $res['requestsTotal'][array_key_last($res['requestsTotal'])]['value']);
|
|
|
|
$this->validateDates($res['requestsTotal']);
|
|
|
|
$this->assertEquals($databasesTotal, $res['databasesTotal'][array_key_last($res['databasesTotal'])]['value']);
|
|
|
|
$this->validateDates($res['databasesTotal']);
|
|
|
|
$this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']);
|
|
|
|
$this->validateDates($res['documentsTotal']);
|
2022-07-05 18:53:57 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_GET,
|
|
|
|
'/databases/usage?range=30d',
|
|
|
|
$data['consoleHeaders']
|
|
|
|
);
|
2022-07-05 18:53:57 +12:00
|
|
|
$res = $res['body'];
|
2022-09-10 05:16:22 +12:00
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertEquals($databasesTotal, $res['databasesTotal'][array_key_last($res['databasesTotal'])]['value']);
|
|
|
|
$this->validateDates($res['databasesTotal']);
|
|
|
|
$this->assertEquals($collectionsTotal, $res['collectionsTotal'][array_key_last($res['collectionsTotal'])]['value']);
|
|
|
|
$this->validateDates($res['collectionsTotal']);
|
|
|
|
$this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']);
|
|
|
|
$this->validateDates($res['documentsTotal']);
|
2022-07-05 18:53:57 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$res = $this->client->call(
|
|
|
|
Client::METHOD_GET,
|
|
|
|
'/databases/' . $databaseId . '/usage?range=30d',
|
|
|
|
$data['consoleHeaders']
|
|
|
|
);
|
2022-07-05 18:53:57 +12:00
|
|
|
$res = $res['body'];
|
2022-09-10 05:16:22 +12:00
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertEquals($collectionsTotal, $res['collectionsTotal'][array_key_last($res['collectionsTotal'])]['value']);
|
|
|
|
$this->validateDates($res['collectionsTotal']);
|
2022-09-10 05:16:22 +12:00
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']);
|
|
|
|
$this->validateDates($res['documentsTotal']);
|
2022-07-05 18:53:57 +12:00
|
|
|
|
2022-12-23 02:02:41 +13:00
|
|
|
$res = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId . '/usage?range=30d', $data['consoleHeaders']);
|
2022-07-05 18:53:57 +12:00
|
|
|
$res = $res['body'];
|
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']);
|
|
|
|
$this->validateDates($res['documentsTotal']);
|
2022-07-05 18:53:57 +12:00
|
|
|
|
2023-02-06 09:07:46 +13:00
|
|
|
$data['requestsTotal'] = $requestsTotal;
|
2022-07-28 19:28:00 +12:00
|
|
|
|
|
|
|
return $data;
|
2022-07-05 18:53:57 +12:00
|
|
|
}
|
|
|
|
|
2022-08-18 13:49:41 +12:00
|
|
|
|
2022-07-28 21:01:03 +12:00
|
|
|
/** @depends testDatabaseStats */
|
2022-09-10 05:16:22 +12:00
|
|
|
public function testPrepareFunctionsStats(array $data): array
|
2022-07-05 18:53:57 +12:00
|
|
|
{
|
2022-12-20 00:21:09 +13:00
|
|
|
$dateValidator = new DatetimeValidator();
|
2022-08-18 13:49:41 +12:00
|
|
|
$headers = $data['headers'];
|
2022-07-17 22:30:58 +12:00
|
|
|
$executionTime = 0;
|
2022-07-10 14:12:49 +12:00
|
|
|
$executions = 0;
|
|
|
|
$failures = 0;
|
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$response1 = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/functions',
|
|
|
|
$headers,
|
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'functionId' => 'unique()',
|
|
|
|
'name' => 'Test',
|
|
|
|
'runtime' => 'php-8.0',
|
|
|
|
'vars' => [
|
|
|
|
'funcKey1' => 'funcValue1',
|
|
|
|
'funcKey2' => 'funcValue2',
|
|
|
|
'funcKey3' => 'funcValue3',
|
|
|
|
],
|
|
|
|
'events' => [
|
|
|
|
'users.*.create',
|
|
|
|
'users.*.delete',
|
|
|
|
],
|
|
|
|
'schedule' => '0 0 1 1 *',
|
|
|
|
'timeout' => 10,
|
2022-12-16 06:00:05 +13:00
|
|
|
]
|
|
|
|
);
|
2022-07-10 14:12:49 +12:00
|
|
|
|
|
|
|
$functionId = $response1['body']['$id'] ?? '';
|
|
|
|
|
|
|
|
$this->assertEquals(201, $response1['headers']['status-code']);
|
|
|
|
$this->assertNotEmpty($response1['body']['$id']);
|
|
|
|
|
2022-08-18 13:49:41 +12:00
|
|
|
$code = realpath(__DIR__ . '/../../resources/functions') . "/php/code.tar.gz";
|
|
|
|
$this->packageCode('php');
|
2022-07-10 14:12:49 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$deployment = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/functions/' . $functionId . '/deployments',
|
|
|
|
array_merge($headers, ['content-type' => 'multipart/form-data',]),
|
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'entrypoint' => 'index.php',
|
|
|
|
'code' => new CURLFile($code, 'application/x-gzip', \basename($code)),
|
|
|
|
'activate' => true
|
2022-12-16 06:00:05 +13:00
|
|
|
]
|
|
|
|
);
|
2022-07-10 14:12:49 +12:00
|
|
|
|
|
|
|
$deploymentId = $deployment['body']['$id'] ?? '';
|
|
|
|
|
2022-08-17 22:36:30 +12:00
|
|
|
$this->assertEquals(202, $deployment['headers']['status-code']);
|
2022-07-10 14:12:49 +12:00
|
|
|
$this->assertNotEmpty($deployment['body']['$id']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertEquals(true, (new DatetimeValidator())->isValid($deployment['body']['$createdAt']));
|
2022-07-10 14:12:49 +12:00
|
|
|
$this->assertEquals('index.php', $deployment['body']['entrypoint']);
|
|
|
|
|
|
|
|
// Wait for deployment to build.
|
2022-12-15 20:56:06 +13:00
|
|
|
sleep(self::WAIT + 20);
|
2022-07-17 21:33:24 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$response = $this->client->call(
|
|
|
|
Client::METHOD_PATCH,
|
|
|
|
'/functions/' . $functionId . '/deployments/' . $deploymentId,
|
|
|
|
$headers
|
|
|
|
);
|
2022-07-17 21:33:24 +12:00
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
|
|
|
$this->assertNotEmpty($response['body']['$id']);
|
2023-02-06 09:07:46 +13:00
|
|
|
|
|
|
|
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['$createdAt']));
|
|
|
|
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['$updatedAt']));
|
2022-07-17 21:33:24 +12:00
|
|
|
$this->assertEquals($deploymentId, $response['body']['deployment']);
|
2022-07-17 22:30:58 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$execution = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/functions/' . $functionId . '/executions',
|
|
|
|
$headers,
|
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'async' => false,
|
2022-12-16 06:00:05 +13:00
|
|
|
]
|
|
|
|
);
|
2022-07-17 22:30:58 +12:00
|
|
|
|
2022-07-10 14:12:49 +12:00
|
|
|
$this->assertEquals(201, $execution['headers']['status-code']);
|
|
|
|
$this->assertNotEmpty($execution['body']['$id']);
|
|
|
|
$this->assertEquals($functionId, $execution['body']['functionId']);
|
2022-12-15 20:56:06 +13:00
|
|
|
|
2022-09-10 08:19:09 +12:00
|
|
|
$executionTime += (int) ($execution['body']['duration'] * 1000);
|
2022-12-15 22:45:43 +13:00
|
|
|
|
2022-08-18 13:50:55 +12:00
|
|
|
if ($execution['body']['status'] == 'failed') {
|
2022-08-18 13:49:41 +12:00
|
|
|
$failures++;
|
2022-08-18 17:13:30 +12:00
|
|
|
} elseif ($execution['body']['status'] == 'completed') {
|
2022-08-18 13:49:41 +12:00
|
|
|
$executions++;
|
|
|
|
}
|
2022-07-17 22:30:58 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$execution = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/functions/' . $functionId . '/executions',
|
|
|
|
$headers,
|
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'async' => false,
|
2022-12-16 06:00:05 +13:00
|
|
|
]
|
|
|
|
);
|
2022-07-17 22:30:58 +12:00
|
|
|
|
2022-07-17 21:33:24 +12:00
|
|
|
$this->assertEquals(201, $execution['headers']['status-code']);
|
|
|
|
$this->assertNotEmpty($execution['body']['$id']);
|
|
|
|
$this->assertEquals($functionId, $execution['body']['functionId']);
|
2022-08-18 13:50:55 +12:00
|
|
|
if ($execution['body']['status'] == 'failed') {
|
2022-08-18 13:49:41 +12:00
|
|
|
$failures++;
|
2022-11-15 22:33:07 +13:00
|
|
|
} elseif ($execution['body']['status'] == 'completed') {
|
|
|
|
$executions++;
|
|
|
|
}
|
|
|
|
$executionTime += (int) ($execution['body']['duration'] * 1000);
|
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$execution = $this->client->call(
|
|
|
|
Client::METHOD_POST,
|
|
|
|
'/functions/' . $functionId . '/executions',
|
|
|
|
$headers,
|
|
|
|
[
|
2023-08-05 07:15:32 +12:00
|
|
|
'async' => true,
|
2022-12-16 06:00:05 +13:00
|
|
|
]
|
|
|
|
);
|
2022-11-15 22:33:07 +13:00
|
|
|
|
2022-11-15 22:41:55 +13:00
|
|
|
$this->assertEquals(202, $execution['headers']['status-code']);
|
2022-11-15 22:33:07 +13:00
|
|
|
$this->assertNotEmpty($execution['body']['$id']);
|
|
|
|
$this->assertEquals($functionId, $execution['body']['functionId']);
|
|
|
|
|
2022-12-15 20:56:06 +13:00
|
|
|
sleep(self::WAIT);
|
2022-11-15 22:33:07 +13:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$execution = $this->client->call(
|
|
|
|
Client::METHOD_GET,
|
|
|
|
'/functions/' . $functionId . '/executions/' . $execution['body']['$id'],
|
|
|
|
$headers
|
|
|
|
);
|
2022-11-15 22:33:07 +13:00
|
|
|
|
|
|
|
if ($execution['body']['status'] == 'failed') {
|
|
|
|
$failures++;
|
2022-08-18 17:13:30 +12:00
|
|
|
} elseif ($execution['body']['status'] == 'completed') {
|
2022-08-18 13:49:41 +12:00
|
|
|
$executions++;
|
|
|
|
}
|
2022-12-15 22:45:43 +13:00
|
|
|
|
2022-09-10 09:47:24 +12:00
|
|
|
$executionTime += (int) ($execution['body']['duration'] * 1000);
|
2022-07-17 21:33:24 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
return array_merge($data, [
|
2022-09-10 05:16:22 +12:00
|
|
|
'functionId' => $functionId,
|
|
|
|
'executionTime' => $executionTime,
|
|
|
|
'executions' => $executions,
|
|
|
|
'failures' => $failures,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @depends testPrepareFunctionsStats */
|
|
|
|
public function testFunctionsStats(array $data): void
|
|
|
|
{
|
|
|
|
$functionId = $data['functionId'];
|
|
|
|
$executionTime = $data['executionTime'];
|
|
|
|
$executions = $data['executions'];
|
|
|
|
|
2022-12-15 20:56:06 +13:00
|
|
|
sleep(self::WAIT);
|
2022-07-10 14:12:49 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$response = $this->client->call(
|
|
|
|
Client::METHOD_GET,
|
|
|
|
'/functions/' . $functionId . '/usage?range=30d',
|
|
|
|
$data['consoleHeaders']
|
|
|
|
);
|
2022-07-10 14:12:49 +12:00
|
|
|
|
2022-07-17 22:30:58 +12:00
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
2022-12-21 22:22:29 +13:00
|
|
|
$this->assertEquals(8, count($response['body']));
|
2022-07-17 22:30:58 +12:00
|
|
|
$this->assertEquals('30d', $response['body']['range']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertIsArray($response['body']['deploymentsTotal']);
|
2022-12-15 20:56:06 +13:00
|
|
|
$this->assertIsArray($response['body']['deploymentsStorage']);
|
2022-08-17 22:36:30 +12:00
|
|
|
$this->assertIsArray($response['body']['buildsTotal']);
|
|
|
|
$this->assertIsArray($response['body']['buildsTime']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertIsArray($response['body']['executionsTotal']);
|
|
|
|
$this->assertIsArray($response['body']['executionsTime']);
|
2022-07-10 14:12:49 +12:00
|
|
|
|
2022-07-17 21:33:24 +12:00
|
|
|
$response = $response['body'];
|
2022-07-10 14:12:49 +12:00
|
|
|
|
2022-08-17 22:36:30 +12:00
|
|
|
$this->assertEquals($executions, $response['executionsTotal'][array_key_last($response['executionsTotal'])]['value']);
|
2022-09-16 11:48:09 +12:00
|
|
|
$this->validateDates($response['executionsTotal']);
|
2022-08-18 12:36:25 +12:00
|
|
|
$this->assertEquals($executionTime, $response['executionsTime'][array_key_last($response['executionsTime'])]['value']);
|
2022-09-16 11:48:09 +12:00
|
|
|
$this->validateDates($response['executionsTime']);
|
2022-07-10 14:12:49 +12:00
|
|
|
|
2022-12-16 06:00:05 +13:00
|
|
|
$response = $this->client->call(
|
|
|
|
Client::METHOD_GET,
|
|
|
|
'/functions/usage?range=30d',
|
|
|
|
$data['consoleHeaders']
|
|
|
|
);
|
2022-07-17 22:30:58 +12:00
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
2022-08-17 22:36:30 +12:00
|
|
|
$this->assertEquals(9, count($response['body']));
|
2022-07-17 22:30:58 +12:00
|
|
|
$this->assertEquals($response['body']['range'], '30d');
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertIsArray($response['body']['functionsTotal']);
|
|
|
|
$this->assertIsArray($response['body']['deploymentsTotal']);
|
2022-12-15 20:56:06 +13:00
|
|
|
$this->assertIsArray($response['body']['deploymentsStorage']);
|
2022-08-17 22:36:30 +12:00
|
|
|
$this->assertIsArray($response['body']['buildsTotal']);
|
|
|
|
$this->assertIsArray($response['body']['buildsTime']);
|
2023-02-06 09:07:46 +13:00
|
|
|
$this->assertIsArray($response['body']['executionsTotal']);
|
|
|
|
$this->assertIsArray($response['body']['executionsTime']);
|
2022-12-15 20:56:06 +13:00
|
|
|
|
2022-07-17 22:30:58 +12:00
|
|
|
$response = $response['body'];
|
|
|
|
|
2022-08-17 22:36:30 +12:00
|
|
|
$this->assertEquals($executions, $response['executionsTotal'][array_key_last($response['executionsTotal'])]['value']);
|
2022-09-16 11:48:09 +12:00
|
|
|
$this->validateDates($response['executionsTotal']);
|
2022-08-17 22:36:30 +12:00
|
|
|
$this->assertEquals($executionTime, $response['executionsTime'][array_key_last($response['executionsTime'])]['value']);
|
2022-09-16 11:48:09 +12:00
|
|
|
$this->validateDates($response['executionsTime']);
|
2022-08-17 22:36:30 +12:00
|
|
|
$this->assertGreaterThan(0, $response['buildsTime'][array_key_last($response['buildsTime'])]['value']);
|
2022-09-16 11:48:09 +12:00
|
|
|
$this->validateDates($response['buildsTime']);
|
2022-08-17 22:36:30 +12:00
|
|
|
}
|
2022-07-27 20:28:23 +12:00
|
|
|
|
2022-12-21 22:22:29 +13:00
|
|
|
public function tearDown(): void
|
2022-07-27 20:28:23 +12:00
|
|
|
{
|
2023-08-05 07:15:32 +12:00
|
|
|
$this->projectId = '';
|
2022-07-27 20:28:23 +12:00
|
|
|
}
|
2022-06-30 21:40:27 +12:00
|
|
|
}
|