From 4e594eb407541a3a5df84f0cfaf1b03d3f23bf3f Mon Sep 17 00:00:00 2001 From: Dennis Dmitriev Date: Tue, 8 Sep 2015 15:14:26 +0300 Subject: [PATCH] Fix uploading test cases that use dots in names Change-Id: Ic833de553ceacae90a0c4686e874262f8af17b1e Closes-Bug:#1485308 --- fuelweb_test/testrail/report.py | 18 +++++++++++++----- .../testrail/upload_cases_description.py | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/fuelweb_test/testrail/report.py b/fuelweb_test/testrail/report.py index ccddd4feb..07ffc4174 100755 --- a/fuelweb_test/testrail/report.py +++ b/fuelweb_test/testrail/report.py @@ -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 diff --git a/fuelweb_test/testrail/upload_cases_description.py b/fuelweb_test/testrail/upload_cases_description.py index 88dab4101..f3badc12b 100644 --- a/fuelweb_test/testrail/upload_cases_description.py +++ b/fuelweb_test/testrail/upload_cases_description.py @@ -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