Support openstack_tasks in mapping tests

Change-Id: I8b6a53148522e08055e61bf4746fa2ca43f3e2df
Closes-Bug: #1567372
This commit is contained in:
Tatyana Leontovich 2016-04-07 19:28:18 +03:00 committed by tatyana-leontovich
parent 54c7179ac6
commit abc8eb9179
3 changed files with 37 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import re
from six.moves import xrange from six.moves import xrange
# pylint: enable=redefined-builtin # pylint: enable=redefined-builtin
from fuelweb_test import logger
from fuelweb_test import settings from fuelweb_test import settings
from fuelweb_test.helpers.gerrit.gerrit_client import GerritClient from fuelweb_test.helpers.gerrit.gerrit_client import GerritClient
from fuelweb_test.helpers.gerrit import utils from fuelweb_test.helpers.gerrit import utils
@ -35,6 +36,10 @@ class FuelLibraryModulesProvider(object):
os.path.join(MODULE_ROOT_PATH, OSNAILYFACTER_NAME, 'modular/') os.path.join(MODULE_ROOT_PATH, OSNAILYFACTER_NAME, 'modular/')
OSNAILYFACTER_ROLES_PATH = os.path.join(OSNAILYFACTER_PATH, 'roles/') OSNAILYFACTER_ROLES_PATH = os.path.join(OSNAILYFACTER_PATH, 'roles/')
TASKS_YAML_PATH = os.path.join(OSNAILYFACTER_ROLES_PATH, 'tasks.yaml') TASKS_YAML_PATH = os.path.join(OSNAILYFACTER_ROLES_PATH, 'tasks.yaml')
OPENSTACK_TASKS_PATH = os.path.join(MODULE_ROOT_PATH,
'openstack_tasks/manifests/')
OS_TASKS_YAML_PATH = os.path.join(MODULE_ROOT_PATH,
'openstack_tasks/tasks.yaml')
PUPPETFILE_PATH = 'deployment/Puppetfile' PUPPETFILE_PATH = 'deployment/Puppetfile'
def __init__(self, gerrit_review): def __init__(self, gerrit_review):
@ -71,6 +76,7 @@ class FuelLibraryModulesProvider(object):
r = self._request_file_list() r = self._request_file_list()
text = r.text text = r.text
files = utils.filter_response_text(text) files = utils.filter_response_text(text)
logger.debug('Changed files list {}'.format(files))
self._files_list.update(set(filter(lambda x: x != '/COMMIT_MSG', self._files_list.update(set(filter(lambda x: x != '/COMMIT_MSG',
utils.json_to_dict(files).keys()))) utils.json_to_dict(files).keys())))
@ -83,21 +89,40 @@ class FuelLibraryModulesProvider(object):
if f.startswith(FuelLibraryModulesProvider.MODULE_ROOT_PATH): if f.startswith(FuelLibraryModulesProvider.MODULE_ROOT_PATH):
split_path = f.split('/') split_path = f.split('/')
module = split_path[-1] module = split_path[-1]
logger.debug('Process next module {}'.format(module))
self._add_module_from_files(module, split_path) self._add_module_from_files(module, split_path)
self._add_module_from_osnailyfacter(f, split_path) self._add_module_from_osnailyfacter(f, split_path)
self._add_module_from_openstack_tasks(f, split_path)
def _add_module_from_files(self, module, split_path): def _add_module_from_files(self, module, split_path):
if module != FuelLibraryModulesProvider.OSNAILYFACTER_NAME: if module != FuelLibraryModulesProvider.OSNAILYFACTER_NAME:
module_path = os.path.join( module_path = os.path.join(
FuelLibraryModulesProvider.PROJECT_ROOT_PATH, *split_path[:3] FuelLibraryModulesProvider.PROJECT_ROOT_PATH, *split_path[:3]
) )
logger.debug('Add module {0} from files by path {1}'.format(
module, module_path))
self._add_module(module, module_path)
def _add_module_from_openstack_tasks(self, filename, split_path):
if filename.startswith(
FuelLibraryModulesProvider.OPENSTACK_TASKS_PATH) \
and filename != FuelLibraryModulesProvider.OS_TASKS_YAML_PATH:
module = split_path[4]
module_path = os.path.join(
FuelLibraryModulesProvider.PROJECT_ROOT_PATH,
*split_path[0:-1])
logger.debug('Add module {0} from openstack_tasks '
'by path {1}'.format(module, module_path))
self._add_module(module, module_path) self._add_module(module, module_path)
def _add_module(self, module, module_path): def _add_module(self, module, module_path):
logger.debug('Changed modules are {}'.format(self.changed_modules))
if module in self.changed_modules: if module in self.changed_modules:
logger.debug('Add module {} to changed modules'.format(module))
self.changed_modules[module].add(module_path) self.changed_modules[module].add(module_path)
else: else:
self.changed_modules[module] = {module_path} self.changed_modules[module] = {module_path}
logger.debug('Add module {} to changed modules'.format(module))
def _add_module_from_osnailyfacter(self, filename, split_path): def _add_module_from_osnailyfacter(self, filename, split_path):
if filename.startswith(FuelLibraryModulesProvider.OSNAILYFACTER_PATH) \ if filename.startswith(FuelLibraryModulesProvider.OSNAILYFACTER_PATH) \
@ -108,6 +133,8 @@ class FuelLibraryModulesProvider(object):
module_path = os.path.join( module_path = os.path.join(
FuelLibraryModulesProvider.PROJECT_ROOT_PATH, *split_path[:5] FuelLibraryModulesProvider.PROJECT_ROOT_PATH, *split_path[:5]
) )
logger.debug('Add module {0} from osnailyfacter '
'by path {1}'.format(module, module_path))
self._add_module(module, module_path) self._add_module(module, module_path)
def _get_puppetfile_content_as_dict(self): def _get_puppetfile_content_as_dict(self):

