Skip to content

Commit d2ee743

Browse files
updated tests configuration (#109)
1 parent d72be84 commit d2ee743

File tree

13 files changed

+132
-51
lines changed

13 files changed

+132
-51
lines changed

.github/workflows/db-test-php-8.yml renamed to .github/workflows/db.44.2204.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests with a database PHP8
1+
name: Tests with Neo4j 4.4 on PHP^8
22

33
on:
44
push:
@@ -7,21 +7,21 @@ on:
77
branches: [ master ]
88

99
jobs:
10-
tests:
11-
runs-on: ubuntu-20.04
10+
db-tests-44-2204:
11+
runs-on: ubuntu-22.04
1212
name: "Running Integration tests for PHP ${{ matrix.php-version }} on Neo4j ${{ matrix.neo4j-version }}"
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
neo4j-version: ["4.4", "5.1", "5.2"]
17-
php-version: ['8.0', '8.1']
16+
neo4j-version: ['4.4']
17+
php-version: ['8.0', '8.1', '8.2']
1818

1919
services:
2020
neo4j:
2121
image: neo4j:${{ matrix.neo4j-version }}
2222
env:
2323
NEO4J_AUTH: neo4j/nothing
24-
NEO4JLABS_PLUGINS: '["apoc"]'
24+
NEO4JLABS_PLUGINS: '["apoc-core"]'
2525
ports:
2626
- 7687:7687
2727
- 7474:7474
@@ -44,4 +44,7 @@ jobs:
4444
run: composer install --no-progress
4545

4646
- name: Test with phpunit
47+
env:
48+
GDB_USERNAME: neo4j
49+
GDB_PASSWORD: nothing
4750
run: vendor/bin/phpunit --configuration phpunit.xml --testsuite "Database"

.github/workflows/db.50.2204.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Tests with Neo4j^5 on PHP^8
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
db-tests-50-2204:
11+
runs-on: ubuntu-22.04
12+
name: "Running Integration tests for PHP ${{ matrix.php-version }} on Neo4j ${{ matrix.neo4j-version }}"
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
neo4j-version: ['5.1', '5.2', '5.3']
17+
php-version: ['8.0', '8.1', '8.2']
18+
19+
services:
20+
neo4j:
21+
image: neo4j:${{ matrix.neo4j-version }}
22+
env:
23+
NEO4J_AUTH: neo4j/nothing123
24+
NEO4J_PLUGINS: '["apoc"]'
25+
ports:
26+
- 7687:7687
27+
- 7474:7474
28+
options: >-
29+
--health-cmd "wget http://localhost:7474 || exit 1"
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v3
34+
35+
- name: Setup PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: ${{ matrix.php-version }}
39+
extensions: mbstring, sockets
40+
coverage: xdebug
41+
ini-values: max_execution_time=0
42+
43+
- name: Install dependencies
44+
run: composer install --no-progress
45+
46+
- name: Test with phpunit
47+
env:
48+
GDB_USERNAME: neo4j
49+
GDB_PASSWORD: nothing123
50+
run: vendor/bin/phpunit --configuration phpunit.xml --testsuite "Database"

.github/workflows/no-db-test-php-8.yml renamed to .github/workflows/no-db.2204.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests without a database PHP8
1+
name: Tests without a database PHP^8
22

33
on:
44
push:
@@ -7,13 +7,13 @@ on:
77
branches: [ master ]
88

99
jobs:
10-
tests:
11-
runs-on: ubuntu-20.04
10+
no-db-tests-2204:
11+
runs-on: ubuntu-22.04
1212
name: "Running Tests for PHP ${{ matrix.php-version }}"
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php-version: ['8.0', '8.1']
16+
php-version: ['8.0', '8.1', '8.2']
1717

1818
steps:
1919
- name: Checkout

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# Bolt
44
PHP library for communication with graph database over TCP socket with Bolt protocol specification. Bolt protocol was created by [Neo4j](https://neo4j.com/) and documentation is available at [https://www.neo4j.com/](https://www.neo4j.com/docs/bolt/current/). This library is aimed to be low level, support all available versions and keep up with protocol messages architecture and specifications.
55

6-
![DB Tests PHP8](https://github.com/neo4j-php/Bolt/actions/workflows/db-test-php-8.yml/badge.svg?branch=master)
7-
![No DB Tests PHP8](https://github.com/neo4j-php/Bolt/actions/workflows/no-db-test-php-8.yml/badge.svg?branch=master)
8-
96
[![](https://img.shields.io/github/stars/stefanak-michal/Bolt)](https://github.com/neo4j-php/Bolt/stargazers)
107
[![](https://img.shields.io/packagist/dt/stefanak-michal/bolt)](https://packagist.org/packages/stefanak-michal/bolt/stats)
118
[![](https://img.shields.io/github/v/release/stefanak-michal/bolt)](https://github.com/neo4j-php/Bolt/releases)

phpunit.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="src/autoload.php">
33
<testsuites>
44
<testsuite name="Database">
5-
<directory>./tests/connection</directory>
65
<file>./tests/BoltTest.php</file>
6+
<directory>./tests/connection</directory>
77
<directory>./tests/error</directory>
88
<directory>./tests/packstream</directory>
99
<directory>./tests/structures</directory>
10+
<file>./tests/PerformanceTest.php</file>
1011
</testsuite>
1112
<testsuite name="NoDatabase">
1213
<directory>./tests/protocol</directory>

tests/ATest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Bolt\tests;
4+
5+
/**
6+
* Class ATest
7+
* @package Bolt\tests
8+
*/
9+
class ATest extends \PHPUnit\Framework\TestCase
10+
{
11+
public static function setUpBeforeClass(): void
12+
{
13+
parent::setUpBeforeClass();
14+
$user = getenv('GDB_USERNAME');
15+
if (!empty($user))
16+
$GLOBALS['NEO_USER'] = $user;
17+
$pwd = getenv('GDB_PASSWORD');
18+
if (!empty($pwd))
19+
$GLOBALS['NEO_PASS'] = $pwd;
20+
$host = getenv('GDB_HOST');
21+
if (!empty($host))
22+
$GLOBALS['NEO_HOST'] = $host;
23+
$port = getenv('GDB_PORT');
24+
if (!empty($port))
25+
$GLOBALS['NEO_PORT'] = $port;
26+
}
27+
}

tests/BoltTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Bolt\Bolt;
66
use Exception;
7-
use PHPUnit\Framework\TestCase;
87
use Bolt\protocol\{
98
AProtocol,
109
Response,
@@ -26,9 +25,8 @@
2625
* @link https://github.com/neo4j-php/Bolt
2726
* @package Bolt\tests
2827
*/
29-
class BoltTest extends TestCase
28+
class BoltTest extends ATest
3029
{
31-
3230
public function testSockets(): void
3331
{
3432
if (!extension_loaded('sockets'))
@@ -100,6 +98,7 @@ public function testPull(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5 $protocol)
10098
$res = $protocol->getResponse()->getContent();
10199
$this->assertEquals(1, $res[0] ?? 0);
102100
$this->assertEquals(2, $res[1] ?? 0);
101+
$protocol->getResponse(); // last success message
103102
}
104103

105104
/**

tests/PerformanceTest.php

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace Bolt\tests;
44

55
use Bolt\Bolt;
6-
use Bolt\connection\StreamSocket;
6+
use Bolt\connection\Socket;
77
use Bolt\helpers\Auth;
88
use Bolt\protocol\{
99
AProtocol,
10+
Response,
1011
V1,
1112
V2,
1213
V3,
@@ -18,52 +19,55 @@
1819
V5
1920
};
2021
use Bolt\tests\packstream\v1\generators\RandomDataGenerator;
21-
use PHPUnit\Framework\TestCase;
2222

2323
/**
2424
* Class PerformanceTest
2525
* @author Ghlen Nagels
2626
* @link https://github.com/neo4j-php/Bolt
2727
* @package Bolt\tests
2828
*/
29-
class PerformanceTest extends TestCase
29+
class PerformanceTest extends ATest
3030
{
3131
public function test50KRecords(): void
3232
{
3333
$amount = 50000;
3434

35-
$conn = new StreamSocket($GLOBALS['NEO_HOST'] ?? 'localhost', $GLOBALS['NEO_PORT'] ?? 7687, 60);
35+
$conn = new Socket($GLOBALS['NEO_HOST'] ?? 'localhost', $GLOBALS['NEO_PORT'] ?? 7687, 60);
3636
/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5 $protocol */
3737
$protocol = (new Bolt($conn))->build();
3838
$this->assertEquals(\Bolt\protocol\Response::SIGNATURE_SUCCESS, $protocol->hello(Auth::basic($GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']))->getSignature());
3939

40+
//prevent multiple runs at once
41+
while (true) {
42+
$protocol->run('MATCH (n:Test50k) RETURN count(n)')->getResponse();
43+
$response = $protocol->pull()->getResponse();
44+
if ($response !== Response::SIGNATURE_RECORD)
45+
$this->markTestSkipped();
46+
$runs = $response->getContent()[0];
47+
$protocol->getResponse();
48+
if ($runs > 0) {
49+
sleep(60);
50+
} else {
51+
$protocol->run('CREATE (n:Test50k)')->getResponse();
52+
break;
53+
}
54+
}
55+
4056
$generator = new RandomDataGenerator($amount);
4157
$protocol
4258
->run('UNWIND $x as x RETURN x', ['x' => $generator])
4359
->getResponse();
4460

45-
$count = 0;
46-
while (true) {
47-
$gen = $protocol
48-
->pull(['n' => 1])
49-
->getResponses();
50-
51-
if ($gen->current()->getSignature() != \Bolt\protocol\Response::SIGNATURE_RECORD)
52-
$this->markTestIncomplete('Response does not contains record message');
53-
54-
$gen->next();
55-
56-
if ($gen->current()->getSignature() != \Bolt\protocol\Response::SIGNATURE_SUCCESS)
57-
$this->markTestIncomplete('Response does not contains success message');
5861

59-
$count++;
60-
61-
if ($gen->current()->getContent()['has_more'] ?? false)
62-
continue;
63-
else
64-
break;
62+
$iterator = $protocol->pull()->getResponses();
63+
$count = 0;
64+
/** @var Response $response */
65+
foreach ($iterator as $response) {
66+
if ($response->getSignature() === Response::SIGNATURE_RECORD)
67+
$count++;
6568
}
6669

70+
$protocol->run('MATCH (n:Test50k) DELETE n');
6771
$this->assertEquals($amount, $count);
6872
}
6973
}

tests/connection/ConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616
V4_4,
1717
V5
1818
};
19+
use Bolt\tests\ATest;
1920
use Bolt\connection\{
2021
IConnection,
2122
Socket,
2223
StreamSocket
2324
};
2425
use Bolt\error\ConnectionTimeoutException;
2526
use Bolt\helpers\Auth;
26-
use PHPUnit\Framework\TestCase;
2727

2828
/**
2929
* Class ConnectionTest
3030
*
3131
* @link https://github.com/neo4j-php/Bolt
3232
* @package Bolt\tests\connection
3333
*/
34-
final class ConnectionTest extends TestCase
34+
final class ConnectionTest extends ATest
3535
{
3636
public function provideConnections(): array
3737
{

tests/packstream/v1/BytesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
V4_4,
1818
V5
1919
};
20-
use PHPUnit\Framework\TestCase;
20+
use Bolt\tests\ATest;
2121

2222
/**
2323
* Class BytesTest
2424
* @package Bolt\tests\packstream\v1
2525
*/
26-
class BytesTest extends TestCase
26+
class BytesTest extends ATest
2727
{
2828
public function testInit(): AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5
2929
{

0 commit comments

Comments
 (0)