Report presence of any records with errors

If there are any records with errors Shaker will report
them as SLA failure and add them in subunit output.

Change-Id: If23e2c09f577792ca82dc096f0960c5ea57cd392
This commit is contained in:
Ilya Shakhat 2018-10-22 12:00:06 +02:00
parent accb9a9d3b
commit 0b10da4cb6
1 changed files with 7 additions and 3 deletions

View File

@ -76,11 +76,15 @@ def calculate_stats(records, tests):
def verify_sla(records, tests):
record_map = collections.defaultdict(list) # test -> [record]
sla_records = []
for r in records.values():
if ('test' in r) and ('sla' in tests[r['test']]):
record_map[r['test']].append(r)
if r.get('status') != 'ok':
sla_records.append(sla.SLAItem(r, sla.STATE_FALSE,
'status of all records is ok'))
sla_records = []
for test_id, records_per_test in record_map.items():
for sla_expr in tests[test_id]['sla']:
sla_records += sla.eval_expr(sla_expr, records_per_test)
@ -92,8 +96,8 @@ def log_sla(sla_records):
if sla_records:
LOG.info('*' * 80)
for item in sla_records:
test_id = _get_location(item.record) + ':' + item.expression
LOG.info('%-73s %7s' % (test_id, '[%s]' % item.state))
test_id = _get_location(item.record) + ': ' + item.expression
LOG.info('%-72s %7s' % (test_id, '[%s]' % item.state))
LOG.info('*' * 80)