View File

@ -24,8 +24,10 @@ bvt_2:
- horizon - horizon
- inifile - inifile
- keystone - keystone
- keystone.pp
- l23network - l23network
- logging - logging
- mon
- mcollective - mcollective
- memcached - memcached
- monit - monit
@ -62,8 +64,10 @@ bvt_2:
- vmware - vmware
deploy_heat_ha: deploy_heat_ha:
- adhoc
- ceilometer - ceilometer
- ceilometer_ha - ceilometer_ha
- cfn_keystone.pp
- heat - heat
- heat_ha - heat_ha
- mongo - mongo
@ -104,6 +108,7 @@ deploy_sahara_ha_tun:
neutron_vlan_ha: neutron_vlan_ha:
- swift - swift
- proxy
positive_cic_maintenance_mode: positive_cic_maintenance_mode:
- umm - umm
@ -111,3 +116,5 @@ positive_cic_maintenance_mode:
deploy_ha_cgroup: deploy_ha_cgroup:
- cgroups - cgroups
basic_env_for_hugepages:
- allocated_hugepages

View File

@ -443,12 +443,13 @@ def puppet_modules_mapping(modules):
# checking that module from review covered by system_test # checking that module from review covered by system_test
for module in modules.keys(): for module in modules.keys():
if module not in all_modules: if module.split('.')[0] not in all_modules:
logger.warning( logger.warning(
"{}:{} module not exist or not covered by system_test" "{}:{} module not exist or not covered by system_test"
.format(module, modules[module])) .format(module, modules[module]))
# find test group which has better coverage of modules from review # find test group which has better coverage of modules from review
formatted_modules = [module.split('.')[0] for module in modules]
system_test = "bvt_2" system_test = "bvt_2"
max_intersection = 0 max_intersection = 0
if not ("ceph" in modules and if not ("ceph" in modules and
@ -456,7 +457,7 @@ def puppet_modules_mapping(modules):
set(modules)): set(modules)):
for test in mapping: for test in mapping:
test_intersection = len( test_intersection = len(
set(mapping[test]).intersection(set(modules))) set(mapping[test]).intersection(set(formatted_modules)))
if test_intersection > max_intersection: if test_intersection > max_intersection:
max_intersection = test_intersection max_intersection = test_intersection
system_test = test system_test = test