diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b51d5e71..c433e085 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,8 +4,8 @@ on: push: { branches: [main] } jobs: - tests: - name: Run Test Suite + mockapi: + name: Run Mock API Test Suite runs-on: ubuntu-latest env: COMPOSE_FILE: docker-compose.yml @@ -14,6 +14,32 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Run Tests + - name: Bring up services + run: docker-compose up -d --build && sleep 20 + + - name: Run Supabase Test Suite + run: | + docker compose exec tests php ./vendor/bin/phpunit --group Supabase + + - name: Run NHost Test Suite + run: | + docker compose exec tests php ./vendor/bin/phpunit --group NHost + appwrite: + name: Run Appwrite Test Suite + runs-on: ubuntu-latest + env: + COMPOSE_FILE: docker-compose.yml + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Appwrite + run: | + git clone https://github.com/appwrite/appwrite.git + cd appwrite + docker-compose up -d --build + + - name: Run Appwrite Test Suite run: | - docker-compose up -d --build && sleep 5 && docker compose exec tests php ./vendor/bin/phpunit \ No newline at end of file + docker compose exec tests php ./vendor/bin/phpunit --group Appwrite diff --git a/src/Migration/Cache.php b/src/Migration/Cache.php index 1eb505c7..7246ad87 100644 --- a/src/Migration/Cache.php +++ b/src/Migration/Cache.php @@ -119,13 +119,13 @@ public function getAll() } /** - * Wipe Cache + * Clear Cache * * Removes all resources from the cache. * * @return void */ - public function wipe() + public function clear() { $this->cache = []; } diff --git a/src/Migration/Source.php b/src/Migration/Source.php index 774eb9ab..9f0cb147 100644 --- a/src/Migration/Source.php +++ b/src/Migration/Source.php @@ -82,6 +82,9 @@ public function exportResources(array $resources, int $batchSize) $this->exportGroupFunctions($batchSize, $resources); break; } + + // Clear the cache after each group + $this->cache->clear(); } } diff --git a/tests/Migration/E2E/Sources/NHostTest.php b/tests/Migration/E2E/Sources/NHostTest.php index 410216fa..dd28e65f 100644 --- a/tests/Migration/E2E/Sources/NHostTest.php +++ b/tests/Migration/E2E/Sources/NHostTest.php @@ -77,6 +77,9 @@ protected function setUp(): void $this->transfer = new Transfer($this->source, $this->destination); } + /** + * @group NHost + */ public function testSourceReport() { // Test report all @@ -91,6 +94,8 @@ public function testSourceReport() /** * @depends testSourceReport + * + * @group NHost */ public function testRunTransfer($state) { @@ -110,10 +115,13 @@ function () { /** * @depends testRunTransfer + * + * @group NHost */ public function testValidateTransfer($state) { $statusCounters = $state['transfer']->getStatusCounters(); + $this->assertNotEmpty($statusCounters); foreach ($statusCounters as $resource => $counters) { @@ -131,6 +139,8 @@ public function testValidateTransfer($state) /** * @depends testValidateTransfer + * + * @group NHost */ public function testValidateUserTransfer($state): void { @@ -162,6 +172,8 @@ public function testValidateUserTransfer($state): void /** * @depends testValidateTransfer + * + * @group NHost */ public function testValidateDatabaseTransfer($state): void { @@ -215,6 +227,8 @@ public function testValidateDatabaseTransfer($state): void /** * @depends testValidateTransfer + * + * @group NHost */ public function testValidateStorageTransfer($state): void { diff --git a/tests/Migration/E2E/Sources/SupabaseTest.php b/tests/Migration/E2E/Sources/SupabaseTest.php index 832e7835..8e9f54c7 100644 --- a/tests/Migration/E2E/Sources/SupabaseTest.php +++ b/tests/Migration/E2E/Sources/SupabaseTest.php @@ -57,6 +57,9 @@ protected function setUp(): void $this->transfer = new Transfer($this->source, $this->destination); } + /** + * @group Supabase + */ public function testSourceReport() { // Test report all @@ -71,6 +74,8 @@ public function testSourceReport() /** * @depends testSourceReport + * + * @group Supabase */ public function testRunTransfer($state) { @@ -89,6 +94,8 @@ function () { /** * @depends testRunTransfer + * + * @group Supabase */ public function testValidateTransfer($state) { @@ -110,6 +117,8 @@ public function testValidateTransfer($state) /** * @depends testValidateTransfer + * + * @group Supabase */ public function testValidateUserTransfer($state): void { @@ -141,6 +150,8 @@ public function testValidateUserTransfer($state): void /** * @depends testValidateTransfer + * + * @group Supabase */ public function testValidateDatabaseTransfer($state): void { @@ -220,6 +231,8 @@ public function testValidateDatabaseTransfer($state): void /** * @depends testValidateTransfer + * + * @group Supabase */ public function testValidateStorageTransfer($state): void { diff --git a/tests/Migration/resources/appwrite/initializeProject.sh b/tests/Migration/resources/appwrite/initializeProject.sh new file mode 100755 index 00000000..593d78be --- /dev/null +++ b/tests/Migration/resources/appwrite/initializeProject.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +# Create Console Account +curl -s -k 'https://localhost/v1/account' \ + -H 'content-type: application/json' \ + -H 'x-appwrite-project: console' \ + --data-raw '{"userId":"admin","email":"admin@appwrite.io","password":"Password123","name":"Admin"}' \ + --compressed \ + --insecure + +# Login +curl -s -k -b console-cookies.txt -c console-cookies.txt 'https://localhost/v1/account/sessions/email' \ + -H 'content-type: application/json' \ + -H 'x-appwrite-project: console' \ + --data-raw '{"email":"admin@appwrite.io","password":"Password123"}' \ + --compressed \ + --insecure + +# Create Team +curl -s -k -b console-cookies.txt -c console-cookies.txt 'https://localhost/v1/teams' \ + -H 'content-type: application/json' \ + -H 'x-appwrite-project: console' \ + --data-raw '{"teamId":"personal","name":"Personal Projects"}' \ + --compressed \ + --insecure + +# Create Project +curl -s -k -b console-cookies.txt -c console-cookies.txt 'https://localhost/v1/projects' \ + -H 'content-type: application/json' \ + -H 'x-appwrite-project: console' \ + --data-raw '{"projectId":"test","name":"Test","teamId":"personal","region":"default"}' \ + --compressed \ + --insecure \ No newline at end of file diff --git a/tests/Migration/resources/appwrite/teardownProject.sh b/tests/Migration/resources/appwrite/teardownProject.sh new file mode 100755 index 00000000..15121421 --- /dev/null +++ b/tests/Migration/resources/appwrite/teardownProject.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# Delete Project +curl -s -k -b console-cookies.txt -c console-cookies.txt 'https://localhost/v1/projects/test' \ + -X DELETE \ + -H 'content-type: application/json' \ + -H 'x-appwrite-project: console' \ + --compressed \ + --insecure + +# Delete Team +curl -s -k -b console-cookies.txt -c console-cookies.txt 'https://localhost/v1/teams/personal' \ + -X DELETE \ + -H 'content-type: application/json' \ + -H 'x-appwrite-project: console' \ + --compressed \ + --insecure + +# Delete Console Account +curl -s -k -b console-cookies.txt -c console-cookies.txt 'https://localhost/v1/account' \ + -X DELETE \ + -H 'content-type: application/json' \ + -H 'x-appwrite-project: console' \ + --compressed \ + --insecure \ No newline at end of file