Handle multiple validation logs results
Change-Id: I49d284edc2e1c54fb8c365e52146c656440b5db2
This commit is contained in:
parent
4f57229c23
commit
b5cc8dff75
|
@ -172,3 +172,34 @@ class TestValidationLogs(TestCase):
|
||||||
'Unreachable_Hosts': '',
|
'Unreachable_Hosts': '',
|
||||||
'Duration': '0:00:03.753',
|
'Duration': '0:00:03.753',
|
||||||
'Validations': 'foo'}])
|
'Validations': 'foo'}])
|
||||||
|
|
||||||
|
def test_get_results_none(self):
|
||||||
|
vlogs = ValidationLogs('/tmp/foo')
|
||||||
|
self.assertRaises(RuntimeError, vlogs.get_results, uuid=None)
|
||||||
|
|
||||||
|
@mock.patch('validations_libs.validation_logs.ValidationLogs.'
|
||||||
|
'get_logfile_by_uuid_validation_id')
|
||||||
|
@mock.patch('json.load',
|
||||||
|
return_value=fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0])
|
||||||
|
@mock.patch('six.moves.builtins.open')
|
||||||
|
def test_get_results_list(self, mock_open, mock_json, mock_get_validation):
|
||||||
|
mock_get_validation.return_value = \
|
||||||
|
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
|
||||||
|
vlogs = ValidationLogs('/tmp/foo')
|
||||||
|
content = vlogs.get_results(uuid=['123', '123'], validation_id='foo')
|
||||||
|
self.assertEquals(content, [{'UUID': '123',
|
||||||
|
'Validations': 'foo',
|
||||||
|
'Status': 'PASSED',
|
||||||
|
'Status_by_Host': 'undercloud,PASSED',
|
||||||
|
'Host_Group': 'undercloud',
|
||||||
|
'Unreachable_Hosts': '',
|
||||||
|
'Duration': '0:00:03.753',
|
||||||
|
'Validations': 'foo'},
|
||||||
|
{'UUID': '123',
|
||||||
|
'Validations': 'foo',
|
||||||
|
'Status': 'PASSED',
|
||||||
|
'Status_by_Host': 'undercloud,PASSED',
|
||||||
|
'Host_Group': 'undercloud',
|
||||||
|
'Unreachable_Hosts': '',
|
||||||
|
'Duration': '0:00:03.753',
|
||||||
|
'Validations': 'foo'}])
|
||||||
|
|
|
@ -125,8 +125,9 @@ class ValidationActions(object):
|
||||||
if run_async:
|
if run_async:
|
||||||
return results
|
return results
|
||||||
# Return log results
|
# Return log results
|
||||||
|
uuid = [id['UUID'] for id in results]
|
||||||
vlog = ValidationLogs()
|
vlog = ValidationLogs()
|
||||||
return vlog.get_results(validation_uuid)
|
return vlog.get_results(uuid)
|
||||||
|
|
||||||
def group_information(self, groups):
|
def group_information(self, groups):
|
||||||
"""Get Information about Validation Groups"""
|
"""Get Information about Validation Groups"""
|
||||||
|
|
|
@ -232,13 +232,24 @@ class ValidationLogs(object):
|
||||||
Return a list of validation results by uuid
|
Return a list of validation results by uuid
|
||||||
Can be filter by validation_id
|
Can be filter by validation_id
|
||||||
"""
|
"""
|
||||||
|
if isinstance(uuid, list):
|
||||||
|
results = []
|
||||||
|
for id in uuid:
|
||||||
|
results.extend(self.get_logfile_by_uuid_validation_id(
|
||||||
|
id,
|
||||||
|
validation_id)
|
||||||
|
if validation_id else
|
||||||
|
self.get_logfile_by_uuid(id))
|
||||||
|
elif isinstance(uuid, str):
|
||||||
results = (self.get_logfile_by_uuid_validation_id(uuid,
|
results = (self.get_logfile_by_uuid_validation_id(uuid,
|
||||||
validation_id)
|
validation_id)
|
||||||
if validation_id else self.get_logfile_by_uuid(uuid))
|
if validation_id else self.get_logfile_by_uuid(uuid))
|
||||||
data = {}
|
else:
|
||||||
|
raise RuntimeError("uuid should be either a str or a list")
|
||||||
res = []
|
res = []
|
||||||
for result in results:
|
for result in results:
|
||||||
vlog = ValidationLog(logfile=result)
|
vlog = ValidationLog(logfile=result)
|
||||||
|
data = {}
|
||||||
data['UUID'] = vlog.get_uuid
|
data['UUID'] = vlog.get_uuid
|
||||||
data['Validations'] = vlog.get_validation_id
|
data['Validations'] = vlog.get_validation_id
|
||||||
data['Status'] = vlog.get_status
|
data['Status'] = vlog.get_status
|
||||||
|
|
Loading…
Reference in New Issue