Skip to content

Commit 3704d08

Browse files
authored
ci: Add testkit (#258)
* ci: Add testkit * Test commit to trigger CI * ci: Rename workflow * chore: Only export env vars if they don't already exist * chore: Restart testkit_backend after composer install * ci: Add --rm to docker compose run commands * ci: Remove redundant pull request branch specification from workflow files * fix: Rename protocol to protocolVersion in ServerInfo::toArray * fix: Update test execution logic in testkit.sh to capture exit codes
1 parent 594b3d8 commit 3704d08

File tree

9 files changed

+77
-34
lines changed

9 files changed

+77
-34
lines changed

.github/workflows/integration-test-cluster-neo4j-4.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55
branches:
66
- main
77
pull_request:
8-
branches:
9-
- main
108

119
jobs:
1210
tests:
@@ -29,5 +27,5 @@ jobs:
2927
up-flags: '--build --remove-orphans'
3028
- name: Test
3129
run: |
32-
docker compose run client composer install
33-
docker compose run client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration
30+
docker compose run --rm client composer install
31+
docker compose run --rm client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration

.github/workflows/integration-test-cluster-neo4j-5.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55
branches:
66
- main
77
pull_request:
8-
branches:
9-
- main
108

119
jobs:
1210
tests:
@@ -29,5 +27,5 @@ jobs:
2927
up-flags: '--build --remove-orphans'
3028
- name: Test
3129
run: |
32-
docker compose run client composer install
33-
docker compose run client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration
30+
docker compose run --rm client composer install
31+
docker compose run --rm client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration

.github/workflows/integration-test-single-server.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55
branches:
66
- main
77
pull_request:
8-
branches:
9-
- main
108

119
jobs:
1210
tests-v4:
@@ -62,16 +60,16 @@ jobs:
6260
up-flags: '--build'
6361
- name: Composer install
6462
run: |
65-
docker compose run client composer install
63+
docker compose run --rm client composer install
6664
- name: Test neo4j://
6765
run: |
68-
docker compose run \
66+
docker compose run --rm \
6967
-e PHP_VERSION=${{ matrix.php }} \
7068
-e CONNECTION=neo4j://neo4j:testtest@neo4j \
7169
client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration
7270
- name: Test bolt://
7371
run: |
74-
docker compose run \
72+
docker compose run --rm \
7573
-e PHP_VERSION=${{ matrix.php }} \
7674
-e CONNECTION=bolt://neo4j:testtest@neo4j \
7775
client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ on:
55
branches:
66
- main
77
pull_request:
8-
branches:
9-
- main
8+
109
jobs:
1110
php-cs-fixer:
1211
name: "Lint & Analyse"

.github/workflows/testkit.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Testkit
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
name: "Testkit"
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Populate .env
17+
run: |
18+
echo "PHP_VERSION=8.3.17" > .env
19+
echo "CONNECTION=neo4j://neo4j:testtest@server1" >> .env
20+
- uses: hoverkraft-tech/[email protected]
21+
name: Start services
22+
with:
23+
compose-file: './docker-compose.yml'
24+
up-flags: '--build --remove-orphans'
25+
- name: Test
26+
run: |
27+
docker compose run --rm client composer install
28+
# We need to restart the testkit_backend service since it relies on the previous step (composer install) to work
29+
docker compose restart testkit_backend
30+
docker compose logs testkit_backend
31+
docker compose run --rm testkit ./testkit.sh

.github/workflows/unit-test.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55
branches:
66
- main
77
pull_request:
8-
branches:
9-
- main
108

119
jobs:
1210
tests:
@@ -33,7 +31,7 @@ jobs:
3331

3432
- name: Install dependencies
3533
run: composer install
36-
34+
3735
- uses: php-actions/phpunit@v4
3836
with:
3937
configuration: phpunit.xml.dist

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,21 @@ services:
118118
NEO4J_server_bolt_advertised__address: server4:7687
119119
NEO4J_server_http_advertised__address: server4:7474
120120

121+
testkit:
122+
image: python:3.13
123+
volumes:
124+
- .:/opt/project
125+
working_dir: /opt/project/testkit-backend
126+
networks:
127+
- neo4j
128+
environment:
129+
TEST_NEO4J_HOST: neo4j
130+
TEST_NEO4J_USER: neo4j
131+
TEST_NEO4J_PASS: testtest
132+
TEST_DRIVER_NAME: php
133+
TEST_DRIVER_REPO: /opt/project
134+
TEST_BACKEND_HOST: testkit_backend
135+
121136
testkit_backend:
122137
<<: *common-php
123138
environment:

src/Databags/ServerInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function toArray(): array
6161
{
6262
return [
6363
'address' => $this->address,
64-
'protocol' => $this->protocol,
64+
'protocolVersion' => $this->protocol,
6565
'agent' => $this->agent,
6666
];
6767
}

testkit-backend/testkit.sh

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
TESTKIT_VERSION=5.0
44

5-
export TEST_NEO4J_HOST=neo4j
6-
export TEST_NEO4J_USER=neo4j
7-
export TEST_NEO4J_PASS=testtest
8-
export TEST_DRIVER_NAME=php
5+
[ -z "$TEST_NEO4J_HOST" ] && export TEST_NEO4J_HOST=neo4j
6+
[ -z "$TEST_NEO4J_USER" ] && export TEST_NEO4J_USER=neo4j
7+
[ -z "$TEST_NEO4J_PASS" ] && export TEST_NEO4J_PASS=testtest
8+
[ -z "$TEST_DRIVER_NAME" ] && export TEST_DRIVER_NAME=php
99

10-
11-
TEST_DRIVER_REPO=$(realpath ..)
12-
export TEST_DRIVER_REPO
10+
[ -z "$TEST_DRIVER_REPO" ] && TEST_DRIVER_REPO=$(realpath ..) && export TEST_DRIVER_REPO
1311

1412
if [ "$1" == "--clean" ]; then
1513
if [ -d testkit ]; then
@@ -18,7 +16,7 @@ if [ "$1" == "--clean" ]; then
1816
fi
1917

2018
if [ ! -d testkit ]; then
21-
git clone git@github.com:neo4j-drivers/testkit.git
19+
git clone https://github.com/neo4j-drivers/testkit.git
2220
if [ "$(cd testkit && git branch --show-current)" != "${TESTKIT_VERSION}" ]; then
2321
(cd testkit && git checkout ${TESTKIT_VERSION})
2422
fi
@@ -31,12 +29,20 @@ python3 -m venv venv
3129
source venv/bin/activate
3230
pip install -r requirements.txt
3331

32+
# python3 main.py --tests UNIT_TESTS
33+
3434
echo "Starting tests..."
35-
# exec python3 main.py --tests UNIT_TESTS
36-
(exec python3 -m unittest tests.neo4j.test_authentication.TestAuthenticationBasic) || true
37-
#echo "TestAuthenticationBasic Done"
38-
python3 -m unittest tests.neo4j.test_bookmarks.TestBookmarks || true
39-
echo "TestBookmarks Done"
40-
#python3 -m unittest tests.neo4j.test_session_run.TestSessionRun.test_recover_from_fail_on_streaming|| true
41-
#echo "TestSessionRun Done"
35+
36+
EXIT_CODE=0
37+
38+
python3 -m unittest tests.neo4j.test_authentication.TestAuthenticationBasic || EXIT_CODE=1
39+
40+
python3 -m unittest tests.neo4j.test_bookmarks.TestBookmarks || EXIT_CODE=1
41+
42+
python3 -m unittest tests.neo4j.test_session_run.TestSessionRun.test_iteration_nested || EXIT_CODE=1
43+
44+
# Uncomment to run this test as well
45+
# python3 -m unittest tests.neo4j.test_session_run.TestSessionRun.test_recover_from_fail_on_streaming || EXIT_CODE=1
46+
47+
exit $EXIT_CODE
4248

0 commit comments

Comments
 (0)