From aaf896f27e9fcfe96a51e18fc7cf08f15a56cd63 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 2 Nov 2022 13:16:42 +1300 Subject: [PATCH] Fix tests --- phpbench.json | 4 ++-- tests/benchmarks/Database/Base.php | 8 +++----- tests/e2e/General/AbuseTest.php | 2 +- tests/e2e/General/UsageTest.php | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/phpbench.json b/phpbench.json index 3fcac1b65a..614a7cadf1 100644 --- a/phpbench.json +++ b/phpbench.json @@ -3,8 +3,8 @@ "runner.path": "tests/benchmarks", "runner.file_pattern": "*Bench.php", "runner.bootstrap": "app/init.php", - "runner.revs": 500, - "runner.iterations": 3, + "runner.revs": 1000, + "runner.iterations": 5, "runner.warmup": 1, "report.generators": { "appwrite": { diff --git a/tests/benchmarks/Database/Base.php b/tests/benchmarks/Database/Base.php index 9426053788..67acd8ee01 100644 --- a/tests/benchmarks/Database/Base.php +++ b/tests/benchmarks/Database/Base.php @@ -82,7 +82,6 @@ abstract class Base extends Scope public function createDatabase(array $params = []) { - // Create database $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -96,8 +95,7 @@ abstract class Base extends Scope public function createCollection(array $params = []) { - // Create collection - $movies = $this->client->call(Client::METHOD_POST, '/databases/' . static::$databaseId . '/collections', [ + $collection = $this->client->call(Client::METHOD_POST, '/databases/' . static::$databaseId . '/collections', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'] @@ -110,7 +108,7 @@ abstract class Base extends Scope Permission::write(Role::user($this->getUser()['$id'])), ], ]); - static::$collectionId = $movies['body']['$id']; + static::$collectionId = $collection['body']['$id']; // Create attribute $this->client->call(Client::METHOD_POST, '/databases/' . static::$databaseId . '/collections/' . static::$collectionId . '/attributes/string', [ @@ -123,6 +121,7 @@ abstract class Base extends Scope 'required' => true, ]); + // Wait for attribute to be ready sleep(2); } @@ -130,7 +129,6 @@ abstract class Base extends Scope { $count = $params['documents'] ?? 1; - // Create documents for ($i = 0; $i < $count; $i++) { $response = $this->client->call(Client::METHOD_POST, '/databases/' . static::$databaseId . '/collections/' . static::$collectionId . '/documents', [ 'content-type' => 'application/json', diff --git a/tests/e2e/General/AbuseTest.php b/tests/e2e/General/AbuseTest.php index 90a4b33800..0db8ce04d9 100644 --- a/tests/e2e/General/AbuseTest.php +++ b/tests/e2e/General/AbuseTest.php @@ -17,7 +17,7 @@ class AbuseTest extends Scope use ProjectCustom; use SideNone; - protected function setUp(): void + public function setUp(): void { parent::setUp(); diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index 0c42c42ff2..8139ba456f 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -21,7 +21,7 @@ class UsageTest extends Scope protected string $projectId; - protected function setUp(): void + public function setUp(): void { parent::setUp(); } @@ -754,7 +754,7 @@ class UsageTest extends Scope $this->validateDates($response['executionsFailure']); } - protected function tearDown(): void + public function tearDown(): void { $this->usersCount = 0; $this->requestsCount = 0;