Add parsing test uuids from test result
Test uuids are parsed from subunit test results and posted to refstack API. Depends on git https://review.openstack.org/#/c/161760/ Change-Id: I04740e3b190cd2248aa09ebc7539963c21c1e140
This commit is contained in:
parent
748d259296
commit
da58c0828d
@ -31,15 +31,30 @@ class TempestSubunitTestResultPassOnly(testtools.TestResult):
|
||||
super(TempestSubunitTestResultPassOnly, self).__init__()
|
||||
self.results = []
|
||||
|
||||
@staticmethod
|
||||
def get_test_uuid(test):
|
||||
attrs = None
|
||||
try:
|
||||
attrs = test.split('[')[1].split(']')[0].split(',')
|
||||
except IndexError:
|
||||
pass
|
||||
if not attrs:
|
||||
return
|
||||
for attr in attrs:
|
||||
if attr.startswith('id-'):
|
||||
return '-'.join(attr.split('-')[1:])
|
||||
|
||||
def addSuccess(self, testcase):
|
||||
"""Overwrite super class method for additional data processing."""
|
||||
super(TempestSubunitTestResultPassOnly, self).addSuccess(testcase)
|
||||
# Remove any [] from the test ID before appending it.
|
||||
# Will leave in any () for now as they are the only thing discerning
|
||||
# certain test cases.
|
||||
self.results.append(
|
||||
{'name': re.sub('\[.*\]', '', testcase.id())}
|
||||
)
|
||||
test_result = {'name': str(re.sub('\[.*\]', '', testcase.id()))}
|
||||
uuid = self.get_test_uuid(str(testcase.id()))
|
||||
if uuid:
|
||||
test_result['uuid'] = uuid
|
||||
self.results.append(test_result)
|
||||
|
||||
def get_results(self):
|
||||
return self.results
|
||||
|
@ -4,20 +4,13 @@ test: tempest.passed.test
|
||||
time: 2014-08-15 10:34:51.020584Z
|
||||
successful: tempest.passed.test [ multipart
|
||||
]
|
||||
tags: -worker-0
|
||||
time: 2014-08-15 10:34:57.543400Z
|
||||
tags: worker-0
|
||||
test: tempest.failed.test
|
||||
time: 2014-08-15 10:34:57.548225Z
|
||||
failure: tempest.failed.test [ multipart
|
||||
Content-Type: text/x-traceback;charset="utf8",language="python"
|
||||
traceback
|
||||
2E4
|
||||
Traceback (most recent call last):
|
||||
File "/usr/lib/python2.7/some_file.py", line 2335, in exit
|
||||
_sys.exit(status)
|
||||
SystemExit: 2
|
||||
0
|
||||
time: 2014-08-15 10:34:58.010492Z
|
||||
tags: worker-0
|
||||
test: tempest.tagged_passed.test[gate,id-0146f675-ffbd-4208-b3a4-60eb628dbc5e]
|
||||
time: 2014-08-15 10:34:58.020584Z
|
||||
successful: tempest.tagged_passed.test[gate,id-0146f675-ffbd-4208-b3a4-60eb628dbc5e] [ multipart
|
||||
]
|
||||
tags: -worker-0
|
||||
|
||||
time: 2014-08-15 10:34:58.543400Z
|
||||
tags: worker-0
|
@ -2,7 +2,8 @@
|
||||
"duration_seconds": 0,
|
||||
"cpid": "test-id",
|
||||
"results": [
|
||||
{"name": "tempest.passed.test"}
|
||||
{"name": "tempest.passed.test"},
|
||||
{"name": "tempest.tagged_passed.test",
|
||||
"uuid": "0146f675-ffbd-4208-b3a4-60eb628dbc5e"}
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,11 @@ class TestRefstackClient(unittest.TestCase):
|
||||
client = rc.RefstackClient(args)
|
||||
subunit_file = self.test_path + "/.testrepository/0"
|
||||
results = client.get_passed_tests(subunit_file)
|
||||
expected = [{'name': 'tempest.passed.test'}]
|
||||
expected = [
|
||||
{'name': 'tempest.passed.test'},
|
||||
{'name': 'tempest.tagged_passed.test',
|
||||
'uuid': '0146f675-ffbd-4208-b3a4-60eb628dbc5e'}
|
||||
]
|
||||
self.assertEqual(expected, results)
|
||||
|
||||
def test_post_results(self):
|
||||
@ -230,7 +234,7 @@ class TestRefstackClient(unittest.TestCase):
|
||||
client.logger.info = MagicMock()
|
||||
content = {'duration_seconds': 0,
|
||||
'cpid': 'test-id',
|
||||
'results': [{'name': 'tempest.passed.test'}]}
|
||||
'results': [{'name': 'tempest.passed.test', 'uid': None}]}
|
||||
expected_response = json.dumps({'test_id': 42})
|
||||
|
||||
@httmock.urlmatch(netloc=r'(.*\.)?127.0.0.1$', path='/v1/results/')
|
||||
@ -372,10 +376,15 @@ class TestRefstackClient(unittest.TestCase):
|
||||
|
||||
client.post_results = MagicMock()
|
||||
client.upload()
|
||||
expected_json = {'duration_seconds': 0,
|
||||
'cpid': 'test-id',
|
||||
'results': [{'name': 'tempest.passed.test'}]}
|
||||
|
||||
expected_json = {
|
||||
'duration_seconds': 0,
|
||||
'cpid': 'test-id',
|
||||
'results': [
|
||||
{'name': 'tempest.passed.test'},
|
||||
{'name': 'tempest.tagged_passed.test',
|
||||
'uuid': '0146f675-ffbd-4208-b3a4-60eb628dbc5e'}
|
||||
]
|
||||
}
|
||||
client.post_results.assert_called_with('http://api.test.org',
|
||||
expected_json)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user