aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2018-09-11 23:15:03 +0200
committerGravatar Jan Tattermusch <jtattermusch@google.com>2018-09-12 11:09:10 -0700
commit1e69a21beb223617f797a2a323e2cb842861acf0 (patch)
tree8bfa2465231c191cd9d07f6abcd229f308901202
parent584dd0564605091a6299a624e85f80bfc2a57acf (diff)
upload test duration for foundry tests
-rw-r--r--tools/run_tests/python_utils/upload_rbe_results.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/run_tests/python_utils/upload_rbe_results.py b/tools/run_tests/python_utils/upload_rbe_results.py
index d29ebc6219..74f329048f 100644
--- a/tools/run_tests/python_utils/upload_rbe_results.py
+++ b/tools/run_tests/python_utils/upload_rbe_results.py
@@ -40,13 +40,14 @@ _RESULTS_SCHEMA = [
('test_case', 'STRING', 'Name of test case'),
('result', 'STRING', 'Test or build result'),
('timestamp', 'TIMESTAMP', 'Timestamp of test run'),
+ ('duration', 'FLOAT', 'Duration of the test run'),
]
_TABLE_ID = 'rbe_test_results'
def _get_api_key():
"""Returns string with API key to access ResultStore.
- Intended to be used in Kokoro envrionment."""
+ Intended to be used in Kokoro environment."""
api_key_directory = os.getenv('KOKORO_GFILE_DIR')
api_key_file = os.path.join(api_key_directory, 'resultstore_api_key')
assert os.path.isfile(api_key_file), 'Must add --api_key arg if not on ' \
@@ -57,7 +58,7 @@ def _get_api_key():
def _get_invocation_id():
"""Returns String of Bazel invocation ID. Intended to be used in
- Kokoro envirionment."""
+ Kokoro environment."""
bazel_id_directory = os.getenv('KOKORO_ARTIFACTS_DIR')
bazel_id_file = os.path.join(bazel_id_directory, 'bazel_invocation_ids')
assert os.path.isfile(bazel_id_file), 'bazel_invocation_ids file, written ' \
@@ -66,6 +67,16 @@ def _get_invocation_id():
return f.read().replace('\n', '')
+def _parse_test_duration(duration_str):
+ """Parse test duration string in '123.567s' format"""
+ try:
+ if duration_str.endswith('s'):
+ duration_str = duration_str[:-1]
+ return float(duration_str)
+ except:
+ return None
+
+
def _upload_results_to_bq(rows):
"""Upload test results to a BQ table.
@@ -205,6 +216,8 @@ if __name__ == "__main__":
result,
'timestamp':
action['timing']['startTime'],
+ 'duration':
+ _parse_test_duration(action['timing']['duration']),
}
})
except Exception as e: