Commit 0045165d authored by Mikhail Khokhlov's avatar Mikhail Khokhlov Committed by Commit Bot

[toold/perf] Rename 'isExpected' field to 'expected'

This is to comply with the latest changes in the LUCI protocol.

Bug: 1018248
Change-Id: I2c71dfc1a15fd456f77b9a39e54eb8de1207c7c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1884290Reviewed-by: default avatarJuan Antonio Navarro Pérez <perezju@chromium.org>
Commit-Queue: Mikhail Khokhlov <khokhlov@google.com>
Cr-Commit-Position: refs/heads/master@{#710291}
parent fe877ab0
...@@ -47,7 +47,7 @@ def Convert(test_results, base_dir): ...@@ -47,7 +47,7 @@ def Convert(test_results, base_dir):
benchmark_name, story_name = result['testPath'].split('/') benchmark_name, story_name = result['testPath'].split('/')
story_name = urllib.unquote(story_name) story_name = urllib.unquote(story_name)
actual_status = result['status'] actual_status = result['status']
expected_status = actual_status if result['isExpected'] else 'PASS' expected_status = actual_status if result['expected'] else 'PASS'
status_counter[actual_status] += 1 status_counter[actual_status] += 1
artifacts = result.get('outputArtifacts', {}) artifacts = result.get('outputArtifacts', {})
shard = _GetTagValue(result.get('tags', []), 'shard', as_type=int) shard = _GetTagValue(result.get('tags', []), 'shard', as_type=int)
...@@ -58,7 +58,7 @@ def Convert(test_results, base_dir): ...@@ -58,7 +58,7 @@ def Convert(test_results, base_dir):
story_name: { story_name: {
'actual': actual_status, 'actual': actual_status,
'expected': expected_status, 'expected': expected_status,
'is_unexpected': not result['isExpected'], 'is_unexpected': not result['expected'],
'times': float(result['runDuration'].rstrip('s')), 'times': float(result['runDuration'].rstrip('s')),
'shard': shard, 'shard': shard,
'artifacts': { 'artifacts': {
...@@ -86,7 +86,7 @@ def Convert(test_results, base_dir): ...@@ -86,7 +86,7 @@ def Convert(test_results, base_dir):
else datetime.datetime.utcnow().isoformat() + 'Z') else datetime.datetime.utcnow().isoformat() + 'Z')
# If Telemetry stops with a unhandleable error, then remaining stories # If Telemetry stops with a unhandleable error, then remaining stories
# are marked as unexpectedly skipped. # are marked as unexpectedly skipped.
interrupted = any(t['status'] == 'SKIP' and not t['isExpected'] interrupted = any(t['status'] == 'SKIP' and not t['expected']
for t in test_results) for t in test_results)
results.update( results.update(
seconds_since_epoch=util.IsoTimestampToEpoch(test_suite_start_time), seconds_since_epoch=util.IsoTimestampToEpoch(test_suite_start_time),
......
...@@ -106,7 +106,7 @@ class Json3OutputTest(unittest.TestCase): ...@@ -106,7 +106,7 @@ class Json3OutputTest(unittest.TestCase):
testing.TestResult('benchmark/story2', status='PASS'), testing.TestResult('benchmark/story2', status='PASS'),
testing.TestResult('benchmark/story1', status='FAIL'), testing.TestResult('benchmark/story1', status='FAIL'),
testing.TestResult('benchmark/story2', status='SKIP', testing.TestResult('benchmark/story2', status='SKIP',
is_expected=False), expected=False),
]) ])
test_result = self.FindTestResult(results, 'benchmark', 'story1') test_result = self.FindTestResult(results, 'benchmark', 'story1')
......
...@@ -159,6 +159,11 @@ def _LoadTestResults(intermediate_dir): ...@@ -159,6 +159,11 @@ def _LoadTestResults(intermediate_dir):
if 'benchmarkRun' in record: if 'benchmarkRun' in record:
benchmark_run.update(record['benchmarkRun']) benchmark_run.update(record['benchmarkRun'])
if 'testResult' in record: if 'testResult' in record:
# TODO(crbug.com/1018248): Remove this after the field is renamed
# in Telemetry.
if 'isExpected' in record['testResult']:
record['testResult']['expected'] = record['testResult']['isExpected']
del record['testResult']['isExpected']
test_results.append(record['testResult']) test_results.append(record['testResult'])
for test_result in test_results: for test_result in test_results:
test_result['_benchmarkRun'] = benchmark_run test_result['_benchmarkRun'] = benchmark_run
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import json import json
def TestResult(test_path, status='PASS', is_expected=None, def TestResult(test_path, status='PASS', expected=None,
start_time='2015-10-21T07:28:00.000Z', run_duration='1.00s', start_time='2015-10-21T07:28:00.000Z', run_duration='1.00s',
output_artifacts=None, tags=None): output_artifacts=None, tags=None):
"""Build a TestResult dict. """Build a TestResult dict.
...@@ -20,7 +20,7 @@ def TestResult(test_path, status='PASS', is_expected=None, ...@@ -20,7 +20,7 @@ def TestResult(test_path, status='PASS', is_expected=None,
the form '{benchmark_name}/{story_name}'. the form '{benchmark_name}/{story_name}'.
status: An optional string indicating the status of the test run. Usually status: An optional string indicating the status of the test run. Usually
one of 'PASS', 'SKIP', 'FAIL'. Defaults to 'PASS'. one of 'PASS', 'SKIP', 'FAIL'. Defaults to 'PASS'.
is_expected: An optional bool indicating whether the status result is expected: An optional bool indicating whether the status result is
expected. Defaults to True for 'PASS', 'SKIP'; and False otherwise. expected. Defaults to True for 'PASS', 'SKIP'; and False otherwise.
start_time: An optional UTC timestamp recording when the test run started. start_time: An optional UTC timestamp recording when the test run started.
run_duration: An optional duration string recording the amount of time run_duration: An optional duration string recording the amount of time
...@@ -34,12 +34,12 @@ def TestResult(test_path, status='PASS', is_expected=None, ...@@ -34,12 +34,12 @@ def TestResult(test_path, status='PASS', is_expected=None,
Returns: Returns:
A TestResult dict. A TestResult dict.
""" """
if is_expected is None: if expected is None:
is_expected = status in ('PASS', 'SKIP') expected = status in ('PASS', 'SKIP')
test_result = { test_result = {
'testPath': test_path, 'testPath': test_path,
'status': status, 'status': status,
'isExpected': is_expected, 'expected': expected,
'startTime': start_time, 'startTime': start_time,
'runDuration': run_duration 'runDuration': run_duration
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment