From ac02f0bd66cd7b1b5f46800239e619b64893f6d6 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 21 Mar 2025 10:50:46 +0000 Subject: [PATCH] chore: removing unwanted specs test --- .../Functions/FunctionsCustomServerTest.php | 134 ------------------ 1 file changed, 134 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 182e6902a3..7fbc60be6d 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -2,7 +2,6 @@ namespace Tests\E2E\Services\Functions; -use Appwrite\Functions\Specification; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; @@ -1054,96 +1053,6 @@ class FunctionsCustomServerTest extends Scope return $data; } - - - /** - * @depends testGetExecution - */ - public function testUpdateSpecs($data): array - { - /** - * Test for SUCCESS - */ - // Change the function specs - $function = $this->client->call(Client::METHOD_PUT, '/functions/' . $data['functionId'], array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'name' => 'Test1', - 'events' => [ - 'users.*.update.name', - 'users.*.update.email', - ], - 'timeout' => 15, - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', - 'specification' => Specification::S_1VCPU_1GB, - ]); - - $this->assertEquals(200, $function['headers']['status-code']); - $this->assertNotEmpty($function['body']['$id']); - $this->assertEquals(Specification::S_1VCPU_1GB, $function['body']['specification']); - - // Verify the updated specs - $execution = $this->createExecution($data['functionId']); - - $output = json_decode($execution['body']['responseBody'], true); - - $this->assertEquals(1, $output['APPWRITE_FUNCTION_CPUS']); - $this->assertEquals(1024, $output['APPWRITE_FUNCTION_MEMORY']); - - // Change the specs to 1vcpu 512mb - $function = $this->client->call(Client::METHOD_PUT, '/functions/' . $data['functionId'], array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'name' => 'Test1', - 'events' => [ - 'users.*.update.name', - 'users.*.update.email', - ], - 'timeout' => 15, - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', - 'specification' => Specification::S_1VCPU_512MB, - ]); - - $this->assertEquals(200, $function['headers']['status-code']); - $this->assertNotEmpty($function['body']['$id']); - $this->assertEquals(Specification::S_1VCPU_512MB, $function['body']['specification']); - - // Verify the updated specs - $execution = $this->createExecution($data['functionId']); - - $output = json_decode($execution['body']['responseBody'], true); - - $this->assertEquals(1, $output['APPWRITE_FUNCTION_CPUS']); - $this->assertEquals(512, $output['APPWRITE_FUNCTION_MEMORY']); - - /** - * Test for FAILURE - */ - $function = $this->client->call(Client::METHOD_PUT, '/functions/' . $data['functionId'], array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'name' => 'Test1', - 'events' => [ - 'users.*.update.name', - 'users.*.update.email', - ], - 'timeout' => 15, - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', - 'specification' => 's-2vcpu-512mb', // Invalid specification - ]); - - $this->assertEquals(400, $function['headers']['status-code']); - $this->assertStringStartsWith('Invalid `specification` param: Specification must be one of:', $function['body']['message']); - - return $data; - } - /** * @depends testGetExecution */ @@ -1980,47 +1889,4 @@ class FunctionsCustomServerTest extends Scope $this->cleanupFunction($functionId); } - - public function testFunctionSpecifications() - { - // Check if the function specifications are correctly set in builds - $function = $this->createFunction([ - 'functionId' => ID::unique(), - 'runtime' => 'node-18.0', - 'name' => 'Specification Test', - 'entrypoint' => 'index.js', - 'logging' => false, - 'execute' => ['any'], - 'specification' => Specification::S_2VCPU_2GB, - 'commands' => 'echo $APPWRITE_FUNCTION_MEMORY:$APPWRITE_FUNCTION_CPUS', - ]); - - $this->assertEquals(201, $function['headers']['status-code']); - $this->assertEquals(Specification::S_2VCPU_2GB, $function['body']['specification']); - $this->assertNotEmpty($function['body']['$id']); - - $functionId = $functionId = $function['body']['$id'] ?? ''; - - $deploymentId = $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('node'), - 'activate' => true - ]); - - $this->assertEventually(function () use ($functionId, $deploymentId) { - $deployment = $this->getDeployment($functionId, $deploymentId); - $this->assertTrue(str_contains($deployment['body']['buildLogs'], '2048:2')); - }, 10000, 500); - - // Check if the function specifications are correctly set in executions - $execution = $this->createExecution($functionId); - - $this->assertEquals(201, $execution['headers']['status-code']); - $this->assertNotEmpty($execution['body']['$id']); - - $executionResponse = json_decode($execution['body']['responseBody'], true); - $this->assertEquals('2048', $executionResponse['APPWRITE_FUNCTION_MEMORY']); - $this->assertEquals('2', $executionResponse['APPWRITE_FUNCTION_CPUS']); - - $this->cleanupFunction($functionId); - } }