aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Matt Kwong <mattkwong@google.com>2018-07-09 14:22:04 -0700
committerGravatar Matt Kwong <mattkwong@google.com>2018-07-09 14:22:04 -0700
commitb2670fceb70a9d8f9d00c74eeba5404ea2defb85 (patch)
treeaa30f42526a1d6b2f77242b585d519e78f3cd01c
parent39ab59ff36b2110a6ad6e761301289a1ed54fbd2 (diff)
Add error handling for when a test result cannot be parsed
-rw-r--r--tools/run_tests/python_utils/upload_rbe_results.py65
1 files changed, 45 insertions, 20 deletions
diff --git a/tools/run_tests/python_utils/upload_rbe_results.py b/tools/run_tests/python_utils/upload_rbe_results.py
index f35869cd4b..d29ebc6219 100644
--- a/tools/run_tests/python_utils/upload_rbe_results.py
+++ b/tools/run_tests/python_utils/upload_rbe_results.py
@@ -186,26 +186,51 @@ if __name__ == "__main__":
result = 'UNKNOWN'
else:
result = 'PASSED'
- bq_rows.append({
- 'insertId': str(uuid.uuid4()),
- 'json': {
- 'job_name':
- os.getenv('KOKORO_JOB_NAME'),
- 'build_id':
- os.getenv('KOKORO_BUILD_NUMBER'),
- 'build_url':
- 'https://source.cloud.google.com/results/invocations/%s' %
- invocation_id,
- 'test_target':
- action['id']['targetId'],
- 'test_case':
- test_case['testCase']['caseName'],
- 'result':
- result,
- 'timestamp':
- action['timing']['startTime'],
- }
- })
+ try:
+ bq_rows.append({
+ 'insertId': str(uuid.uuid4()),
+ 'json': {
+ 'job_name':
+ os.getenv('KOKORO_JOB_NAME'),
+ 'build_id':
+ os.getenv('KOKORO_BUILD_NUMBER'),
+ 'build_url':
+ 'https://source.cloud.google.com/results/invocations/%s'
+ % invocation_id,
+ 'test_target':
+ action['id']['targetId'],
+ 'test_case':
+ test_case['testCase']['caseName'],
+ 'result':
+ result,
+ 'timestamp':
+ action['timing']['startTime'],
+ }
+ })
+ except Exception as e:
+ print('Failed to parse test result. Error: %s' % str(e))
+ print(json.dumps(test_case, indent=4))
+ bq_rows.append({
+ 'insertId': str(uuid.uuid4()),
+ 'json': {
+ 'job_name':
+ os.getenv('KOKORO_JOB_NAME'),
+ 'build_id':
+ os.getenv('KOKORO_BUILD_NUMBER'),
+ 'build_url':
+ 'https://source.cloud.google.com/results/invocations/%s'
+ % invocation_id,
+ 'test_target':
+ action['id']['targetId'],
+ 'test_case':
+ 'N/A',
+ 'result':
+ 'UNPARSEABLE',
+ 'timestamp':
+ 'N/A',
+ }
+ })
+
# BigQuery sometimes fails with large uploads, so batch 1,000 rows at a time.
for i in range((len(bq_rows) / 1000) + 1):
_upload_results_to_bq(bq_rows[i * 1000:(i + 1) * 1000])