Compare commits

...
Author SHA1 Message Date
Luke B. SilverandGitHub 7cf0010469 Merge branch '1.6.x' into test-fix-cloud 2025-03-21 10:49:30 +00:00
Christy JacobandGitHub 50e7986f84 Merge pull request #9547 from appwrite/fix-audit-deletion
chore: fix console audits delete
2025-03-21 15:23:06 +05:30
Christy JacobandGitHub c7301af18a Merge pull request #9525 from appwrite/pla-2676
chore: stop tests on failure
2025-03-21 15:15:09 +05:30
Chirag Aggarwal c0c0c921dc chore: fix naming 2025-03-21 08:08:30 +00:00
Chirag Aggarwal 7c795da72f chore: fix type 2025-03-21 07:48:50 +00:00
Chirag Aggarwal 13750f7dbd feat: introduce new env 2025-03-21 07:42:10 +00:00
loks0n a0191908ee fix: transaction commit 2025-03-20 16:05:34 +00:00
loks0n 30f8d29f24 fix: transaction commit 2025-03-20 15:24:19 +00:00
loks0n 10ae233c27 test: fix delete timeout tests 2025-03-20 13:46:06 +00:00
Chirag Aggarwal b0b57935da chore: add comments 2025-03-20 13:42:19 +00:00
Chirag Aggarwal 7c3f8504bb chore: fix initialization 2025-03-20 13:15:14 +00:00
loks0n ff9c9bd1dd chore: revert manual purge 2025-03-20 12:32:52 +00:00
loks0n 8817bf4ba0 fix: invalidate user cache 2025-03-20 11:59:23 +00:00
Chirag Aggarwal 9d82892219 chore: update logic 2025-03-20 11:32:06 +00:00
loks0n 2ebdcd8147 test: more deployment wait 2025-03-20 11:02:06 +00:00
loks0n edb69223b8 test: more deployment wait 2025-03-20 10:58:14 +00:00
Chirag Aggarwal 5eb7c36f50 chore: add console audit retention 2025-03-20 10:32:36 +00:00
loks0n 50d74fc84b debug: remove sleep 2025-03-20 10:04:28 +00:00
loks0n 5ac2864aff Merge branch '1.6.x' of https://github.com/appwrite/appwrite into test-fix-cloud 2025-03-20 10:01:13 +00:00
Jake BarnbyandGitHub 9345025ade Merge pull request #9546 from appwrite/feat-improve-maintenance
Use cursor pagination with bigger limit for maintenance project loop
2025-03-20 02:51:31 +00:00
Jake Barnby 31ca35782b Use cursor pagination with bigger limit for maintenance project loop 2025-03-20 15:21:24 +13:00
Christy JacobandGitHub 2505e25da8 Merge pull request #9430 from appwrite/updates-projects-regions
Remove default region
2025-03-19 22:36:30 +05:30
shimon 88d6150db2 revert 2025-03-19 10:29:18 +02:00
shimon faed019d92 revert 2025-03-19 09:32:48 +02:00
shimon b318c2cc08 Merge branch '1.6.x' of github.com:appwrite/appwrite into updates-projects-regions 2025-03-18 21:54:55 +02:00
shimon eb4340cf4c revert 2025-03-18 21:49:28 +02:00
shimon ee09e2c91b revert 2025-03-18 21:47:54 +02:00
shimon e6e7c5c816 revert 2025-03-18 21:44:34 +02:00
shimon e9841e53b9 revert 2025-03-18 21:40:46 +02:00
Eldad A. FuxandGitHub 7d86ce76d8 Merge pull request #9536 from appwrite/pla-2687
chore: set min operations to 1 for reads and writes
2025-03-18 16:30:52 +01:00
Chirag Aggarwal aab8bca91e fix: logic 2025-03-18 14:20:25 +00:00
Chirag Aggarwal 70e27748be chore: set min operations to 1 for reads and writes 2025-03-18 12:52:41 +00:00
Jake BarnbyandGitHub 556e00b62b Merge pull request #9526 from appwrite/feat-disable-pdo-persist
Disable PDO persistence since we manage our own pool
2025-03-18 12:19:58 +00:00
Christy JacobandGitHub 370a8e231c Merge pull request #9530 from appwrite/PLA-2662
feat: add pool telemetry
2025-03-18 14:44:52 +05:30
Fabian Gruber aa5ea7f3a1 feat: add pool telemetry 2025-03-18 10:01:06 +01:00
Jake BarnbyandGitHub 8a77eaf2bb Merge pull request #9529 from appwrite/feat-migration-read-db
Migration read from db
2025-03-18 08:01:07 +00:00
Jake Barnby fe308b4f1f Update lib 2025-03-18 20:49:19 +13:00
Jake Barnby e43a3109eb Update migration lib 2025-03-18 20:05:12 +13:00
Jake Barnby d9fbe9658d Merge branch '1.6.x' into feat-migration-read-db 2025-03-18 20:04:23 +13:00
Jake BarnbyandGitHub 1e2f5bcb84 Merge branch '1.6.x' into feat-disable-pdo-persist 2025-03-18 07:02:54 +00:00
Christy JacobandGitHub 088d0998cd Merge pull request #9514 from appwrite/feat-domains-count
Feat: domains count
2025-03-18 11:03:45 +05:30
Jake Barnby a7165e6a32 Disable PDO persistence since we manage our own pool 2025-03-18 16:51:00 +13:00
Chirag Aggarwal 5f7ceecb30 chore: stop tests on failure 2025-03-18 03:46:14 +00:00
shimon e5261e7d70 _app_region 2025-03-17 18:31:14 +02:00
loks0n 2c5776850e debug: add sleep to compression test 2025-03-17 16:23:33 +00:00
loks0n d7bd007564 debug: add sleep to compression test 2025-03-17 16:18:07 +00:00
shimon 60912cb084 _app_region 2025-03-17 18:14:58 +02:00
shimon 7149deeacb _app_region 2025-03-17 18:11:49 +02:00
shimon 59f613f9bb _app_region 2025-03-17 17:33:48 +02:00
shimon 8184bc8c78 _app_region 2025-03-17 17:31:24 +02:00
loks0n 740c88d43e chore: fmt 2025-03-17 15:03:17 +00:00
loks0n a1218d5191 fix: invalidate cache after prefs set 2025-03-17 13:08:14 +00:00
loks0n 8f42cf747f test: refactor usagetest, compression test log 2025-03-17 12:36:27 +00:00
shimon 9cb860d446 _app_region 2025-03-17 13:52:17 +02:00
shimon 6eff011100 Merge branch '1.6.x' of github.com:appwrite/appwrite into updates-projects-regions
# Conflicts:
#	app/views/install/compose.phtml
2025-03-17 13:29:22 +02:00
Damodar LohaniandGitHub 8fd877810d Merge branch '1.6.x' into feat-domains-count 2025-03-17 12:49:59 +05:45
Jake Barnby 04711d8c02 Add doc 2025-03-17 19:21:31 +13:00
Damodar Lohani 4eece99768 Feat: domains count 2025-03-16 02:35:10 +00:00
shimon d6e53d8e2e Merge branch '1.6.x' of github.com:appwrite/appwrite into updates-projects-regions 2025-03-11 11:17:18 +02:00
shimon 2a5b3317bf update region 2025-03-04 11:36:45 +02:00
shimon 19ad2088a0 update region 2025-03-04 10:08:07 +02:00
28 changed files with 342 additions and 368 deletions
+1
View File
@@ -86,6 +86,7 @@ _APP_MAINTENANCE_RETENTION_CACHE=2592000
_APP_MAINTENANCE_RETENTION_EXECUTION=1209600
_APP_MAINTENANCE_RETENTION_ABUSE=86400
_APP_MAINTENANCE_RETENTION_AUDIT=1209600
_APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE=15778800
_APP_USAGE_AGGREGATION_INTERVAL=30
_APP_STATS_RESOURCES_INTERVAL=3600
_APP_MAINTENANCE_RETENTION_USAGE_HOURLY=8640000
+1 -65
View File
@@ -3,72 +3,8 @@
return [
'default' => [
'$id' => 'default',
'name' => 'Frankfurt',
'name' => 'default',
'disabled' => false,
'flag' => 'de',
'default' => true,
],
'fra' => [
'$id' => 'fra',
'name' => 'Frankfurt',
'disabled' => false,
'flag' => 'de',
'default' => true,
],
'nyc' => [
'$id' => 'nyc',
'name' => 'New York',
'disabled' => true,
'flag' => 'us',
'default' => true,
],
'sfo' => [
'$id' => 'sfo',
'name' => 'San Francisco',
'disabled' => true,
'flag' => 'us',
'default' => true,
],
'blr' => [
'$id' => 'blr',
'name' => 'Bengaluru',
'disabled' => true,
'flag' => 'in',
'default' => true,
],
'lon' => [
'$id' => 'lon',
'name' => 'London',
'disabled' => true,
'flag' => 'gb',
'default' => true,
],
'ams' => [
'$id' => 'ams',
'name' => 'Amsterdam',
'disabled' => true,
'flag' => 'nl',
'default' => true,
],
'sgp' => [
'$id' => 'sgp',
'name' => 'Singapore',
'disabled' => true,
'flag' => 'sg',
'default' => true,
],
'tor' => [
'$id' => 'tor',
'name' => 'Toronto',
'disabled' => true,
'flag' => 'ca',
'default' => true,
],
'syd' => [
'$id' => 'syd',
'name' => 'Sydney',
'disabled' => true,
'flag' => 'au',
'default' => true,
],
];
+10 -1
View File
@@ -1048,13 +1048,22 @@ return [
],
[
'name' => '_APP_MAINTENANCE_RETENTION_AUDIT',
'description' => 'IThe maximum duration (in seconds) upto which to retain audit logs. The default value is 1209600 seconds (14 days).',
'description' => 'The maximum duration (in seconds) upto which to retain audit logs. The default value is 1209600 seconds (14 days).',
'introduction' => '0.7.0',
'default' => '1209600',
'required' => false,
'question' => '',
'filter' => ''
],
[
'name' => '_APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE',
'description' => 'The maximum duration (in seconds) upto which to retain console audit logs. The default value is 15778800 seconds (6 months).',
'introduction' => '1.6.2',
'default' => '15778800',
'required' => false,
'question' => '',
'filter' => ''
],
[
'name' => '_APP_MAINTENANCE_RETENTION_ABUSE',
'description' => 'The maximum duration (in seconds) upto which to retain abuse logs. The default value is 86400 seconds (1 day).',
+4 -4
View File
@@ -3355,7 +3355,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
$processDocument($collection, $document);
$queueForStatsUsage
->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, $operations)
->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, max($operations, 1))
->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_WRITES), $operations)
->addMetric(str_replace(['{databaseInternalId}', '{collectionInternalId}'], [$database->getInternalId(), $collection->getInternalId()], METRIC_DATABASE_ID_COLLECTION_ID_STORAGE), 1); // per collection
@@ -3520,7 +3520,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
}
$queueForStatsUsage
->addMetric(METRIC_DATABASES_OPERATIONS_READS, $operations)
->addMetric(METRIC_DATABASES_OPERATIONS_READS, max($operations, 1))
->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_READS), $operations);
$response->addHeader('X-Debug-Operations', $operations);
@@ -3661,7 +3661,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen
$processDocument($collection, $document);
$queueForStatsUsage
->addMetric(METRIC_DATABASES_OPERATIONS_READS, $operations)
->addMetric(METRIC_DATABASES_OPERATIONS_READS, max($operations, 1))
->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_READS), $operations);
$response->addHeader('X-Debug-Operations', $operations);
@@ -3959,7 +3959,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
$setCollection($collection, $newDocument);
$queueForStatsUsage
->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, $operations)
->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, max($operations, 1))
->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_WRITES), $operations);
$response->addHeader('X-Debug-Operations', $operations);
+2 -2
View File
@@ -295,7 +295,7 @@ App::post('/v1/functions')
$schedule = Authorization::skip(
fn () => $dbForPlatform->createDocument('schedules', new Document([
'region' => System::getEnv('_APP_REGION', 'default'), // Todo replace with projects region
'region' => $project->getAttribute('region'),
'resourceType' => 'function',
'resourceId' => $function->getId(),
'resourceInternalId' => $function->getInternalId(),
@@ -2079,7 +2079,7 @@ App::post('/v1/functions/:functionId/executions')
];
$schedule = $dbForPlatform->createDocument('schedules', new Document([
'region' => System::getEnv('_APP_REGION', 'default'),
'region' => $project->getAttribute('region'),
'resourceType' => ScheduleExecutions::getSupportedResource(),
'resourceId' => $execution->getId(),
'resourceInternalId' => $execution->getInternalId(),
+6 -6
View File
@@ -2936,7 +2936,7 @@ App::post('/v1/messaging/messages/email')
break;
case MessageStatus::SCHEDULED:
$schedule = $dbForPlatform->createDocument('schedules', new Document([
'region' => System::getEnv('_APP_REGION', 'default'),
'region' => $project->getAttribute('region'),
'resourceType' => 'message',
'resourceId' => $message->getId(),
'resourceInternalId' => $message->getInternalId(),
@@ -3058,7 +3058,7 @@ App::post('/v1/messaging/messages/sms')
break;
case MessageStatus::SCHEDULED:
$schedule = $dbForPlatform->createDocument('schedules', new Document([
'region' => System::getEnv('_APP_REGION', 'default'),
'region' => $project->getAttribute('region'),
'resourceType' => 'message',
'resourceId' => $message->getId(),
'resourceInternalId' => $message->getInternalId(),
@@ -3275,7 +3275,7 @@ App::post('/v1/messaging/messages/push')
break;
case MessageStatus::SCHEDULED:
$schedule = $dbForPlatform->createDocument('schedules', new Document([
'region' => System::getEnv('_APP_REGION', 'default'),
'region' => $project->getAttribute('region'),
'resourceType' => 'message',
'resourceId' => $message->getId(),
'resourceInternalId' => $message->getInternalId(),
@@ -3661,7 +3661,7 @@ App::patch('/v1/messaging/messages/email/:messageId')
if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) {
$schedule = $dbForPlatform->createDocument('schedules', new Document([
'region' => System::getEnv('_APP_REGION', 'default'),
'region' => $project->getAttribute('region'),
'resourceType' => 'message',
'resourceId' => $message->getId(),
'resourceInternalId' => $message->getInternalId(),
@@ -3862,7 +3862,7 @@ App::patch('/v1/messaging/messages/sms/:messageId')
if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) {
$schedule = $dbForPlatform->createDocument('schedules', new Document([
'region' => System::getEnv('_APP_REGION', 'default'),
'region' => $project->getAttribute('region'),
'resourceType' => 'message',
'resourceId' => $message->getId(),
'resourceInternalId' => $message->getInternalId(),
@@ -4035,7 +4035,7 @@ App::patch('/v1/messaging/messages/push/:messageId')
if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) {
$schedule = $dbForPlatform->createDocument('schedules', new Document([
'region' => System::getEnv('_APP_REGION', 'default'),
'region' => $project->getAttribute('region'),
'resourceType' => 'message',
'resourceId' => $message->getId(),
'resourceInternalId' => $message->getInternalId(),
+1
View File
@@ -221,6 +221,7 @@ const METRIC_TOPICS = 'topics';
const METRIC_TARGETS = 'targets';
const METRIC_PROVIDER_TYPE_TARGETS = '{providerType}.targets';
const METRIC_KEYS = 'keys';
const METRIC_DOMAINS = 'domains';
const METRIC_RESOURCE_TYPE_ID_BUILDS = '{resourceType}.{resourceInternalId}.builds';
const METRIC_RESOURCE_TYPE_ID_BUILDS_STORAGE = '{resourceType}.{resourceInternalId}.builds.storage';
const METRIC_RESOURCE_TYPE_ID_DEPLOYMENTS = '{resourceType}.{resourceInternalId}.deployments';
+1 -1
View File
@@ -217,7 +217,7 @@ $register->set('pools', function () {
return new PDOProxy(function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) {
return new PDO("mysql:host={$dsnHost};port={$dsnPort};dbname={$dsnDatabase};charset=utf8mb4", $dsnUser, $dsnPass, array(
PDO::ATTR_TIMEOUT => 3, // Seconds
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_PERSISTENT => false,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => true,
PDO::ATTR_STRINGIFY_FETCHES => true
+3 -1
View File
@@ -148,6 +148,7 @@ $image = $this->getParam('image', '');
- _APP_MAINTENANCE_RETENTION_CACHE
- _APP_MAINTENANCE_RETENTION_ABUSE
- _APP_MAINTENANCE_RETENTION_AUDIT
- _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE
- _APP_MAINTENANCE_RETENTION_USAGE_HOURLY
- _APP_MAINTENANCE_RETENTION_SCHEDULES
- _APP_SMS_PROVIDER
@@ -164,7 +165,6 @@ $image = $this->getParam('image', '');
- _APP_MIGRATIONS_FIREBASE_CLIENT_ID
- _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET
- _APP_ASSISTANT_OPENAI_API_KEY
appwrite-console:
<<: *x-logging
container_name: appwrite-console
@@ -341,6 +341,7 @@ $image = $this->getParam('image', '');
- _APP_EXECUTOR_HOST
- _APP_MAINTENANCE_RETENTION_ABUSE
- _APP_MAINTENANCE_RETENTION_AUDIT
- _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE
- _APP_MAINTENANCE_RETENTION_EXECUTION
- _APP_SYSTEM_SECURITY_EMAIL_ADDRESS
- _APP_EMAIL_CERTIFICATES
@@ -652,6 +653,7 @@ $image = $this->getParam('image', '');
- _APP_MAINTENANCE_RETENTION_CACHE
- _APP_MAINTENANCE_RETENTION_ABUSE
- _APP_MAINTENANCE_RETENTION_AUDIT
- _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE
- _APP_MAINTENANCE_RETENTION_USAGE_HOURLY
- _APP_MAINTENANCE_RETENTION_SCHEDULES
+6 -3
View File
@@ -215,15 +215,18 @@ Server::setResource('getLogsDB', function (Group $pools, Cache $cache) {
}, ['pools', 'cache']);
Server::setResource('abuseRetention', function () {
return time() - (int) System::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', 86400);
return time() - (int) System::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', 86400); // 1 day
});
Server::setResource('auditRetention', function () {
return DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', 1209600));
return [
'project' => DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', 1209600)), // 14 days
'console' => DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE', 15778800)) // 6 months
];
});
Server::setResource('executionRetention', function () {
return DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_EXECUTION', 1209600));
return DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_EXECUTION', 1209600)); // 14 days
});
Server::setResource('cache', function (Registry $register) {
+2 -2
View File
@@ -60,10 +60,10 @@
"utopia-php/locale": "0.4.*",
"utopia-php/logger": "0.6.*",
"utopia-php/messaging": "0.16.*",
"utopia-php/migration": "0.6.*",
"utopia-php/migration": "0.8.*",
"utopia-php/orchestration": "0.9.*",
"utopia-php/platform": "0.7.*",
"utopia-php/pools": "0.5.*",
"utopia-php/pools": "0.7.*",
"utopia-php/preloader": "0.2.*",
"utopia-php/queue": "0.9.*",
"utopia-php/registry": "0.5.*",
Generated
+39 -37
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "44c6436ced36b0b026139edba252052e",
"content-hash": "e0d7f21b681e4591144fec16c4f0d6aa",
"packages": [
{
"name": "adhocore/jwt",
@@ -753,16 +753,16 @@
},
{
"name": "jean85/pretty-package-versions",
"version": "2.1.0",
"version": "2.1.1",
"source": {
"type": "git",
"url": "https://github.com/Jean85/pretty-package-versions.git",
"reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10"
"reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/3c4e5f62ba8d7de1734312e4fff32f67a8daaf10",
"reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10",
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/4d7aa5dab42e2a76d99559706022885de0e18e1a",
"reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a",
"shasum": ""
},
"require": {
@@ -772,8 +772,9 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.2",
"jean85/composer-provided-replaced-stub-package": "^1.0",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^7.5|^8.5|^9.6",
"rector/rector": "^2.0",
"vimeo/psalm": "^4.3 || ^5.0"
},
"type": "library",
@@ -806,9 +807,9 @@
],
"support": {
"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",
@@ -4159,16 +4160,16 @@
},
{
"name": "utopia-php/migration",
"version": "0.6.22",
"version": "0.8.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/migration.git",
"reference": "a0269746bd318ff0993f5aa008675b971689d5b5"
"reference": "36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/a0269746bd318ff0993f5aa008675b971689d5b5",
"reference": "a0269746bd318ff0993f5aa008675b971689d5b5",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab",
"reference": "36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab",
"shasum": ""
},
"require": {
@@ -4209,9 +4210,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/migration/issues",
"source": "https://github.com/utopia-php/migration/tree/0.6.22"
"source": "https://github.com/utopia-php/migration/tree/0.8.1"
},
"time": "2025-03-13T07:35:55+00:00"
"time": "2025-03-18T07:48:08+00:00"
},
{
"name": "utopia-php/mongo",
@@ -4375,25 +4376,26 @@
},
{
"name": "utopia-php/pools",
"version": "0.5.0",
"version": "0.7.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/pools.git",
"reference": "6f716a213a08db95eda1b5dddfa90983c1834817"
"reference": "ad64d45afda08ec8b29e2642a8d18075964d40bf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/pools/zipball/6f716a213a08db95eda1b5dddfa90983c1834817",
"reference": "6f716a213a08db95eda1b5dddfa90983c1834817",
"url": "https://api.github.com/repos/utopia-php/pools/zipball/ad64d45afda08ec8b29e2642a8d18075964d40bf",
"reference": "ad64d45afda08ec8b29e2642a8d18075964d40bf",
"shasum": ""
},
"require": {
"php": ">=8.0"
"php": ">=8.3",
"utopia-php/telemetry": "0.1.*"
},
"require-dev": {
"laravel/pint": "1.2.*",
"phpstan/phpstan": "1.8.*",
"phpunit/phpunit": "^9.3"
"laravel/pint": "1.*",
"phpstan/phpstan": "1.*",
"phpunit/phpunit": "11.*"
},
"type": "library",
"autoload": {
@@ -4420,9 +4422,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/pools/issues",
"source": "https://github.com/utopia-php/pools/tree/0.5.0"
"source": "https://github.com/utopia-php/pools/tree/0.7.0"
},
"time": "2024-04-19T11:11:54+00:00"
"time": "2025-03-18T03:55:33+00:00"
},
{
"name": "utopia-php/preloader",
@@ -4760,16 +4762,16 @@
},
{
"name": "utopia-php/telemetry",
"version": "0.1.0",
"version": "0.1.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/telemetry.git",
"reference": "d35f2f0632f4ee0be63fb7ace6a94a6adda71a80"
"reference": "437f0021777f0e575dfb9e8a1a081b3aed75e33f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/telemetry/zipball/d35f2f0632f4ee0be63fb7ace6a94a6adda71a80",
"reference": "d35f2f0632f4ee0be63fb7ace6a94a6adda71a80",
"url": "https://api.github.com/repos/utopia-php/telemetry/zipball/437f0021777f0e575dfb9e8a1a081b3aed75e33f",
"reference": "437f0021777f0e575dfb9e8a1a081b3aed75e33f",
"shasum": ""
},
"require": {
@@ -4790,7 +4792,7 @@
"type": "library",
"autoload": {
"psr-4": {
"Utopia\\": "src/"
"Utopia\\Telemetry\\": "src/Telemetry"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -4804,9 +4806,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/telemetry/issues",
"source": "https://github.com/utopia-php/telemetry/tree/0.1.0"
"source": "https://github.com/utopia-php/telemetry/tree/0.1.1"
},
"time": "2024-11-13T10:29:53+00:00"
"time": "2025-03-17T11:57:52+00:00"
},
{
"name": "utopia-php/vcs",
@@ -5043,16 +5045,16 @@
"packages-dev": [
{
"name": "appwrite/sdk-generator",
"version": "0.40.7",
"version": "0.40.9",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "9e89b0bc4d8e6c81817d27096629f34a149fa873"
"reference": "dbb45a5db22cdc3368fe2573c07ba6088f188fa4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/9e89b0bc4d8e6c81817d27096629f34a149fa873",
"reference": "9e89b0bc4d8e6c81817d27096629f34a149fa873",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/dbb45a5db22cdc3368fe2573c07ba6088f188fa4",
"reference": "dbb45a5db22cdc3368fe2573c07ba6088f188fa4",
"shasum": ""
},
"require": {
@@ -5088,9 +5090,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/0.40.7"
"source": "https://github.com/appwrite/sdk-generator/tree/0.40.9"
},
"time": "2025-03-12T08:43:55+00:00"
"time": "2025-03-17T18:39:14+00:00"
},
{
"name": "doctrine/annotations",
+7 -3
View File
@@ -171,6 +171,7 @@ services:
- _APP_MAINTENANCE_RETENTION_CACHE
- _APP_MAINTENANCE_RETENTION_ABUSE
- _APP_MAINTENANCE_RETENTION_AUDIT
- _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE
- _APP_MAINTENANCE_RETENTION_USAGE_HOURLY
- _APP_MAINTENANCE_RETENTION_SCHEDULES
- _APP_SMS_PROVIDER
@@ -389,6 +390,8 @@ services:
- _APP_DATABASE_SHARED_TABLES
- _APP_DATABASE_SHARED_TABLES_V1
- _APP_EMAIL_CERTIFICATES
- _APP_MAINTENANCE_RETENTION_AUDIT
- _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE
appwrite-worker-databases:
entrypoint: worker-databases
@@ -721,6 +724,7 @@ services:
- _APP_MAINTENANCE_RETENTION_CACHE
- _APP_MAINTENANCE_RETENTION_ABUSE
- _APP_MAINTENANCE_RETENTION_AUDIT
- _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE
- _APP_MAINTENANCE_RETENTION_USAGE_HOURLY
- _APP_MAINTENANCE_RETENTION_SCHEDULES
- _APP_MAINTENANCE_DELAY
@@ -756,7 +760,7 @@ services:
- _APP_LOGGING_CONFIG
- _APP_DATABASE_SHARED_TABLES
- _APP_STATS_RESOURCES_INTERVAL
appwrite-worker-stats-resources:
entrypoint: worker-stats-resources
<<: *x-logging
@@ -787,7 +791,7 @@ services:
- _APP_LOGGING_CONFIG
- _APP_USAGE_AGGREGATION_INTERVAL
- _APP_DATABASE_SHARED_TABLES
appwrite-worker-stats-usage:
entrypoint: worker-stats-usage
<<: *x-logging
@@ -850,7 +854,7 @@ services:
- _APP_USAGE_AGGREGATION_INTERVAL
- _APP_DATABASE_SHARED_TABLES
- _APP_STATS_USAGE_DUAL_WRITING_DBS
appwrite-task-scheduler-functions:
entrypoint: schedule-functions
<<: *x-logging
+1 -1
View File
@@ -6,7 +6,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
stopOnFailure="true"
>
<extensions>
<extension class="Appwrite\Tests\TestHook" />
+4 -29
View File
@@ -47,13 +47,15 @@ class Maintenance extends Action
Console::info("[{$time}] Notifying workers with maintenance tasks every {$interval} seconds");
$this->foreachProject($dbForPlatform, function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) {
$dbForPlatform->foreach('projects', function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) {
$queueForDeletes
->setType(DELETE_TYPE_MAINTENANCE)
->setProject($project)
->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly))
->trigger();
});
}, [
Query::limit(100),
]);
$queueForDeletes
->setType(DELETE_TYPE_MAINTENANCE)
@@ -68,33 +70,6 @@ class Maintenance extends Action
}, $interval, $delay);
}
protected function foreachProject(Database $dbForPlatform, callable $callback): void
{
// TODO: @Meldiron name of this method no longer matches. It does not delete, and it gives whole document
$count = 0;
$chunk = 0;
$limit = 50;
$sum = $limit;
$executionStart = \microtime(true);
while ($sum === $limit) {
$projects = $dbForPlatform->find('projects', [Query::limit($limit), Query::offset($chunk * $limit)]);
$chunk++;
/** @var string[] $projectIds */
$sum = count($projects);
foreach ($projects as $project) {
$callback($project);
$count++;
}
}
$executionEnd = \microtime(true);
Console::info("Found {$count} projects " . ($executionEnd - $executionStart) . " seconds");
}
private function notifyDeleteConnections(Delete $queueForDeletes): void
{
$queueForDeletes
+4 -4
View File
@@ -57,7 +57,7 @@ class Deletes extends Action
->inject('auditRetention')
->inject('log')
->callback(
fn ($message, Document $project, Database $dbForPlatform, callable $getProjectDB, callable $getLogsDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, string $auditRetention, Log $log) =>
fn ($message, Document $project, Database $dbForPlatform, callable $getProjectDB, callable $getLogsDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, array $auditRetention, Log $log) =>
$this->action($message, $project, $dbForPlatform, $getProjectDB, $getLogsDB, $deviceForFiles, $deviceForFunctions, $deviceForBuilds, $deviceForCache, $certificates, $executionRetention, $auditRetention, $log)
);
}
@@ -66,7 +66,7 @@ class Deletes extends Action
* @throws Exception
* @throws Throwable
*/
public function action(Message $message, Document $project, Database $dbForPlatform, callable $getProjectDB, callable $getLogsDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, string $auditRetention, Log $log): void
public function action(Message $message, Document $project, Database $dbForPlatform, callable $getProjectDB, callable $getLogsDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, array $auditRetention, Log $log): void
{
$payload = $message->getPayload() ?? [];
@@ -746,14 +746,14 @@ class Deletes extends Action
* @return void
* @throws Exception
*/
private function deleteAuditLogs(Document $project, callable $getProjectDB, string $auditRetention): void
private function deleteAuditLogs(Document $project, callable $getProjectDB, array $auditRetention): void
{
$projectId = $project->getId();
$dbForProject = $getProjectDB($project);
try {
$this->deleteByGroup(Audit::COLLECTION, [
Query::lessThan('time', $auditRetention),
Query::lessThan('time', ($projectId === 'console' ? $auditRetention['console'] : $auditRetention['project'])),
Query::orderDesc('time'),
Query::orderDesc('$internalId'),
], $dbForProject);
@@ -34,6 +34,9 @@ class Migrations extends Action
protected Document $project;
/**
* @var callable
*/
protected $logError;
public static function getName(): string
@@ -114,6 +114,13 @@ class StatsResources extends Action
$keys = $dbForPlatform->count('keys', [
Query::equal('projectInternalId', [$project->getInternalId()])
]);
$domains = $dbForPlatform->count('rules', [
Query::equal('projectInternalId', [$project->getInternalId()]),
Query::equal('owner', ['']),
]);
$databases = $dbForProject->count('databases');
$buckets = $dbForProject->count('buckets');
$users = $dbForProject->count('users');
@@ -162,6 +169,7 @@ class StatsResources extends Action
METRIC_PROVIDERS => $providers,
METRIC_TOPICS => $topics,
METRIC_KEYS => $keys,
METRIC_DOMAINS => $domains,
METRIC_TARGETS => $targets,
str_replace('{providerType}', MESSAGE_TYPE_EMAIL, METRIC_PROVIDER_TYPE_TARGETS) => $emailTargets,
str_replace('{providerType}', MESSAGE_TYPE_PUSH, METRIC_PROVIDER_TYPE_TARGETS) => $pushTargets,
+4 -3
View File
@@ -74,7 +74,7 @@ class CompressionTest extends Scope
], $this->getHeaders()));
$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']));
// get prefs without compression
@@ -116,7 +116,7 @@ class CompressionTest extends Scope
]);
$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([
'content-type' => 'application/json',
'accept-encoding' => 'gzip',
@@ -125,7 +125,8 @@ class CompressionTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
$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([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
+185 -171
View File
@@ -3,10 +3,8 @@
namespace Tests\E2E\General;
use Appwrite\Functions\Specification;
use Appwrite\Tests\Retry;
use CURLFile;
use DateTime;
use PHPUnit\Framework\ExpectationFailedException;
use Tests\E2E\Client;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
@@ -23,8 +21,8 @@ class UsageTest extends Scope
use SideServer;
use FunctionsBase;
private const WAIT = 5;
private const CREATE = 20;
private const WAIT = 5; //
private const RESOURCE_COUNT = 10; // Number of resources to create for each test
protected string $projectId;
@@ -77,7 +75,7 @@ class UsageTest extends Scope
$usersTotal = 0;
$requestsTotal = 0;
for ($i = 0; $i < self::CREATE; $i++) {
for ($i = 0; $i < self::RESOURCE_COUNT; $i++) {
$params = [
'userId' => 'unique()',
'email' => uniqid() . 'user@usage.test',
@@ -102,7 +100,7 @@ class UsageTest extends Scope
$usersTotal += 1;
$requestsTotal += 1;
if ($i < (self::CREATE / 2)) {
if ($i < (self::RESOURCE_COUNT / 2)) {
$userId = $response['body']['$id'];
$response = $this->client->call(
@@ -131,40 +129,43 @@ class UsageTest extends Scope
/**
* @depends testPrepareUsersStats
*/
#[Retry(count: 1)]
public function testUsersStats(array $data): array
{
$requestsTotal = $data['requestsTotal'];
$response = $this->client->call(
Client::METHOD_GET,
'/project/usage',
$this->getConsoleHeaders(),
[
'period' => '1h',
'startDate' => self::getToday(),
'endDate' => self::getTomorrow(),
]
);
$this->assertEventually(function () use ($data) {
$response = $this->client->call(
Client::METHOD_GET,
'/project/usage',
$this->getConsoleHeaders(),
[
'period' => '1h',
'startDate' => self::getToday(),
'endDate' => self::getTomorrow(),
]
);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(31, count($response['body']));
$this->validateDates($response['body']['network']);
$this->validateDates($response['body']['requests']);
$this->validateDates($response['body']['users']);
$this->assertArrayHasKey('executionsBreakdown', $response['body']);
$this->assertArrayHasKey('bucketsBreakdown', $response['body']);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(31, count($response['body']));
$this->validateDates($response['body']['network']);
$this->validateDates($response['body']['requests']);
$this->validateDates($response['body']['users']);
$this->assertArrayHasKey('executionsBreakdown', $response['body']);
$this->assertArrayHasKey('bucketsBreakdown', $response['body']);
});
$response = $this->client->call(
Client::METHOD_GET,
'/users/usage?range=90d',
$this->getConsoleHeaders()
);
$this->assertEventually(function () {
$response = $this->client->call(
Client::METHOD_GET,
'/users/usage?range=90d',
$this->getConsoleHeaders()
);
$this->assertEquals('90d', $response['body']['range']);
$this->assertEquals(90, count($response['body']['users']));
$this->assertEquals(90, count($response['body']['sessions']));
$this->assertEquals((self::CREATE / 2), $response['body']['users'][array_key_last($response['body']['users'])]['value']);
$this->assertEquals('90d', $response['body']['range']);
$this->assertEquals(90, count($response['body']['users']));
$this->assertEquals(90, count($response['body']['sessions']));
$this->assertEquals((self::RESOURCE_COUNT / 2), $response['body']['users'][array_key_last($response['body']['users'])]['value']);
});
return array_merge($data, [
'requestsTotal' => $requestsTotal
@@ -180,7 +181,7 @@ class UsageTest extends Scope
$storageTotal = 0;
$filesTotal = 0;
for ($i = 0; $i < self::CREATE; $i++) {
for ($i = 0; $i < self::RESOURCE_COUNT; $i++) {
$name = uniqid() . ' bucket';
$response = $this->client->call(
@@ -212,7 +213,7 @@ class UsageTest extends Scope
$bucketId = $response['body']['$id'];
if ($i < (self::CREATE / 2)) {
if ($i < (self::RESOURCE_COUNT / 2)) {
$response = $this->client->call(
Client::METHOD_DELETE,
'/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)];
$response = $this->client->call(
@@ -277,7 +278,7 @@ class UsageTest extends Scope
$fileId = $response['body']['$id'];
if ($i < (self::CREATE / 2)) {
if ($i < (self::RESOURCE_COUNT / 2)) {
$response = $this->client->call(
Client::METHOD_DELETE,
'/storage/buckets/' . $bucketId . '/files/' . $fileId,
@@ -307,7 +308,6 @@ class UsageTest extends Scope
/**
* @depends testPrepareStorageStats
*/
#[Retry(count: 10)]
public function testStorageStats(array $data): array
{
$bucketId = $data['bucketId'];
@@ -316,44 +316,50 @@ class UsageTest extends Scope
$storageTotal = $data['storageTotal'];
$filesTotal = $data['filesTotal'];
$response = $this->client->call(
Client::METHOD_GET,
'/project/usage',
$this->getConsoleHeaders(),
[
'period' => '1d',
'startDate' => self::getToday(),
'endDate' => self::getTomorrow(),
]
);
$this->assertEventually(function () use ($requestsTotal, $storageTotal) {
$response = $this->client->call(
Client::METHOD_GET,
'/project/usage',
$this->getConsoleHeaders(),
[
'period' => '1d',
'startDate' => self::getToday(),
'endDate' => self::getTomorrow(),
]
);
$this->assertEquals(31, count($response['body']));
$this->assertEquals(1, count($response['body']['requests']));
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
$this->validateDates($response['body']['requests']);
$this->assertEquals($storageTotal, $response['body']['filesStorageTotal']);
$this->assertEquals(31, count($response['body']));
$this->assertEquals(1, count($response['body']['requests']));
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
$this->validateDates($response['body']['requests']);
$this->assertEquals($storageTotal, $response['body']['filesStorageTotal']);
});
$response = $this->client->call(
Client::METHOD_GET,
'/storage/usage?range=30d',
$this->getConsoleHeaders()
);
$this->assertEventually(function () use ($bucketsTotal, $storageTotal, $filesTotal) {
$response = $this->client->call(
Client::METHOD_GET,
'/storage/usage?range=30d',
$this->getConsoleHeaders()
);
$this->assertEquals($storageTotal, $response['body']['storage'][array_key_last($response['body']['storage'])]['value']);
$this->validateDates($response['body']['storage']);
$this->assertEquals($bucketsTotal, $response['body']['buckets'][array_key_last($response['body']['buckets'])]['value']);
$this->validateDates($response['body']['buckets']);
$this->assertEquals($filesTotal, $response['body']['files'][array_key_last($response['body']['files'])]['value']);
$this->validateDates($response['body']['files']);
$this->assertEquals($storageTotal, $response['body']['storage'][array_key_last($response['body']['storage'])]['value']);
$this->validateDates($response['body']['storage']);
$this->assertEquals($bucketsTotal, $response['body']['buckets'][array_key_last($response['body']['buckets'])]['value']);
$this->validateDates($response['body']['buckets']);
$this->assertEquals($filesTotal, $response['body']['files'][array_key_last($response['body']['files'])]['value']);
$this->validateDates($response['body']['files']);
});
$response = $this->client->call(
Client::METHOD_GET,
'/storage/' . $bucketId . '/usage?range=30d',
$this->getConsoleHeaders()
);
$this->assertEventually(function () use ($bucketId, $storageTotal, $filesTotal) {
$response = $this->client->call(
Client::METHOD_GET,
'/storage/' . $bucketId . '/usage?range=30d',
$this->getConsoleHeaders()
);
$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($storageTotal, $response['body']['storage'][array_key_last($response['body']['storage'])]['value']);
$this->assertEquals($filesTotal, $response['body']['files'][array_key_last($response['body']['files'])]['value']);
});
return $data;
}
@@ -367,7 +373,7 @@ class UsageTest extends Scope
$collectionsTotal = 0;
$documentsTotal = 0;
for ($i = 0; $i < self::CREATE; $i++) {
for ($i = 0; $i < self::RESOURCE_COUNT; $i++) {
$name = uniqid() . ' database';
$response = $this->client->call(
@@ -391,7 +397,7 @@ class UsageTest extends Scope
$databaseId = $response['body']['$id'];
if ($i < (self::CREATE / 2)) {
if ($i < (self::RESOURCE_COUNT / 2)) {
$response = $this->client->call(
Client::METHOD_DELETE,
'/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';
$response = $this->client->call(
@@ -438,7 +444,7 @@ class UsageTest extends Scope
$collectionId = $response['body']['$id'];
if ($i < (self::CREATE / 2)) {
if ($i < (self::RESOURCE_COUNT / 2)) {
$response = $this->client->call(
Client::METHOD_DELETE,
'/databases/' . $databaseId . '/collections/' . $collectionId,
@@ -474,7 +480,7 @@ class UsageTest extends Scope
$requestsTotal += 1;
for ($i = 0; $i < self::CREATE; $i++) {
for ($i = 0; $i < self::RESOURCE_COUNT; $i++) {
$name = uniqid() . ' collection';
$response = $this->client->call(
@@ -498,7 +504,7 @@ class UsageTest extends Scope
$documentId = $response['body']['$id'];
if ($i < (self::CREATE / 2)) {
if ($i < (self::RESOURCE_COUNT / 2)) {
$response = $this->client->call(
Client::METHOD_DELETE,
'/databases/' . $databaseId . '/collections/' . $collectionId . '/documents/' . $documentId,
@@ -525,7 +531,6 @@ class UsageTest extends Scope
}
/** @depends testPrepareDatabaseStats */
#[Retry(count: 1)]
public function testDatabaseStats(array $data): array
{
$databaseId = $data['databaseId'];
@@ -535,60 +540,66 @@ class UsageTest extends Scope
$collectionsTotal = $data['collectionsTotal'];
$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(
Client::METHOD_GET,
'/project/usage',
$this->getConsoleHeaders(),
[
'period' => '1d',
'startDate' => self::getToday(),
'endDate' => self::getTomorrow(),
]
);
$this->assertEquals(31, count($response['body']));
$this->assertEquals(1, count($response['body']['requests']));
$this->assertEquals(1, count($response['body']['network']));
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
$this->validateDates($response['body']['requests']);
$this->assertEquals($databasesTotal, $response['body']['databasesTotal']);
$this->assertEquals($documentsTotal, $response['body']['documentsTotal']);
});
$this->assertEquals(31, count($response['body']));
$this->assertEquals(1, count($response['body']['requests']));
$this->assertEquals(1, count($response['body']['network']));
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
$this->validateDates($response['body']['requests']);
$this->assertEquals($databasesTotal, $response['body']['databasesTotal']);
$this->assertEquals($documentsTotal, $response['body']['documentsTotal']);
$this->assertEventually(function () use ($databasesTotal, $collectionsTotal, $documentsTotal) {
$response = $this->client->call(
Client::METHOD_GET,
'/databases/usage?range=30d',
$this->getConsoleHeaders()
);
$response = $this->client->call(
Client::METHOD_GET,
'/databases/usage?range=30d',
$this->getConsoleHeaders()
);
$this->assertEquals($databasesTotal, $response['body']['databases'][array_key_last($response['body']['databases'])]['value']);
$this->validateDates($response['body']['databases']);
$this->assertEquals($collectionsTotal, $response['body']['collections'][array_key_last($response['body']['collections'])]['value']);
$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->validateDates($response['body']['databases']);
$this->assertEquals($collectionsTotal, $response['body']['collections'][array_key_last($response['body']['collections'])]['value']);
$this->validateDates($response['body']['collections']);
$this->assertEquals($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
$this->validateDates($response['body']['documents']);
$this->assertEventually(function () use ($databaseId, $collectionsTotal, $documentsTotal) {
$response = $this->client->call(
Client::METHOD_GET,
'/databases/' . $databaseId . '/usage?range=30d',
$this->getConsoleHeaders()
);
$response = $this->client->call(
Client::METHOD_GET,
'/databases/' . $databaseId . '/usage?range=30d',
$this->getConsoleHeaders()
);
$this->assertEquals($collectionsTotal, $response['body']['collections'][array_key_last($response['body']['collections'])]['value']);
$this->validateDates($response['body']['collections']);
$this->assertEquals($collectionsTotal, $response['body']['collections'][array_key_last($response['body']['collections'])]['value']);
$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($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
$this->validateDates($response['body']['documents']);
$this->assertEventually(function () use ($databaseId, $collectionId, $documentsTotal) {
$response = $this->client->call(
Client::METHOD_GET,
'/databases/' . $databaseId . '/collections/' . $collectionId . '/usage?range=30d',
$this->getConsoleHeaders()
);
$response = $this->client->call(
Client::METHOD_GET,
'/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']);
$this->assertEquals($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
$this->validateDates($response['body']['documents']);
});
return $data;
}
@@ -1010,62 +1021,65 @@ class UsageTest extends Scope
}
/** @depends testPrepareFunctionsStats */
#[Retry(count: 1)]
public function testFunctionsStats(array $data): array
{
$functionId = $data['functionId'];
$executionTime = $data['executionTime'];
$executions = $data['executions'];
$response = $this->client->call(
Client::METHOD_GET,
'/functions/' . $functionId . '/usage?range=30d',
$this->getConsoleHeaders()
);
$this->assertEventually(function () use ($functionId, $executionTime, $executions) {
$response = $this->client->call(
Client::METHOD_GET,
'/functions/' . $functionId . '/usage?range=30d',
$this->getConsoleHeaders()
);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(19, count($response['body']));
$this->assertEquals('30d', $response['body']['range']);
$this->assertIsArray($response['body']['deployments']);
$this->assertIsArray($response['body']['deploymentsStorage']);
$this->assertIsNumeric($response['body']['deploymentsStorageTotal']);
$this->assertIsNumeric($response['body']['buildsMbSecondsTotal']);
$this->assertIsNumeric($response['body']['executionsMbSecondsTotal']);
$this->assertIsArray($response['body']['builds']);
$this->assertIsArray($response['body']['buildsTime']);
$this->assertIsArray($response['body']['buildsMbSeconds']);
$this->assertIsArray($response['body']['executions']);
$this->assertIsArray($response['body']['executionsTime']);
$this->assertIsArray($response['body']['executionsMbSeconds']);
$this->assertEquals($executions, $response['body']['executions'][array_key_last($response['body']['executions'])]['value']);
$this->validateDates($response['body']['executions']);
$this->assertEquals($executionTime, $response['body']['executionsTime'][array_key_last($response['body']['executionsTime'])]['value']);
$this->validateDates($response['body']['executionsTime']);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(19, count($response['body']));
$this->assertEquals('30d', $response['body']['range']);
$this->assertIsArray($response['body']['deployments']);
$this->assertIsArray($response['body']['deploymentsStorage']);
$this->assertIsNumeric($response['body']['deploymentsStorageTotal']);
$this->assertIsNumeric($response['body']['buildsMbSecondsTotal']);
$this->assertIsNumeric($response['body']['executionsMbSecondsTotal']);
$this->assertIsArray($response['body']['builds']);
$this->assertIsArray($response['body']['buildsTime']);
$this->assertIsArray($response['body']['buildsMbSeconds']);
$this->assertIsArray($response['body']['executions']);
$this->assertIsArray($response['body']['executionsTime']);
$this->assertIsArray($response['body']['executionsMbSeconds']);
$this->assertEquals($executions, $response['body']['executions'][array_key_last($response['body']['executions'])]['value']);
$this->validateDates($response['body']['executions']);
$this->assertEquals($executionTime, $response['body']['executionsTime'][array_key_last($response['body']['executionsTime'])]['value']);
$this->validateDates($response['body']['executionsTime']);
});
$response = $this->client->call(
Client::METHOD_GET,
'/functions/usage?range=30d',
$this->getConsoleHeaders()
);
$this->assertEventually(function () use ($executionTime, $executions) {
$response = $this->client->call(
Client::METHOD_GET,
'/functions/usage?range=30d',
$this->getConsoleHeaders()
);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(21, count($response['body']));
$this->assertEquals($response['body']['range'], '30d');
$this->assertIsArray($response['body']['functions']);
$this->assertIsArray($response['body']['deployments']);
$this->assertIsArray($response['body']['deploymentsStorage']);
$this->assertIsArray($response['body']['builds']);
$this->assertIsArray($response['body']['buildsTime']);
$this->assertIsArray($response['body']['buildsMbSeconds']);
$this->assertIsArray($response['body']['executions']);
$this->assertIsArray($response['body']['executionsTime']);
$this->assertIsArray($response['body']['executionsMbSeconds']);
$this->assertEquals($executions, $response['body']['executions'][array_key_last($response['body']['executions'])]['value']);
$this->validateDates($response['body']['executions']);
$this->assertEquals($executionTime, $response['body']['executionsTime'][array_key_last($response['body']['executionsTime'])]['value']);
$this->validateDates($response['body']['executionsTime']);
$this->assertGreaterThan(0, $response['body']['buildsTime'][array_key_last($response['body']['buildsTime'])]['value']);
$this->validateDates($response['body']['buildsTime']);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(21, count($response['body']));
$this->assertEquals($response['body']['range'], '30d');
$this->assertIsArray($response['body']['functions']);
$this->assertIsArray($response['body']['deployments']);
$this->assertIsArray($response['body']['deploymentsStorage']);
$this->assertIsArray($response['body']['builds']);
$this->assertIsArray($response['body']['buildsTime']);
$this->assertIsArray($response['body']['buildsMbSeconds']);
$this->assertIsArray($response['body']['executions']);
$this->assertIsArray($response['body']['executionsTime']);
$this->assertIsArray($response['body']['executionsMbSeconds']);
$this->assertEquals($executions, $response['body']['executions'][array_key_last($response['body']['executions'])]['value']);
$this->validateDates($response['body']['executions']);
$this->assertEquals($executionTime, $response['body']['executionsTime'][array_key_last($response['body']['executionsTime'])]['value']);
$this->validateDates($response['body']['executionsTime']);
$this->assertGreaterThan(0, $response['body']['buildsTime'][array_key_last($response['body']['buildsTime'])]['value']);
$this->validateDates($response['body']['buildsTime']);
});
return $data;
}
+2 -1
View File
@@ -4,6 +4,7 @@ namespace Tests\E2E\Scopes;
use Tests\E2E\Client;
use Utopia\Database\Helpers\ID;
use Utopia\System\System;
trait ProjectCustom
{
@@ -42,7 +43,7 @@ trait ProjectCustom
'x-appwrite-project' => 'console',
], [
'projectId' => ID::unique(),
'region' => 'default',
'region' => System::getEnv('_APP_REGION', 'default'),
'name' => 'Demo Project',
'teamId' => $team['body']['$id'],
'description' => 'Demo Project Description',
@@ -1862,10 +1862,11 @@ class AccountCustomClientTest extends Scope
'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('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([
'origin' => 'http://localhost',
@@ -46,7 +46,7 @@ trait FunctionsBase
'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));
}, 50000, 500);
}, 120000, 1000);
return $deploymentId;
}
@@ -8,6 +8,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Role;
use Utopia\System\System;
class FunctionsCustomClientTest extends Scope
{
@@ -111,7 +112,7 @@ class FunctionsCustomClientTest extends Scope
$this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']);
$this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']);
$this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']);
$this->assertEquals('default', $output['APPWRITE_REGION']);
$this->assertEquals(System::getEnv('_APP_REGION', 'default'), $output['APPWRITE_REGION']);
$this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']);
$this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']);
$this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']);
@@ -221,7 +222,7 @@ class FunctionsCustomClientTest extends Scope
$this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']);
$this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']);
$this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']);
$this->assertEquals('default', $output['APPWRITE_REGION']);
$this->assertEquals(System::getEnv('_APP_REGION', 'default'), $output['APPWRITE_REGION']);
$this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']);
$this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']);
$this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']);
@@ -1926,7 +1926,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals('completed', $execution['body']['status']);
$this->assertEmpty($execution['body']['logs']);
$this->assertEmpty($execution['body']['errors']);
}, 10000, 500);
}, 20000, 1000);
// Domain Executions test
$rules = $this->client->call(Client::METHOD_GET, '/proxy/rules', array_merge([
@@ -14,6 +14,7 @@ use Utopia\Database\DateTime;
use Utopia\Database\Document;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Query;
use Utopia\System\System;
class ProjectsConsoleClientTest extends Scope
{
@@ -49,7 +50,7 @@ class ProjectsConsoleClientTest extends Scope
'projectId' => ID::unique(),
'name' => 'Project Test',
'teamId' => $team['body']['$id'],
'region' => 'default',
'region' => System::getEnv('_APP_REGION', 'default')
]);
$this->assertEquals(201, $response['headers']['status-code']);
@@ -89,7 +90,7 @@ class ProjectsConsoleClientTest extends Scope
'projectId' => ID::unique(),
'name' => '',
'teamId' => $team['body']['$id'],
'region' => 'default'
'region' => System::getEnv('_APP_REGION', 'default')
]);
$this->assertEquals(400, $response['headers']['status-code']);
@@ -100,7 +101,7 @@ class ProjectsConsoleClientTest extends Scope
], $this->getHeaders()), [
'projectId' => ID::unique(),
'name' => 'Project Test',
'region' => 'default'
'region' => System::getEnv('_APP_REGION', 'default')
]);
$this->assertEquals(401, $response['headers']['status-code']);
@@ -129,7 +130,7 @@ class ProjectsConsoleClientTest extends Scope
'projectId' => $projectId,
'name' => 'Project Duplicate',
'teamId' => $teamId,
'region' => 'default'
'region' => System::getEnv('_APP_REGION', 'default')
]);
$this->assertEquals(409, $response['headers']['status-code']);
@@ -178,7 +179,7 @@ class ProjectsConsoleClientTest extends Scope
'projectId' => ID::unique(),
'name' => 'Team 1 Project',
'teamId' => $team1,
'region' => 'default',
'region' => System::getEnv('_APP_REGION', 'default'),
]);
$this->assertEquals(201, $response['headers']['status-code']);
@@ -277,7 +278,7 @@ class ProjectsConsoleClientTest extends Scope
'projectId' => ID::unique(),
'name' => 'Project Test 2',
'teamId' => $team['body']['$id'],
'region' => 'default'
'region' => System::getEnv('_APP_REGION', 'default')
]);
$this->assertEquals(201, $response['headers']['status-code']);
@@ -2042,7 +2043,7 @@ class ProjectsConsoleClientTest extends Scope
'projectId' => ID::unique(),
'name' => 'Project Test',
'teamId' => $team['body']['$id'],
'region' => 'default'
'region' => System::getEnv('_APP_REGION', 'default')
]);
$this->assertEquals(201, $project['headers']['status-code']);
@@ -2135,7 +2136,7 @@ class ProjectsConsoleClientTest extends Scope
'projectId' => ID::unique(),
'name' => 'Project Test',
'teamId' => $team['body']['$id'],
'region' => 'default'
'region' => System::getEnv('_APP_REGION', 'default')
]);
$this->assertEquals(201, $project['headers']['status-code']);
@@ -3749,7 +3750,7 @@ class ProjectsConsoleClientTest extends Scope
'projectId' => ID::unique(),
'name' => 'Amazing Project',
'teamId' => $teamId,
'region' => 'default'
'region' => System::getEnv('_APP_REGION', 'default')
]);
$this->assertEquals(201, $project['headers']['status-code']);
@@ -3820,7 +3821,7 @@ class ProjectsConsoleClientTest extends Scope
'projectId' => ID::unique(),
'name' => 'Amazing Project 1',
'teamId' => $teamId,
'region' => 'default'
'region' => System::getEnv('_APP_REGION', 'default')
]);
$project2 = $this->client->call(Client::METHOD_POST, '/projects', array_merge([
@@ -3830,7 +3831,7 @@ class ProjectsConsoleClientTest extends Scope
'projectId' => ID::unique(),
'name' => 'Amazing Project 2',
'teamId' => $teamId,
'region' => 'default'
'region' => System::getEnv('_APP_REGION', 'default')
]);
$project1Id = $project1['body']['$id'];
@@ -2,6 +2,7 @@
namespace Tests\E2E\Services\Storage;
use Appwrite\Tests\Async;
use Tests\E2E\Client;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
@@ -16,6 +17,7 @@ class StorageCustomServerTest extends Scope
use StorageBase;
use ProjectCustom;
use SideServer;
use Async;
public function testCreateBucket(): array
{
@@ -286,18 +288,21 @@ class StorageCustomServerTest extends Scope
$this->assertEquals(204, $response['headers']['status-code']);
$this->assertEmpty($response['body']);
$response = $this->client->call(
Client::METHOD_GET,
'/storage/buckets/' . $id,
array_merge(
[
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
],
$this->getHeaders()
)
);
$this->assertEquals(404, $response['headers']['status-code']);
$this->assertEventually(function () use ($id) {
$response = $this->client->call(
Client::METHOD_GET,
'/storage/buckets/' . $id,
array_merge(
[
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
],
$this->getHeaders()
)
);
$this->assertEquals(404, $response['headers']['status-code']);
});
return $data;
}
+11 -5
View File
@@ -2,6 +2,7 @@
namespace Tests\E2E\Services\Teams;
use Appwrite\Tests\Async;
use Tests\E2E\Client;
use Utopia\Database\Document;
use Utopia\Database\Helpers\ID;
@@ -10,6 +11,8 @@ use Utopia\Database\Validator\Datetime as DatetimeValidator;
trait TeamsBase
{
use Async;
public function testCreateTeam(): array
{
/**
@@ -379,12 +382,15 @@ trait TeamsBase
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEventually(function () use ($teamUid) {
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(404, $response['headers']['status-code']);
});
$this->assertEquals(404, $response['headers']['status-code']);
return [];
}