From 213e16050bd5cbd5021d40534c9b9dc2c930b99e Mon Sep 17 00:00:00 2001 From: Fabian Gruber Date: Wed, 5 Feb 2025 13:17:21 +0100 Subject: [PATCH 1/2] fix(test): use assertEventually instead of while(true) --- .../Services/GraphQL/FunctionsClientTest.php | 18 +++++------------- .../Services/GraphQL/FunctionsServerTest.php | 19 +++++-------------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/tests/e2e/Services/GraphQL/FunctionsClientTest.php b/tests/e2e/Services/GraphQL/FunctionsClientTest.php index e7e8421254..0b43ed5772 100644 --- a/tests/e2e/Services/GraphQL/FunctionsClientTest.php +++ b/tests/e2e/Services/GraphQL/FunctionsClientTest.php @@ -2,6 +2,7 @@ namespace Tests\E2E\Services\GraphQL; +use Appwrite\Tests\Async; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; @@ -14,6 +15,7 @@ class FunctionsClientTest extends Scope use ProjectCustom; use SideClient; use Base; + use Async; public function testCreateFunction(): array { @@ -119,7 +121,7 @@ class FunctionsClientTest extends Scope ] ]; - while (true) { + $this->assertEventually(function () use ($projectId, $gqlPayload, &$deployment) { $deployment = $this->client->call(Client::METHOD_POST, '/graphql', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, @@ -130,18 +132,8 @@ class FunctionsClientTest extends Scope $this->assertArrayNotHasKey('errors', $deployment['body']); $deployment = $deployment['body']['data']['functionsGetDeployment']; - - if ( - $deployment['status'] === 'ready' - || $deployment['status'] === 'failed' - ) { - break; - } - - \sleep(1); - } - - $this->assertEquals('ready', $deployment['status']); + $this->assertEquals('ready', $deployment['status']); + }); return $deployment; } diff --git a/tests/e2e/Services/GraphQL/FunctionsServerTest.php b/tests/e2e/Services/GraphQL/FunctionsServerTest.php index c3606244c4..e49ac43619 100644 --- a/tests/e2e/Services/GraphQL/FunctionsServerTest.php +++ b/tests/e2e/Services/GraphQL/FunctionsServerTest.php @@ -2,6 +2,7 @@ namespace Tests\E2E\Services\GraphQL; +use Appwrite\Tests\Async; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; @@ -14,6 +15,7 @@ class FunctionsServerTest extends Scope use ProjectCustom; use SideServer; use Base; + use Async; public function testCreateFunction(): array { @@ -117,7 +119,7 @@ class FunctionsServerTest extends Scope ] ]; - while (true) { + $this->assertEventually(function () use ($projectId, $gqlPayload, &$deployment) { $deployment = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, @@ -127,19 +129,8 @@ class FunctionsServerTest extends Scope $this->assertArrayNotHasKey('errors', $deployment['body']); $deployment = $deployment['body']['data']['functionsGetDeployment']; - - if ( - $deployment['status'] === 'ready' - || $deployment['status'] === 'failed' - ) { - break; - } - - \sleep(1); - } - - $this->assertEquals('ready', $deployment['status']); - + $this->assertEquals('ready', $deployment['status']); + }); return $deployment; } From 78dd753e8f5363292b5ae57416df102b43694535 Mon Sep 17 00:00:00 2001 From: Fabian Gruber Date: Wed, 5 Feb 2025 18:01:55 +0100 Subject: [PATCH 2/2] fix(certificate worker): events are published without queue name --- src/Appwrite/Platform/Workers/Certificates.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index e763cb54ee..7e220b2734 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -370,6 +370,8 @@ class Certificates extends Action /** Trigger Webhook */ $ruleModel = new Rule(); $queueForEvents + ->setQueue(Event::WEBHOOK_QUEUE_NAME) + ->setClass(Event::WEBHOOK_CLASS_NAME) ->setProject($project) ->setEvent('rules.[ruleId].update') ->setParam('ruleId', $rule->getId())