forked from neo4j-drivers/testkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stress.py
86 lines (72 loc) · 2.6 KB
/
stress.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""Run the stress test suite for a given driver.
It's assumed there there is a running database instance.
Builds the driver in the drivers Docker container and invokes the driver
native stress test suite.
"""
import atexit
import os
import sys
import urllib.parse
import docker
import driver
import neo4j
import settings as settings_module
def run(settings):
artifacts_path = os.path.abspath(
os.path.join(".", "artifacts")
)
print("Putting artifacts in %s" % artifacts_path)
atexit.register(docker.cleanup)
driver_container = driver.start_container(settings.testkit_path,
settings.branch,
settings.driver_name,
settings.driver_repo,
artifacts_path)
driver_container.clean_artifacts()
print("Building driver")
driver_container.build_driver_and_backend()
# Retrieve info about the Neo4j database from environment
# Use same naming here as we use in communication with the
# driver glue in Docker container (a bit weird to read them,
# package them and then read again by another part...)
user = os.environ.get("TEST_NEO4J_USER", "neo4j")
password = os.environ.get("TEST_NEO4J_PASS")
uri = os.environ.get("TEST_NEO4J_URI")
if uri:
# Split in parts...
parts = urllib.parse.urlsplit(uri)
scheme = parts[0]
host = parts[1] # Might include port
port = parts.port if parts.port else ""
else:
# Retrieve the individual parts
host = os.environ.get("TEST_NEO4J_HOST")
port = os.environ.get("TEST_NEO4J_PORT")
scheme = os.environ.get("TEST_NEO4J_SCHEME")
if not port:
port = "7687"
neo4j_config = neo4j.Config(
name="Custom stress",
image="",
version=os.environ.get("TEST_NEO4J_VERSION", "drop"),
edition=os.environ.get("TEST_NEO4J_EDITION"),
cluster=os.environ.get("TEST_NEO4J_IS_CLUSTER", True),
suite="",
scheme=scheme,
stress_test_duration=10 * 60
)
print("Running stress test suite..")
driver_container.run_stress_tests(host, port,
user, password,
neo4j_config)
def main():
this_path = os.path.dirname(os.path.abspath(__file__))
try:
settings = settings_module.build(this_path)
except settings_module.ArgumentError as e:
print("")
print(e)
sys.exit(-1)
run(settings)
if __name__ == "__main__":
main()