diff --git a/README.md b/README.md index 4a1becc0bd..4111f16380 100644 --- a/README.md +++ b/README.md @@ -106,13 +106,41 @@ Testkit is a tooling that is used to run integration tests for all of the driver Some older tests still rely on [`boltkit`](https://github.com/neo4j-drivers/boltkit), the predecessor to Testkit. If `boltkit` is not installed, then all tests that requires `boltkit` will be ignored and will not be executed. -In case you want or can verify contributions with unit tests alone, use the following command to skip all integration tests: +In case you want or can verify contributions with unit tests alone, use the following command to skip all integration and Testkit tests: ``` -mvn clean install -DskipITs +mvn clean install -DskipITs -P skip-testkit ``` -Otherwise, if you have Git, Python3 and Docker installed, please go ahead and clone Testkit and run as follows: +There are 2 ways of running Testkit tests: +1. Using the `testkit-tests` module of this project. +2. Manually cloning Testkit and running it directly. + +##### Using the testkit-tests module + +The `testkit-tests` module will automatically checkout Testkit and run it during Maven build. + +Prerequisites: +- Docker +- `/var/run/docker.sock` available to be passed through to running containers. + This is required because Testkit needs access to Docker in order to launch additional containers. +- The driver project location must be sharable with Docker containers as Testkit container needs to have access to it. + +Make sure to run build for the whole project and not just for `testkit-tests` module. Sample commands: +- `mvn clean verify` - runs all tests. +- `mvn clean verify -DskipTests` - skips all tests. +- `mvn clean verify -DtestkitArgs='--tests STUB_TESTS'` - runs all project tests and Testkit stub tests. +- `mvn clean verify -DskipTests -P testkit-tests` - skips all project tests and runs Testkit tests. +- `mvn clean verify -DskipTests -DtestkitArgs='--tests STUB_TESTS'` - skips all project tests and runs Testkit stub tests. + +##### Running Testkit manually + +Prerequisites: +- Docker +- Python3 +- Git + +Clone Testkit and run as follows: ``` git clone git@github.com:neo4j/neo4j-java-driver.git diff --git a/pom.xml b/pom.xml index 43496a4753..bba06ea836 100644 --- a/pom.xml +++ b/pom.xml @@ -50,6 +50,7 @@ driver examples testkit-backend + testkit-tests diff --git a/testkit-tests/pom.xml b/testkit-tests/pom.xml new file mode 100644 index 0000000000..9c52bfc907 --- /dev/null +++ b/testkit-tests/pom.xml @@ -0,0 +1,179 @@ + + 4.0.0 + + + org.neo4j.driver + neo4j-java-driver-parent + 4.3-SNAPSHOT + .. + + + testkit-tests + + Neo4j Java Driver Testkit Tests + Tests this driver using Testkit. + + + ${project.basedir}/.. + + https://github.com/neo4j-drivers/testkit.git + 4.3 + + --tests TESTKIT_TESTS INTEGRATION_TESTS STUB_TESTS STRESS_TESTS TLS_TESTS + 7200000 + + 0.36.1 + true + + + + + + io.fabric8 + docker-maven-plugin + + + + + + + io.fabric8 + docker-maven-plugin + ${docker-maven-plugin.version} + + + + + testkit-launcher:%v + + + ${project.basedir}/src/main/docker + + + + + %n + + 0 + + + + ${testkit.url} + ${project.build.directory}/testkit + ${testkit.version} + ${testkit.args} + java + ${rootDir} + true + + + + + /var/run/docker.sock:/var/run/docker.sock + + ${rootDir}:${rootDir} + + + + + + + + + + build-testkit-launcher + pre-integration-test + + build + + + + run-testkit + integration-test + + + start + + + + remove-testkit-launcher + post-integration-test + + + stop + + + + + + + + + + + + skip-testkit + + + skipTests + + + + true + + + + + skip-testkit-teamcity + + + env.TEAMCITY_VERSION + + + + true + + + + + testkit-tests + + false + + + + + testkit-custom-args + + + testkitArgs + + + + false + ${testkitArgs} + + + + + testkit-docker-verbose + + true + + + + diff --git a/testkit-tests/src/main/docker/Dockerfile b/testkit-tests/src/main/docker/Dockerfile new file mode 100644 index 0000000000..758c243460 --- /dev/null +++ b/testkit-tests/src/main/docker/Dockerfile @@ -0,0 +1,22 @@ +FROM python:3.10.0b4-buster + +RUN apt-get update && apt-get install -y \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg \ + lsb-release + +RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + +RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" \ + | tee /etc/apt/sources.list.d/docker.list > /dev/null + +RUN apt-get update && apt-get install -y \ + docker-ce-cli + +COPY /entrypoint.sh / + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/testkit-tests/src/main/docker/entrypoint.sh b/testkit-tests/src/main/docker/entrypoint.sh new file mode 100755 index 0000000000..ca023e4d35 --- /dev/null +++ b/testkit-tests/src/main/docker/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +rm -rf $TESTKIT_CHECKOUT_PATH +git clone $TESTKIT_URL $TESTKIT_CHECKOUT_PATH +cd $TESTKIT_CHECKOUT_PATH +git checkout $TESTKIT_VERSION + +echo "Testkit args: '$TESTKIT_ARGS'" +python main.py $TESTKIT_ARGS diff --git a/testkit/build.py b/testkit/build.py index a7c3f83042..c680bab3bc 100644 --- a/testkit/build.py +++ b/testkit/build.py @@ -3,6 +3,7 @@ Responsible for building driver and test backend. """ import subprocess +import os def run(args): @@ -10,5 +11,5 @@ def run(args): args, universal_newlines=True, stderr=subprocess.STDOUT, check=True) -if __name__ == "__main__": +if __name__ == "__main__" and "TEST_SKIP_BUILD" not in os.environ: run(["mvn", "clean", "install", "-P", "!determine-revision", "-DskipTests"])