Skip to content

Add better-integ-test buildspec #1019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions buildspecs/better-integ-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 0.2

phases:
build:
commands:
- python scripts/run-integ-test
72 changes: 72 additions & 0 deletions scripts/run-integ-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/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
"""
ret = Popen(["git", "diff", "HEAD^", "--name-only"], stdout=PIPE)

diff, stderr = ret.communicate()
return diff.splitlines(False)

def get_modules(file_path):
"""
Parse the changed file path and get the respective module names
"""
path = file_path.split('/')
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[path[1]]
elif top_directory== "services":
return path[1]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no else clause so this can return None. Is that expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is expected. We don't need to run integ tests for changes in other modules such as build-tools

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", "-Dmaven.wagon.httpconnectionManager.maxPerRoute=2"])
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")