diff --git a/phpunit.xml b/phpunit.xml index 9748c5a5c8..4d15f60ce0 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -37,6 +37,7 @@ ./tests/e2e/Services/ProjectWebhooks ./tests/e2e/Services/Messaging ./tests/e2e/Services/Migrations + ./tests/e2e/Services/Notifications ./tests/e2e/Services/Project ./tests/e2e/Services/Functions/FunctionsBase.php ./tests/e2e/Services/Functions/FunctionsCustomServerTest.php diff --git a/tests/e2e/Services/Notifications/NotificationsCustomServerTest.php b/tests/e2e/Services/Notifications/NotificationsCustomServerTest.php new file mode 100644 index 0000000000..37f3dead10 --- /dev/null +++ b/tests/e2e/Services/Notifications/NotificationsCustomServerTest.php @@ -0,0 +1,67 @@ +client->call(Client::METHOD_GET, '/health/queue/notifications', \array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertSame(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertGreaterThanOrEqual(0, $response['body']['size']); + } + + public function testHealthQueueNotificationsThresholdGuard(): void + { + $response = $this->client->call(Client::METHOD_GET, '/health/queue/notifications', \array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), ['threshold' => '0']); + + // threshold=0 means any non-zero queue length is unhealthy. The size + // is racy under load, so accept either response — the contract is + // that the parameter is honoured, not that the queue is hot. + $this->assertContains($response['headers']['status-code'], [200, 503]); + } + + public function testHealthQueueFailedAcceptsNotifications(): void + { + $response = $this->client->call(Client::METHOD_GET, '/health/queue/failed/v1-notifications', \array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertSame(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + } +}