Fix inconsistent treatment of test status

This commit is the follow on to change
Ib84eb5e4b2da4847e86ff24c8bc5ba19a0df5b37 which fixed an unhandled
condition when xfail or uxsuccess was in the passed in results stream.
While that fixed the failure condition it neglected to update how we
treat those test result statuses in all other cases. This commit does
that by making sure we treat xfail and uxsuccess as success and failure
respectively for aggregate counts.

Change-Id: I1d2308d2c68f4f6b432ab733ead19a0167ba0b94
Story: 2000701
Task: 3176
This commit is contained in:
Matthew Treinish 2018-12-24 16:05:53 -05:00 committed by Masayuki Igawa
parent 4202e4c195
commit ae1c4485ca
2 changed files with 33 additions and 4 deletions

View File

@ -120,8 +120,10 @@ def increment_counts(test, results):
def get_run_totals(results):
success = len([x for x in results if results[x]['status'] == 'success'])
fails = len([x for x in results if results[x]['status'] == 'fail'])
success = len(
[x for x in results if results[x]['status'] in ['success', 'xfail']])
fails = len(
[x for x in results if results[x]['status'] in ['fail', 'uxsuccess']])
skips = len([x for x in results if results[x]['status'] == 'skip'])
totals = {
'success': success,
@ -184,10 +186,10 @@ def process_results(results, run_at=None, artifacts=None, run_id=None,
for test in results:
db_test = api.get_test_by_test_id(test, session)
if not db_test:
if results[test]['status'] == 'success':
if results[test]['status'] in ['success', 'xfail']:
success = 1
fails = 0
elif results[test]['status'] == 'fail':
elif results[test]['status'] in ['fail', 'uxsuccess']:
fails = 1
success = 0
else:

View File

@ -49,6 +49,33 @@ class TestShell(base.TestCase):
self.assertEqual(totals['fails'], 16)
self.assertEqual(totals['skips'], 50)
def test_run_totals_with_xfail_and_uxsuccess(self):
fake_results = {}
# Fake Success
for num in range(100):
test_name = 'fake_test_' + str(num)
fake_results[test_name] = {'status': 'success'}
# Fake skips
for num in range(50):
test_name = 'fake_test_skip_' + str(num)
fake_results[test_name] = {'status': 'skip'}
# Fake fails
for num in range(16):
test_name = 'fake_test_fail_' + str(num)
fake_results[test_name] = {'status': 'fail'}
# Fake xfail
for num in range(50):
test_name = 'fake_test_xfail_' + str(num)
fake_results[test_name] = {'status': 'xfail'}
# Fake uxsuccess
for num in range(16):
test_name = 'fake_test_unxsuccess_' + str(num)
fake_results[test_name] = {'status': 'uxsuccess'}
totals = shell.get_run_totals(fake_results)
self.assertEqual(totals['success'], 150)
self.assertEqual(totals['fails'], 32)
self.assertEqual(totals['skips'], 50)
def test_running_avg(self):
fake_test = mock.MagicMock()
fake_test.success = 150