-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathintegration.py
More file actions
executable file
·67 lines (60 loc) · 3.02 KB
/
integration.py
File metadata and controls
executable file
·67 lines (60 loc) · 3.02 KB
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
#!/usr/bin/env -S python3 -u
# Copyright 2025 XTX Markets Technologies Limited
#
# SPDX-License-Identifier: GPL-2.0-or-later
import argparse
import socket
import os
import subprocess
from common import *
parser = argparse.ArgumentParser()
parser.add_argument('--short', action='store_true')
parser.add_argument('--docker', action='store_true')
parser.add_argument('--leader-only', action='store_true', help='Run only LogsDB leader with LEADER_NO_FOLLOWERS')
parser.add_argument('--close-tracker-object', default=None, type=str, help='Run fuse driver with the given close tracker object')
parser.add_argument('--filter', default=None, type=str, help='Regex to filter test names')
args = parser.parse_args()
script_dir = os.path.dirname(os.path.realpath(__file__))
os.chdir(script_dir)
if args.docker:
build_sanitized = 'build/ubuntusanitized'
build_release = 'build/ubuntu'
build_valgrind = 'build/ubuntuvalgrind'
if os.environ.get('GID') is not None and os.environ.get('UID') is not None:
# setup right user -- we need it with a name because of fusermount
gid = int(os.environ['GID'])
uid = int(os.environ['UID'])
subprocess.run(['groupadd', '-g', str(gid), 'ternfsgroup'])
subprocess.run(['useradd', '-u', str(uid), '-g', 'ternfsgroup', 'ternfsuser'])
os.setgid(gid)
os.setuid(uid)
else:
build_sanitized = 'build/sanitized'
build_release = 'build/release'
build_valgrind = 'build/valgrind'
bold_print('integration tests')
short = ['-short'] if args.short else []
leader_only = ['-leader-only'] if args.leader_only else []
filter_arg = ['-filter', args.filter] if args.filter else []
# -block-service-killer does not work with FUSE driver, unless we're using
# the close tracker (the duplicated FDs of the child processes confuse the
# FUSE driver).
close_tracker_object = ['-block-service-killer', '-close-tracker-object', args.close_tracker_object] if args.close_tracker_object else []
tests = [
['./go/terntests/terntests', '-binaries-dir', build_sanitized, '-verbose', '-repo-dir', '.', '-tmp-dir', '.', '-outgoing-packet-drop', '0.02'] + short + leader_only + filter_arg,
# valgrind is super slow, it still surfaced bugs in the past but only run a couple of tests
# and only short
['./go/terntests/terntests', '-binaries-dir', build_valgrind, '-verbose', '-repo-dir', '.', '-tmp-dir', '.', '-short', '-filter', args.filter if args.filter else 'history|direct|cp'] + leader_only,
]
# we need three free ports, we get them here upfront rather than in registry to reduce
# the chance of races -- if we got it from the integration tests it'll be while
# tons of things are started in another integration test
ports = []
for _ in range(len(tests)):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(('', 0))
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # Ensure the port is immediately reusable
ports.append(s.getsockname()[1])
wait_cmds(
[run_cmd(test + ['-registry-port', str(port)]) for test, port in zip(tests, ports)],
)