mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
addressing comments
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
use Appwrite\Auth\Auth;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
$providers = Config::getParam('providers', []);
|
||||
$auth = Config::getParam('auth', []);
|
||||
|
||||
@@ -29,10 +29,10 @@ use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Exception\Duplicate;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Locale\Locale;
|
||||
@@ -53,7 +53,6 @@ App::post('/v1/account/invite')
|
||||
->label('audits.event', 'user.create')
|
||||
->label('audits.resource', 'user/{response.$id}')
|
||||
->label('audits.userId', '{response.$id}')
|
||||
->label('usage.metric', 'users.{scope}.requests.create')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'account')
|
||||
->label('sdk.method', 'createWithInviteCode')
|
||||
|
||||
@@ -4,10 +4,10 @@ use Utopia\App;
|
||||
use Appwrite\Event\Delete;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Utopia\Audit\Audit;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\DatetimeValidator;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Validator\Boolean;
|
||||
use Utopia\Validator\FloatValidator;
|
||||
use Utopia\Validator\Integer;
|
||||
@@ -851,7 +851,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/string
|
||||
->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).')
|
||||
->param('key', '', new Key(), 'Attribute Key.')
|
||||
->param('size', null, new Range(1, APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH, Range::TYPE_INTEGER), 'Attribute size for text attributes, in number of characters.')
|
||||
->param('required', null, new Boolean(true), 'Is attribute required?')
|
||||
->param('required', null, new Boolean(), 'Is attribute required?')
|
||||
->param('default', null, new Text(0), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true)
|
||||
->param('array', false, new Boolean(), 'Is attribute an array?', true)
|
||||
->inject('response')
|
||||
@@ -2447,9 +2447,9 @@ App::get('/v1/databases/usage')
|
||||
}
|
||||
$response->dynamic(new Document([
|
||||
'range' => $range,
|
||||
'databasesCount' => $usage[$metrics[0]],
|
||||
'collectionsCount' => $usage[$metrics[1]],
|
||||
'documentsCount' => $usage[$metrics[2]],
|
||||
'databasesTotal' => $usage[$metrics[0]],
|
||||
'collectionsTotal' => $usage[$metrics[1]],
|
||||
'documentsTotal' => $usage[$metrics[2]],
|
||||
]), Response::MODEL_USAGE_DATABASES);
|
||||
});
|
||||
|
||||
@@ -2522,8 +2522,8 @@ App::get('/v1/databases/:databaseId/usage')
|
||||
|
||||
$response->dynamic(new Document([
|
||||
'range' => $range,
|
||||
'collectionsCount' => $usage[$metrics[0]],
|
||||
'documentsCount' => $usage[$metrics[1]],
|
||||
'collectionsTotal' => $usage[$metrics[0]],
|
||||
'documentsTotal' => $usage[$metrics[1]],
|
||||
]), Response::MODEL_USAGE_DATABASE);
|
||||
});
|
||||
|
||||
@@ -2599,6 +2599,6 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/usage')
|
||||
|
||||
$response->dynamic(new Document([
|
||||
'range' => $range,
|
||||
'documentsCount' => $usage[$metrics[0]],
|
||||
'documentsTotal' => $usage[$metrics[0]],
|
||||
]), Response::MODEL_USAGE_COLLECTION);
|
||||
});
|
||||
|
||||
@@ -10,9 +10,9 @@ use Appwrite\Event\Usage;
|
||||
use Appwrite\Event\Validator\Event as ValidatorEvent;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Utopia\Database\Validator\CustomId;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Storage\Device;
|
||||
use Utopia\Storage\Validator\File;
|
||||
@@ -85,6 +85,7 @@ App::post('/v1/functions')
|
||||
'deployment' => '',
|
||||
'events' => $events,
|
||||
'schedule' => $schedule,
|
||||
'scheduleInternalId' => '',
|
||||
'scheduleUpdatedAt' => DateTime::now(),
|
||||
'timeout' => $timeout,
|
||||
'search' => implode(' ', [$functionId, $name, $runtime])
|
||||
@@ -95,6 +96,7 @@ App::post('/v1/functions')
|
||||
'region' => App::getEnv('_APP_REGION', 'default'), // Todo replace with projects region
|
||||
'resourceType' => 'function',
|
||||
'resourceId' => $function->getId(),
|
||||
'resourceInternalId' => $function->getInternalId(),
|
||||
'resourceUpdatedAt' => DateTime::now(),
|
||||
'projectId' => $project->getId(),
|
||||
'schedule' => $function->getAttribute('schedule'),
|
||||
@@ -236,8 +238,8 @@ App::get('/v1/functions/:functionId/usage')
|
||||
$stats = $usage = [];
|
||||
$days = $periods[$range];
|
||||
$metrics = [
|
||||
str_replace(['{resourceType}', '{resourceInternalId}'], ['functions', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS),
|
||||
str_replace(['{resourceType}', '{resourceInternalId}'], $function->getInternalId(), METRIC_FUNCTION_ID_STORAGE),
|
||||
str_replace(['{resourceType}', '{resourceInternalId}'], ['function', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS),
|
||||
str_replace(['{resourceType}', '{resourceInternalId}'], ['function', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE),
|
||||
str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS),
|
||||
str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_STORAGE),
|
||||
str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_COMPUTE),
|
||||
@@ -694,6 +696,7 @@ App::post('/v1/functions/:functionId/deployments')
|
||||
'resourceInternalId' => $function->getInternalId(),
|
||||
'resourceId' => $function->getId(),
|
||||
'resourceType' => 'functions',
|
||||
'buildInternalId' => '',
|
||||
'entrypoint' => $entrypoint,
|
||||
'path' => $path,
|
||||
'size' => $fileSize,
|
||||
@@ -725,6 +728,7 @@ App::post('/v1/functions/:functionId/deployments')
|
||||
'resourceInternalId' => $function->getInternalId(),
|
||||
'resourceId' => $function->getId(),
|
||||
'resourceType' => 'functions',
|
||||
'buildInternalId' => '',
|
||||
'entrypoint' => $entrypoint,
|
||||
'path' => $path,
|
||||
'size' => $fileSize,
|
||||
@@ -1168,8 +1172,8 @@ App::post('/v1/functions/:functionId/executions')
|
||||
* Sync execution compute usage from
|
||||
*/
|
||||
$queueForUsage
|
||||
->addMetric('executions.compute', (int)($executionResponse['duration'] * 1000))// per project
|
||||
->addMetric("{$function->getInternalId()}" . ".executions.compute", (int)($executionResponse['duration'] * 1000))// per function
|
||||
->addMetric(METRIC_EXECUTIONS_COMPUTE, (int)($executionResponse['duration'] * 1000))// per project
|
||||
->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE), (int)($executionResponse['duration'] * 1000))// per function
|
||||
;
|
||||
} catch (\Throwable $th) {
|
||||
$interval = (new \DateTime())->diff(new \DateTime($execution->getCreatedAt()));
|
||||
|
||||
@@ -29,15 +29,15 @@ App::get('/v1/project/usage')
|
||||
$stats = $usage = [];
|
||||
$days = $periods[$range];
|
||||
$metrics = [
|
||||
'network.requests',
|
||||
'network.inbound',
|
||||
'network.outbound',
|
||||
'executions',
|
||||
'documents',
|
||||
'databases',
|
||||
'users',
|
||||
'files.storage',
|
||||
'buckets',
|
||||
METRIC_NETWORK_REQUESTS,
|
||||
METRIC_NETWORK_INBOUND,
|
||||
METRIC_NETWORK_OUTBOUND,
|
||||
METRIC_EXECUTIONS,
|
||||
METRIC_DOCUMENTS,
|
||||
METRIC_DATABASES,
|
||||
METRIC_USERS,
|
||||
METRIC_BUCKETS,
|
||||
METRIC_FILES_STORAGE
|
||||
];
|
||||
|
||||
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
|
||||
@@ -50,6 +50,7 @@ App::get('/v1/project/usage')
|
||||
Query::limit($limit),
|
||||
Query::orderDesc('time'),
|
||||
]);
|
||||
|
||||
$stats[$metric] = [];
|
||||
foreach ($results as $result) {
|
||||
$stats[$metric][$result->getAttribute('time')] = [
|
||||
@@ -59,6 +60,7 @@ App::get('/v1/project/usage')
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$format = match ($days['period']) {
|
||||
'1h' => 'Y-m-d\TH:00:00.000P',
|
||||
'1d' => 'Y-m-d\T00:00:00.000P',
|
||||
@@ -77,15 +79,16 @@ App::get('/v1/project/usage')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$response->dynamic(new Document([
|
||||
'range' => $range,
|
||||
'requests' => ($usage[$metrics[0]]),
|
||||
'requestsTotal' => ($usage[$metrics[0]]),
|
||||
'network' => ($usage[$metrics[1]] + $usage[$metrics[2]]),
|
||||
'executions' => $usage[$metrics[3]],
|
||||
'documents' => $usage[$metrics[4]],
|
||||
'databases' => $usage[$metrics[5]],
|
||||
'users' => $usage[$metrics[6]],
|
||||
'storage' => $usage[$metrics[7]],
|
||||
'buckets' => $usage[$metrics[8]],
|
||||
'executionsTotal' => $usage[$metrics[3]],
|
||||
'documentsTotal' => $usage[$metrics[4]],
|
||||
'databasesTotal' => $usage[$metrics[5]],
|
||||
'usersTotal' => $usage[$metrics[6]],
|
||||
'bucketsTotal' => $usage[$metrics[7]],
|
||||
'filesStorage' => $usage[$metrics[8]],
|
||||
]), Response::MODEL_USAGE_PROJECT);
|
||||
});
|
||||
|
||||
@@ -17,11 +17,11 @@ use Utopia\Audit\Audit;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\DatetimeValidator;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Domains\Domain;
|
||||
|
||||
@@ -16,10 +16,10 @@ use Utopia\Database\Exception\Duplicate;
|
||||
use Utopia\Database\Exception\Authorization as AuthorizationException;
|
||||
use Utopia\Database\Exception\Duplicate as DuplicateException;
|
||||
use Utopia\Database\Exception\Structure as StructureException;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\Permissions;
|
||||
use Utopia\Database\Validator\UID;
|
||||
@@ -1439,8 +1439,8 @@ App::get('/v1/storage/:bucketId/usage')
|
||||
$stats = $usage = [];
|
||||
$days = $periods[$range];
|
||||
$metrics = [
|
||||
$bucket->getInternalId() . '.files',
|
||||
$bucket->getInternalId() . '.files.storage',
|
||||
str_replace('{bucketId}', $bucket->getInternalId(), METRIC_BUCKET_ID_FILES),
|
||||
str_replace('{bucketId}', $bucket->getInternalId(), METRIC_BUCKET_ID_FILES_STORAGE),
|
||||
];
|
||||
|
||||
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
|
||||
@@ -1483,7 +1483,7 @@ App::get('/v1/storage/:bucketId/usage')
|
||||
|
||||
$response->dynamic(new Document([
|
||||
'range' => $range,
|
||||
'filesCount' => $usage[$metrics[0]],
|
||||
'filesTotal' => $usage[$metrics[0]],
|
||||
'filesStorage' => $usage[$metrics[1]],
|
||||
]), Response::MODEL_USAGE_BUCKETS);
|
||||
});
|
||||
@@ -1507,9 +1507,9 @@ App::get('/v1/storage/usage')
|
||||
$stats = $usage = [];
|
||||
$days = $periods[$range];
|
||||
$metrics = [
|
||||
'buckets',
|
||||
'files',
|
||||
'files.storage',
|
||||
METRIC_BUCKETS,
|
||||
METRIC_FILES,
|
||||
METRIC_FILES_STORAGE,
|
||||
];
|
||||
|
||||
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
|
||||
@@ -1551,8 +1551,8 @@ App::get('/v1/storage/usage')
|
||||
|
||||
$response->dynamic(new Document([
|
||||
'range' => $range,
|
||||
'bucketsCount' => $usage[$metrics[0]],
|
||||
'filesCount' => $usage[$metrics[1]],
|
||||
'bucketsTotal' => $usage[$metrics[0]],
|
||||
'filesTotal' => $usage[$metrics[1]],
|
||||
'filesStorage' => $usage[$metrics[2]],
|
||||
]), Response::MODEL_USAGE_STORAGE);
|
||||
});
|
||||
|
||||
@@ -25,11 +25,11 @@ use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Exception\Authorization as AuthorizationException;
|
||||
use Utopia\Database\Exception\Duplicate;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\Key;
|
||||
use Utopia\Database\Validator\UID;
|
||||
|
||||
@@ -16,9 +16,9 @@ use Appwrite\Utopia\Response;
|
||||
use Utopia\App;
|
||||
use Utopia\Audit\Audit;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Locale\Locale;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Utopia\Database\Document;
|
||||
@@ -1089,8 +1089,8 @@ App::get('/v1/users/usage')
|
||||
$stats = $usage = [];
|
||||
$days = $periods[$range];
|
||||
$metrics = [
|
||||
'users',
|
||||
'sessions',
|
||||
METRIC_USERS,
|
||||
METRIC_SESSIONS,
|
||||
];
|
||||
|
||||
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
|
||||
@@ -1132,7 +1132,7 @@ App::get('/v1/users/usage')
|
||||
|
||||
$response->dynamic(new Document([
|
||||
'range' => $range,
|
||||
'usersCount' => $usage[$metrics[0]],
|
||||
'sessionsCount' => $usage[$metrics[1]],
|
||||
'usersTotal' => $usage[$metrics[0]],
|
||||
'sessionsTotal' => $usage[$metrics[1]],
|
||||
]), Response::MODEL_USAGE_USERS);
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
require_once __DIR__ . '/../init.php';
|
||||
|
||||
use Utopia\App;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Locale\Locale;
|
||||
use Utopia\Logger\Logger;
|
||||
use Utopia\Logger\Log;
|
||||
|
||||
@@ -7,14 +7,13 @@ use Utopia\Database\Document;
|
||||
use Appwrite\Network\Validator\Host;
|
||||
use Appwrite\Utopia\Request;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
use Utopia\App;
|
||||
use Utopia\Validator\ArrayList;
|
||||
use Utopia\Validator\Integer;
|
||||
use Utopia\Validator\Text;
|
||||
use Utopia\Storage\Validator\File;
|
||||
use Utopia\Validator\WhiteList;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
App::get('/v1/mock/tests/foo')
|
||||
->desc('Get Foo')
|
||||
|
||||
@@ -137,7 +137,7 @@ $databaseListener = function (string $event, Document $document, Document $proje
|
||||
->addMetric(METRIC_DEPLOYMENTS, $value) // per project
|
||||
->addMetric(METRIC_DEPLOYMENTS_STORAGE, $document->getAttribute('size') * $value) // per project
|
||||
->addMetric(str_replace(['{resourceType}', '{resourceInternalId}'], [$document->getAttribute('resourceType'), $document->getAttribute('resourceInternalId')], METRIC_FUNCTION_ID_DEPLOYMENTS), $value)// per function
|
||||
->addMetric(str_replace(['{resourceType}', '{resourceInternalId}'], [$document->getAttribute('resourceType'), $document->getAttribute('resourceInternalId')], METRIC_FUNCTION_ID_STORAGE), $document->getAttribute('size') * $value);// per function
|
||||
->addMetric(str_replace(['{resourceType}', '{resourceInternalId}'], [$document->getAttribute('resourceType'), $document->getAttribute('resourceInternalId')], METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE), $document->getAttribute('size') * $value);// per function
|
||||
|
||||
break;
|
||||
case $document->getCollection() === 'executions':
|
||||
@@ -514,19 +514,20 @@ App::shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($project->getId() !== 'console') {
|
||||
if ($mode !== APP_MODE_ADMIN) {
|
||||
$fileSize = 0;
|
||||
$file = $request->getFiles('file');
|
||||
|
||||
if (!empty($file)) {
|
||||
$fileSize = (\is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size'];
|
||||
}
|
||||
|
||||
$queueForUsage
|
||||
->addMetric('network.requests', 1)
|
||||
->addMetric("network.inbound", $request->getSize() + $fileSize)
|
||||
->addMetric("network.outbound", $response->getSize());
|
||||
->addMetric(METRIC_NETWORK_REQUESTS, 1)
|
||||
->addMetric(METRIC_NETWORK_INBOUND, $request->getSize() + $fileSize)
|
||||
->addMetric(METRIC_NETWORK_OUTBOUND, $response->getSize());
|
||||
}
|
||||
|
||||
$queueForUsage
|
||||
|
||||
+3
-3
@@ -10,9 +10,9 @@ use Swoole\Http\Response as SwooleResponse;
|
||||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Audit\Audit;
|
||||
use Utopia\Abuse\Adapters\TimeLimit;
|
||||
|
||||
+5
-3
@@ -41,7 +41,7 @@ use Appwrite\URL\URL as AppwriteURL;
|
||||
use Utopia\App;
|
||||
use Utopia\Validator\Range;
|
||||
use Utopia\Validator\WhiteList;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Query;
|
||||
@@ -199,12 +199,14 @@ const METRIC_FUNCTION_ID_BUILDS = '{functionInternalId}.builds';
|
||||
const METRIC_FUNCTION_ID_BUILDS_STORAGE = '{functionInternalId}.builds.storage';
|
||||
const METRIC_FUNCTION_ID_BUILDS_COMPUTE = '{functionInternalId}.builds.compute';
|
||||
const METRIC_FUNCTION_ID_DEPLOYMENTS = '{resourceType}.{resourceInternalId}.deployments';
|
||||
const METRIC_FUNCTION_ID_STORAGE = '{resourceType}.{resourceInternalId}.deployments.storage';
|
||||
const METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE = '{resourceType}.{resourceInternalId}.deployments.storage';
|
||||
const METRIC_EXECUTIONS = 'executions';
|
||||
const METRIC_EXECUTIONS_COMPUTE = 'executions.compute';
|
||||
const METRIC_FUNCTION_ID_EXECUTIONS = '{functionInternalId}.executions';
|
||||
const METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE = '{functionInternalId}.executions.compute';
|
||||
|
||||
const METRIC_NETWORK_REQUESTS = 'network.requests';
|
||||
const METRIC_NETWORK_INBOUND = 'network.inbound';
|
||||
const METRIC_NETWORK_OUTBOUND = 'network.outbound';
|
||||
|
||||
$register = new Registry();
|
||||
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ use Utopia\Abuse\Abuse;
|
||||
use Utopia\Abuse\Adapters\TimeLimit;
|
||||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Logger\Log;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Document;
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ Server::setResource('pools', function ($register) {
|
||||
$pools = $register->get('pools');
|
||||
$connection = $pools->get('queue')->pop()->getResource();
|
||||
$workerNumber = swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6));
|
||||
|
||||
$workerNumber = 1;
|
||||
if (empty(App::getEnv('QUEUE'))) {
|
||||
throw new Exception('Please configure "QUEUE" environemnt variable.');
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use Executor\Executor;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\DSN\DSN;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Config\Config;
|
||||
|
||||
@@ -8,7 +8,7 @@ use Utopia\CLI\Console;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Domains\Domain;
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@ use Utopia\CLI\Console;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Queue\Server;
|
||||
|
||||
|
||||
+34
-32
@@ -45,27 +45,27 @@ Server::setResource('reduce', function (Cache $cache, Registry $register, $pools
|
||||
|
||||
switch (true) {
|
||||
case $document->getCollection() === 'users': // users
|
||||
$sessions = count($document->getAttribute('sessions', 0));
|
||||
$sessions = count($document->getAttribute(METRIC_SESSIONS, 0));
|
||||
if (!empty($sessions)) {
|
||||
$metrics[] = [
|
||||
'key' => 'sessions',
|
||||
'key' => METRIC_SESSIONS,
|
||||
'value' => ($sessions * -1),
|
||||
];
|
||||
}
|
||||
break;
|
||||
case $document->getCollection() === 'databases': // databases
|
||||
$collections = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".collections"));
|
||||
$documents = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".documents"));
|
||||
$collections = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{databaseId}', $document->getInternalId(), METRIC_DATABASE_ID_COLLECTIONS)));
|
||||
$documents = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{databaseId}', $document->getInternalId(), METRIC_DATABASE_ID_DOCUMENTS)));
|
||||
if (!empty($collections['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'collections',
|
||||
'key' => METRIC_COLLECTIONS,
|
||||
'value' => ($collections['value'] * -1),
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($documents['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'documents',
|
||||
'key' => METRIC_DOCUMENTS,
|
||||
'value' => ($documents['value'] * -1),
|
||||
];
|
||||
}
|
||||
@@ -73,93 +73,93 @@ Server::setResource('reduce', function (Cache $cache, Registry $register, $pools
|
||||
case str_starts_with($document->getCollection(), 'database_') && !str_contains($document->getCollection(), 'collection'): //collections
|
||||
$parts = explode('_', $document->getCollection());
|
||||
$databaseId = $parts[1] ?? 0;
|
||||
$documents = $dbForProject->getDocument('stats', md5("_inf_" . "{$databaseId}" . "." . "{$document->getInternalId()}" . ".documents"));
|
||||
$documents = $dbForProject->getDocument('stats', md5("_inf_" . str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $document->getInternalId()], METRIC_DATABASE_ID_COLLECTION_ID_DOCUMENTS)));
|
||||
|
||||
if (!empty($documents['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'documents',
|
||||
'key' => METRIC_DOCUMENTS,
|
||||
'value' => ($documents['value'] * -1),
|
||||
];
|
||||
$metrics[] = [
|
||||
'key' => "{$databaseId}" . ".documents",
|
||||
'key' => str_replace('{databaseId}', $databaseId, METRIC_DATABASE_ID_DOCUMENTS),
|
||||
'value' => ($documents['value'] * -1),
|
||||
];
|
||||
}
|
||||
break;
|
||||
|
||||
case $document->getCollection() === 'buckets':
|
||||
$files = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".files"));
|
||||
$storage = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".files.storage"));
|
||||
$files = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{bucketId}', $document->getInternalId(), METRIC_BUCKET_ID_FILES)));
|
||||
$storage = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{bucketId}', $document->getInternalId(), METRIC_BUCKET_ID_FILES_STORAGE)));
|
||||
|
||||
if (!empty($files['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'files',
|
||||
'key' => METRIC_FILES,
|
||||
'value' => ($files['value'] * -1),
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($storage['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'files.storage',
|
||||
'key' => METRIC_FILES_STORAGE,
|
||||
'value' => ($storage['value'] * -1),
|
||||
];
|
||||
}
|
||||
break;
|
||||
|
||||
case $document->getCollection() === 'functions':
|
||||
$deployments = $dbForProject->getDocument('stats', md5("_inf_function." . "{$document->getInternalId()}" . ".deployments"));
|
||||
$deploymentsStorage = $dbForProject->getDocument('stats', md5("_inf_function." . "{$document->getInternalId()}" . ".deployments.storage"));
|
||||
$builds = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".builds"));
|
||||
$buildsStorage = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".builds.storage"));
|
||||
$buildsCompute = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".builds.compute"));
|
||||
$executions = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".executions"));
|
||||
$executionsCompute = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".executions.compute"));
|
||||
$deployments = $dbForProject->getDocument('stats', md5("_inf_" . str_replace(['{resourceType}', '{resourceInternalId}'], ['function', $document->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS)));
|
||||
$deploymentsStorage = $dbForProject->getDocument('stats', md5("_inf_" . str_replace(['{resourceType}', '{resourceInternalId}'], ['function', $document->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE)));
|
||||
$builds = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_BUILDS)));
|
||||
$buildsStorage = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_BUILDS_STORAGE)));
|
||||
$buildsCompute = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_BUILDS_COMPUTE)));
|
||||
$executions = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS)));
|
||||
$executionsCompute = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE)));
|
||||
|
||||
if (!empty($deployments['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'deployments',
|
||||
'key' => METRIC_DEPLOYMENTS,
|
||||
'value' => ($deployments['value'] * -1),
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($deploymentsStorage['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'deployments.storage',
|
||||
'key' => METRIC_DEPLOYMENTS_STORAGE,
|
||||
'value' => ($deploymentsStorage['value'] * -1),
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($builds['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'builds',
|
||||
'key' => METRIC_BUILDS,
|
||||
'value' => ($builds['value'] * -1),
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($buildsStorage['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'builds.storage',
|
||||
'key' => METRIC_BUILDS_STORAGE,
|
||||
'value' => ($buildsStorage['value'] * -1),
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($buildsCompute['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'builds.compute',
|
||||
'key' => METRIC_BUILDS_COMPUTE,
|
||||
'value' => ($buildsCompute['value'] * -1),
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($executions['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'executions',
|
||||
'key' => METRIC_EXECUTIONS,
|
||||
'value' => ($executionsCompute['value'] * -1),
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($executionsCompute['value'])) {
|
||||
$metrics[] = [
|
||||
'key' => 'executions.compute',
|
||||
'key' => METRIC_EXECUTIONS_COMPUTE,
|
||||
'value' => ($executionsCompute['value'] * -1),
|
||||
];
|
||||
}
|
||||
@@ -234,7 +234,7 @@ $server
|
||||
|
||||
$dbForProject->setNamespace('_' . $projectInternalId);
|
||||
|
||||
foreach ($project['keys'] as $key => $value) {
|
||||
foreach ($project['keys'] ?? [] as $key => $value) {
|
||||
if ($value == 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -271,10 +271,12 @@ $server
|
||||
}
|
||||
}
|
||||
}
|
||||
$dbForProject->createDocument('statsLogger', new Document([
|
||||
'time' => DateTime::now(),
|
||||
'metrics' => $project['keys'],
|
||||
]));
|
||||
if (!empty($project['keys'])) {
|
||||
$dbForProject->createDocument('statsLogger', new Document([
|
||||
'time' => DateTime::now(),
|
||||
'metrics' => $project['keys'],
|
||||
]));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
console::error("[logger] " . " {DateTime::now()} " . " {$projectInternalId} " . " {$e->getMessage()}");
|
||||
} finally {
|
||||
|
||||
Generated
+34
-33
@@ -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": "36ef20efb91c04f1985f7dbaf52450f5",
|
||||
"content-hash": "290f8f03716871b264f9dd88b0ef60a9",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
@@ -2246,16 +2246,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/storage",
|
||||
"version": "0.13.0",
|
||||
"version": "0.13.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/storage.git",
|
||||
"reference": "f34c010e4f8394a6b4aff70b6de55041d9a145d3"
|
||||
"reference": "ad1c00f24ca56e73888acc2af3deee4919b1194b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/storage/zipball/f34c010e4f8394a6b4aff70b6de55041d9a145d3",
|
||||
"reference": "f34c010e4f8394a6b4aff70b6de55041d9a145d3",
|
||||
"url": "https://api.github.com/repos/utopia-php/storage/zipball/ad1c00f24ca56e73888acc2af3deee4919b1194b",
|
||||
"reference": "ad1c00f24ca56e73888acc2af3deee4919b1194b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2295,9 +2295,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/storage/issues",
|
||||
"source": "https://github.com/utopia-php/storage/tree/0.13.0"
|
||||
"source": "https://github.com/utopia-php/storage/tree/0.13.2"
|
||||
},
|
||||
"time": "2022-11-17T15:10:18+00:00"
|
||||
"time": "2022-12-20T11:11:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/swoole",
|
||||
@@ -3162,20 +3162,20 @@
|
||||
},
|
||||
{
|
||||
"name": "phpspec/prophecy",
|
||||
"version": "v1.16.0",
|
||||
"version": "v1.17.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpspec/prophecy.git",
|
||||
"reference": "be8cac52a0827776ff9ccda8c381ac5b71aeb359"
|
||||
"reference": "15873c65b207b07765dbc3c95d20fdf4a320cbe2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/be8cac52a0827776ff9ccda8c381ac5b71aeb359",
|
||||
"reference": "be8cac52a0827776ff9ccda8c381ac5b71aeb359",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/15873c65b207b07765dbc3c95d20fdf4a320cbe2",
|
||||
"reference": "15873c65b207b07765dbc3c95d20fdf4a320cbe2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/instantiator": "^1.2",
|
||||
"doctrine/instantiator": "^1.2 || ^2.0",
|
||||
"php": "^7.2 || 8.0.* || 8.1.* || 8.2.*",
|
||||
"phpdocumentor/reflection-docblock": "^5.2",
|
||||
"sebastian/comparator": "^3.0 || ^4.0",
|
||||
@@ -3183,6 +3183,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "^6.0 || ^7.0",
|
||||
"phpstan/phpstan": "^1.9",
|
||||
"phpunit/phpunit": "^8.0 || ^9.0"
|
||||
},
|
||||
"type": "library",
|
||||
@@ -3223,9 +3224,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/phpspec/prophecy/issues",
|
||||
"source": "https://github.com/phpspec/prophecy/tree/v1.16.0"
|
||||
"source": "https://github.com/phpspec/prophecy/tree/v1.17.0"
|
||||
},
|
||||
"time": "2022-11-29T15:06:56+00:00"
|
||||
"time": "2023-02-02T15:41:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
@@ -4014,16 +4015,16 @@
|
||||
},
|
||||
{
|
||||
"name": "sebastian/environment",
|
||||
"version": "5.1.4",
|
||||
"version": "5.1.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/environment.git",
|
||||
"reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7"
|
||||
"reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7",
|
||||
"reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed",
|
||||
"reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -4065,7 +4066,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/environment/issues",
|
||||
"source": "https://github.com/sebastianbergmann/environment/tree/5.1.4"
|
||||
"source": "https://github.com/sebastianbergmann/environment/tree/5.1.5"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -4073,7 +4074,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-04-03T09:37:03+00:00"
|
||||
"time": "2023-02-03T06:03:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/exporter",
|
||||
@@ -4387,16 +4388,16 @@
|
||||
},
|
||||
{
|
||||
"name": "sebastian/recursion-context",
|
||||
"version": "4.0.4",
|
||||
"version": "4.0.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/recursion-context.git",
|
||||
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172"
|
||||
"reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172",
|
||||
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1",
|
||||
"reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -4435,10 +4436,10 @@
|
||||
}
|
||||
],
|
||||
"description": "Provides functionality to recursively process PHP variables",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
|
||||
"homepage": "https://github.com/sebastianbergmann/recursion-context",
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
|
||||
"source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4"
|
||||
"source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -4446,7 +4447,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2020-10-26T13:17:30+00:00"
|
||||
"time": "2023-02-03T06:07:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/resource-operations",
|
||||
@@ -4505,16 +4506,16 @@
|
||||
},
|
||||
{
|
||||
"name": "sebastian/type",
|
||||
"version": "3.2.0",
|
||||
"version": "3.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/type.git",
|
||||
"reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e"
|
||||
"reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e",
|
||||
"reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7",
|
||||
"reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -4549,7 +4550,7 @@
|
||||
"homepage": "https://github.com/sebastianbergmann/type",
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/type/issues",
|
||||
"source": "https://github.com/sebastianbergmann/type/tree/3.2.0"
|
||||
"source": "https://github.com/sebastianbergmann/type/tree/3.2.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -4557,7 +4558,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-09-12T14:47:03+00:00"
|
||||
"time": "2023-02-03T06:13:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/version",
|
||||
|
||||
+5
-3
@@ -554,6 +554,8 @@ services:
|
||||
environment:
|
||||
- _APP_ENV
|
||||
- _APP_WORKER_PER_CORE
|
||||
- _APP_CONNECTIONS_MAX
|
||||
- _APP_POOL_CLIENTS
|
||||
- _APP_DOMAIN
|
||||
- _APP_DOMAIN_TARGET
|
||||
- _APP_OPENSSL_KEY_V1
|
||||
@@ -653,7 +655,7 @@ services:
|
||||
image: openruntimes/executor:0.2.0
|
||||
networks:
|
||||
- appwrite
|
||||
- openruntimes-runtimes
|
||||
- runtimes
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- appwrite-builds:/storage/builds:rw
|
||||
@@ -809,8 +811,8 @@ networks:
|
||||
name: gateway
|
||||
appwrite:
|
||||
name: appwrite
|
||||
openruntimes-runtimes:
|
||||
name: openruntimes-runtimes
|
||||
runtimes:
|
||||
name: runtimes
|
||||
|
||||
volumes:
|
||||
appwrite-mariadb:
|
||||
|
||||
@@ -9,10 +9,9 @@ use Appwrite\Auth\Hash\Phpass;
|
||||
use Appwrite\Auth\Hash\Scrypt;
|
||||
use Appwrite\Auth\Hash\Scryptmodified;
|
||||
use Appwrite\Auth\Hash\Sha;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\Roles;
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Document;
|
||||
use Appwrite\Messaging\Adapter;
|
||||
use Utopia\App;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class Realtime extends Adapter
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ use Utopia\CLI\Console;
|
||||
use Utopia\Config\Config;
|
||||
use Exception;
|
||||
use Utopia\App;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
|
||||
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
|
||||
|
||||
@@ -11,9 +11,9 @@ use Utopia\CLI\Console;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class V15 extends Migration
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
|
||||
class PatchCreateMissingSchedules extends Action
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace Appwrite\Specification\Format;
|
||||
use Appwrite\Specification\Format;
|
||||
use Appwrite\Template\Template;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Validator;
|
||||
|
||||
class OpenAPI3 extends Format
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace Appwrite\Specification\Format;
|
||||
use Appwrite\Specification\Format;
|
||||
use Appwrite\Template\Template;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Validator;
|
||||
|
||||
class Swagger2 extends Format
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace Appwrite\Utopia\Request\Filters;
|
||||
|
||||
use Appwrite\Utopia\Request\Filter;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class V15 extends Filter
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace Appwrite\Utopia\Response\Filters;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Filter;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class V15 extends Filter
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class Execution extends Model
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ class UsageBuckets extends Model
|
||||
'default' => '',
|
||||
'example' => '30d',
|
||||
])
|
||||
->addRule('filesCount', [
|
||||
->addRule('filesTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for total number of files in this bucket.',
|
||||
'default' => [],
|
||||
|
||||
@@ -16,7 +16,7 @@ class UsageCollection extends Model
|
||||
'default' => '',
|
||||
'example' => '30d',
|
||||
])
|
||||
->addRule('documentsCount', [
|
||||
->addRule('documentsTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for total number of documents.',
|
||||
'default' => [],
|
||||
|
||||
@@ -16,14 +16,14 @@ class UsageDatabase extends Model
|
||||
'default' => '',
|
||||
'example' => '30d',
|
||||
])
|
||||
->addRule('collectionsCount', [
|
||||
->addRule('collectionsTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for total number of collections.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('documentsCount', [
|
||||
->addRule('documentsTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for total number of documents.',
|
||||
'default' => [],
|
||||
|
||||
@@ -16,21 +16,21 @@ class UsageDatabases extends Model
|
||||
'default' => '',
|
||||
'example' => '30d',
|
||||
])
|
||||
->addRule('databasesCount', [
|
||||
->addRule('databasesTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for total number of documents.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('collectionsCount', [
|
||||
->addRule('collectionsTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for total number of collections.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('documentsCount', [
|
||||
->addRule('documentsTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for total number of documents.',
|
||||
'default' => [],
|
||||
|
||||
@@ -16,7 +16,7 @@ class UsageProject extends Model
|
||||
'default' => '',
|
||||
'example' => '30d',
|
||||
])
|
||||
->addRule('requests', [
|
||||
->addRule('requestsTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for number of requests.',
|
||||
'default' => [],
|
||||
@@ -30,42 +30,42 @@ class UsageProject extends Model
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('executions', [
|
||||
->addRule('executionsTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for function executions.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('documents', [
|
||||
->addRule('documentsTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for number of documents.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('databases', [
|
||||
->addRule('databasesTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for number of databases.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('users', [
|
||||
->addRule('usersTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for number of users.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('storage', [
|
||||
->addRule('filesStorage', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for the occupied storage size (in bytes).',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('buckets', [
|
||||
->addRule('bucketsTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for number of buckets.',
|
||||
'default' => [],
|
||||
|
||||
@@ -16,14 +16,14 @@ class UsageStorage extends Model
|
||||
'default' => '',
|
||||
'example' => '30d',
|
||||
])
|
||||
->addRule('bucketsCount', [
|
||||
->addRule('bucketsTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for total number of buckets.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('filesCount', [
|
||||
->addRule('filesTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for total number of files.',
|
||||
'default' => [],
|
||||
|
||||
@@ -16,7 +16,7 @@ class UsageUsers extends Model
|
||||
'default' => '',
|
||||
'example' => '30d',
|
||||
])
|
||||
->addRule('usersCount', [
|
||||
->addRule('usersTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for total number of users.',
|
||||
'default' => [],
|
||||
@@ -24,7 +24,7 @@ class UsageUsers extends Model
|
||||
'array' => true
|
||||
])
|
||||
|
||||
->addRule('sessionsCount', [
|
||||
->addRule('sessionsTotal', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated stats for sessions created.',
|
||||
'default' => [],
|
||||
|
||||
@@ -8,9 +8,9 @@ use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideNone;
|
||||
use Utopia\App;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class AbuseTest extends Scope
|
||||
{
|
||||
|
||||
+127
-125
@@ -9,8 +9,9 @@ use Tests\E2E\Scopes\SideServer;
|
||||
use CURLFile;
|
||||
use Tests\E2E\Services\Functions\FunctionsBase;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\DatetimeValidator;
|
||||
|
||||
class UsageTest extends Scope
|
||||
{
|
||||
@@ -45,8 +46,8 @@ class UsageTest extends Scope
|
||||
$headers['x-appwrite-key'] = $project['apiKey'];
|
||||
$headers['content-type'] = 'application/json';
|
||||
|
||||
$usersCount = 0;
|
||||
$requestsCount = 0;
|
||||
$usersTotal = 0;
|
||||
$requestsTotal = 0;
|
||||
for ($i = 0; $i < self::CREATE; $i++) {
|
||||
$email = uniqid() . 'user@usage.test';
|
||||
$password = 'password';
|
||||
@@ -65,23 +66,23 @@ class UsageTest extends Scope
|
||||
|
||||
$this->assertEquals($email, $res['body']['email']);
|
||||
$this->assertNotEmpty($res['body']['$id']);
|
||||
$usersCount++;
|
||||
$requestsCount++;
|
||||
$usersTotal++;
|
||||
$requestsTotal++;
|
||||
|
||||
if ($i < (self::CREATE / 2)) {
|
||||
$userId = $res['body']['$id'];
|
||||
$res = $this->client->call(Client::METHOD_DELETE, '/users/' . $userId, $headers);
|
||||
$this->assertEmpty($res['body']);
|
||||
$requestsCount++;
|
||||
$usersCount--;
|
||||
$requestsTotal++;
|
||||
$usersTotal--;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'projectId' => $projectId,
|
||||
'headers' => $headers,
|
||||
'usersCount' => $usersCount,
|
||||
'requestsCount' => $requestsCount
|
||||
'usersTotal' => $usersTotal,
|
||||
'requestsTotal' => $requestsTotal
|
||||
];
|
||||
}
|
||||
|
||||
@@ -94,8 +95,8 @@ class UsageTest extends Scope
|
||||
|
||||
$projectId = $data['projectId'];
|
||||
$headers = $data['headers'];
|
||||
$usersCount = $data['usersCount'];
|
||||
$requestsCount = $data['requestsCount'];
|
||||
$usersTotal = $data['usersTotal'];
|
||||
$requestsTotal = $data['requestsTotal'];
|
||||
|
||||
$consoleHeaders = [
|
||||
'origin' => 'http://localhost',
|
||||
@@ -114,12 +115,12 @@ class UsageTest extends Scope
|
||||
|
||||
$this->assertEquals('24h', $res['range']);
|
||||
$this->assertEquals(9, count($res));
|
||||
$this->assertEquals(24, count($res['requests']));
|
||||
$this->assertEquals(24, count($res['users']));
|
||||
$this->assertEquals($usersCount, $res['users'][array_key_last($res['users'])]['value']);
|
||||
$this->validateDates($res['users']);
|
||||
$this->assertEquals($requestsCount, $res['requests'][array_key_last($res['requests'])]['value']);
|
||||
$this->validateDates($res['requests']);
|
||||
$this->assertEquals(24, count($res['requestsTotal']));
|
||||
$this->assertEquals(24, count($res['usersTotal']));
|
||||
$this->assertEquals($usersTotal, $res['usersTotal'][array_key_last($res['usersTotal'])]['value']);
|
||||
$this->validateDates($res['usersTotal']);
|
||||
$this->assertEquals($requestsTotal, $res['requestsTotal'][array_key_last($res['requestsTotal'])]['value']);
|
||||
$this->validateDates($res['requestsTotal']);
|
||||
|
||||
$res = $this->client->call(
|
||||
Client::METHOD_GET,
|
||||
@@ -129,15 +130,15 @@ class UsageTest extends Scope
|
||||
|
||||
$res = $res['body'];
|
||||
$this->assertEquals('90d', $res['range']);
|
||||
$this->assertEquals(90, count($res['usersCount']));
|
||||
$this->assertEquals(90, count($res['sessionsCount']));
|
||||
$this->assertEquals((self::CREATE / 2), $res['usersCount'][array_key_last($res['usersCount'])]['value']);
|
||||
$this->assertEquals(90, count($res['usersTotal']));
|
||||
$this->assertEquals(90, count($res['sessionsTotal']));
|
||||
$this->assertEquals((self::CREATE / 2), $res['usersTotal'][array_key_last($res['usersTotal'])]['value']);
|
||||
|
||||
return [
|
||||
'projectId' => $projectId,
|
||||
'headers' => $headers,
|
||||
'consoleHeaders' => $consoleHeaders,
|
||||
'requestsCount' => $requestsCount,
|
||||
'requestsTotal' => $requestsTotal,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -145,10 +146,10 @@ class UsageTest extends Scope
|
||||
public function testPrepareStorageStats(array $data): array
|
||||
{
|
||||
$headers = $data['headers'];
|
||||
$bucketsCount = 0;
|
||||
$requestsCount = $data['requestsCount'];
|
||||
$bucketsTotal = 0;
|
||||
$requestsTotal = $data['requestsTotal'];
|
||||
$storageTotal = 0;
|
||||
$filesCount = 0;
|
||||
$filesTotal = 0;
|
||||
|
||||
|
||||
for ($i = 0; $i < self::CREATE; $i++) {
|
||||
@@ -177,8 +178,8 @@ class UsageTest extends Scope
|
||||
$this->assertEquals($name, $res['body']['name']);
|
||||
$this->assertNotEmpty($res['body']['$id']);
|
||||
$bucketId = $res['body']['$id'];
|
||||
$bucketsCount++;
|
||||
$requestsCount++;
|
||||
$bucketsTotal++;
|
||||
$requestsTotal++;
|
||||
|
||||
if ($i < (self::CREATE / 2)) {
|
||||
$res = $this->client->call(
|
||||
@@ -187,8 +188,8 @@ class UsageTest extends Scope
|
||||
$headers
|
||||
);
|
||||
$this->assertEmpty($res['body']);
|
||||
$requestsCount++;
|
||||
$bucketsCount--;
|
||||
$requestsTotal++;
|
||||
$bucketsTotal--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,8 +230,8 @@ class UsageTest extends Scope
|
||||
|
||||
$fileSize = $res['body']['sizeOriginal'];
|
||||
$storageTotal += $fileSize;
|
||||
$filesCount++;
|
||||
$requestsCount++;
|
||||
$filesTotal++;
|
||||
$requestsTotal++;
|
||||
|
||||
$fileId = $res['body']['$id'];
|
||||
if ($i < (self::CREATE / 2)) {
|
||||
@@ -240,18 +241,18 @@ class UsageTest extends Scope
|
||||
$headers
|
||||
);
|
||||
$this->assertEmpty($res['body']);
|
||||
$requestsCount++;
|
||||
$filesCount--;
|
||||
$requestsTotal++;
|
||||
$filesTotal--;
|
||||
$storageTotal -= $fileSize;
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge($data, [
|
||||
'bucketId' => $bucketId,
|
||||
'bucketsCount' => $bucketsCount,
|
||||
'requestsCount' => $requestsCount,
|
||||
'bucketsTotal' => $bucketsTotal,
|
||||
'requestsTotal' => $requestsTotal,
|
||||
'storageTotal' => $storageTotal,
|
||||
'filesCount' => $filesCount,
|
||||
'filesTotal' => $filesTotal,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -261,10 +262,10 @@ class UsageTest extends Scope
|
||||
public function testStorageStats(array $data): array
|
||||
{
|
||||
$bucketId = $data['bucketId'];
|
||||
$bucketsCount = $data['bucketsCount'];
|
||||
$requestsCount = $data['requestsCount'];
|
||||
$bucketsTotal = $data['bucketsTotal'];
|
||||
$requestsTotal = $data['requestsTotal'];
|
||||
$storageTotal = $data['storageTotal'];
|
||||
$filesCount = $data['filesCount'];
|
||||
$filesTotal = $data['filesTotal'];
|
||||
|
||||
sleep(self::WAIT);
|
||||
|
||||
@@ -279,12 +280,12 @@ class UsageTest extends Scope
|
||||
$res = $res['body'];
|
||||
|
||||
$this->assertEquals(9, count($res));
|
||||
$this->assertEquals(30, count($res['requests']));
|
||||
$this->assertEquals(30, count($res['storage']));
|
||||
$this->assertEquals($requestsCount, $res['requests'][array_key_last($res['requests'])]['value']);
|
||||
$this->validateDates($res['requests']);
|
||||
$this->assertEquals($storageTotal, $res['storage'][array_key_last($res['storage'])]['value']);
|
||||
$this->validateDates($res['storage']);
|
||||
$this->assertEquals(30, count($res['requestsTotal']));
|
||||
$this->assertEquals(30, count($res['filesStorage']));
|
||||
$this->assertEquals($requestsTotal, $res['requestsTotal'][array_key_last($res['requestsTotal'])]['value']);
|
||||
$this->validateDates($res['requestsTotal']);
|
||||
$this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesStorage'])]['value']);
|
||||
$this->validateDates($res['filesStorage']);
|
||||
|
||||
$res = $this->client->call(
|
||||
Client::METHOD_GET,
|
||||
@@ -296,12 +297,12 @@ class UsageTest extends Scope
|
||||
);
|
||||
|
||||
$res = $res['body'];
|
||||
$this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesStorage'])]['value']);
|
||||
$this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesTotal'])]['value']);
|
||||
$this->validateDates($res['filesStorage']);
|
||||
$this->assertEquals($bucketsCount, $res['bucketsCount'][array_key_last($res['bucketsCount'])]['value']);
|
||||
$this->validateDates($res['bucketsCount']);
|
||||
$this->assertEquals($filesCount, $res['filesCount'][array_key_last($res['filesCount'])]['value']);
|
||||
$this->validateDates($res['filesCount']);
|
||||
$this->assertEquals($bucketsTotal, $res['bucketsTotal'][array_key_last($res['bucketsTotal'])]['value']);
|
||||
$this->validateDates($res['bucketsTotal']);
|
||||
$this->assertEquals($filesTotal, $res['filesTotal'][array_key_last($res['filesTotal'])]['value']);
|
||||
$this->validateDates($res['filesTotal']);
|
||||
|
||||
$res = $this->client->call(
|
||||
Client::METHOD_GET,
|
||||
@@ -314,9 +315,9 @@ class UsageTest extends Scope
|
||||
|
||||
$res = $res['body'];
|
||||
$this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesStorage'])]['value']);
|
||||
$this->assertEquals($filesCount, $res['filesCount'][array_key_last($res['filesCount'])]['value']);
|
||||
$this->assertEquals($filesTotal, $res['filesTotal'][array_key_last($res['filesTotal'])]['value']);
|
||||
|
||||
$data['requestsCount'] = $requestsCount;
|
||||
$data['requestsTotal'] = $requestsTotal;
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -326,10 +327,10 @@ class UsageTest extends Scope
|
||||
{
|
||||
$headers = $data['headers'];
|
||||
|
||||
$requestsCount = $data['requestsCount'];
|
||||
$databasesCount = 0;
|
||||
$collectionsCount = 0;
|
||||
$documentsCount = 0;
|
||||
$requestsTotal = $data['requestsTotal'];
|
||||
$databasesTotal = 0;
|
||||
$collectionsTotal = 0;
|
||||
$documentsTotal = 0;
|
||||
|
||||
for ($i = 0; $i < self::CREATE; $i++) {
|
||||
$name = uniqid() . ' database';
|
||||
@@ -348,8 +349,8 @@ class UsageTest extends Scope
|
||||
$this->assertNotEmpty($res['body']['$id']);
|
||||
$databaseId = $res['body']['$id'];
|
||||
|
||||
$requestsCount++;
|
||||
$databasesCount++;
|
||||
$requestsTotal++;
|
||||
$databasesTotal++;
|
||||
|
||||
if ($i < (self::CREATE / 2)) {
|
||||
$res = $this->client->call(
|
||||
@@ -359,8 +360,8 @@ class UsageTest extends Scope
|
||||
);
|
||||
$this->assertEmpty($res['body']);
|
||||
|
||||
$databasesCount--;
|
||||
$requestsCount++;
|
||||
$databasesTotal--;
|
||||
$requestsTotal++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,8 +388,8 @@ class UsageTest extends Scope
|
||||
$this->assertNotEmpty($res['body']['$id']);
|
||||
$collectionId = $res['body']['$id'];
|
||||
|
||||
$requestsCount++;
|
||||
$collectionsCount++;
|
||||
$requestsTotal++;
|
||||
$collectionsTotal++;
|
||||
|
||||
if ($i < (self::CREATE / 2)) {
|
||||
$res = $this->client->call(
|
||||
@@ -397,8 +398,8 @@ class UsageTest extends Scope
|
||||
$headers
|
||||
);
|
||||
$this->assertEmpty($res['body']);
|
||||
$collectionsCount--;
|
||||
$requestsCount++;
|
||||
$collectionsTotal--;
|
||||
$requestsTotal++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,7 +415,7 @@ class UsageTest extends Scope
|
||||
);
|
||||
|
||||
$this->assertEquals('name', $res['body']['key']);
|
||||
$requestsCount++;
|
||||
$requestsTotal++;
|
||||
|
||||
sleep(self::WAIT);
|
||||
|
||||
@@ -433,8 +434,8 @@ class UsageTest extends Scope
|
||||
$this->assertNotEmpty($res['body']['$id']);
|
||||
$documentId = $res['body']['$id'];
|
||||
|
||||
$requestsCount++;
|
||||
$documentsCount++;
|
||||
$requestsTotal++;
|
||||
$documentsTotal++;
|
||||
|
||||
if ($i < (self::CREATE / 2)) {
|
||||
$res = $this->client->call(
|
||||
@@ -443,18 +444,18 @@ class UsageTest extends Scope
|
||||
$headers
|
||||
);
|
||||
$this->assertEmpty($res['body']);
|
||||
$documentsCount--;
|
||||
$requestsCount++;
|
||||
$documentsTotal--;
|
||||
$requestsTotal++;
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge($data, [
|
||||
'databaseId' => $databaseId,
|
||||
'collectionId' => $collectionId,
|
||||
'requestsCount' => $requestsCount,
|
||||
'databasesCount' => $databasesCount,
|
||||
'collectionsCount' => $collectionsCount,
|
||||
'documentsCount' => $documentsCount,
|
||||
'requestsTotal' => $requestsTotal,
|
||||
'databasesTotal' => $databasesTotal,
|
||||
'collectionsTotal' => $collectionsTotal,
|
||||
'documentsTotal' => $documentsTotal,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -466,10 +467,10 @@ class UsageTest extends Scope
|
||||
$projectId = $data['projectId'];
|
||||
$databaseId = $data['databaseId'];
|
||||
$collectionId = $data['collectionId'];
|
||||
$requestsCount = $data['requestsCount'];
|
||||
$databasesCount = $data['databasesCount'];
|
||||
$collectionsCount = $data['collectionsCount'];
|
||||
$documentsCount = $data['documentsCount'];
|
||||
$requestsTotal = $data['requestsTotal'];
|
||||
$databasesTotal = $data['databasesTotal'];
|
||||
$collectionsTotal = $data['collectionsTotal'];
|
||||
$documentsTotal = $data['documentsTotal'];
|
||||
|
||||
sleep(self::WAIT);
|
||||
|
||||
@@ -481,14 +482,14 @@ class UsageTest extends Scope
|
||||
$res = $res['body'];
|
||||
|
||||
$this->assertEquals(9, count($res));
|
||||
$this->assertEquals(30, count($res['requests']));
|
||||
$this->assertEquals(30, count($res['storage']));
|
||||
$this->assertEquals($requestsCount, $res['requests'][array_key_last($res['requests'])]['value']);
|
||||
$this->validateDates($res['requests']);
|
||||
$this->assertEquals($databasesCount, $res['databases'][array_key_last($res['databases'])]['value']);
|
||||
$this->validateDates($res['databases']);
|
||||
$this->assertEquals($documentsCount, $res['documents'][array_key_last($res['documents'])]['value']);
|
||||
$this->validateDates($res['documents']);
|
||||
$this->assertEquals(30, count($res['requestsTotal']));
|
||||
$this->assertEquals(30, count($res['filesStorage']));
|
||||
$this->assertEquals($requestsTotal, $res['requestsTotal'][array_key_last($res['requestsTotal'])]['value']);
|
||||
$this->validateDates($res['requestsTotal']);
|
||||
$this->assertEquals($databasesTotal, $res['databasesTotal'][array_key_last($res['databasesTotal'])]['value']);
|
||||
$this->validateDates($res['databasesTotal']);
|
||||
$this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']);
|
||||
$this->validateDates($res['documentsTotal']);
|
||||
|
||||
$res = $this->client->call(
|
||||
Client::METHOD_GET,
|
||||
@@ -497,12 +498,12 @@ class UsageTest extends Scope
|
||||
);
|
||||
$res = $res['body'];
|
||||
|
||||
$this->assertEquals($databasesCount, $res['databasesCount'][array_key_last($res['databasesCount'])]['value']);
|
||||
$this->validateDates($res['databasesCount']);
|
||||
$this->assertEquals($collectionsCount, $res['collectionsCount'][array_key_last($res['collectionsCount'])]['value']);
|
||||
$this->validateDates($res['collectionsCount']);
|
||||
$this->assertEquals($documentsCount, $res['documentsCount'][array_key_last($res['documentsCount'])]['value']);
|
||||
$this->validateDates($res['documentsCount']);
|
||||
$this->assertEquals($databasesTotal, $res['databasesTotal'][array_key_last($res['databasesTotal'])]['value']);
|
||||
$this->validateDates($res['databasesTotal']);
|
||||
$this->assertEquals($collectionsTotal, $res['collectionsTotal'][array_key_last($res['collectionsTotal'])]['value']);
|
||||
$this->validateDates($res['collectionsTotal']);
|
||||
$this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']);
|
||||
$this->validateDates($res['documentsTotal']);
|
||||
|
||||
$res = $this->client->call(
|
||||
Client::METHOD_GET,
|
||||
@@ -511,19 +512,19 @@ class UsageTest extends Scope
|
||||
);
|
||||
$res = $res['body'];
|
||||
|
||||
$this->assertEquals($collectionsCount, $res['collectionsCount'][array_key_last($res['collectionsCount'])]['value']);
|
||||
$this->validateDates($res['collectionsCount']);
|
||||
$this->assertEquals($collectionsTotal, $res['collectionsTotal'][array_key_last($res['collectionsTotal'])]['value']);
|
||||
$this->validateDates($res['collectionsTotal']);
|
||||
|
||||
$this->assertEquals($documentsCount, $res['documentsCount'][array_key_last($res['documentsCount'])]['value']);
|
||||
$this->validateDates($res['documentsCount']);
|
||||
$this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']);
|
||||
$this->validateDates($res['documentsTotal']);
|
||||
|
||||
$res = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId . '/usage?range=30d', $data['consoleHeaders']);
|
||||
$res = $res['body'];
|
||||
|
||||
$this->assertEquals($documentsCount, $res['documentsCount'][array_key_last($res['documentsCount'])]['value']);
|
||||
$this->validateDates($res['documentsCount']);
|
||||
$this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']);
|
||||
$this->validateDates($res['documentsTotal']);
|
||||
|
||||
$data['requestsCount'] = $requestsCount;
|
||||
$data['requestsTotal'] = $requestsTotal;
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -582,7 +583,7 @@ class UsageTest extends Scope
|
||||
|
||||
$this->assertEquals(202, $deployment['headers']['status-code']);
|
||||
$this->assertNotEmpty($deployment['body']['$id']);
|
||||
$this->assertEquals(true, DateTime::isValid($deployment['body']['$createdAt']));
|
||||
$this->assertEquals(true, (new DatetimeValidator())->isValid($deployment['body']['$createdAt']));
|
||||
$this->assertEquals('index.php', $deployment['body']['entrypoint']);
|
||||
|
||||
// Wait for deployment to build.
|
||||
@@ -596,8 +597,10 @@ class UsageTest extends Scope
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
|
||||
$this->assertEquals(true, DateTime::isValid($response['body']['$updatedAt']));
|
||||
|
||||
|
||||
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['$createdAt']));
|
||||
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['$updatedAt']));
|
||||
$this->assertEquals($deploymentId, $response['body']['deployment']);
|
||||
|
||||
$execution = $this->client->call(
|
||||
@@ -695,20 +698,19 @@ class UsageTest extends Scope
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals(8, count($response['body']));
|
||||
$this->assertEquals('30d', $response['body']['range']);
|
||||
$this->assertIsArray($response['body']['deployments']);
|
||||
$this->assertIsArray($response['body']['deploymentsTotal']);
|
||||
$this->assertIsArray($response['body']['deploymentsStorage']);
|
||||
$this->assertIsArray($response['body']['builds']);
|
||||
$this->assertIsArray($response['body']['buildsCompute']);
|
||||
$this->assertIsArray($response['body']['executions']);
|
||||
$this->assertIsArray($response['body']['executionsCompute']);
|
||||
$this->assertIsArray($response['body']['buildsTotal']);
|
||||
$this->assertIsArray($response['body']['buildsTime']);
|
||||
$this->assertIsArray($response['body']['executionsTotal']);
|
||||
$this->assertIsArray($response['body']['executionsTime']);
|
||||
|
||||
$response = $response['body'];
|
||||
|
||||
$this->assertEquals($executions, $response['executions'][array_key_last($response['executions'])]['value']);
|
||||
$this->validateDates($response['executions']);
|
||||
|
||||
$this->assertEquals($executionTime, $response['executionsCompute'][array_key_last($response['executionsCompute'])]['value']);
|
||||
$this->validateDates($response['executionsCompute']);
|
||||
$this->assertEquals($executions, $response['executionsTotal'][array_key_last($response['executionsTotal'])]['value']);
|
||||
$this->validateDates($response['executionsTotal']);
|
||||
$this->assertEquals($executionTime, $response['executionsTime'][array_key_last($response['executionsTime'])]['value']);
|
||||
$this->validateDates($response['executionsTime']);
|
||||
|
||||
$response = $this->client->call(
|
||||
Client::METHOD_GET,
|
||||
@@ -719,28 +721,28 @@ class UsageTest extends Scope
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals(9, count($response['body']));
|
||||
$this->assertEquals($response['body']['range'], '30d');
|
||||
$this->assertIsArray($response['body']['functions']);
|
||||
$this->assertIsArray($response['body']['deployments']);
|
||||
$this->assertIsArray($response['body']['functionsTotal']);
|
||||
$this->assertIsArray($response['body']['deploymentsTotal']);
|
||||
$this->assertIsArray($response['body']['deploymentsStorage']);
|
||||
$this->assertIsArray($response['body']['builds']);
|
||||
$this->assertIsArray($response['body']['buildsCompute']);
|
||||
$this->assertIsArray($response['body']['executions']);
|
||||
$this->assertIsArray($response['body']['executionsCompute']);
|
||||
$this->assertIsArray($response['body']['buildsTotal']);
|
||||
$this->assertIsArray($response['body']['buildsTime']);
|
||||
$this->assertIsArray($response['body']['executionsTotal']);
|
||||
$this->assertIsArray($response['body']['executionsTime']);
|
||||
|
||||
$response = $response['body'];
|
||||
|
||||
$this->assertEquals($executions, $response['executions'][array_key_last($response['executions'])]['value']);
|
||||
$this->validateDates($response['executions']);
|
||||
$this->assertEquals($executionTime, $response['executionsCompute'][array_key_last($response['executionsCompute'])]['value']);
|
||||
$this->validateDates($response['executionsCompute']);
|
||||
$this->assertGreaterThan(0, $response['buildsCompute'][array_key_last($response['buildsCompute'])]['value']);
|
||||
$this->validateDates($response['buildsCompute']);
|
||||
$this->assertEquals($executions, $response['executionsTotal'][array_key_last($response['executionsTotal'])]['value']);
|
||||
$this->validateDates($response['executionsTotal']);
|
||||
$this->assertEquals($executionTime, $response['executionsTime'][array_key_last($response['executionsTime'])]['value']);
|
||||
$this->validateDates($response['executionsTime']);
|
||||
$this->assertGreaterThan(0, $response['buildsTime'][array_key_last($response['buildsTime'])]['value']);
|
||||
$this->validateDates($response['buildsTime']);
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
$this->usersCount = 0;
|
||||
$this->requestsCount = 0;
|
||||
$this->usersTotal = 0;
|
||||
$this->requestsTotal = 0;
|
||||
$projectId = '';
|
||||
$headers = [];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Tests\E2E\Scopes;
|
||||
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
trait ProjectConsole
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Tests\E2E\Scopes;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
trait ProjectCustom
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Tests\E2E\Scopes;
|
||||
use Appwrite\Tests\Retryable;
|
||||
use Tests\E2E\Client;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
abstract class Scope extends TestCase
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\E2E\Services\Account;
|
||||
|
||||
use Appwrite\Tests\Retry;
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\DateTime;
|
||||
|
||||
trait AccountBase
|
||||
|
||||
@@ -6,7 +6,7 @@ use Appwrite\Extend\Exception;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectConsole;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\DateTime;
|
||||
use Tests\E2E\Client;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
use function sleep;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideServer;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
class AccountCustomServerTest extends Scope
|
||||
{
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
namespace Tests\E2E\Services\Databases;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
trait DatabasesBase
|
||||
{
|
||||
|
||||
@@ -6,9 +6,9 @@ use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\SideConsole;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class DatabasesConsoleClientTest extends Scope
|
||||
{
|
||||
|
||||
@@ -6,9 +6,9 @@ use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class DatabasesCustomClientTest extends Scope
|
||||
{
|
||||
|
||||
@@ -6,10 +6,9 @@ use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideServer;
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class DatabasesCustomServerTest extends Scope
|
||||
{
|
||||
|
||||
@@ -6,9 +6,9 @@ use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
|
||||
class DatabasesPermissionsGuestTest extends Scope
|
||||
|
||||
@@ -6,9 +6,9 @@ use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class DatabasesPermissionsMemberTest extends Scope
|
||||
{
|
||||
|
||||
@@ -6,9 +6,9 @@ use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class DatabasesPermissionsTeamTest extends Scope
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\SideConsole;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class FunctionsConsoleClientTest extends Scope
|
||||
{
|
||||
|
||||
@@ -7,10 +7,8 @@ use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class FunctionsCustomClientTest extends Scope
|
||||
{
|
||||
|
||||
@@ -8,10 +8,8 @@ use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideServer;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
class FunctionsCustomServerTest extends Scope
|
||||
{
|
||||
|
||||
@@ -6,11 +6,9 @@ use Appwrite\Auth\Auth;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectConsole;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Tests\E2E\Services\Projects\ProjectsBase;
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
class ProjectsConsoleClientTest extends Scope
|
||||
{
|
||||
|
||||
@@ -8,9 +8,9 @@ use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\SideConsole;
|
||||
use Tests\E2E\Services\Functions\FunctionsBase;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class RealtimeConsoleClientTest extends Scope
|
||||
{
|
||||
|
||||
@@ -8,9 +8,9 @@ use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use WebSocket\ConnectionException;
|
||||
|
||||
class RealtimeCustomClientTest extends Scope
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace Tests\E2E\Services\Storage;
|
||||
use CURLFile;
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
trait StorageBase
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\SideConsole;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
class StorageConsoleClientTest extends Scope
|
||||
{
|
||||
@@ -97,7 +97,7 @@ class StorageConsoleClientTest extends Scope
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertEquals(count($response['body']), 3);
|
||||
$this->assertEquals($response['body']['range'], '24h');
|
||||
$this->assertIsArray($response['body']['filesCount']);
|
||||
$this->assertIsArray($response['body']['filesTotal']);
|
||||
$this->assertIsArray($response['body']['filesStorage']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,9 @@ use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class StorageCustomClientTest extends Scope
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideServer;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
class StorageCustomServerTest extends Scope
|
||||
{
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
namespace Tests\E2E\Services\Teams;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
trait TeamsBase
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\E2E\Services\Teams;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
trait TeamsBaseClient
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectConsole;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
class TeamsConsoleClientTest extends Scope
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\E2E\Services\Users;
|
||||
|
||||
use Appwrite\Tests\Retry;
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
trait UsersBase
|
||||
{
|
||||
|
||||
@@ -6,9 +6,9 @@ use Appwrite\Tests\Retry;
|
||||
use CURLFile;
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
trait WebhooksBase
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
class WebhooksCustomClientTest extends Scope
|
||||
{
|
||||
|
||||
@@ -9,9 +9,9 @@ use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideServer;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class WebhooksCustomServerTest extends Scope
|
||||
{
|
||||
|
||||
@@ -5,11 +5,10 @@ namespace Tests\Unit\Auth;
|
||||
use Appwrite\Auth\Auth;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Validator\Roles;
|
||||
|
||||
class AuthTest extends TestCase
|
||||
|
||||
@@ -6,8 +6,8 @@ use Appwrite\Auth\Auth;
|
||||
use Utopia\Database\Document;
|
||||
use Appwrite\Messaging\Adapter\Realtime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class MessagingChannelsTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace Tests\Unit\Messaging;
|
||||
|
||||
use Appwrite\Messaging\Adapter\Realtime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class MessagingGuestTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace Tests\Unit\Messaging;
|
||||
use Utopia\Database\Document;
|
||||
use Appwrite\Messaging\Adapter\Realtime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class MessagingTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\Unit\Network\Validators;
|
||||
|
||||
use Appwrite\Network\Validator\Origin;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
class OriginTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -4,10 +4,9 @@ namespace Tests\Unit\Utopia\Response\Filters;
|
||||
|
||||
use Appwrite\Utopia\Response\Filters\V15;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use stdClass;
|
||||
|
||||
class V15Test extends TestCase
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user