Fix uploading test cases that use dots in names

Change-Id: Ic833de553ceacae90a0c4686e874262f8af17b1e
Closes-Bug:#1485308
This commit is contained in:
Dennis Dmitriev 2015-09-08 15:14:26 +03:00
parent bbe4557f1e
commit 4e594eb407
2 changed files with 15 additions and 7 deletions

View File

@ -167,28 +167,36 @@ def get_version_from_artifacts(jenkins_build_data):
''
def expand_test_group(group, systest_build_name):
def expand_test_group(group, systest_build_name, os):
"""Expand specified test names with the group name of the job
which is taken from the build name, for example:
group: 'setup_master'
systest_build_name: '7.0.system_test.ubuntu.bonding_ha_one_controller'
os: str, release name in lower case, for example: 'ubuntu'
return: 'setup_master_bonding_ha_one_controller'
"""
if group in GROUPS_TO_EXPAND:
systest_group_name = systest_build_name.split('.')[-1]
if os in systest_build_name:
sep = '.' + os + '.'
else:
sep = '.'
systest_group_name = systest_build_name.split(sep)[-1]
if systest_group_name:
group = '_'.join([group, systest_group_name])
return group
@retry(count=3)
def get_tests_results(systest_build):
def get_tests_results(systest_build, os):
tests_results = []
test_build = Build(systest_build['name'], systest_build['number'])
for test in test_build.test_data()['suites'][0]['cases']:
test_result = TestResult(
name=test['name'],
group=expand_test_group(test['className'], systest_build['name']),
group=expand_test_group(test['className'],
systest_build['name'],
os),
status=test['status'].lower(),
duration='{0}s'.format(int(test['duration']) + 1),
url='{0}testReport/(root)/{1}/'.format(test_build.url,
@ -461,7 +469,7 @@ def main():
continue
for os in tests_results.keys():
if os in systest_build['name'].lower():
tests_results[os].extend(get_tests_results(systest_build))
tests_results[os].extend(get_tests_results(systest_build, os))
# STEP #3
# Create new TestPlan in TestRail (or get existing) and add TestRuns

View File

@ -122,8 +122,8 @@ def get_tests_groups_from_jenkins(runner_name, build_number, distros):
sep = '.' + distro + '.'
res.append(job_name.split(sep)[-1])
break
else:
res.append(job_name.split('.')[-1])
else:
res.append(job_name.split('.')[-1])
return res