diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a87f1e574f..385016db91 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: cl-1.4.x - name: Login to Docker Hub uses: docker/login-action@v2 diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index d6a2612f32..6aabb17940 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -387,6 +387,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/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" } 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..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,9 +172,124 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['size']); $this->assertLessThan(100, $response['body']['size']); + return []; + } + + public function testFunctionsSuccess(): array + { /** - * Test for FAILURE + * 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']); + + 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']); + + 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']); + + 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']); + + 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']); + + 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']); + + 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']); return []; } @@ -226,10 +309,6 @@ class HealthCustomServerTest extends Scope $this->assertIsInt($response['body']['ping']); $this->assertLessThan(100, $response['body']['ping']); - /** - * Test for FAILURE - */ - return []; } @@ -248,10 +327,6 @@ class HealthCustomServerTest extends Scope $this->assertIsString($response['body']['status']); $this->assertIsString($response['body']['version']); - /** - * Test for FAILURE - */ - return []; } }