Merge branch 'main' into feat-impl-queue-retry

This commit is contained in:
Bradley Schofield 2024-01-22 16:51:18 +00:00 committed by GitHub
commit 448b3b0cc0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 66 additions and 24 deletions

View file

@ -75,8 +75,32 @@ jobs:
- name: Run Unit Tests - name: Run Unit Tests
run: docker compose exec appwrite test /usr/src/code/tests/unit run: docker compose exec appwrite test /usr/src/code/tests/unit
e2e_test: e2e_general_test:
name: E2E Test name: E2E General Test
runs-on: ubuntu-latest
needs: setup
steps:
- name: checkout
uses: actions/checkout@v3
- name: Load Cache
uses: actions/cache@v3
with:
key: ${{ env.CACHE_KEY }}
path: /tmp/${{ env.IMAGE }}.tar
fail-on-cache-miss: true
- name: Load and Start Appwrite
run: |
docker load --input /tmp/${{ env.IMAGE }}.tar
docker compose up -d
sleep 10
- name: Run General Tests
run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/General --debug
e2e_service_test:
name: E2E Service Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: setup needs: setup
strategy: strategy:

View file

@ -850,7 +850,7 @@ App::get('/v1/account/identities')
}); });
App::delete('/v1/account/identities/:identityId') App::delete('/v1/account/identities/:identityId')
->desc('Delete Identity') ->desc('Delete identity')
->groups(['api', 'account']) ->groups(['api', 'account'])
->label('scope', 'account') ->label('scope', 'account')
->label('event', 'users.[userId].identities.[identityId].delete') ->label('event', 'users.[userId].identities.[identityId].delete')
@ -867,7 +867,8 @@ App::delete('/v1/account/identities/:identityId')
->param('identityId', '', new UID(), 'Identity ID.') ->param('identityId', '', new UID(), 'Identity ID.')
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->action(function (string $identityId, Response $response, Database $dbForProject) { ->inject('queueForEvents')
->action(function (string $identityId, Response $response, Database $dbForProject, Event $queueForEvents) {
$identity = $dbForProject->getDocument('identities', $identityId); $identity = $dbForProject->getDocument('identities', $identityId);
@ -877,6 +878,11 @@ App::delete('/v1/account/identities/:identityId')
$dbForProject->deleteDocument('identities', $identityId); $dbForProject->deleteDocument('identities', $identityId);
$queueForEvents
->setParam('userId', $identity->getAttribute('userId'))
->setParam('identityId', $identity->getId())
->setPayload($response->output($identity, Response::MODEL_IDENTITY));
return $response->noContent(); return $response->noContent();
}); });

View file

@ -1211,7 +1211,7 @@ App::delete('/v1/users/:userId')
}); });
App::delete('/v1/users/identities/:identityId') App::delete('/v1/users/identities/:identityId')
->desc('Delete Identity') ->desc('Delete identity')
->groups(['api', 'users']) ->groups(['api', 'users'])
->label('event', 'users.[userId].identities.[identityId].delete') ->label('event', 'users.[userId].identities.[identityId].delete')
->label('scope', 'users.write') ->label('scope', 'users.write')
@ -1227,7 +1227,8 @@ App::delete('/v1/users/identities/:identityId')
->param('identityId', '', new UID(), 'Identity ID.') ->param('identityId', '', new UID(), 'Identity ID.')
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->action(function (string $identityId, Response $response, Database $dbForProject) { ->inject('queueForEvents')
->action(function (string $identityId, Response $response, Database $dbForProject, Event $queueForEvents) {
$identity = $dbForProject->getDocument('identities', $identityId); $identity = $dbForProject->getDocument('identities', $identityId);
@ -1237,6 +1238,11 @@ App::delete('/v1/users/identities/:identityId')
$dbForProject->deleteDocument('identities', $identityId); $dbForProject->deleteDocument('identities', $identityId);
$queueForEvents
->setParam('userId', $identity->getAttribute('userId'))
->setParam('identityId', $identity->getId())
->setPayload($response->output($identity, Response::MODEL_IDENTITY));
return $response->noContent(); return $response->noContent();
}); });

View file

@ -652,7 +652,7 @@ services:
- _APP_DB_PASS - _APP_DB_PASS
appwrite-assistant: appwrite-assistant:
image: appwrite/assistant:0.2.2 image: appwrite/assistant:0.3.0
container_name: appwrite-assistant container_name: appwrite-assistant
<<: *x-logging <<: *x-logging
restart: unless-stopped restart: unless-stopped

View file

@ -711,7 +711,7 @@ services:
appwrite-assistant: appwrite-assistant:
container_name: appwrite-assistant container_name: appwrite-assistant
image: appwrite/assistant:0.2.2 image: appwrite/assistant:0.3.0
networks: networks:
- appwrite - appwrite
environment: environment:

View file

@ -8,6 +8,7 @@ use Appwrite\Docker\Env;
use Appwrite\Utopia\View; use Appwrite\Utopia\View;
use Utopia\CLI\Console; use Utopia\CLI\Console;
use Utopia\Config\Config; use Utopia\Config\Config;
use Utopia\Validator\Boolean;
use Utopia\Validator\Text; use Utopia\Validator\Text;
use Utopia\Platform\Action; use Utopia\Platform\Action;
@ -24,15 +25,16 @@ class Install extends Action
{ {
$this $this
->desc('Install Appwrite') ->desc('Install Appwrite')
->param('httpPort', '', new Text(4), 'Server HTTP port', true) ->param('http-port', '', new Text(4), 'Server HTTP port', true)
->param('httpsPort', '', new Text(4), 'Server HTTPS port', true) ->param('https-port', '', new Text(4), 'Server HTTPS port', true)
->param('organization', 'appwrite', new Text(0), 'Docker Registry organization', true) ->param('organization', 'appwrite', new Text(0), 'Docker Registry organization', true)
->param('image', 'appwrite', new Text(0), 'Main appwrite docker image', true) ->param('image', 'appwrite', new Text(0), 'Main appwrite docker image', true)
->param('interactive', 'Y', new Text(1), 'Run an interactive session', true) ->param('interactive', 'Y', new Text(1), 'Run an interactive session', true)
->callback(fn ($httpPort, $httpsPort, $organization, $image, $interactive) => $this->action($httpPort, $httpsPort, $organization, $image, $interactive)); ->param('no-start', false, new Boolean(true), 'Run an interactive session', true)
->callback(fn ($httpPort, $httpsPort, $organization, $image, $interactive, $noStart) => $this->action($httpPort, $httpsPort, $organization, $image, $interactive, $noStart));
} }
public function action(string $httpPort, string $httpsPort, string $organization, string $image, string $interactive): void public function action(string $httpPort, string $httpsPort, string $organization, string $image, string $interactive, bool $noStart): void
{ {
$config = Config::getParam('variables'); $config = Config::getParam('variables');
$defaultHTTPPort = '80'; $defaultHTTPPort = '80';
@ -220,9 +222,11 @@ class Install extends Action
} }
} }
Console::log("Running \"docker compose up -d --remove-orphans --renew-anon-volumes\""); $exit = 0;
if (!$noStart) {
$exit = Console::execute("$env docker compose --project-directory $this->path up -d --remove-orphans --renew-anon-volumes", '', $stdout, $stderr); Console::log("Running \"docker compose up -d --remove-orphans --renew-anon-volumes\"");
$exit = Console::execute("$env docker compose --project-directory $this->path up -d --remove-orphans --renew-anon-volumes", '', $stdout, $stderr);
}
if ($exit !== 0) { if ($exit !== 0) {
$message = 'Failed to install Appwrite dockers'; $message = 'Failed to install Appwrite dockers';

View file

@ -3,6 +3,7 @@
namespace Appwrite\Platform\Tasks; namespace Appwrite\Platform\Tasks;
use Utopia\CLI\Console; use Utopia\CLI\Console;
use Utopia\Validator\Boolean;
use Utopia\Validator\Text; use Utopia\Validator\Text;
class Upgrade extends Install class Upgrade extends Install
@ -16,15 +17,16 @@ class Upgrade extends Install
{ {
$this $this
->desc('Upgrade Appwrite') ->desc('Upgrade Appwrite')
->param('httpPort', '', new Text(4), 'Server HTTP port', true) ->param('http-port', '', new Text(4), 'Server HTTP port', true)
->param('httpsPort', '', new Text(4), 'Server HTTPS port', true) ->param('https-port', '', new Text(4), 'Server HTTPS port', true)
->param('organization', 'appwrite', new Text(0), 'Docker Registry organization', true) ->param('organization', 'appwrite', new Text(0), 'Docker Registry organization', true)
->param('image', 'appwrite', new Text(0), 'Main appwrite docker image', true) ->param('image', 'appwrite', new Text(0), 'Main appwrite docker image', true)
->param('interactive', 'Y', new Text(1), 'Run an interactive session', true) ->param('interactive', 'Y', new Text(1), 'Run an interactive session', true)
->callback(fn ($httpPort, $httpsPort, $organization, $image, $interactive) => $this->action($httpPort, $httpsPort, $organization, $image, $interactive)); ->param('no-start', false, new Boolean(true), 'Run an interactive session', true)
->callback(fn ($httpPort, $httpsPort, $organization, $image, $interactive, $noStart) => $this->action($httpPort, $httpsPort, $organization, $image, $interactive, $noStart));
} }
public function action(string $httpPort, string $httpsPort, string $organization, string $image, string $interactive): void public function action(string $httpPort, string $httpsPort, string $organization, string $image, string $interactive, bool $noStart): void
{ {
// Check for previous installation // Check for previous installation
$data = @file_get_contents($this->path . '/docker-compose.yml'); $data = @file_get_contents($this->path . '/docker-compose.yml');
@ -37,6 +39,6 @@ class Upgrade extends Install
Console::log(' └── docker-compose.yml'); Console::log(' └── docker-compose.yml');
Console::exit(1); Console::exit(1);
} }
parent::action($httpPort, $httpsPort, $organization, $image, $interactive); parent::action($httpPort, $httpsPort, $organization, $image, $interactive, $noStart);
} }
} }

View file

@ -72,6 +72,7 @@ class Executor
) { ) {
$runtimeId = "$projectId-$deploymentId-build"; $runtimeId = "$projectId-$deploymentId-build";
$route = "/runtimes"; $route = "/runtimes";
$timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900);
$params = [ $params = [
'runtimeId' => $runtimeId, 'runtimeId' => $runtimeId,
'source' => $source, 'source' => $source,
@ -84,10 +85,9 @@ class Executor
'cpus' => $this->cpus, 'cpus' => $this->cpus,
'memory' => $this->memory, 'memory' => $this->memory,
'version' => $version, 'version' => $version,
'timeout' => $timeout,
]; ];
$timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900);
$response = $this->call(self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout); $response = $this->call(self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout);
$status = $response['headers']['status-code']; $status = $response['headers']['status-code'];
@ -111,7 +111,7 @@ class Executor
string $projectId, string $projectId,
callable $callback callable $callback
) { ) {
$timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900); $timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900);
$runtimeId = "$projectId-$deploymentId-build"; $runtimeId = "$projectId-$deploymentId-build";
$route = "/runtimes/{$runtimeId}/logs"; $route = "/runtimes/{$runtimeId}/logs";