forked from hazelcast/hazelcast-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
51 lines (40 loc) · 1.34 KB
/
run_tests.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
import os
import socket
import subprocess
import sys
import time
from contextlib import closing
from start_rc import start_rc
def wait_until_rc_is_ready():
timeout = 300 + time.time()
while time.time() < timeout:
with closing(socket.socket()) as sock:
if sock.connect_ex(("localhost", 9701)) == 0:
return
print("Remote controller is not ready yet. Sleeping 1 second.")
time.sleep(1)
raise Exception("Remote controller failed to start.")
with open("rc_stdout.log", "w") as rc_stdout:
with open("rc_stderr.log", "w") as rc_stderr:
rc_process = start_rc(rc_stdout, rc_stderr)
try:
wait_until_rc_is_ready()
sys.stdout.flush()
args = [
"pytest",
"--cov=hazelcast",
"--cov-report=xml",
]
args.extend(sys.argv[1:])
enterprise_key = os.environ.get("HAZELCAST_ENTERPRISE_KEY", None)
if not enterprise_key:
args.extend(["-m", "not enterprise"])
print(f"Args: {' '.join(args)}")
process = subprocess.run(args)
rc_process.kill()
rc_process.wait()
sys.exit(process.returncode)
except:
rc_process.kill()
rc_process.wait()
raise