-
Notifications
You must be signed in to change notification settings - Fork 124
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
[Cherry Pick] Enable canary report generation #634
Merged
jsitu777
merged 46 commits into
awslabs:release-v1.6.1-aws-b1.0.1
from
jsitu777:enable-xml-report
Mar 30, 2023
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
8a2eefe
increase cert-manager wait time for kubeflow-issuer to be install
jsitu777 fbf91ac
Merge branch 'release-v1.6.1-aws-b1.0.1' of https://github.com/awslab…
jsitu777 0e973cf
enable canary report
jsitu777 76f1bb6
modify container name
jsitu777 8c3662d
change docker command
jsitu777 3d97489
change docker command
jsitu777 5e657e3
print out container file structure to debug
jsitu777 ae0609e
print out container file structure to debug
jsitu777 ebd48b4
debug container
jsitu777 8c6efd9
fix canary.buildspec.yaml
jsitu777 045b498
fix canary.buildspec.yaml
jsitu777 4ca26b4
fix canary.buildspec.yaml
jsitu777 ff4c386
push to ECR after cp
jsitu777 b5f838d
push to ECR after cp
jsitu777 bc81c59
run container in detached mode so it's still running after build
jsitu777 e4bd53b
sleep 30s to ensure container still running
jsitu777 77bd0a7
remove sleep
jsitu777 3be38a8
push to cloudwatch
jsitu777 147debd
minor fix
jsitu777 02db0e1
bug fixes
jsitu777 fadb8e7
rename test log to xml
jsitu777 10350bf
add dimensions to cloudwatch metrics
jsitu777 76a15e4
use trap to make sure it python executes if pytest fails
jsitu777 a8891c1
use list_project for codebuild
jsitu777 09104dc
fix datetime module error
jsitu777 fc4cd2d
remove region as cloudwatch metric dimension
jsitu777 7c8b247
keep only total test, failure, success metric to push to cloud watch
jsitu777 d2e4595
run pytest first then trap python script
jsitu777 fd2154b
add int type for success
jsitu777 868da1e
get codebuild project name from env instead of boto3
jsitu777 7111dc4
change success into int type
jsitu777 bd1d95a
intent to test fail for debugging
jsitu777 112ec17
call python script inside a function
jsitu777 abd90bc
run push to cloudwatch onerror
jsitu777 c9a6132
modify to exit instead of on error
jsitu777 bebf9b0
add set -e in buildspec
jsitu777 350b322
to ensure docker always exit with 0
jsitu777 92dc0b2
bug fix
jsitu777 b81c41c
remove || true after docker run, hard code codebuild project name for…
jsitu777 95ab554
restore kf installation and uninstallation in fixture
jsitu777 3a61765
test if cloudwatch can push metrics if test fails
jsitu777 25aa392
teest if can get env variable directly
jsitu777 5e930d3
restore kf installation and notebook test
jsitu777 2e395b4
add || true to docker cp command so next command will continue even i…
jsitu777 fe09879
rename cloudwatch metric namespace
jsitu777 f703021
move trap code at the beginning; remove getting cluster_name env
jsitu777 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 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
This file contains 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,90 @@ | ||
import boto3 | ||
from datetime import datetime | ||
import xml.etree.ElementTree as ET | ||
import os | ||
|
||
|
||
xml_path = "../canary/integration_tests.xml" | ||
|
||
|
||
def readXML_and_publish_metrics_to_cw(): | ||
if os.path.isfile(xml_path): | ||
tree = ET.parse(xml_path) | ||
testsuite = tree.find("testsuite") | ||
failures = testsuite.attrib["failures"] | ||
tests = testsuite.attrib["tests"] | ||
successes = int(tests) - int(failures) | ||
else: | ||
failures = 0 | ||
successes = 0 | ||
tests = 1 | ||
|
||
timestamp = datetime.now().strftime("%Y-%m-%dT%H:%M:%S") | ||
|
||
print(f"Failures: {failures}") | ||
print(f"Total tests: {tests}") | ||
print(f"Success: {successes}") | ||
|
||
# push to cloudwatch | ||
cw_client = boto3.client("cloudwatch") | ||
project_name = "CodeBuild-Run-All-Tests" | ||
|
||
# Define the metric data | ||
metric_data = [ | ||
{ | ||
"MetricName": "failures", | ||
"Timestamp": timestamp, | ||
"Dimensions": [ | ||
{"Name": "CodeBuild Project Name", "Value": project_name}, | ||
], | ||
"Value": int(failures), | ||
"Unit": "Count", | ||
}, | ||
{ | ||
"MetricName": "total_tests", | ||
"Timestamp": timestamp, | ||
"Dimensions": [ | ||
{"Name": "CodeBuild Project Name", "Value": project_name}, | ||
], | ||
"Value": int(tests), | ||
"Unit": "Count", | ||
}, | ||
{ | ||
"MetricName": "successes", | ||
"Timestamp": timestamp, | ||
"Dimensions": [ | ||
{"Name": "CodeBuild Project Name", "Value": project_name}, | ||
], | ||
"Value": int(successes), | ||
"Unit": "Count", | ||
}, | ||
] | ||
|
||
# Use the put_metric_data method to push the metric data to CloudWatch | ||
try: | ||
response = cw_client.put_metric_data( | ||
Namespace="Canary_Metrics", MetricData=metric_data | ||
) | ||
if response["ResponseMetadata"]["HTTPStatusCode"] == 200: | ||
print("Successfully pushed data to CloudWatch") | ||
# return 200 status code if successful | ||
return 200 | ||
else: | ||
# raise exception if the status code is not 200 | ||
raise Exception( | ||
"Unexpected response status code: {}".format( | ||
response["ResponseMetadata"]["HTTPStatusCode"] | ||
) | ||
) | ||
except Exception as e: | ||
print("Error pushing data to CloudWatch: {}".format(e)) | ||
# raise exception if there was an error pushing data to CloudWatch | ||
raise | ||
|
||
|
||
def main(): | ||
readXML_and_publish_metrics_to_cw() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -63,7 +63,6 @@ def on_create(): | |
install_kubeflow(installation_option, deployment_option, cluster) | ||
|
||
def on_delete(): | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: revert? or coming from black |
||
uninstall_kubeflow(installation_option, deployment_option) | ||
|
||
|
||
|
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.
format using black. couple of extra lines
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.
formatted with black