From 5c8c31933820fea4e7c4ecdfd41d249a404c3a5c Mon Sep 17 00:00:00 2001 From: Antonio Barcelos Date: Fri, 29 Jan 2021 15:58:17 +0100 Subject: [PATCH] Move testkit configuration to the driver source code --- testkit/.dockerignore | 2 ++ testkit/Dockerfile | 20 ++++++++++++++++++++ testkit/backend.py | 15 +++++++++++++++ testkit/build.py | 19 +++++++++++++++++++ testkit/integration.py | 13 +++++++++++++ testkit/stress.py | 14 ++++++++++++++ testkit/unittests.py | 16 ++++++++++++++++ 7 files changed, 99 insertions(+) create mode 100644 testkit/.dockerignore create mode 100644 testkit/Dockerfile create mode 100644 testkit/backend.py create mode 100644 testkit/build.py create mode 100644 testkit/integration.py create mode 100644 testkit/stress.py create mode 100644 testkit/unittests.py diff --git a/testkit/.dockerignore b/testkit/.dockerignore new file mode 100644 index 000000000..fe7d40a54 --- /dev/null +++ b/testkit/.dockerignore @@ -0,0 +1,2 @@ +*.py + diff --git a/testkit/Dockerfile b/testkit/Dockerfile new file mode 100644 index 000000000..a791f7b41 --- /dev/null +++ b/testkit/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:18.04 + +RUN apt-get update && \ + apt-get install -y \ + git \ + curl \ + python3 \ + firefox \ + nodejs \ + npm \ + && rm -rf /var/lib/apt/lists/* + +RUN npm install -g npm \ + && /bin/bash -c 'hash -d npm' +RUN npm install -g gulp + +# Install our own CAs on the image. +# Assumes Linux Debian based image. +COPY CAs/* /usr/local/share/ca-certificates/ +RUN update-ca-certificates diff --git a/testkit/backend.py b/testkit/backend.py new file mode 100644 index 000000000..6af2e7c19 --- /dev/null +++ b/testkit/backend.py @@ -0,0 +1,15 @@ +""" +Executed in Javascript driver container. +Assumes driver and backend has been built. +Responsible for starting the test backend. +""" +import os +import subprocess + +if __name__ == "__main__": + goPath = "/home/build" + backendPath = os.path.join(goPath, "bin", "testkit-backend") + err = open("/artifacts/backenderr.log", "w") + out = open("/artifacts/backendout.log", "w") + subprocess.check_call( + ["node", "build/testkit-backend/main.js"], stdout=out, stderr=err) diff --git a/testkit/build.py b/testkit/build.py new file mode 100644 index 000000000..fc77c5d59 --- /dev/null +++ b/testkit/build.py @@ -0,0 +1,19 @@ +""" +Executed in Javascript driver container. +Responsible for building driver and test backend. +""" +import os +import subprocess +import shutil + + +def run(args, env=None): + subprocess.run( + args, universal_newlines=True, stderr=subprocess.STDOUT, check=True, env=env) + + +if __name__ == "__main__": + run(['rm', '-fr', 'node_modules', 'lib', 'build']) + run(["npm", "ci"]) + run(["gulp", "nodejs"]) + run(["gulp", "testkit-backend"]) diff --git a/testkit/integration.py b/testkit/integration.py new file mode 100644 index 000000000..07e71e964 --- /dev/null +++ b/testkit/integration.py @@ -0,0 +1,13 @@ +import subprocess +import os + + +def run(args): + subprocess.run( + args, universal_newlines=True, stderr=subprocess.STDOUT, check=True) + + +if __name__ == "__main__": + os.environ["TEST_NEO4J_IPV6_ENABLED"] = "False" + run(["gulp", "test-browser"]) + run(["gulp", "test-nodejs-integration"]) diff --git a/testkit/stress.py b/testkit/stress.py new file mode 100644 index 000000000..530b9d619 --- /dev/null +++ b/testkit/stress.py @@ -0,0 +1,14 @@ +import subprocess +import os + + +def run(args): + subprocess.run( + args, universal_newlines=True, stderr=subprocess.STDOUT, check=True) + + +if __name__ == "__main__": + os.environ['STRESS_TEST_MODE'] = 'fastest' + os.environ['RUNNING_TIME_IN_SECONDS'] = \ + os.environ.get('TEST_NEO4J_STRESS_DURATION', 0) + run(["npm", "run", "run-stress-tests"]) diff --git a/testkit/unittests.py b/testkit/unittests.py new file mode 100644 index 000000000..85358e2e2 --- /dev/null +++ b/testkit/unittests.py @@ -0,0 +1,16 @@ +""" +Executed in Javascript driver container. +Responsible for running unit tests. +Assumes driver has been setup by build script prior to this. +""" +import subprocess + + +def run(args): + subprocess.run( + args, universal_newlines=True, stderr=subprocess.STDOUT, check=True) + + +if __name__ == "__main__": + run(["gulp", "test-nodejs-unit"]) + run(["gulp", "run-ts-declaration-tests"])