forked from quic-interop/quic-interop-runner
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
executable file
·152 lines (141 loc) · 4.92 KB
/
run.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env python3
import argparse
import sys
from typing import List, Tuple
import testcases
from implementations import IMPLEMENTATIONS, Role
from interop import InteropRunner
from testcases import MEASUREMENTS, TESTCASES
implementations = {
name: {"image": value["image"], "url": value["url"]}
for name, value in IMPLEMENTATIONS.items()
}
client_implementations = [
name
for name, value in IMPLEMENTATIONS.items()
if value["role"] == Role.BOTH or value["role"] == Role.CLIENT
]
server_implementations = [
name
for name, value in IMPLEMENTATIONS.items()
if value["role"] == Role.BOTH or value["role"] == Role.SERVER
]
def main():
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"-d",
"--debug",
action="store_const",
const=True,
default=False,
help="turn on debug logs",
)
parser.add_argument(
"-s", "--server", help="server implementations (comma-separated)"
)
parser.add_argument(
"-c", "--client", help="client implementations (comma-separated)"
)
parser.add_argument(
"-t",
"--test",
help="test cases (comma-separatated). Valid test cases are: "
+ ", ".join([x.name() for x in TESTCASES + MEASUREMENTS]),
)
parser.add_argument(
"-r",
"--replace",
help="replace path of implementation. Example: -r myquicimpl=dockertagname",
)
parser.add_argument(
"-a",
"--congestion",
help="congestion control algorithm (CUBIC/BBR/BBR2/BBR3/COPA) for the implementation. Example: -a cubic",
default="CUBIC",
)
parser.add_argument(
"-n",
"--scenario",
help="replace scenario for the ns3 simulator. Example: -n \"drop-rate --delay=15ms --bandwidth=10Mbps --queue=25 --rate_to_server=2 --rate_to_client=2\"",
)
parser.add_argument(
"-l",
"--log-dir",
help="log directory",
default="",
)
parser.add_argument(
"-f", "--save-files", help="save downloaded files if a test fails"
)
parser.add_argument(
"-j", "--json", help="output the matrix to file in json format"
)
return parser.parse_args()
replace_arg = get_args().replace
if replace_arg:
for s in replace_arg.split(","):
pair = s.split("=")
if len(pair) != 2:
sys.exit("Invalid format for replace")
name, image = pair[0], pair[1]
if name not in IMPLEMENTATIONS:
sys.exit("Implementation " + name + " not found.")
implementations[name]["image"] = image
def get_impls(arg, availableImpls, role) -> List[str]:
if not arg:
return availableImpls
impls = []
for s in arg.split(","):
if s not in availableImpls:
sys.exit(role + " implementation " + s + " not found.")
impls.append(s)
return impls
def get_tests_and_measurements(
arg,
) -> Tuple[List[testcases.TestCase], List[testcases.TestCase]]:
if arg is None:
return TESTCASES, MEASUREMENTS
elif arg == "onlyTests":
return TESTCASES, []
elif arg == "onlyMeasurements":
return [], MEASUREMENTS
elif not arg:
return []
tests = []
measurements = []
for t in arg.split(","):
if t in [tc.name() for tc in TESTCASES]:
tests += [tc for tc in TESTCASES if tc.name() == t]
elif t in [tc.name() for tc in MEASUREMENTS]:
measurements += [tc for tc in MEASUREMENTS if tc.name() == t]
else:
print(
(
"Test case {} not found.\n"
"Available testcases: {}\n"
"Available measurements: {}"
).format(
t,
", ".join([t.name() for t in TESTCASES]),
", ".join([t.name() for t in MEASUREMENTS]),
)
)
sys.exit()
return tests, measurements
t = get_tests_and_measurements(get_args().test)
return InteropRunner(
implementations=implementations,
servers=get_impls(get_args().server, server_implementations, "Server"),
clients=get_impls(get_args().client, client_implementations, "Client"),
tests=t[0],
measurements=t[1],
congestion=get_args().congestion,
scenario=get_args().scenario,
output=get_args().json,
debug=get_args().debug,
log_dir=get_args().log_dir,
save_files=get_args().save_files,
).run()
if __name__ == "__main__":
sys.exit(main())