diff --git a/.github/workflows/integration-test-cluster-neo4j-4.yml b/.github/workflows/integration-test-cluster-neo4j-4.yml index c1147c51..1051ea69 100644 --- a/.github/workflows/integration-test-cluster-neo4j-4.yml +++ b/.github/workflows/integration-test-cluster-neo4j-4.yml @@ -17,126 +17,14 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Cache Composer dependencies - uses: actions/cache@v2 + - name: Populate .env + run: | + echo "CONNECTION=neo4j://neo4j:testtest@neo4j" > .env + - uses: hoverkraft-tech/compose-action@v2.0.2 with: - path: /tmp/composer-cache - key: ${{ runner.os }}-8.0-${{ hashFiles('**/composer.lock') }} - - uses: php-actions/composer@v6 - with: - progress: yes - php_version: 8.1 - version: 2 - - uses: php-actions/phpunit@v3 - with: - configuration: phpunit.xml.dist - php_version: 8.1 - memory_limit: 1024M - version: 10 - testsuite: Integration - bootstrap: vendor/autoload.php - - services: - core1: - image: neo4j:4.4-enterprise - options: >- - --health-cmd "wget -q --method=HEAD http://localhost:7475 || exit 1" - --health-start-period "60s" - --health-interval "30s" - --health-timeout "15s" - --health-retries "5" - ports: - - 7688:7688 - - 7475:7475 - env: - NEO4J_ACCEPT_LICENSE_AGREEMENT: yes - NEO4JLABS_PLUGINS: '["apoc"]' - NEO4J_AUTH: neo4j/testtest - NEO4J_dbms_mode: CORE - NEO4J_causal__clustering_discovery__advertised__address: core1:5000 - NEO4J_causal__clustering_transaction__advertised__address: core1:6000 - NEO4J_causal__clustering_raft__advertised__address: core1:7000 - NEO4J_causal__clustering_initial__discovery__members: core1:5000,core2:5000,core3:5000 - NEO4J_causal__clustering_discovery__listen__address: 0.0.0.0:5000 - NEO4J_causal__clustering_transaction__listen__address: 0.0.0.0:6000 - NEO4J_causal__clustering_raft__listen__address: 0.0.0.0:7000 - NEO4J_dbms_connector_http_listen__address: 0.0.0.0:7475 - NEO4J_dbms_connector_bolt_listen__address: 0.0.0.0:7688 - - core2: - image: neo4j:4.4-enterprise - options: >- - --health-cmd "wget -q --method=HEAD http://localhost:7476 || exit 1" - --health-start-period "60s" - --health-interval "30s" - --health-timeout "15s" - --health-retries "5" - ports: - - 7689:7689 - - 7476:7476 - env: - NEO4J_ACCEPT_LICENSE_AGREEMENT: yes - NEO4JLABS_PLUGINS: '["apoc"]' - NEO4J_AUTH: neo4j/testtest - NEO4J_dbms_mode: CORE - NEO4J_causal__clustering_discovery__advertised__address: core2:5000 - NEO4J_causal__clustering_transaction__advertised__address: core2:6000 - NEO4J_causal__clustering_raft__advertised__address: core2:7000 - NEO4J_causal__clustering_initial__discovery__members: core1:5000,core2:5000,core3:5000 - NEO4J_causal__clustering_discovery__listen__address: 0.0.0.0:5000 - NEO4J_causal__clustering_transaction__listen__address: 0.0.0.0:6000 - NEO4J_causal__clustering_raft__listen__address: 0.0.0.0:7000 - NEO4J_dbms_connector_http_listen__address: 0.0.0.0:7476 - NEO4J_dbms_connector_bolt_listen__address: 0.0.0.0:7689 - - core3: - image: neo4j:4.4-enterprise - options: >- - --health-cmd "wget -q --method=HEAD http://localhost:7477 || exit 1" - --health-start-period "60s" - --health-interval "30s" - --health-timeout "15s" - --health-retries "5" - ports: - - 7690:7690 - - 7477:7477 - env: - NEO4J_ACCEPT_LICENSE_AGREEMENT: yes - NEO4JLABS_PLUGINS: '["apoc"]' - NEO4J_AUTH: neo4j/testtest - NEO4J_dbms_mode: CORE - NEO4J_causal__clustering_discovery__advertised__address: core3:5000 - NEO4J_causal__clustering_transaction__advertised__address: core3:6000 - NEO4J_causal__clustering_raft__advertised__address: core3:7000 - NEO4J_causal__clustering_initial__discovery__members: core1:5000,core2:5000,core3:5000 - NEO4J_causal__clustering_discovery__listen__address: 0.0.0.0:5000 - NEO4J_causal__clustering_transaction__listen__address: 0.0.0.0:6000 - NEO4J_causal__clustering_raft__listen__address: 0.0.0.0:7000 - NEO4J_dbms_connector_http_listen__address: 0.0.0.0:7477 - NEO4J_dbms_connector_bolt_listen__address: 0.0.0.0:7690 - - readreplica1: - image: neo4j:4.4-enterprise - options: >- - --health-cmd "wget -q --method=HEAD http://localhost:7478 || exit 1" - --health-start-period "60s" - --health-interval "30s" - --health-timeout "15s" - --health-retries "5" - ports: - - 7691:7691 - - 7478:7478 - env: - NEO4J_ACCEPT_LICENSE_AGREEMENT: yes - NEO4JLABS_PLUGINS: '["apoc"]' - NEO4J_AUTH: neo4j/testtest - NEO4J_dbms_mode: READ_REPLICA - NEO4J_causal__clustering_discovery__advertised__address: readreplica1:5000 - NEO4J_causal__clustering_transaction__advertised__address: readreplica1:6000 - NEO4J_causal__clustering_raft__advertised__address: readreplica1:7000 - NEO4J_causal__clustering_initial__discovery__members: core1:5000,core2:5000,core3:5000 - NEO4J_causal__clustering_discovery__listen__address: 0.0.0.0:5000 - NEO4J_causal__clustering_transaction__listen__address: 0.0.0.0:6000 - NEO4J_causal__clustering_raft__listen__address: 0.0.0.0:7000 - NEO4J_dbms_connector_http_listen__address: 0.0.0.0:7478 - NEO4J_dbms_connector_bolt_listen__address: 0.0.0.0:7691 + compose-file: './docker-compose-neo4j-4.yml' + up-flags: '--build' + - name: Test + run: | + docker compose run client composer install + docker compose run client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration diff --git a/.github/workflows/integration-test-cluster-neo4j-5.yml b/.github/workflows/integration-test-cluster-neo4j-5.yml index 1dcaa958..cde68e1f 100644 --- a/.github/workflows/integration-test-cluster-neo4j-5.yml +++ b/.github/workflows/integration-test-cluster-neo4j-5.yml @@ -17,107 +17,14 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Cache Composer dependencies - uses: actions/cache@v2 + - name: Populate .env + run: | + echo "CONNECTION=neo4j://neo4j:testtest@neo4j" > .env + - uses: hoverkraft-tech/compose-action@v2.0.2 with: - path: /tmp/composer-cache - key: ${{ runner.os }}-8.0-${{ hashFiles('**/composer.lock') }} - - uses: php-actions/composer@v6 - with: - progress: yes - php_version: 8.1 - version: 2 - - uses: php-actions/phpunit@v3 - with: - configuration: phpunit.xml.dist - php_version: 8.1 - memory_limit: 1024M - version: 10 - testsuite: Integration - bootstrap: vendor/autoload.php - - services: - server1: - image: neo4j:5.20-enterprise - ports: - - 7687:7687 - - 7473:7473 - - 7474:7474 - env: - NEO4J_initial_server_mode__constraint: PRIMARY - NEO4J_dbms_cluster_discovery_endpoints: server1:5000,server2:5000,server3:5000 - NEO4J_ACCEPT_LICENSE_AGREEMENT: yes - NEO4j_server_bolt_advertised_address: localhost:7687 - NEO4j_server_http_advertised_address: localhost:7474 - NEO4J_PLUGINS: '["apoc"]' - NEO4J_AUTH: neo4j/testtest - options: >- - --hostname server1 - --health-cmd "wget -q --method=HEAD http://localhost:7474 || exit 1" - --health-start-period "60s" - --health-interval "30s" - --health-timeout "15s" - --health-retries "5" - server2: - image: neo4j:5.20-enterprise - ports: - - 8687:7687 - - 8473:7473 - - 8474:7474 - env: - NEO4J_initial_server_mode__constraint: PRIMARY - NEO4J_dbms_cluster_discovery_endpoints: server1:5000,server2:5000,server3:5000 - NEO4J_ACCEPT_LICENSE_AGREEMENT: yes - NEO4j_server_bolt_advertised_address: localhost:8687 - NEO4j_server_http_advertised_address: localhost:8474 - NEO4J_PLUGINS: '["apoc"]' - NEO4J_AUTH: neo4j/testtest - options: >- - --hostname server2 - --health-cmd "wget -q --method=HEAD http://localhost:7474 || exit 1" - --health-start-period "60s" - --health-interval "30s" - --health-timeout "15s" - --health-retries "5" - server3: - image: neo4j:5.20-enterprise - ports: - - 9474:7474 - - 9473:7473 - - 9687:7687 - env: - NEO4J_initial_server_mode__constraint: PRIMARY - NEO4J_dbms_cluster_discovery_endpoints: server1:5000,server2:5000,server3:5000 - NEO4J_ACCEPT_LICENSE_AGREEMENT: yes - NEO4j_server_bolt_advertised_address: localhost:9687 - NEO4j_server_http_advertised_address: localhost:9474 - NEO4J_PLUGINS: '["apoc"]' - NEO4J_AUTH: neo4j/testtest - options: >- - --hostname server3 - --health-cmd "wget -q --method=HEAD http://localhost:7474 || exit 1" - --health-start-period "60s" - --health-interval "30s" - --health-timeout "15s" - --health-retries "5" - read-server4: - image: neo4j:5.20-enterprise - ports: - - 10474:7474 - - 10473:7473 - - 10687:7687 - env: - NEO4J_initial_server_mode__constraint: SECONDARY - NEO4J_dbms_cluster_discovery_endpoints: server1:5000,server2:5000,server3:5000 - NEO4J_ACCEPT_LICENSE_AGREEMENT: yes - NEO4j_server_bolt_advertised_address: localhost:10687 - NEO4j_server_http_advertised_address: localhost:10474 - NEO4J_PLUGINS: '["apoc"]' - NEO4J_AUTH: neo4j/testtest - options: >- - --hostname read-server4 - --health-cmd "wget -q --method=HEAD http://localhost:7474 || exit 1" - --health-start-period "60s" - --health-interval "30s" - --health-timeout "15s" - --health-retries "5" + compose-file: './docker-compose.yml' + up-flags: '--build' + - name: Test + run: | + docker compose run client composer install + docker compose run client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration diff --git a/.github/workflows/integration-test-single-server.yml b/.github/workflows/integration-test-single-server.yml index 671c1a6b..b6bdbccc 100644 --- a/.github/workflows/integration-test-single-server.yml +++ b/.github/workflows/integration-test-single-server.yml @@ -9,41 +9,53 @@ on: - main jobs: - tests: + tests-v4: runs-on: ubuntu-latest - name: "Running on PHP 8.2 with a Neo4j 5 instance connecting over all available protocols" - - services: - neo4j: - image: neo4j:5 - env: - NEO4J_AUTH: neo4j/testtest - NEO4JLABS_PLUGINS: '["apoc"]' - ports: - - 7687:7687 - - 7474:7474 - options: >- - --health-cmd "wget -q --method=HEAD http://localhost:7474 || exit 1" - --health-start-period "60s" - --health-interval "30s" - --health-timeout "15s" - --health-retries "5" + name: "Running on PHP 8.1 with a Neo4j 4 instance connecting over all available protocols" steps: - uses: actions/checkout@v2 - - name: Cache Composer dependencies - uses: actions/cache@v2 + - name: Populate .env + run: | + echo "CONNECTION=neo4j://neo4j:testtest@neo4j" > .env + - uses: hoverkraft-tech/compose-action@v2.0.2 with: - path: /tmp/composer-cache - key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - - uses: php-actions/composer@v6 + compose-file: './docker-compose-neo4j-4.yml' + up-flags: '--build' + - name: Composer install + run: | + docker compose run client composer install + - name: Test neo4j:// + run: | + docker compose run -e CONNECTION=neo4j://neo4j:testtest@neo4j client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration + - name: Test bolt:// + run: | + docker compose run -e CONNECTION=bolt://neo4j:testtest@neo4j client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration + - name: Test http:// + run: | + docker compose run -e CONNECTION=http://neo4j:testtest@neo4j client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration + tests-v5: + runs-on: ubuntu-latest + name: "Running on PHP 8.1 with a Neo4j 5 instance connecting over all available protocols" + + steps: + - uses: actions/checkout@v2 + - name: Populate .env + run: | + echo "CONNECTION=neo4j://neo4j:testtest@neo4j" > .env + - uses: hoverkraft-tech/compose-action@v2.0.2 with: - progress: yes - php_version: 8.2 - version: 2 - - name: Test multiple connections - run: | - CONNECTION=neo4j://neo4j:testtest@localhost ./vendor/bin/phpunit --configuration=phpunit.xml.dist --testsuite=Integration & \ - CONNECTION=bolt://neo4j:testtest@localhost ./vendor/bin/phpunit --configuration=phpunit.xml.dist --testsuite=Integration & \ - CONNECTION=http://neo4j:testtest@localhost ./vendor/bin/phpunit --configuration=phpunit.xml.dist --testsuite=Integration & \ - wait + compose-file: './docker-compose.yml' + up-flags: '--build' + - name: Composer install + run: | + docker compose run client composer install + - name: Test neo4j:// + run: | + docker compose run -e CONNECTION=neo4j://neo4j:testtest@neo4j client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration + - name: Test bolt:// + run: | + docker compose run -e CONNECTION=bolt://neo4j:testtest@neo4j client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration + - name: Test http:// + run: | + docker compose run -e CONNECTION=http://neo4j:testtest@neo4j client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration diff --git a/docker-compose-neo4j-4.yml b/docker-compose-neo4j-4.yml index 4b3acb4c..ce6bda62 100644 --- a/docker-compose-neo4j-4.yml +++ b/docker-compose-neo4j-4.yml @@ -1,10 +1,9 @@ -version: '3.8' - x-shared: &common - NEO4J_AUTH: neo4j/test + NEO4J_AUTH: neo4j/testtest NEO4J_ACCEPT_LICENSE_AGREEMENT: "yes" NEO4J_dbms_security_allow__csv__import__from__file__urls: "true" + NEO4JLABS_PLUGINS: '["apoc"]' x-shared-cluster: &common-cluster @@ -31,16 +30,15 @@ services: build: context: . dockerfile: Dockerfile - image: arestravel/php-8.0 - working_dir: /opt/project networks: - neo4j volumes: - .:/opt/project - expose: - - 9000 env_file: - .env + depends_on: + neo4j: + condition: service_healthy testkit-backend: build: context: . diff --git a/docker-compose.yml b/docker-compose.yml index df0d5660..5be247b6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,7 +24,6 @@ x-definitions: build: context: . dockerfile: Dockerfile -# image: neo4j-php-client:latest volumes: - .:/opt/project x-common-cluster: @@ -48,6 +47,9 @@ services: - .:/opt/project env_file: - .env + depends_on: + neo4j: + condition: service_healthy neo4j: <<: *common image: neo4j:5.20-community diff --git a/src/Http/HttpHelper.php b/src/Http/HttpHelper.php index 3212dba5..822e6880 100644 --- a/src/Http/HttpHelper.php +++ b/src/Http/HttpHelper.php @@ -49,7 +49,7 @@ final class HttpHelper */ public static function interpretResponse(ResponseInterface $response): stdClass { - if ($response->getStatusCode() >= 400) { + if ($response->getStatusCode() >= 500) { throw new RuntimeException('HTTP Error: '.$response->getReasonPhrase()); } diff --git a/tests/Integration/SummarizedResultFormatterTest.php b/tests/Integration/SummarizedResultFormatterTest.php index 60bfaf2c..b42d291b 100644 --- a/tests/Integration/SummarizedResultFormatterTest.php +++ b/tests/Integration/SummarizedResultFormatterTest.php @@ -104,6 +104,10 @@ public function testAvailableAfter(): void public function testDateTime(): void { + if (str_starts_with($_ENV['CONNECTION'] ?? '', 'http')) { + $this->markTestSkipped('http does not support datetime conversion'); + } + $dt = new DateTimeImmutable(); $ls = $this->getSession()->run('RETURN $x AS x', ['x' => $dt])->first()->get('x'); diff --git a/tests/Integration/TransactionIntegrationTest.php b/tests/Integration/TransactionIntegrationTest.php index 4d5f0a59..e575129b 100644 --- a/tests/Integration/TransactionIntegrationTest.php +++ b/tests/Integration/TransactionIntegrationTest.php @@ -226,10 +226,15 @@ public function testCommitInvalid(): void $exception = null; try { $tsx->commit(); - } catch (ClientException $e) { + } catch (ClientException|Neo4jException $e) { $exception = $e; } - self::assertTrue($exception instanceof ClientException); + + if (str_starts_with($_ENV['CONNECTION'] ?? '', 'http')) { + self::assertTrue($exception instanceof Neo4jException); + } else { + self::assertTrue($exception instanceof ClientException); + } self::assertTrue($tsx->isFinished()); self::assertFalse($tsx->isRolledBack()); @@ -259,10 +264,15 @@ public function testRollbackInvalid(): void $exception = null; try { $tsx->rollback(); - } catch (ClientException $e) { + } catch (ClientException|Neo4jException $e) { $exception = $e; } - self::assertTrue($exception instanceof ClientException); + + if (str_starts_with($_ENV['CONNECTION'] ?? '', 'http')) { + self::assertTrue($exception instanceof Neo4jException); + } else { + self::assertTrue($exception instanceof ClientException); + } self::assertTrue($tsx->isFinished()); self::assertTrue($tsx->isRolledBack());