Add error handling for when a test result cannot be parsed

pull/15918/head
Matt Kwong 7 years ago
parent 39ab59ff36
commit b2670fceb7
  1. 65
      tools/run_tests/python_utils/upload_rbe_results.py

@ -186,26 +186,51 @@ if __name__ == "__main__":
result = 'UNKNOWN' result = 'UNKNOWN'
else: else:
result = 'PASSED' result = 'PASSED'
bq_rows.append({ try:
'insertId': str(uuid.uuid4()), bq_rows.append({
'json': { 'insertId': str(uuid.uuid4()),
'job_name': 'json': {
os.getenv('KOKORO_JOB_NAME'), 'job_name':
'build_id': os.getenv('KOKORO_JOB_NAME'),
os.getenv('KOKORO_BUILD_NUMBER'), 'build_id':
'build_url': os.getenv('KOKORO_BUILD_NUMBER'),
'https://source.cloud.google.com/results/invocations/%s' % 'build_url':
invocation_id, 'https://source.cloud.google.com/results/invocations/%s'
'test_target': % invocation_id,
action['id']['targetId'], 'test_target':
'test_case': action['id']['targetId'],
test_case['testCase']['caseName'], 'test_case':
'result': test_case['testCase']['caseName'],
result, 'result':
'timestamp': result,
action['timing']['startTime'], '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. # BigQuery sometimes fails with large uploads, so batch 1,000 rows at a time.
for i in range((len(bq_rows) / 1000) + 1): for i in range((len(bq_rows) / 1000) + 1):
_upload_results_to_bq(bq_rows[i * 1000:(i + 1) * 1000]) _upload_results_to_bq(bq_rows[i * 1000:(i + 1) * 1000])

Loading…
Cancel
Save