-
Notifications
You must be signed in to change notification settings - Fork 914
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
|
||
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") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 returnNone
. Is that expected?There was a problem hiding this comment.
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