mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cf0010469 | ||
|
|
a0191908ee | ||
|
|
30f8d29f24 | ||
|
|
10ae233c27 | ||
|
|
ff9c9bd1dd | ||
|
|
8817bf4ba0 | ||
|
|
2ebdcd8147 | ||
|
|
edb69223b8 | ||
|
|
50d74fc84b | ||
|
|
5ac2864aff | ||
|
|
2c5776850e | ||
|
|
d7bd007564 | ||
|
|
740c88d43e | ||
|
|
a1218d5191 | ||
|
|
8f42cf747f |
Generated
+9
-8
@@ -753,16 +753,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "jean85/pretty-package-versions",
|
"name": "jean85/pretty-package-versions",
|
||||||
"version": "2.1.0",
|
"version": "2.1.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Jean85/pretty-package-versions.git",
|
"url": "https://github.com/Jean85/pretty-package-versions.git",
|
||||||
"reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10"
|
"reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/3c4e5f62ba8d7de1734312e4fff32f67a8daaf10",
|
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/4d7aa5dab42e2a76d99559706022885de0e18e1a",
|
||||||
"reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10",
|
"reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -772,8 +772,9 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"friendsofphp/php-cs-fixer": "^3.2",
|
"friendsofphp/php-cs-fixer": "^3.2",
|
||||||
"jean85/composer-provided-replaced-stub-package": "^1.0",
|
"jean85/composer-provided-replaced-stub-package": "^1.0",
|
||||||
"phpstan/phpstan": "^1.4",
|
"phpstan/phpstan": "^2.0",
|
||||||
"phpunit/phpunit": "^7.5|^8.5|^9.6",
|
"phpunit/phpunit": "^7.5|^8.5|^9.6",
|
||||||
|
"rector/rector": "^2.0",
|
||||||
"vimeo/psalm": "^4.3 || ^5.0"
|
"vimeo/psalm": "^4.3 || ^5.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
@@ -806,9 +807,9 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/Jean85/pretty-package-versions/issues",
|
"issues": "https://github.com/Jean85/pretty-package-versions/issues",
|
||||||
"source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.0"
|
"source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.1"
|
||||||
},
|
},
|
||||||
"time": "2024-11-18T16:19:46+00:00"
|
"time": "2025-03-19T14:43:43+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "league/csv",
|
"name": "league/csv",
|
||||||
@@ -8403,7 +8404,7 @@
|
|||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": {},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class CompressionTest extends Scope
|
|||||||
], $this->getHeaders()));
|
], $this->getHeaders()));
|
||||||
|
|
||||||
$this->assertEquals(200, $response['headers']['status-code']);
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
$this->assertArrayHasKey('content-encoding', $response['headers'], 'Content encoding should be gzip, headers received: ' . json_encode($response['headers'], JSON_PRETTY_PRINT));
|
$this->assertArrayHasKey('content-encoding', $response['headers'], '`Content-Encoding` should be gzip, instead received response: ' . json_encode($response, JSON_PRETTY_PRINT));
|
||||||
$this->assertLessThan(2000, intval($response['headers']['content-length']));
|
$this->assertLessThan(2000, intval($response['headers']['content-length']));
|
||||||
|
|
||||||
// get prefs without compression
|
// get prefs without compression
|
||||||
@@ -116,7 +116,7 @@ class CompressionTest extends Scope
|
|||||||
]);
|
]);
|
||||||
$fileId = $file['body']['$id'];
|
$fileId = $file['body']['$id'];
|
||||||
|
|
||||||
// get image with header
|
// get image with accept header
|
||||||
$response = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $fileId, array_merge([
|
$response = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $fileId, array_merge([
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'accept-encoding' => 'gzip',
|
'accept-encoding' => 'gzip',
|
||||||
@@ -125,7 +125,8 @@ class CompressionTest extends Scope
|
|||||||
|
|
||||||
$this->assertEquals(200, $response['headers']['status-code']);
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
$this->assertArrayNotHasKey('content-encoding', $response['headers']);
|
$this->assertArrayNotHasKey('content-encoding', $response['headers']);
|
||||||
// get image without
|
|
||||||
|
// get image without accept header
|
||||||
$response = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $fileId, array_merge([
|
$response = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $fileId, array_merge([
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
|||||||
+185
-171
@@ -3,10 +3,8 @@
|
|||||||
namespace Tests\E2E\General;
|
namespace Tests\E2E\General;
|
||||||
|
|
||||||
use Appwrite\Functions\Specification;
|
use Appwrite\Functions\Specification;
|
||||||
use Appwrite\Tests\Retry;
|
|
||||||
use CURLFile;
|
use CURLFile;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use PHPUnit\Framework\ExpectationFailedException;
|
|
||||||
use Tests\E2E\Client;
|
use Tests\E2E\Client;
|
||||||
use Tests\E2E\Scopes\ProjectCustom;
|
use Tests\E2E\Scopes\ProjectCustom;
|
||||||
use Tests\E2E\Scopes\Scope;
|
use Tests\E2E\Scopes\Scope;
|
||||||
@@ -23,8 +21,8 @@ class UsageTest extends Scope
|
|||||||
use SideServer;
|
use SideServer;
|
||||||
use FunctionsBase;
|
use FunctionsBase;
|
||||||
|
|
||||||
private const WAIT = 5;
|
private const WAIT = 5; //
|
||||||
private const CREATE = 20;
|
private const RESOURCE_COUNT = 10; // Number of resources to create for each test
|
||||||
|
|
||||||
protected string $projectId;
|
protected string $projectId;
|
||||||
|
|
||||||
@@ -77,7 +75,7 @@ class UsageTest extends Scope
|
|||||||
$usersTotal = 0;
|
$usersTotal = 0;
|
||||||
$requestsTotal = 0;
|
$requestsTotal = 0;
|
||||||
|
|
||||||
for ($i = 0; $i < self::CREATE; $i++) {
|
for ($i = 0; $i < self::RESOURCE_COUNT; $i++) {
|
||||||
$params = [
|
$params = [
|
||||||
'userId' => 'unique()',
|
'userId' => 'unique()',
|
||||||
'email' => uniqid() . 'user@usage.test',
|
'email' => uniqid() . 'user@usage.test',
|
||||||
@@ -102,7 +100,7 @@ class UsageTest extends Scope
|
|||||||
$usersTotal += 1;
|
$usersTotal += 1;
|
||||||
$requestsTotal += 1;
|
$requestsTotal += 1;
|
||||||
|
|
||||||
if ($i < (self::CREATE / 2)) {
|
if ($i < (self::RESOURCE_COUNT / 2)) {
|
||||||
$userId = $response['body']['$id'];
|
$userId = $response['body']['$id'];
|
||||||
|
|
||||||
$response = $this->client->call(
|
$response = $this->client->call(
|
||||||
@@ -131,40 +129,43 @@ class UsageTest extends Scope
|
|||||||
/**
|
/**
|
||||||
* @depends testPrepareUsersStats
|
* @depends testPrepareUsersStats
|
||||||
*/
|
*/
|
||||||
#[Retry(count: 1)]
|
|
||||||
public function testUsersStats(array $data): array
|
public function testUsersStats(array $data): array
|
||||||
{
|
{
|
||||||
$requestsTotal = $data['requestsTotal'];
|
$requestsTotal = $data['requestsTotal'];
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEventually(function () use ($data) {
|
||||||
Client::METHOD_GET,
|
$response = $this->client->call(
|
||||||
'/project/usage',
|
Client::METHOD_GET,
|
||||||
$this->getConsoleHeaders(),
|
'/project/usage',
|
||||||
[
|
$this->getConsoleHeaders(),
|
||||||
'period' => '1h',
|
[
|
||||||
'startDate' => self::getToday(),
|
'period' => '1h',
|
||||||
'endDate' => self::getTomorrow(),
|
'startDate' => self::getToday(),
|
||||||
]
|
'endDate' => self::getTomorrow(),
|
||||||
);
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$this->assertEquals(200, $response['headers']['status-code']);
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
$this->assertEquals(31, count($response['body']));
|
$this->assertEquals(31, count($response['body']));
|
||||||
$this->validateDates($response['body']['network']);
|
$this->validateDates($response['body']['network']);
|
||||||
$this->validateDates($response['body']['requests']);
|
$this->validateDates($response['body']['requests']);
|
||||||
$this->validateDates($response['body']['users']);
|
$this->validateDates($response['body']['users']);
|
||||||
$this->assertArrayHasKey('executionsBreakdown', $response['body']);
|
$this->assertArrayHasKey('executionsBreakdown', $response['body']);
|
||||||
$this->assertArrayHasKey('bucketsBreakdown', $response['body']);
|
$this->assertArrayHasKey('bucketsBreakdown', $response['body']);
|
||||||
|
});
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEventually(function () {
|
||||||
Client::METHOD_GET,
|
$response = $this->client->call(
|
||||||
'/users/usage?range=90d',
|
Client::METHOD_GET,
|
||||||
$this->getConsoleHeaders()
|
'/users/usage?range=90d',
|
||||||
);
|
$this->getConsoleHeaders()
|
||||||
|
);
|
||||||
|
|
||||||
$this->assertEquals('90d', $response['body']['range']);
|
$this->assertEquals('90d', $response['body']['range']);
|
||||||
$this->assertEquals(90, count($response['body']['users']));
|
$this->assertEquals(90, count($response['body']['users']));
|
||||||
$this->assertEquals(90, count($response['body']['sessions']));
|
$this->assertEquals(90, count($response['body']['sessions']));
|
||||||
$this->assertEquals((self::CREATE / 2), $response['body']['users'][array_key_last($response['body']['users'])]['value']);
|
$this->assertEquals((self::RESOURCE_COUNT / 2), $response['body']['users'][array_key_last($response['body']['users'])]['value']);
|
||||||
|
});
|
||||||
|
|
||||||
return array_merge($data, [
|
return array_merge($data, [
|
||||||
'requestsTotal' => $requestsTotal
|
'requestsTotal' => $requestsTotal
|
||||||
@@ -180,7 +181,7 @@ class UsageTest extends Scope
|
|||||||
$storageTotal = 0;
|
$storageTotal = 0;
|
||||||
$filesTotal = 0;
|
$filesTotal = 0;
|
||||||
|
|
||||||
for ($i = 0; $i < self::CREATE; $i++) {
|
for ($i = 0; $i < self::RESOURCE_COUNT; $i++) {
|
||||||
$name = uniqid() . ' bucket';
|
$name = uniqid() . ' bucket';
|
||||||
|
|
||||||
$response = $this->client->call(
|
$response = $this->client->call(
|
||||||
@@ -212,7 +213,7 @@ class UsageTest extends Scope
|
|||||||
|
|
||||||
$bucketId = $response['body']['$id'];
|
$bucketId = $response['body']['$id'];
|
||||||
|
|
||||||
if ($i < (self::CREATE / 2)) {
|
if ($i < (self::RESOURCE_COUNT / 2)) {
|
||||||
$response = $this->client->call(
|
$response = $this->client->call(
|
||||||
Client::METHOD_DELETE,
|
Client::METHOD_DELETE,
|
||||||
'/storage/buckets/' . $bucketId,
|
'/storage/buckets/' . $bucketId,
|
||||||
@@ -250,7 +251,7 @@ class UsageTest extends Scope
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
for ($i = 0; $i < self::CREATE; $i++) {
|
for ($i = 0; $i < self::RESOURCE_COUNT; $i++) {
|
||||||
$file = $files[$i % count($files)];
|
$file = $files[$i % count($files)];
|
||||||
|
|
||||||
$response = $this->client->call(
|
$response = $this->client->call(
|
||||||
@@ -277,7 +278,7 @@ class UsageTest extends Scope
|
|||||||
|
|
||||||
$fileId = $response['body']['$id'];
|
$fileId = $response['body']['$id'];
|
||||||
|
|
||||||
if ($i < (self::CREATE / 2)) {
|
if ($i < (self::RESOURCE_COUNT / 2)) {
|
||||||
$response = $this->client->call(
|
$response = $this->client->call(
|
||||||
Client::METHOD_DELETE,
|
Client::METHOD_DELETE,
|
||||||
'/storage/buckets/' . $bucketId . '/files/' . $fileId,
|
'/storage/buckets/' . $bucketId . '/files/' . $fileId,
|
||||||
@@ -307,7 +308,6 @@ class UsageTest extends Scope
|
|||||||
/**
|
/**
|
||||||
* @depends testPrepareStorageStats
|
* @depends testPrepareStorageStats
|
||||||
*/
|
*/
|
||||||
#[Retry(count: 10)]
|
|
||||||
public function testStorageStats(array $data): array
|
public function testStorageStats(array $data): array
|
||||||
{
|
{
|
||||||
$bucketId = $data['bucketId'];
|
$bucketId = $data['bucketId'];
|
||||||
@@ -316,44 +316,50 @@ class UsageTest extends Scope
|
|||||||
$storageTotal = $data['storageTotal'];
|
$storageTotal = $data['storageTotal'];
|
||||||
$filesTotal = $data['filesTotal'];
|
$filesTotal = $data['filesTotal'];
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEventually(function () use ($requestsTotal, $storageTotal) {
|
||||||
Client::METHOD_GET,
|
$response = $this->client->call(
|
||||||
'/project/usage',
|
Client::METHOD_GET,
|
||||||
$this->getConsoleHeaders(),
|
'/project/usage',
|
||||||
[
|
$this->getConsoleHeaders(),
|
||||||
'period' => '1d',
|
[
|
||||||
'startDate' => self::getToday(),
|
'period' => '1d',
|
||||||
'endDate' => self::getTomorrow(),
|
'startDate' => self::getToday(),
|
||||||
]
|
'endDate' => self::getTomorrow(),
|
||||||
);
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$this->assertEquals(31, count($response['body']));
|
$this->assertEquals(31, count($response['body']));
|
||||||
$this->assertEquals(1, count($response['body']['requests']));
|
$this->assertEquals(1, count($response['body']['requests']));
|
||||||
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
|
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
|
||||||
$this->validateDates($response['body']['requests']);
|
$this->validateDates($response['body']['requests']);
|
||||||
$this->assertEquals($storageTotal, $response['body']['filesStorageTotal']);
|
$this->assertEquals($storageTotal, $response['body']['filesStorageTotal']);
|
||||||
|
});
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEventually(function () use ($bucketsTotal, $storageTotal, $filesTotal) {
|
||||||
Client::METHOD_GET,
|
$response = $this->client->call(
|
||||||
'/storage/usage?range=30d',
|
Client::METHOD_GET,
|
||||||
$this->getConsoleHeaders()
|
'/storage/usage?range=30d',
|
||||||
);
|
$this->getConsoleHeaders()
|
||||||
|
);
|
||||||
|
|
||||||
$this->assertEquals($storageTotal, $response['body']['storage'][array_key_last($response['body']['storage'])]['value']);
|
$this->assertEquals($storageTotal, $response['body']['storage'][array_key_last($response['body']['storage'])]['value']);
|
||||||
$this->validateDates($response['body']['storage']);
|
$this->validateDates($response['body']['storage']);
|
||||||
$this->assertEquals($bucketsTotal, $response['body']['buckets'][array_key_last($response['body']['buckets'])]['value']);
|
$this->assertEquals($bucketsTotal, $response['body']['buckets'][array_key_last($response['body']['buckets'])]['value']);
|
||||||
$this->validateDates($response['body']['buckets']);
|
$this->validateDates($response['body']['buckets']);
|
||||||
$this->assertEquals($filesTotal, $response['body']['files'][array_key_last($response['body']['files'])]['value']);
|
$this->assertEquals($filesTotal, $response['body']['files'][array_key_last($response['body']['files'])]['value']);
|
||||||
$this->validateDates($response['body']['files']);
|
$this->validateDates($response['body']['files']);
|
||||||
|
});
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEventually(function () use ($bucketId, $storageTotal, $filesTotal) {
|
||||||
Client::METHOD_GET,
|
$response = $this->client->call(
|
||||||
'/storage/' . $bucketId . '/usage?range=30d',
|
Client::METHOD_GET,
|
||||||
$this->getConsoleHeaders()
|
'/storage/' . $bucketId . '/usage?range=30d',
|
||||||
);
|
$this->getConsoleHeaders()
|
||||||
|
);
|
||||||
|
|
||||||
$this->assertEquals($storageTotal, $response['body']['storage'][array_key_last($response['body']['storage'])]['value']);
|
$this->assertEquals($storageTotal, $response['body']['storage'][array_key_last($response['body']['storage'])]['value']);
|
||||||
$this->assertEquals($filesTotal, $response['body']['files'][array_key_last($response['body']['files'])]['value']);
|
$this->assertEquals($filesTotal, $response['body']['files'][array_key_last($response['body']['files'])]['value']);
|
||||||
|
});
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@@ -367,7 +373,7 @@ class UsageTest extends Scope
|
|||||||
$collectionsTotal = 0;
|
$collectionsTotal = 0;
|
||||||
$documentsTotal = 0;
|
$documentsTotal = 0;
|
||||||
|
|
||||||
for ($i = 0; $i < self::CREATE; $i++) {
|
for ($i = 0; $i < self::RESOURCE_COUNT; $i++) {
|
||||||
$name = uniqid() . ' database';
|
$name = uniqid() . ' database';
|
||||||
|
|
||||||
$response = $this->client->call(
|
$response = $this->client->call(
|
||||||
@@ -391,7 +397,7 @@ class UsageTest extends Scope
|
|||||||
|
|
||||||
$databaseId = $response['body']['$id'];
|
$databaseId = $response['body']['$id'];
|
||||||
|
|
||||||
if ($i < (self::CREATE / 2)) {
|
if ($i < (self::RESOURCE_COUNT / 2)) {
|
||||||
$response = $this->client->call(
|
$response = $this->client->call(
|
||||||
Client::METHOD_DELETE,
|
Client::METHOD_DELETE,
|
||||||
'/databases/' . $databaseId,
|
'/databases/' . $databaseId,
|
||||||
@@ -407,7 +413,7 @@ class UsageTest extends Scope
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < self::CREATE; $i++) {
|
for ($i = 0; $i < self::RESOURCE_COUNT; $i++) {
|
||||||
$name = uniqid() . ' collection';
|
$name = uniqid() . ' collection';
|
||||||
|
|
||||||
$response = $this->client->call(
|
$response = $this->client->call(
|
||||||
@@ -438,7 +444,7 @@ class UsageTest extends Scope
|
|||||||
|
|
||||||
$collectionId = $response['body']['$id'];
|
$collectionId = $response['body']['$id'];
|
||||||
|
|
||||||
if ($i < (self::CREATE / 2)) {
|
if ($i < (self::RESOURCE_COUNT / 2)) {
|
||||||
$response = $this->client->call(
|
$response = $this->client->call(
|
||||||
Client::METHOD_DELETE,
|
Client::METHOD_DELETE,
|
||||||
'/databases/' . $databaseId . '/collections/' . $collectionId,
|
'/databases/' . $databaseId . '/collections/' . $collectionId,
|
||||||
@@ -474,7 +480,7 @@ class UsageTest extends Scope
|
|||||||
|
|
||||||
$requestsTotal += 1;
|
$requestsTotal += 1;
|
||||||
|
|
||||||
for ($i = 0; $i < self::CREATE; $i++) {
|
for ($i = 0; $i < self::RESOURCE_COUNT; $i++) {
|
||||||
$name = uniqid() . ' collection';
|
$name = uniqid() . ' collection';
|
||||||
|
|
||||||
$response = $this->client->call(
|
$response = $this->client->call(
|
||||||
@@ -498,7 +504,7 @@ class UsageTest extends Scope
|
|||||||
|
|
||||||
$documentId = $response['body']['$id'];
|
$documentId = $response['body']['$id'];
|
||||||
|
|
||||||
if ($i < (self::CREATE / 2)) {
|
if ($i < (self::RESOURCE_COUNT / 2)) {
|
||||||
$response = $this->client->call(
|
$response = $this->client->call(
|
||||||
Client::METHOD_DELETE,
|
Client::METHOD_DELETE,
|
||||||
'/databases/' . $databaseId . '/collections/' . $collectionId . '/documents/' . $documentId,
|
'/databases/' . $databaseId . '/collections/' . $collectionId . '/documents/' . $documentId,
|
||||||
@@ -525,7 +531,6 @@ class UsageTest extends Scope
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testPrepareDatabaseStats */
|
/** @depends testPrepareDatabaseStats */
|
||||||
#[Retry(count: 1)]
|
|
||||||
public function testDatabaseStats(array $data): array
|
public function testDatabaseStats(array $data): array
|
||||||
{
|
{
|
||||||
$databaseId = $data['databaseId'];
|
$databaseId = $data['databaseId'];
|
||||||
@@ -535,60 +540,66 @@ class UsageTest extends Scope
|
|||||||
$collectionsTotal = $data['collectionsTotal'];
|
$collectionsTotal = $data['collectionsTotal'];
|
||||||
$documentsTotal = $data['documentsTotal'];
|
$documentsTotal = $data['documentsTotal'];
|
||||||
|
|
||||||
sleep(self::WAIT);
|
$this->assertEventually(function () use ($requestsTotal, $databasesTotal, $documentsTotal) {
|
||||||
|
$response = $this->client->call(
|
||||||
|
Client::METHOD_GET,
|
||||||
|
'/project/usage',
|
||||||
|
$this->getConsoleHeaders(),
|
||||||
|
[
|
||||||
|
'period' => '1d',
|
||||||
|
'startDate' => self::getToday(),
|
||||||
|
'endDate' => self::getTomorrow(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEquals(31, count($response['body']));
|
||||||
Client::METHOD_GET,
|
$this->assertEquals(1, count($response['body']['requests']));
|
||||||
'/project/usage',
|
$this->assertEquals(1, count($response['body']['network']));
|
||||||
$this->getConsoleHeaders(),
|
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
|
||||||
[
|
$this->validateDates($response['body']['requests']);
|
||||||
'period' => '1d',
|
$this->assertEquals($databasesTotal, $response['body']['databasesTotal']);
|
||||||
'startDate' => self::getToday(),
|
$this->assertEquals($documentsTotal, $response['body']['documentsTotal']);
|
||||||
'endDate' => self::getTomorrow(),
|
});
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals(31, count($response['body']));
|
$this->assertEventually(function () use ($databasesTotal, $collectionsTotal, $documentsTotal) {
|
||||||
$this->assertEquals(1, count($response['body']['requests']));
|
$response = $this->client->call(
|
||||||
$this->assertEquals(1, count($response['body']['network']));
|
Client::METHOD_GET,
|
||||||
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
|
'/databases/usage?range=30d',
|
||||||
$this->validateDates($response['body']['requests']);
|
$this->getConsoleHeaders()
|
||||||
$this->assertEquals($databasesTotal, $response['body']['databasesTotal']);
|
);
|
||||||
$this->assertEquals($documentsTotal, $response['body']['documentsTotal']);
|
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEquals($databasesTotal, $response['body']['databases'][array_key_last($response['body']['databases'])]['value']);
|
||||||
Client::METHOD_GET,
|
$this->validateDates($response['body']['databases']);
|
||||||
'/databases/usage?range=30d',
|
$this->assertEquals($collectionsTotal, $response['body']['collections'][array_key_last($response['body']['collections'])]['value']);
|
||||||
$this->getConsoleHeaders()
|
$this->validateDates($response['body']['collections']);
|
||||||
);
|
$this->assertEquals($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
|
||||||
|
$this->validateDates($response['body']['documents']);
|
||||||
|
});
|
||||||
|
|
||||||
$this->assertEquals($databasesTotal, $response['body']['databases'][array_key_last($response['body']['databases'])]['value']);
|
$this->assertEventually(function () use ($databaseId, $collectionsTotal, $documentsTotal) {
|
||||||
$this->validateDates($response['body']['databases']);
|
$response = $this->client->call(
|
||||||
$this->assertEquals($collectionsTotal, $response['body']['collections'][array_key_last($response['body']['collections'])]['value']);
|
Client::METHOD_GET,
|
||||||
$this->validateDates($response['body']['collections']);
|
'/databases/' . $databaseId . '/usage?range=30d',
|
||||||
$this->assertEquals($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
|
$this->getConsoleHeaders()
|
||||||
$this->validateDates($response['body']['documents']);
|
);
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEquals($collectionsTotal, $response['body']['collections'][array_key_last($response['body']['collections'])]['value']);
|
||||||
Client::METHOD_GET,
|
$this->validateDates($response['body']['collections']);
|
||||||
'/databases/' . $databaseId . '/usage?range=30d',
|
|
||||||
$this->getConsoleHeaders()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals($collectionsTotal, $response['body']['collections'][array_key_last($response['body']['collections'])]['value']);
|
$this->assertEquals($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
|
||||||
$this->validateDates($response['body']['collections']);
|
$this->validateDates($response['body']['documents']);
|
||||||
|
});
|
||||||
|
|
||||||
$this->assertEquals($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
|
$this->assertEventually(function () use ($databaseId, $collectionId, $documentsTotal) {
|
||||||
$this->validateDates($response['body']['documents']);
|
$response = $this->client->call(
|
||||||
|
Client::METHOD_GET,
|
||||||
|
'/databases/' . $databaseId . '/collections/' . $collectionId . '/usage?range=30d',
|
||||||
|
$this->getConsoleHeaders()
|
||||||
|
);
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEquals($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
|
||||||
Client::METHOD_GET,
|
$this->validateDates($response['body']['documents']);
|
||||||
'/databases/' . $databaseId . '/collections/' . $collectionId . '/usage?range=30d',
|
});
|
||||||
$this->getConsoleHeaders()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
|
|
||||||
$this->validateDates($response['body']['documents']);
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@@ -1010,62 +1021,65 @@ class UsageTest extends Scope
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testPrepareFunctionsStats */
|
/** @depends testPrepareFunctionsStats */
|
||||||
#[Retry(count: 1)]
|
|
||||||
public function testFunctionsStats(array $data): array
|
public function testFunctionsStats(array $data): array
|
||||||
{
|
{
|
||||||
$functionId = $data['functionId'];
|
$functionId = $data['functionId'];
|
||||||
$executionTime = $data['executionTime'];
|
$executionTime = $data['executionTime'];
|
||||||
$executions = $data['executions'];
|
$executions = $data['executions'];
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEventually(function () use ($functionId, $executionTime, $executions) {
|
||||||
Client::METHOD_GET,
|
$response = $this->client->call(
|
||||||
'/functions/' . $functionId . '/usage?range=30d',
|
Client::METHOD_GET,
|
||||||
$this->getConsoleHeaders()
|
'/functions/' . $functionId . '/usage?range=30d',
|
||||||
);
|
$this->getConsoleHeaders()
|
||||||
|
);
|
||||||
|
|
||||||
$this->assertEquals(200, $response['headers']['status-code']);
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
$this->assertEquals(19, count($response['body']));
|
$this->assertEquals(19, count($response['body']));
|
||||||
$this->assertEquals('30d', $response['body']['range']);
|
$this->assertEquals('30d', $response['body']['range']);
|
||||||
$this->assertIsArray($response['body']['deployments']);
|
$this->assertIsArray($response['body']['deployments']);
|
||||||
$this->assertIsArray($response['body']['deploymentsStorage']);
|
$this->assertIsArray($response['body']['deploymentsStorage']);
|
||||||
$this->assertIsNumeric($response['body']['deploymentsStorageTotal']);
|
$this->assertIsNumeric($response['body']['deploymentsStorageTotal']);
|
||||||
$this->assertIsNumeric($response['body']['buildsMbSecondsTotal']);
|
$this->assertIsNumeric($response['body']['buildsMbSecondsTotal']);
|
||||||
$this->assertIsNumeric($response['body']['executionsMbSecondsTotal']);
|
$this->assertIsNumeric($response['body']['executionsMbSecondsTotal']);
|
||||||
$this->assertIsArray($response['body']['builds']);
|
$this->assertIsArray($response['body']['builds']);
|
||||||
$this->assertIsArray($response['body']['buildsTime']);
|
$this->assertIsArray($response['body']['buildsTime']);
|
||||||
$this->assertIsArray($response['body']['buildsMbSeconds']);
|
$this->assertIsArray($response['body']['buildsMbSeconds']);
|
||||||
$this->assertIsArray($response['body']['executions']);
|
$this->assertIsArray($response['body']['executions']);
|
||||||
$this->assertIsArray($response['body']['executionsTime']);
|
$this->assertIsArray($response['body']['executionsTime']);
|
||||||
$this->assertIsArray($response['body']['executionsMbSeconds']);
|
$this->assertIsArray($response['body']['executionsMbSeconds']);
|
||||||
$this->assertEquals($executions, $response['body']['executions'][array_key_last($response['body']['executions'])]['value']);
|
$this->assertEquals($executions, $response['body']['executions'][array_key_last($response['body']['executions'])]['value']);
|
||||||
$this->validateDates($response['body']['executions']);
|
$this->validateDates($response['body']['executions']);
|
||||||
$this->assertEquals($executionTime, $response['body']['executionsTime'][array_key_last($response['body']['executionsTime'])]['value']);
|
$this->assertEquals($executionTime, $response['body']['executionsTime'][array_key_last($response['body']['executionsTime'])]['value']);
|
||||||
$this->validateDates($response['body']['executionsTime']);
|
$this->validateDates($response['body']['executionsTime']);
|
||||||
|
});
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEventually(function () use ($executionTime, $executions) {
|
||||||
Client::METHOD_GET,
|
$response = $this->client->call(
|
||||||
'/functions/usage?range=30d',
|
Client::METHOD_GET,
|
||||||
$this->getConsoleHeaders()
|
'/functions/usage?range=30d',
|
||||||
);
|
$this->getConsoleHeaders()
|
||||||
|
);
|
||||||
|
|
||||||
$this->assertEquals(200, $response['headers']['status-code']);
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
$this->assertEquals(21, count($response['body']));
|
$this->assertEquals(21, count($response['body']));
|
||||||
$this->assertEquals($response['body']['range'], '30d');
|
$this->assertEquals($response['body']['range'], '30d');
|
||||||
$this->assertIsArray($response['body']['functions']);
|
$this->assertIsArray($response['body']['functions']);
|
||||||
$this->assertIsArray($response['body']['deployments']);
|
$this->assertIsArray($response['body']['deployments']);
|
||||||
$this->assertIsArray($response['body']['deploymentsStorage']);
|
$this->assertIsArray($response['body']['deploymentsStorage']);
|
||||||
$this->assertIsArray($response['body']['builds']);
|
$this->assertIsArray($response['body']['builds']);
|
||||||
$this->assertIsArray($response['body']['buildsTime']);
|
$this->assertIsArray($response['body']['buildsTime']);
|
||||||
$this->assertIsArray($response['body']['buildsMbSeconds']);
|
$this->assertIsArray($response['body']['buildsMbSeconds']);
|
||||||
$this->assertIsArray($response['body']['executions']);
|
$this->assertIsArray($response['body']['executions']);
|
||||||
$this->assertIsArray($response['body']['executionsTime']);
|
$this->assertIsArray($response['body']['executionsTime']);
|
||||||
$this->assertIsArray($response['body']['executionsMbSeconds']);
|
$this->assertIsArray($response['body']['executionsMbSeconds']);
|
||||||
$this->assertEquals($executions, $response['body']['executions'][array_key_last($response['body']['executions'])]['value']);
|
$this->assertEquals($executions, $response['body']['executions'][array_key_last($response['body']['executions'])]['value']);
|
||||||
$this->validateDates($response['body']['executions']);
|
$this->validateDates($response['body']['executions']);
|
||||||
$this->assertEquals($executionTime, $response['body']['executionsTime'][array_key_last($response['body']['executionsTime'])]['value']);
|
$this->assertEquals($executionTime, $response['body']['executionsTime'][array_key_last($response['body']['executionsTime'])]['value']);
|
||||||
$this->validateDates($response['body']['executionsTime']);
|
$this->validateDates($response['body']['executionsTime']);
|
||||||
$this->assertGreaterThan(0, $response['body']['buildsTime'][array_key_last($response['body']['buildsTime'])]['value']);
|
$this->assertGreaterThan(0, $response['body']['buildsTime'][array_key_last($response['body']['buildsTime'])]['value']);
|
||||||
$this->validateDates($response['body']['buildsTime']);
|
$this->validateDates($response['body']['buildsTime']);
|
||||||
|
});
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1862,10 +1862,11 @@ class AccountCustomClientTest extends Scope
|
|||||||
'failure' => 'http://localhost/v1/mock/tests/general/oauth2/failure',
|
'failure' => 'http://localhost/v1/mock/tests/general/oauth2/failure',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$session = $response['cookies']['a_session_' . $this->getProject()['$id']];
|
|
||||||
|
|
||||||
$this->assertEquals(200, $response['headers']['status-code']);
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
$this->assertEquals('success', $response['body']['result']);
|
$this->assertEquals('success', $response['body']['result']);
|
||||||
|
$this->assertArrayHasKey('a_session_' . $this->getProject()['$id'], $response['cookies']);
|
||||||
|
|
||||||
|
$session = $response['cookies']['a_session_' . $this->getProject()['$id']];
|
||||||
|
|
||||||
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
|
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ trait FunctionsBase
|
|||||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||||
]));
|
]));
|
||||||
$this->assertEquals('ready', $deployment['body']['status'], 'Deployment status is not ready, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT));
|
$this->assertEquals('ready', $deployment['body']['status'], 'Deployment status is not ready, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT));
|
||||||
}, 50000, 500);
|
}, 120000, 1000);
|
||||||
|
|
||||||
return $deploymentId;
|
return $deploymentId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1926,7 +1926,7 @@ class FunctionsCustomServerTest extends Scope
|
|||||||
$this->assertEquals('completed', $execution['body']['status']);
|
$this->assertEquals('completed', $execution['body']['status']);
|
||||||
$this->assertEmpty($execution['body']['logs']);
|
$this->assertEmpty($execution['body']['logs']);
|
||||||
$this->assertEmpty($execution['body']['errors']);
|
$this->assertEmpty($execution['body']['errors']);
|
||||||
}, 10000, 500);
|
}, 20000, 1000);
|
||||||
|
|
||||||
// Domain Executions test
|
// Domain Executions test
|
||||||
$rules = $this->client->call(Client::METHOD_GET, '/proxy/rules', array_merge([
|
$rules = $this->client->call(Client::METHOD_GET, '/proxy/rules', array_merge([
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\E2E\Services\Storage;
|
namespace Tests\E2E\Services\Storage;
|
||||||
|
|
||||||
|
use Appwrite\Tests\Async;
|
||||||
use Tests\E2E\Client;
|
use Tests\E2E\Client;
|
||||||
use Tests\E2E\Scopes\ProjectCustom;
|
use Tests\E2E\Scopes\ProjectCustom;
|
||||||
use Tests\E2E\Scopes\Scope;
|
use Tests\E2E\Scopes\Scope;
|
||||||
@@ -16,6 +17,7 @@ class StorageCustomServerTest extends Scope
|
|||||||
use StorageBase;
|
use StorageBase;
|
||||||
use ProjectCustom;
|
use ProjectCustom;
|
||||||
use SideServer;
|
use SideServer;
|
||||||
|
use Async;
|
||||||
|
|
||||||
public function testCreateBucket(): array
|
public function testCreateBucket(): array
|
||||||
{
|
{
|
||||||
@@ -286,18 +288,21 @@ class StorageCustomServerTest extends Scope
|
|||||||
$this->assertEquals(204, $response['headers']['status-code']);
|
$this->assertEquals(204, $response['headers']['status-code']);
|
||||||
$this->assertEmpty($response['body']);
|
$this->assertEmpty($response['body']);
|
||||||
|
|
||||||
$response = $this->client->call(
|
$this->assertEventually(function () use ($id) {
|
||||||
Client::METHOD_GET,
|
$response = $this->client->call(
|
||||||
'/storage/buckets/' . $id,
|
Client::METHOD_GET,
|
||||||
array_merge(
|
'/storage/buckets/' . $id,
|
||||||
[
|
array_merge(
|
||||||
'content-type' => 'application/json',
|
[
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'content-type' => 'application/json',
|
||||||
],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
$this->getHeaders()
|
],
|
||||||
)
|
$this->getHeaders()
|
||||||
);
|
)
|
||||||
$this->assertEquals(404, $response['headers']['status-code']);
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(404, $response['headers']['status-code']);
|
||||||
|
});
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\E2E\Services\Teams;
|
namespace Tests\E2E\Services\Teams;
|
||||||
|
|
||||||
|
use Appwrite\Tests\Async;
|
||||||
use Tests\E2E\Client;
|
use Tests\E2E\Client;
|
||||||
use Utopia\Database\Document;
|
use Utopia\Database\Document;
|
||||||
use Utopia\Database\Helpers\ID;
|
use Utopia\Database\Helpers\ID;
|
||||||
@@ -10,6 +11,8 @@ use Utopia\Database\Validator\Datetime as DatetimeValidator;
|
|||||||
|
|
||||||
trait TeamsBase
|
trait TeamsBase
|
||||||
{
|
{
|
||||||
|
use Async;
|
||||||
|
|
||||||
public function testCreateTeam(): array
|
public function testCreateTeam(): array
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -379,12 +382,15 @@ trait TeamsBase
|
|||||||
/**
|
/**
|
||||||
* Test for FAILURE
|
* Test for FAILURE
|
||||||
*/
|
*/
|
||||||
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid, array_merge([
|
$this->assertEventually(function () use ($teamUid) {
|
||||||
'content-type' => 'application/json',
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid, array_merge([
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'content-type' => 'application/json',
|
||||||
], $this->getHeaders()));
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()));
|
||||||
|
|
||||||
|
$this->assertEquals(404, $response['headers']['status-code']);
|
||||||
|
});
|
||||||
|
|
||||||
$this->assertEquals(404, $response['headers']['status-code']);
|
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user