-
Notifications
You must be signed in to change notification settings - Fork 889
/
Copy pathrun-integ-test
executable file
·80 lines (64 loc) · 2.29 KB
/
run-integ-test
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
#!/usr/bin/env python
"""Run Integ Tests based on the changed files
"""
from subprocess import call, check_call, Popen, PIPE
# Minimal modules to tests when core changes are detected.
# s3 - xml, dynamodb - json, sqs - query
core_modules_to_test = ["s3", "dynamodb", "sqs"]
# Minimal modules to tests when http client changes are detected.
# s3 - streaming/non streaming, kinesis - h2
http_modules_to_test = {
"apache-client": ["s3", "apache-client"],
"netty-nio-client": ["kinesis", "s3", "netty-nio-client"],
"url-connection-client": ["url-connection-client"]
}
def check_diffs():
"""
Retrieve the changed files
"""
process = Popen(["git", "diff", "HEAD^", "--name-only"], stdout=PIPE)
diff, stderr = process.communicate()
if process.returncode !=0:
raise Exception("Unable to do git diff")
return diff.splitlines(False)
def get_modules(file_path):
"""
Parse the changed file path and get the respective module names
"""
path = file_path.split('/')
# filter out non-java file
if not path[-1].endswith(".java"):
return
top_directory = path[0]
if top_directory in ["core", "codegen"]:
return core_modules_to_test
if top_directory in ["http-clients"]:
return http_modules_to_test.get(path[1])
elif top_directory== "services":
return path[1]
def run_tests(modules):
"""
Run integration tests for the given modules
"""
print("Running integ tests in the following modules: " + ', '.join(modules))
modules_to_include = ""
for m in modules:
modules_to_include += ":" + m + ","
# remove last comma
modules_to_include = modules_to_include[:-1]
# build necessary dependencies first
check_call(["mvn", "clean", "install", "-pl", modules_to_include, "-P", "quick", "--am"])
check_call(["mvn", "verify", "-pl", modules_to_include, "-P", "integration-tests", "-Dfailsafe.rerunFailingTestsCount=1"])
if __name__ == "__main__":
diffs = check_diffs()
modules = set()
for d in diffs:
module = get_modules(d)
if isinstance(module, list):
modules.update(module)
elif module:
modules.add(module)
if modules:
run_tests(modules)
else:
print("No modules configured to run. Skipping integ tests")