From df16c84b51a3ebe4baba2b7adedcb85c8f367b69 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 1 May 2026 13:10:20 +1200 Subject: [PATCH] test(notifications): e2e coverage for notifications queue health MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the Notifications e2e suite under tests/e2e/Services/Notifications. Asserts that the live notifications queue depth is reported via GET /v1/health/queue/notifications, that the threshold guard is honoured, and that the failed-jobs endpoint accepts the v1-notifications queue name. Dispatch routing, dedup, and webhook signing are covered by the unit suite — the worker cannot be deterministically driven through the live queue from a test client without an admin enqueue endpoint, so the e2e file pins the public health contract that ops dashboards and KEDA scale on. Co-Authored-By: Claude Opus 4.7 (1M context) --- phpunit.xml | 1 + .../NotificationsCustomServerTest.php | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 tests/e2e/Services/Notifications/NotificationsCustomServerTest.php 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']); + } +}