From c8d57c0f6fc081e23aab1dac5384c3de5d639c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 21 Sep 2023 11:07:07 +0200 Subject: [PATCH 01/22] Fix: Publish CI/CD script --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a87f1e574f..4ee204d9d4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,7 @@ jobs: with: fetch-depth: 2 submodules: recursive - ref: master + ref: 1.4.x - name: Login to Docker Hub uses: docker/login-action@v2 From 66f06cb7798e5f6810a7cb5da35c59b09a65705f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 21 Sep 2023 11:10:03 +0200 Subject: [PATCH 02/22] Update publish.yml --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4ee204d9d4..385016db91 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,7 @@ jobs: with: fetch-depth: 2 submodules: recursive - ref: 1.4.x + ref: cl-1.4.x - name: Login to Docker Hub uses: docker/login-action@v2 From c7e6efc050e1bc7a9f422cfc46cb22e4998fca52 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 21 Sep 2023 10:23:55 +0000 Subject: [PATCH 03/22] chore: update backups schedule --- app/controllers/api/projects.php | 15 ++++++++------- composer.lock | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 11a9f8c558..73051a7953 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -92,16 +92,17 @@ App::post('/v1/projects') $projectId = ($projectId == 'unique()') ? ID::unique() : $projectId; - $backups['database_db_fra1_02'] = ['from' => '7:30', 'to' => '8:15']; - $backups['database_db_fra1_03'] = ['from' => '10:30', 'to' => '11:15']; - $backups['database_db_fra1_04'] = ['from' => '13:30', 'to' => '14:15']; - $backups['database_db_fra1_05'] = ['from' => '4:30', 'to' => '5:15']; - $backups['database_db_fra1_06'] = ['from' => '16:30', 'to' => '17:15']; + $backups['database_db_fra1_v14x_02'] = ['from' => '7:30', 'to' => '8:15']; + $backups['database_db_fra1_v14x_03'] = ['from' => '10:30', 'to' => '11:15']; + $backups['database_db_fra1_v14x_04'] = ['from' => '13:30', 'to' => '14:15']; + $backups['database_db_fra1_v14x_05'] = ['from' => '4:30', 'to' => '5:15']; + $backups['database_db_fra1_v14x_06'] = ['from' => '16:30', 'to' => '17:15']; + $backups['database_db_fra1_v14x_07'] = ['from' => '19:30', 'to' => '20:15']; $databases = Config::getParam('pools-database', []); /** - * Extract db from list while backing + * Remove databases from the list that are currently undergoing an backup */ if (count($databases) > 1) { $now = new \DateTime(); @@ -120,7 +121,7 @@ App::post('/v1/projects') } } - if ($index = array_search('database_db_fra1_06', $databases)) { + if ($index = array_search('database_db_fra1_v14x_07', $databases)) { $database = $databases[$index]; } else { $database = $databases[array_rand($databases)]; diff --git a/composer.lock b/composer.lock index a345b65c45..b154b4b3f0 100644 --- a/composer.lock +++ b/composer.lock @@ -6029,5 +6029,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } From 24204bce547544aeb69ba4629da95a205cae8c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 24 Sep 2023 14:07:37 +0200 Subject: [PATCH 04/22] Add all worker health endpoints --- app/controllers/api/health.php | 111 ++++++++++++- ...{get-queue-logs.md => get-queue-audits.md} | 0 docs/references/health/get-queue-builds.md | 1 + docs/references/health/get-queue-databases.md | 1 + docs/references/health/get-queue-deletes.md | 1 + docs/references/health/get-queue-mails.md | 1 + docs/references/health/get-queue-messaging.md | 1 + .../references/health/get-queue-migrations.md | 1 + .../Health/HealthCustomServerTest.php | 157 ++++++++++++++++++ 9 files changed, 270 insertions(+), 4 deletions(-) rename docs/references/health/{get-queue-logs.md => get-queue-audits.md} (100%) create mode 100644 docs/references/health/get-queue-builds.md create mode 100644 docs/references/health/get-queue-databases.md create mode 100644 docs/references/health/get-queue-deletes.md create mode 100644 docs/references/health/get-queue-mails.md create mode 100644 docs/references/health/get-queue-messaging.md create mode 100644 docs/references/health/get-queue-migrations.md diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index d6a2612f32..ee6a7fc2a0 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -353,14 +353,15 @@ App::get('/v1/health/queue/webhooks') $response->dynamic(new Document([ 'size' => Resque::size(Event::WEBHOOK_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); -App::get('/v1/health/queue/logs') - ->desc('Get Logs Queue') +App::get('/v1/health/queue/audits') + ->alias('/v1/health/queue/logs') + ->desc('Get Audits Queue') ->groups(['api', 'health']) ->label('scope', 'health.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'health') - ->label('sdk.method', 'getQueueLogs') - ->label('sdk.description', '/docs/references/health/get-queue-logs.md') + ->label('sdk.method', 'getQueueAudits') + ->label('sdk.description', '/docs/references/health/get-queue-audits.md') ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) @@ -387,6 +388,108 @@ App::get('/v1/health/queue/certificates') $response->dynamic(new Document([ 'size' => Resque::size(Event::CERTIFICATES_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); +App::get('/v1/health/queue/builds') + ->desc('Get Builds Queue') + ->groups(['api', 'health']) + ->label('scope', 'health.read') + ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueBuilds') + ->label('sdk.description', '/docs/references/health/get-queue-builds.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) + ->inject('response') + ->action(function (Response $response) { + + $response->dynamic(new Document([ 'size' => Resque::size(Event::BUILDS_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); + }, ['response']); + +App::get('/v1/health/queue/databases') + ->desc('Get Databases Queue') + ->groups(['api', 'health']) + ->label('scope', 'health.read') + ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueDatabases') + ->label('sdk.description', '/docs/references/health/get-queue-databases.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) + ->inject('response') + ->action(function (Response $response) { + + $response->dynamic(new Document([ 'size' => Resque::size(Event::DATABASE_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); + }, ['response']); + +App::get('/v1/health/queue/deletes') + ->desc('Get Deletes Queue') + ->groups(['api', 'health']) + ->label('scope', 'health.read') + ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueDeletes') + ->label('sdk.description', '/docs/references/health/get-queue-deletes.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) + ->inject('response') + ->action(function (Response $response) { + + $response->dynamic(new Document([ 'size' => Resque::size(Event::DELETE_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); + }, ['response']); + +App::get('/v1/health/queue/mails') + ->desc('Get Mails Queue') + ->groups(['api', 'health']) + ->label('scope', 'health.read') + ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueMails') + ->label('sdk.description', '/docs/references/health/get-queue-mails.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) + ->inject('response') + ->action(function (Response $response) { + + $response->dynamic(new Document([ 'size' => Resque::size(Event::MAILS_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); + }, ['response']); + +App::get('/v1/health/queue/messaging') + ->desc('Get Messaging Queue') + ->groups(['api', 'health']) + ->label('scope', 'health.read') + ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueMessaging') + ->label('sdk.description', '/docs/references/health/get-queue-messaging.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) + ->inject('response') + ->action(function (Response $response) { + + $response->dynamic(new Document([ 'size' => Resque::size(Event::MESSAGING_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); + }, ['response']); + +App::get('/v1/health/queue/migrations') + ->desc('Get Migrations Queue') + ->groups(['api', 'health']) + ->label('scope', 'health.read') + ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueMigrations') + ->label('sdk.description', '/docs/references/health/get-queue-migrations.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) + ->inject('response') + ->action(function (Response $response) { + + $response->dynamic(new Document([ 'size' => Resque::size(Event::MIGRATIONS_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); + }, ['response']); + App::get('/v1/health/queue/functions') ->desc('Get Functions Queue') ->groups(['api', 'health']) diff --git a/docs/references/health/get-queue-logs.md b/docs/references/health/get-queue-audits.md similarity index 100% rename from docs/references/health/get-queue-logs.md rename to docs/references/health/get-queue-audits.md diff --git a/docs/references/health/get-queue-builds.md b/docs/references/health/get-queue-builds.md new file mode 100644 index 0000000000..fcd5fcf478 --- /dev/null +++ b/docs/references/health/get-queue-builds.md @@ -0,0 +1 @@ +Get the number of builds that are waiting to be processed in the Appwrite internal queue server. \ No newline at end of file diff --git a/docs/references/health/get-queue-databases.md b/docs/references/health/get-queue-databases.md new file mode 100644 index 0000000000..064e6095ce --- /dev/null +++ b/docs/references/health/get-queue-databases.md @@ -0,0 +1 @@ +Get the number of database changes that are waiting to be processed in the Appwrite internal queue server. \ No newline at end of file diff --git a/docs/references/health/get-queue-deletes.md b/docs/references/health/get-queue-deletes.md new file mode 100644 index 0000000000..884b83dd07 --- /dev/null +++ b/docs/references/health/get-queue-deletes.md @@ -0,0 +1 @@ +Get the number of background destructive changes that are waiting to be processed in the Appwrite internal queue server. \ No newline at end of file diff --git a/docs/references/health/get-queue-mails.md b/docs/references/health/get-queue-mails.md new file mode 100644 index 0000000000..6270f64f7a --- /dev/null +++ b/docs/references/health/get-queue-mails.md @@ -0,0 +1 @@ +Get the number of mails that are waiting to be processed in the Appwrite internal queue server. \ No newline at end of file diff --git a/docs/references/health/get-queue-messaging.md b/docs/references/health/get-queue-messaging.md new file mode 100644 index 0000000000..8bc994923f --- /dev/null +++ b/docs/references/health/get-queue-messaging.md @@ -0,0 +1 @@ +Get the number of messages that are waiting to be processed in the Appwrite internal queue server. \ No newline at end of file diff --git a/docs/references/health/get-queue-migrations.md b/docs/references/health/get-queue-migrations.md new file mode 100644 index 0000000000..8645c80379 --- /dev/null +++ b/docs/references/health/get-queue-migrations.md @@ -0,0 +1 @@ +Get the number of migrations that are waiting to be processed in the Appwrite internal queue server. \ No newline at end of file diff --git a/tests/e2e/Services/Health/HealthCustomServerTest.php b/tests/e2e/Services/Health/HealthCustomServerTest.php index 96c9bde5c7..22c869fdef 100644 --- a/tests/e2e/Services/Health/HealthCustomServerTest.php +++ b/tests/e2e/Services/Health/HealthCustomServerTest.php @@ -183,6 +183,16 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); + + $response = $this->client->call(Client::METHOD_GET, '/health/queue/audits', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(100, $response['body']['size']); + /** * Test for FAILURE */ @@ -211,6 +221,153 @@ class HealthCustomServerTest extends Scope return []; } + public function testFunctionsSuccess(): array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/functions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(100, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testBuildsSuccess(): array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/builds', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(100, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testDatabasesSuccess(): array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/databases', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(100, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testDeletesSuccess(): array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/deletes', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(100, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testMailsSuccess(): array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/mails', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(100, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testMessagingSuccess(): array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/messaging', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(100, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testMigrationsSuccess(): array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/migrations', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(100, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + public function testStorageLocalSuccess(): array { /** From 725897c89678968b55869bc1f7d04b4465af6f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 24 Sep 2023 14:36:20 +0200 Subject: [PATCH 05/22] Rename audits back to logs --- app/controllers/api/health.php | 9 ++++----- .../health/{get-queue-audits.md => get-queue-logs.md} | 0 tests/e2e/Services/Health/HealthCustomServerTest.php | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) rename docs/references/health/{get-queue-audits.md => get-queue-logs.md} (100%) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index ee6a7fc2a0..6aabb17940 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -353,15 +353,14 @@ App::get('/v1/health/queue/webhooks') $response->dynamic(new Document([ 'size' => Resque::size(Event::WEBHOOK_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); -App::get('/v1/health/queue/audits') - ->alias('/v1/health/queue/logs') - ->desc('Get Audits Queue') +App::get('/v1/health/queue/logs') + ->desc('Get Logs Queue') ->groups(['api', 'health']) ->label('scope', 'health.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'health') - ->label('sdk.method', 'getQueueAudits') - ->label('sdk.description', '/docs/references/health/get-queue-audits.md') + ->label('sdk.method', 'getQueueLogs') + ->label('sdk.description', '/docs/references/health/get-queue-logs.md') ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) diff --git a/docs/references/health/get-queue-audits.md b/docs/references/health/get-queue-logs.md similarity index 100% rename from docs/references/health/get-queue-audits.md rename to docs/references/health/get-queue-logs.md diff --git a/tests/e2e/Services/Health/HealthCustomServerTest.php b/tests/e2e/Services/Health/HealthCustomServerTest.php index 22c869fdef..0ea9811617 100644 --- a/tests/e2e/Services/Health/HealthCustomServerTest.php +++ b/tests/e2e/Services/Health/HealthCustomServerTest.php @@ -184,7 +184,7 @@ class HealthCustomServerTest extends Scope $this->assertLessThan(100, $response['body']['size']); - $response = $this->client->call(Client::METHOD_GET, '/health/queue/audits', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/logs', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); From b4c5ef2d173e3b87e78dcd45f357cb3da38b9a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 24 Sep 2023 14:36:47 +0200 Subject: [PATCH 06/22] Remove double test --- tests/e2e/Services/Health/HealthCustomServerTest.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/e2e/Services/Health/HealthCustomServerTest.php b/tests/e2e/Services/Health/HealthCustomServerTest.php index 0ea9811617..a2efd30ce0 100644 --- a/tests/e2e/Services/Health/HealthCustomServerTest.php +++ b/tests/e2e/Services/Health/HealthCustomServerTest.php @@ -183,16 +183,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); - - $response = $this->client->call(Client::METHOD_GET, '/health/queue/logs', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertIsInt($response['body']['size']); - $this->assertLessThan(100, $response['body']['size']); - /** * Test for FAILURE */ From 9f244f976e194c43141941396a1ac89851ef7ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 25 Sep 2023 15:32:51 +0200 Subject: [PATCH 07/22] Remvoe unnessessary comments --- .../Health/HealthCustomServerTest.php | 72 ------------------- 1 file changed, 72 deletions(-) diff --git a/tests/e2e/Services/Health/HealthCustomServerTest.php b/tests/e2e/Services/Health/HealthCustomServerTest.php index a2efd30ce0..4ac15bd95c 100644 --- a/tests/e2e/Services/Health/HealthCustomServerTest.php +++ b/tests/e2e/Services/Health/HealthCustomServerTest.php @@ -29,10 +29,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['ping']); $this->assertLessThan(100, $response['body']['ping']); - /** - * Test for FAILURE - */ - return []; } @@ -51,10 +47,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['statuses'][0]['ping']); $this->assertLessThan(100, $response['body']['statuses'][0]['ping']); - /** - * Test for FAILURE - */ - return []; } @@ -73,10 +65,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['statuses'][0]['ping']); $this->assertLessThan(100, $response['body']['statuses'][0]['ping']); - /** - * Test for FAILURE - */ - return []; } @@ -95,10 +83,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['statuses'][0]['ping']); $this->assertLessThan(100, $response['body']['statuses'][0]['ping']); - /** - * Test for FAILURE - */ - return []; } @@ -117,10 +101,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['statuses'][0]['ping']); $this->assertLessThan(100, $response['body']['statuses'][0]['ping']); - /** - * Test for FAILURE - */ - return []; } @@ -141,10 +121,6 @@ class HealthCustomServerTest extends Scope $this->assertNotEmpty($response['body']['localTime']); $this->assertLessThan(10, $response['body']['diff']); - /** - * Test for FAILURE - */ - return []; } @@ -162,10 +138,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); - /** - * Test for FAILURE - */ - return []; } @@ -183,10 +155,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); - /** - * Test for FAILURE - */ - return []; } @@ -204,10 +172,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); - /** - * Test for FAILURE - */ - return []; } @@ -225,10 +189,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); - /** - * Test for FAILURE - */ - return []; } @@ -246,10 +206,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); - /** - * Test for FAILURE - */ - return []; } @@ -267,10 +223,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); - /** - * Test for FAILURE - */ - return []; } @@ -288,10 +240,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); - /** - * Test for FAILURE - */ - return []; } @@ -309,10 +257,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); - /** - * Test for FAILURE - */ - return []; } @@ -330,10 +274,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); - /** - * Test for FAILURE - */ - return []; } @@ -351,10 +291,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); - /** - * Test for FAILURE - */ - return []; } @@ -373,10 +309,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['ping']); $this->assertLessThan(100, $response['body']['ping']); - /** - * Test for FAILURE - */ - return []; } @@ -395,10 +327,6 @@ class HealthCustomServerTest extends Scope $this->assertIsString($response['body']['status']); $this->assertIsString($response['body']['version']); - /** - * Test for FAILURE - */ - return []; } } From d1d523e1dce0c2ff137c9c82adaac488376bddb8 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 26 Sep 2023 00:01:34 +0400 Subject: [PATCH 08/22] chore: update hamster script --- src/Appwrite/Platform/Tasks/Hamster.php | 78 ++++++++++++++++++------- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/Hamster.php b/src/Appwrite/Platform/Tasks/Hamster.php index 5b04c338eb..c19a0e9f3b 100644 --- a/src/Appwrite/Platform/Tasks/Hamster.php +++ b/src/Appwrite/Platform/Tasks/Hamster.php @@ -97,6 +97,32 @@ class Hamster extends Action /** Get Project Name */ $statsPerProject['project_name'] = $project->getAttribute('name'); + /** Total Project Variables */ + $statsPerProject['custom_variables'] = $dbForProject->count('variables', [], APP_LIMIT_COUNT); + + /** Total Migrations */ + $statsPerProject['custom_migrations'] = $dbForProject->count('migrations', [], APP_LIMIT_COUNT); + + /** Get Custom SMTP */ + $smtp = $project->getAttribute('smtp', null); + if ($smtp) { + $statsPerProject['custom_smtp_status'] = $smtp['enabled'] === true ? 'enabled' : 'disabled'; + + /** Get Custom Templates Count */ + $templates = array_keys($project->getAttribute('templates', [])); + $statsPerProject['custom_email_templates'] = array_filter($templates, function ($template) { + return str_contains($template, 'email'); + }); + $statsPerProject['custom_sms_templates'] = array_filter($templates, function ($template) { + return str_contains($template, 'sms'); + }); + } + + /** Get total relationship attributes */ + $statsPerProject['custom_relationship_attributes'] = $dbForProject->count('attributes', [ + Query::equal('type', ['relationship']) + ], APP_LIMIT_COUNT); + /** Get Total Functions */ $statsPerProject['custom_functions'] = $dbForProject->count('functions', [], APP_LIMIT_COUNT); @@ -108,6 +134,17 @@ class Hamster extends Action /** Get Total Deployments */ $statsPerProject['custom_deployments'] = $dbForProject->count('deployments', [], APP_LIMIT_COUNT); + $statsPerProject['custom_deployments_manual'] = $dbForProject->count('deployments', [ + Query::equal('type', ['manual']) + ], APP_LIMIT_COUNT); + $statsPerProject['custom_deployments_git'] = $dbForProject->count('deployments', [ + Query::equal('type', ['vcs']) + ], APP_LIMIT_COUNT); + + /** Get VCS repos connected */ + $statsPerProject['custom_vcs_repositories'] = $dbForConsole->count('repositories', [ + Query::equal('projectInternalId', [$project->getInternalId()]) + ], APP_LIMIT_COUNT); /** Get Total Teams */ $statsPerProject['custom_teams'] = $dbForProject->count('teams', [], APP_LIMIT_COUNT); @@ -132,19 +169,16 @@ class Hamster extends Action throw new Exception('Membership not found. Skipping project : ' . $project->getId()); } - $userInternalId = $membership->getAttribute('userInternalId', null); - if ($userInternalId) { - $user = $dbForConsole->findOne('users', [ - Query::equal('_id', [$userInternalId]), - ]); - + $userId = $membership->getAttribute('userId', null); + if ($userId) { + $user = $dbForConsole->getDocument('users', $userId); $statsPerProject['email'] = $user->getAttribute('email', null); $statsPerProject['name'] = $user->getAttribute('name', null); } } /** Get Domains */ - $statsPerProject['custom_domains'] = $dbForConsole->count('domains', [ + $statsPerProject['custom_domains'] = $dbForConsole->count('rules', [ Query::equal('projectInternalId', [$project->getInternalId()]), Query::limit(APP_LIMIT_COUNT) ]); @@ -234,18 +268,20 @@ class Hamster extends Action if (!$res) { Console::error('Failed to create user profile for project: ' . $project->getId()); } + } - $event = new Event(); - $event - ->setName('Project Daily Usage') - ->setProps($statsPerProject); - $res = $this->mixpanel->createEvent($event); - if (!$res) { - Console::error('Failed to create event for project: ' . $project->getId()); - } + $event = new Event(); + $event + ->setName('Project Daily Usage') + ->setProps($statsPerProject); + $res = $this->mixpanel->createEvent($event); + + if (!$res) { + Console::error('Failed to create event for project: ' . $project->getId()); } } catch (Exception $e) { Console::error('Failed to send stats for project: ' . $project->getId()); + // Console::error($e->getTraceAsString()); Console::error($e->getMessage()); } finally { $pools @@ -278,6 +314,9 @@ class Hamster extends Action $delay = $next->getTimestamp() - $now->getTimestamp(); } + $sleep = 1000; + $delay = 0; + Console::log('[' . $now->format("Y-m-d H:i:s.v") . '] Delaying for ' . $delay . ' setting loop to [' . $next->format("Y-m-d H:i:s.v") . ']'); Console::loop(function () use ($pools, $cache, $dbForConsole, $sleep) { @@ -362,12 +401,9 @@ class Hamster extends Action throw new Exception('Membership not found. Skipping organization : ' . $document->getId()); } - $userInternalId = $membership->getAttribute('userInternalId', null); - if ($userInternalId) { - $user = $dbForConsole->findOne('users', [ - Query::equal('_id', [$userInternalId]), - ]); - + $userId = $membership->getAttribute('userId', null); + if ($userId) { + $user = $dbForConsole->getDocument('users', $userId); $statsPerOrganization['email'] = $user->getAttribute('email', null); } From d4debddc4675858d6e9c8e8298846271270cc0e8 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 26 Sep 2023 00:01:42 +0400 Subject: [PATCH 09/22] chore: update hamster script --- src/Appwrite/Platform/Tasks/Hamster.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/Hamster.php b/src/Appwrite/Platform/Tasks/Hamster.php index c19a0e9f3b..b7d189ce7a 100644 --- a/src/Appwrite/Platform/Tasks/Hamster.php +++ b/src/Appwrite/Platform/Tasks/Hamster.php @@ -314,9 +314,6 @@ class Hamster extends Action $delay = $next->getTimestamp() - $now->getTimestamp(); } - $sleep = 1000; - $delay = 0; - Console::log('[' . $now->format("Y-m-d H:i:s.v") . '] Delaying for ' . $delay . ' setting loop to [' . $next->format("Y-m-d H:i:s.v") . ']'); Console::loop(function () use ($pools, $cache, $dbForConsole, $sleep) { From 39dc153a22aa5ee080c7189fe52d3f0decc9a835 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 26 Sep 2023 00:05:01 +0400 Subject: [PATCH 10/22] chore: remove comments --- src/Appwrite/Platform/Tasks/Hamster.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Appwrite/Platform/Tasks/Hamster.php b/src/Appwrite/Platform/Tasks/Hamster.php index b7d189ce7a..82b0fe5937 100644 --- a/src/Appwrite/Platform/Tasks/Hamster.php +++ b/src/Appwrite/Platform/Tasks/Hamster.php @@ -281,7 +281,6 @@ class Hamster extends Action } } catch (Exception $e) { Console::error('Failed to send stats for project: ' . $project->getId()); - // Console::error($e->getTraceAsString()); Console::error($e->getMessage()); } finally { $pools From 79d7bd8379ec21cad762385b0f50f22f6dc1af84 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 26 Sep 2023 00:10:17 +0400 Subject: [PATCH 11/22] chore: linter --- src/Appwrite/Platform/Tasks/Hamster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Tasks/Hamster.php b/src/Appwrite/Platform/Tasks/Hamster.php index 82b0fe5937..1d5d3b0b26 100644 --- a/src/Appwrite/Platform/Tasks/Hamster.php +++ b/src/Appwrite/Platform/Tasks/Hamster.php @@ -107,7 +107,7 @@ class Hamster extends Action $smtp = $project->getAttribute('smtp', null); if ($smtp) { $statsPerProject['custom_smtp_status'] = $smtp['enabled'] === true ? 'enabled' : 'disabled'; - + /** Get Custom Templates Count */ $templates = array_keys($project->getAttribute('templates', [])); $statsPerProject['custom_email_templates'] = array_filter($templates, function ($template) { From a65c1c1ee58e38436261cdd82491ac889e43ce78 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 28 Sep 2023 22:22:44 +0000 Subject: [PATCH 12/22] chore: fix merge conflict --- app/controllers/api/health.php | 24 ------------------------ composer.lock | 14 +++++++------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 5590f0906e..2b41e2fef8 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -388,11 +388,7 @@ App::get('/v1/health/queue/certificates') }, ['response']); App::get('/v1/health/queue/builds') -<<<<<<< HEAD - ->desc('Get Builds Queue') -======= ->desc('Get builds queue') ->>>>>>> 4f88ba8b881555d351430a4be94d071ebbb35b84 ->groups(['api', 'health']) ->label('scope', 'health.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -409,11 +405,7 @@ App::get('/v1/health/queue/builds') }, ['response']); App::get('/v1/health/queue/databases') -<<<<<<< HEAD - ->desc('Get Databases Queue') -======= ->desc('Get databases queue') ->>>>>>> 4f88ba8b881555d351430a4be94d071ebbb35b84 ->groups(['api', 'health']) ->label('scope', 'health.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -430,11 +422,7 @@ App::get('/v1/health/queue/databases') }, ['response']); App::get('/v1/health/queue/deletes') -<<<<<<< HEAD - ->desc('Get Deletes Queue') -======= ->desc('Get deletes queue') ->>>>>>> 4f88ba8b881555d351430a4be94d071ebbb35b84 ->groups(['api', 'health']) ->label('scope', 'health.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -451,11 +439,7 @@ App::get('/v1/health/queue/deletes') }, ['response']); App::get('/v1/health/queue/mails') -<<<<<<< HEAD - ->desc('Get Mails Queue') -======= ->desc('Get mails queue') ->>>>>>> 4f88ba8b881555d351430a4be94d071ebbb35b84 ->groups(['api', 'health']) ->label('scope', 'health.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -472,11 +456,7 @@ App::get('/v1/health/queue/mails') }, ['response']); App::get('/v1/health/queue/messaging') -<<<<<<< HEAD - ->desc('Get Messaging Queue') -======= ->desc('Get messaging queue') ->>>>>>> 4f88ba8b881555d351430a4be94d071ebbb35b84 ->groups(['api', 'health']) ->label('scope', 'health.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -493,11 +473,7 @@ App::get('/v1/health/queue/messaging') }, ['response']); App::get('/v1/health/queue/migrations') -<<<<<<< HEAD - ->desc('Get Migrations Queue') -======= ->desc('Get migrations queue') ->>>>>>> 4f88ba8b881555d351430a4be94d071ebbb35b84 ->groups(['api', 'health']) ->label('scope', 'health.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) diff --git a/composer.lock b/composer.lock index 4bee848a3e..c484f697e9 100644 --- a/composer.lock +++ b/composer.lock @@ -2152,16 +2152,16 @@ }, { "name": "utopia-php/database", - "version": "0.43.2", + "version": "0.43.3", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "f2626acd42665a9987c94af1c93bf20c28d55c9d" + "reference": "58d33c8d1216212edfba5d080e2f698487612aca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/f2626acd42665a9987c94af1c93bf20c28d55c9d", - "reference": "f2626acd42665a9987c94af1c93bf20c28d55c9d", + "url": "https://api.github.com/repos/utopia-php/database/zipball/58d33c8d1216212edfba5d080e2f698487612aca", + "reference": "58d33c8d1216212edfba5d080e2f698487612aca", "shasum": "" }, "require": { @@ -2202,9 +2202,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.43.2" + "source": "https://github.com/utopia-php/database/tree/0.43.3" }, - "time": "2023-09-07T19:04:33+00:00" + "time": "2023-09-28T01:51:22+00:00" }, { "name": "utopia-php/domains", @@ -6019,5 +6019,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } From d600ae1f746090f2adb4a765f9288a884ea07312 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 28 Sep 2023 22:25:53 +0000 Subject: [PATCH 13/22] chore: revert composer.lock --- composer.lock | 102 +++++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 47 deletions(-) diff --git a/composer.lock b/composer.lock index c484f697e9..2580f92b3a 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "13a3bdc7c1dec5756bf58ec73a49753d", + "content-hash": "54d54b76790d03a0bcfb9bbd23ed1009", "packages": [ { "name": "adhocore/jwt", @@ -1318,16 +1318,16 @@ }, { "name": "psr/http-client", - "version": "1.0.3", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/http-client.git", - "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", - "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31", + "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31", "shasum": "" }, "require": { @@ -1364,9 +1364,9 @@ "psr-18" ], "support": { - "source": "https://github.com/php-fig/http-client" + "source": "https://github.com/php-fig/http-client/tree/1.0.2" }, - "time": "2023-09-23T14:17:50+00:00" + "time": "2023-04-10T20:12:12+00:00" }, { "name": "psr/http-factory", @@ -2152,16 +2152,16 @@ }, { "name": "utopia-php/database", - "version": "0.43.3", + "version": "0.43.2", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "58d33c8d1216212edfba5d080e2f698487612aca" + "reference": "f2626acd42665a9987c94af1c93bf20c28d55c9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/58d33c8d1216212edfba5d080e2f698487612aca", - "reference": "58d33c8d1216212edfba5d080e2f698487612aca", + "url": "https://api.github.com/repos/utopia-php/database/zipball/f2626acd42665a9987c94af1c93bf20c28d55c9d", + "reference": "f2626acd42665a9987c94af1c93bf20c28d55c9d", "shasum": "" }, "require": { @@ -2202,9 +2202,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.43.3" + "source": "https://github.com/utopia-php/database/tree/0.43.2" }, - "time": "2023-09-28T01:51:22+00:00" + "time": "2023-09-07T19:04:33+00:00" }, { "name": "utopia-php/domains", @@ -2564,16 +2564,16 @@ }, { "name": "utopia-php/migration", - "version": "0.3.5", + "version": "0.3.4", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "b2fd3a8310296f4e44ff0e85b0eb0230ad9a2f83" + "reference": "ade836d61b3e1547bc9f0dc300ee75b24ab49f7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/b2fd3a8310296f4e44ff0e85b0eb0230ad9a2f83", - "reference": "b2fd3a8310296f4e44ff0e85b0eb0230ad9a2f83", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/ade836d61b3e1547bc9f0dc300ee75b24ab49f7a", + "reference": "ade836d61b3e1547bc9f0dc300ee75b24ab49f7a", "shasum": "" }, "require": { @@ -2596,6 +2596,16 @@ "license": [ "MIT" ], + "authors": [ + { + "name": "Eldad Fux", + "email": "eldad@appwrite.io" + }, + { + "name": "Bradley Schofield", + "email": "bradley@appwrite.io" + } + ], "description": "A simple library to migrate resources between services.", "keywords": [ "framework", @@ -2606,9 +2616,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.3.5" + "source": "https://github.com/utopia-php/migration/tree/0.3.4" }, - "time": "2023-09-25T16:51:47+00:00" + "time": "2023-09-14T17:17:55+00:00" }, { "name": "utopia-php/mongo", @@ -2988,16 +2998,16 @@ }, { "name": "utopia-php/storage", - "version": "0.17.0", + "version": "0.14.0", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "efec5376c02d3d8330f1beb1469e6d6e313e21ee" + "reference": "eda6651ac16884dc2a79ecb984ea591ba1ed498c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/efec5376c02d3d8330f1beb1469e6d6e313e21ee", - "reference": "efec5376c02d3d8330f1beb1469e6d6e313e21ee", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/eda6651ac16884dc2a79ecb984ea591ba1ed498c", + "reference": "eda6651ac16884dc2a79ecb984ea591ba1ed498c", "shasum": "" }, "require": { @@ -3005,12 +3015,10 @@ "ext-fileinfo": "*", "ext-lz4": "*", "ext-snappy": "*", - "ext-xz": "*", "ext-zlib": "*", "ext-zstd": "*", "php": ">=8.0", - "utopia-php/framework": "0.*.*", - "utopia-php/system": "0.*.*" + "utopia-php/framework": "0.*.*" }, "require-dev": { "laravel/pint": "1.2.*", @@ -3037,9 +3045,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.17.0" + "source": "https://github.com/utopia-php/storage/tree/0.14.0" }, - "time": "2023-08-21T11:28:36+00:00" + "time": "2023-03-15T00:16:34+00:00" }, { "name": "utopia-php/swoole", @@ -3434,16 +3442,16 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.2", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", "shasum": "" }, "require": { @@ -3475,9 +3483,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.2" + "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" }, - "time": "2023-09-27T20:04:15+00:00" + "time": "2023-06-03T09:27:29+00:00" }, { "name": "doctrine/instantiator", @@ -4137,16 +4145,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.2", + "version": "1.24.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "bcad8d995980440892759db0c32acae7c8e79442" + "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", - "reference": "bcad8d995980440892759db0c32acae7c8e79442", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6", + "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6", "shasum": "" }, "require": { @@ -4178,22 +4186,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0" }, - "time": "2023-09-26T12:28:12+00:00" + "time": "2023-09-07T20:46:32+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.29", + "version": "9.2.28", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" + "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", + "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", "shasum": "" }, "require": { @@ -4250,7 +4258,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.28" }, "funding": [ { @@ -4258,7 +4266,7 @@ "type": "github" } ], - "time": "2023-09-19T04:57:46+00:00" + "time": "2023-09-12T14:36:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -6019,5 +6027,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } From c27d5cb721b0047368e86ba26e07d047894fcb3b Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 28 Sep 2023 22:29:49 +0000 Subject: [PATCH 14/22] chore: revert composer.lock --- composer.lock | 88 +++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 48 deletions(-) diff --git a/composer.lock b/composer.lock index b77b6af64a..c484f697e9 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "54d54b76790d03a0bcfb9bbd23ed1009", + "content-hash": "13a3bdc7c1dec5756bf58ec73a49753d", "packages": [ { "name": "adhocore/jwt", @@ -1318,16 +1318,16 @@ }, { "name": "psr/http-client", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/php-fig/http-client.git", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31" + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", "shasum": "" }, "require": { @@ -1364,9 +1364,9 @@ "psr-18" ], "support": { - "source": "https://github.com/php-fig/http-client/tree/1.0.2" + "source": "https://github.com/php-fig/http-client" }, - "time": "2023-04-10T20:12:12+00:00" + "time": "2023-09-23T14:17:50+00:00" }, { "name": "psr/http-factory", @@ -2564,16 +2564,16 @@ }, { "name": "utopia-php/migration", - "version": "0.3.4", + "version": "0.3.5", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "ade836d61b3e1547bc9f0dc300ee75b24ab49f7a" + "reference": "b2fd3a8310296f4e44ff0e85b0eb0230ad9a2f83" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/ade836d61b3e1547bc9f0dc300ee75b24ab49f7a", - "reference": "ade836d61b3e1547bc9f0dc300ee75b24ab49f7a", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/b2fd3a8310296f4e44ff0e85b0eb0230ad9a2f83", + "reference": "b2fd3a8310296f4e44ff0e85b0eb0230ad9a2f83", "shasum": "" }, "require": { @@ -2596,16 +2596,6 @@ "license": [ "MIT" ], - "authors": [ - { - "name": "Eldad Fux", - "email": "eldad@appwrite.io" - }, - { - "name": "Bradley Schofield", - "email": "bradley@appwrite.io" - } - ], "description": "A simple library to migrate resources between services.", "keywords": [ "framework", @@ -2616,9 +2606,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.3.4" + "source": "https://github.com/utopia-php/migration/tree/0.3.5" }, - "time": "2023-09-14T17:17:55+00:00" + "time": "2023-09-25T16:51:47+00:00" }, { "name": "utopia-php/mongo", @@ -2998,16 +2988,16 @@ }, { "name": "utopia-php/storage", - "version": "0.14.0", + "version": "0.17.0", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "eda6651ac16884dc2a79ecb984ea591ba1ed498c" + "reference": "efec5376c02d3d8330f1beb1469e6d6e313e21ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/eda6651ac16884dc2a79ecb984ea591ba1ed498c", - "reference": "eda6651ac16884dc2a79ecb984ea591ba1ed498c", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/efec5376c02d3d8330f1beb1469e6d6e313e21ee", + "reference": "efec5376c02d3d8330f1beb1469e6d6e313e21ee", "shasum": "" }, "require": { @@ -3015,10 +3005,12 @@ "ext-fileinfo": "*", "ext-lz4": "*", "ext-snappy": "*", + "ext-xz": "*", "ext-zlib": "*", "ext-zstd": "*", "php": ">=8.0", - "utopia-php/framework": "0.*.*" + "utopia-php/framework": "0.*.*", + "utopia-php/system": "0.*.*" }, "require-dev": { "laravel/pint": "1.2.*", @@ -3045,9 +3037,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.14.0" + "source": "https://github.com/utopia-php/storage/tree/0.17.0" }, - "time": "2023-03-15T00:16:34+00:00" + "time": "2023-08-21T11:28:36+00:00" }, { "name": "utopia-php/swoole", @@ -3442,16 +3434,16 @@ }, { "name": "doctrine/deprecations", - "version": "v1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", "shasum": "" }, "require": { @@ -3483,9 +3475,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" + "source": "https://github.com/doctrine/deprecations/tree/1.1.2" }, - "time": "2023-06-03T09:27:29+00:00" + "time": "2023-09-27T20:04:15+00:00" }, { "name": "doctrine/instantiator", @@ -4145,16 +4137,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.0", + "version": "1.24.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6" + "reference": "bcad8d995980440892759db0c32acae7c8e79442" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", + "reference": "bcad8d995980440892759db0c32acae7c8e79442", "shasum": "" }, "require": { @@ -4186,22 +4178,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" }, - "time": "2023-09-07T20:46:32+00:00" + "time": "2023-09-26T12:28:12+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.28", + "version": "9.2.29", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef" + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", - "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", "shasum": "" }, "require": { @@ -4258,7 +4250,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.28" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" }, "funding": [ { @@ -4266,7 +4258,7 @@ "type": "github" } ], - "time": "2023-09-12T14:36:20+00:00" + "time": "2023-09-19T04:57:46+00:00" }, { "name": "phpunit/php-file-iterator", From d9f2f1c37bbd1e165440c9cb817c093ba7b385bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sat, 30 Sep 2023 11:54:54 +0200 Subject: [PATCH 15/22] Introduce execution sync timeout --- app/controllers/api/functions.php | 3 ++- app/controllers/general.php | 1 + src/Executor/Executor.php | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 2861ae40c3..18a9b06a4e 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1708,7 +1708,8 @@ App::post('/v1/functions/:functionId/executions') path: $path, method: $method, headers: $headers, - runtimeEntrypoint: $command + runtimeEntrypoint: $command, + requestTimeout: 15 ); $headersFiltered = []; diff --git a/app/controllers/general.php b/app/controllers/general.php index b2b3d37471..0e16f35e29 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -139,6 +139,7 @@ function router(App $utopia, Database $dbForConsole, SwooleRequest $swooleReques \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // \curl_setopt($ch, CURLOPT_HEADER, true); \curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + \curl_setopt($ch, CURLOPT_TIMEOUT, 15); $executionResponse = \curl_exec($ch); $statusCode = \curl_getinfo($ch, CURLINFO_HTTP_CODE); diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index d81a4048c2..41d283cd09 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -177,6 +177,7 @@ class Executor string $method, array $headers, string $runtimeEntrypoint = null, + int $requestTimeout = null ) { if (empty($headers['host'])) { $headers['host'] = App::getEnv('_APP_DOMAIN', ''); @@ -204,9 +205,11 @@ class Executor // Safety timeout. Executor has timeout, and open runtime has soft timeout. // This one shouldn't really happen, but prevents from unexpected networking behaviours. - $timeout = $timeout + 15; + if($requestTimeout == null) { + $requestTimeout = $timeout + 15; + } - $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, $requestTimeout); $status = $response['headers']['status-code']; if ($status >= 400) { From 515fec285806c231cb7a2ecc17e964029a0041a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sat, 30 Sep 2023 11:57:15 +0200 Subject: [PATCH 16/22] Linter fix --- src/Executor/Executor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index 41d283cd09..4b68cc5233 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -205,7 +205,7 @@ class Executor // Safety timeout. Executor has timeout, and open runtime has soft timeout. // This one shouldn't really happen, but prevents from unexpected networking behaviours. - if($requestTimeout == null) { + if ($requestTimeout == null) { $requestTimeout = $timeout + 15; } From 1502bfef74562039672b9830666691b36cada3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sat, 30 Sep 2023 17:24:09 +0200 Subject: [PATCH 17/22] Increase timeout --- app/controllers/api/functions.php | 2 +- app/controllers/general.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 18a9b06a4e..4c41c8bd34 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1709,7 +1709,7 @@ App::post('/v1/functions/:functionId/executions') method: $method, headers: $headers, runtimeEntrypoint: $command, - requestTimeout: 15 + requestTimeout: 30 ); $headersFiltered = []; diff --git a/app/controllers/general.php b/app/controllers/general.php index 0e16f35e29..bc21da50dd 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -139,7 +139,7 @@ function router(App $utopia, Database $dbForConsole, SwooleRequest $swooleReques \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // \curl_setopt($ch, CURLOPT_HEADER, true); \curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); - \curl_setopt($ch, CURLOPT_TIMEOUT, 15); + \curl_setopt($ch, CURLOPT_TIMEOUT, 30); $executionResponse = \curl_exec($ch); $statusCode = \curl_getinfo($ch, CURLINFO_HTTP_CODE); From b456c9df2cd66819f254e88d3daf516971d4775d Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 2 Oct 2023 21:32:05 +0000 Subject: [PATCH 18/22] chore: remove DB creates --- app/controllers/api/projects.php | 2 +- app/http.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 2d2b420951..c1bebfc74d 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -170,7 +170,7 @@ App::post('/v1/projects') $dbForProject = new Database($pools->get($database)->pop()->getResource(), $cache); $dbForProject->setNamespace("_{$project->getInternalId()}"); - $dbForProject->create(); + // $dbForProject->create(); $audit = new Audit($dbForProject); $audit->setup(); diff --git a/app/http.php b/app/http.php index fe1ed48724..0d0058ff18 100644 --- a/app/http.php +++ b/app/http.php @@ -89,7 +89,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) { try { Console::success('[Setup] - Creating database: appwrite...'); - $dbForConsole->create(); + // $dbForConsole->create(); } catch (\Exception $e) { Console::success('[Setup] - Skip: metadata table already exists'); } From 29ad61d4617b25f9e2ef21e88845e257b3b5f595 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 2 Oct 2023 22:01:42 +0000 Subject: [PATCH 19/22] chore: update database --- app/controllers/api/projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index c1bebfc74d..9b4b746bed 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -121,7 +121,7 @@ App::post('/v1/projects') } } - if ($index = array_search('database_db_fra1_v14x_07', $databases)) { + if ($index = array_search('database_db_fra1_v14x_06', $databases)) { $database = $databases[$index]; } else { $database = $databases[array_rand($databases)]; From ff3c25d352b52af8967baeb839184e339b43fc48 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 2 Oct 2023 22:23:35 +0000 Subject: [PATCH 20/22] chore: update database --- app/controllers/api/projects.php | 2 +- app/http.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 9b4b746bed..dbe33bace4 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -170,7 +170,7 @@ App::post('/v1/projects') $dbForProject = new Database($pools->get($database)->pop()->getResource(), $cache); $dbForProject->setNamespace("_{$project->getInternalId()}"); - // $dbForProject->create(); + $dbForProject->create(); $audit = new Audit($dbForProject); $audit->setup(); diff --git a/app/http.php b/app/http.php index 0d0058ff18..fe1ed48724 100644 --- a/app/http.php +++ b/app/http.php @@ -89,7 +89,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) { try { Console::success('[Setup] - Creating database: appwrite...'); - // $dbForConsole->create(); + $dbForConsole->create(); } catch (\Exception $e) { Console::success('[Setup] - Skip: metadata table already exists'); } From adbbb6dc20b5fa273b186b726232220990b85cd8 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 5 Oct 2023 05:53:49 +0000 Subject: [PATCH 21/22] chore: add database overrides --- app/controllers/api/projects.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index dbe33bace4..480d9e3a34 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -121,7 +121,9 @@ App::post('/v1/projects') } } - if ($index = array_search('database_db_fra1_v14x_06', $databases)) { + $databaseOverride = App::getEnv('APP_DATABASE_OVERRIDE', null); + $index = array_search($databaseOverride, $databases); + if ($index) { $database = $databases[$index]; } else { $database = $databases[array_rand($databases)]; From 32ba34cba5a332d858559c9e53442320a32631a4 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 5 Oct 2023 05:58:52 +0000 Subject: [PATCH 22/22] chore: add database overrides --- app/controllers/api/projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 480d9e3a34..a01138225f 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -121,7 +121,7 @@ App::post('/v1/projects') } } - $databaseOverride = App::getEnv('APP_DATABASE_OVERRIDE', null); + $databaseOverride = App::getEnv('_APP_DATABASE_OVERRIDE', null); $index = array_search($databaseOverride, $databases); if ($index) { $database = $databases[$index];