def __are_requirements_matching(param_dic=None, test=None): """ Validates test requirements against test cluster information returns True on match or False otherwise None :param param_dic: dictionary of cluster information from data passed to param list :param_dic type: dic :param test: test object :test type: object :returns True or False or None """ ts_requirements = {} tc_requirements = {} param_count = {} shortname = (socket.gethostname()).split('.', 1)[0] if test is None: return None test_name = getattr(test.test, '_testMethodName', None) if test_name is not None: method = getattr(test.test, test_name, None) if method is not None: tc_requirements = getattr(method, REQUIREMENTS_KEY, {}) cls = method.im_class ts_requirements = getattr(cls, REQUIREMENTS_KEY, {}) if not tc_requirements: if not ts_requirements: return None eff_tc_req = get_effective_reqs(ts_requirements, tc_requirements) setattr(test.test, 'requirements', eff_tc_req) for key in ['servers', 'moms', 'comms', 'clients']: param_count['num_' + key] = len(param_dic[key]) for pk in param_count: if param_count[pk] < eff_tc_req[pk]: return False if set(param_dic['moms']) & set(param_dic['servers']): if eff_tc_req['no_mom_on_server']: return False else: if not eff_tc_req['no_mom_on_server']: return False if set(param_dic['comms']) & set(param_dic['servers']): if eff_tc_req['no_comm_on_server']: return False else: if not eff_tc_req['no_comm_on_server']: return False comm_mom_list = set(param_dic['moms']) & set(param_dic['comms']) if comm_mom_list and shortname in comm_mom_list: # Excluding the server hostname for flag 'no_comm_on_mom' comm_mom_list.remove(shortname) if comm_mom_list: if eff_tc_req['no_comm_on_mom']: return False else: if not eff_tc_req['no_comm_on_mom']: return False
def __are_requirements_matching(param_dic=None, test=None): """ Validates test requirements against test cluster information returns True on match or False otherwise None :param param_dic: dictionary of cluster information from data passed to param list :param_dic type: dic :param test: test object :test type: object :returns True or False or None """ ts_requirements = {} tc_requirements = {} param_count = {} shortname = (socket.gethostname()).split('.', 1)[0] if test is None: return None test_name = getattr(test.test, '_testMethodName', None) if test_name is not None: method = getattr(test.test, test_name, None) if method is not None: tc_requirements = getattr(method, REQUIREMENTS_KEY, {}) cls = method.im_class ts_requirements = getattr(cls, REQUIREMENTS_KEY, {}) if not tc_requirements: if not ts_requirements: return None eff_tc_req = get_effective_reqs(ts_requirements, tc_requirements) setattr(test.test, 'requirements', eff_tc_req) for key in ['servers', 'moms', 'comms', 'clients']: param_count['num_' + key] = len(param_dic[key]) for pk in param_count: if param_count[pk] < eff_tc_req[pk]: return False if set(param_dic['moms']) & set(param_dic['servers']): if eff_tc_req['no_mom_on_server']: return False else: if not eff_tc_req['no_mom_on_server']: return False if set(param_dic['comms']) & set(param_dic['servers']): if eff_tc_req['no_comm_on_server']: return False else: if not eff_tc_req['no_comm_on_server']: return False comm_mom_list = set(param_dic['moms']) & set(param_dic['comms']) if comm_mom_list and shortname in comm_mom_list: # Excluding the server hostname for flag 'no_comm_on_mom' comm_mom_list.remove(shortname) if comm_mom_list: if eff_tc_req['no_comm_on_mom']: return False else: if not eff_tc_req['no_comm_on_mom']: return False
def __are_requirements_matching(param_dic=None, test=None): """ Validates test requirements against test cluster information returns True on match or error message otherwise None :param param_dic: dictionary of cluster information from data passed to param list :param_dic type: dic :param test: test object :test type: object :returns True or error message or None """ logger = logging.getLogger(__name__) ts_requirements = {} tc_requirements = {} param_count = {} _servers = set(param_dic['servers']) _moms = set(param_dic['moms']) _comms = set(param_dic['comms']) _nomom = set(param_dic['nomom']) _no_mom_on_server = param_dic['no_mom_on_server'] _no_comm_on_mom = param_dic['no_comm_on_mom'] _no_comm_on_server = param_dic['no_comm_on_server'] shortname = (socket.gethostname()).split('.', 1)[0] if test is None: return None test_name = getattr(test.test, '_testMethodName', None) if test_name is not None: method = getattr(test.test, test_name, None) if method is not None: tc_requirements = getattr(method, REQUIREMENTS_KEY, {}) cls = method.__self__.__class__ ts_requirements = getattr(cls, REQUIREMENTS_KEY, {}) if not tc_requirements: if not ts_requirements: return None eff_tc_req = get_effective_reqs(ts_requirements, tc_requirements) setattr(test.test, 'requirements', eff_tc_req) for key in ['servers', 'moms', 'comms', 'clients']: param_count['num_' + key] = len(param_dic[key]) for pk in param_count: if param_count[pk] < eff_tc_req[pk]: _msg = 'available ' + pk + " (" _msg += str(param_count[pk]) + ") is less than required " + pk _msg += " (" + str(eff_tc_req[pk]) + ")" logger.error(_msg) return _msg if hasattr(test, 'test'): _test = test.test elif hasattr(test, 'context'): _test = test.context else: return None name = 'moms' if (hasattr(_test, name) and (getattr(_test, name, None) is not None)): for mc in getattr(_test, name).values(): platform = mc.platform if platform not in ['linux', 'shasta', 'cray' ] and mc.hostname in _moms: _moms.remove(mc.hostname) for hostname in _moms: si = SystemInfo() si.get_system_info(hostname) available_sys_ram = getattr(si, 'system_ram', None) if available_sys_ram is None: _msg = 'failed to get ram info on host: ' + hostname logger.error(_msg) return _msg elif eff_tc_req['min_mom_ram'] >= available_sys_ram: _msg = hostname + ': available ram (' + str(available_sys_ram) _msg += ') is less than the minimum required ram (' _msg += str(eff_tc_req['min_mom_ram']) _msg += ') for test execution' logger.error(_msg) return _msg available_sys_disk = getattr(si, 'system_disk', None) if available_sys_disk is None: _msg = 'failed to get disk info on host: ' + hostname logger.error(_msg) return _msg elif eff_tc_req['min_mom_disk'] >= available_sys_disk: _msg = hostname + ': available disk space (' _msg += str(available_sys_disk) _msg += ') is less than the minimum required disk space (' _msg += str(eff_tc_req['min_mom_disk']) _msg += ') for test execution' logger.error(_msg) return _msg for hostname in param_dic['servers']: si = SystemInfo() si.get_system_info(hostname) available_sys_ram = getattr(si, 'system_ram', None) if available_sys_ram is None: _msg = 'failed to get ram info on host: ' + hostname logger.error(_msg) return _msg elif eff_tc_req['min_server_ram'] >= available_sys_ram: _msg = hostname + ': available ram (' + str(available_sys_ram) _msg += ') is less than the minimum required ram (' _msg += str(eff_tc_req['min_server_ram']) _msg += ') for test execution' logger.error(_msg) return _msg available_sys_disk = getattr(si, 'system_disk', None) if available_sys_disk is None: _msg = 'failed to get disk info on host: ' + hostname logger.error(_msg) return _msg elif eff_tc_req['min_server_disk'] >= available_sys_disk: _msg = hostname + ': available disk space (' _msg += str(available_sys_disk) _msg += ') is less than the minimum required disk space (' _msg += str(eff_tc_req['min_server_disk']) _msg += ') for test execution' logger.error(_msg) return _msg if _moms & _servers: if eff_tc_req['no_mom_on_server'] or \ (_nomom - _servers) or \ _no_mom_on_server: _msg = 'no mom on server' logger.error(_msg) return _msg if _comms & _servers: if eff_tc_req['no_comm_on_server'] or _no_comm_on_server: return False _msg = 'no comm on server' logger.error(_msg) return _msg comm_mom_list = _moms & _comms if comm_mom_list and shortname in comm_mom_list: # Excluding the server hostname for flag 'no_comm_on_mom' comm_mom_list.remove(shortname) if comm_mom_list: if eff_tc_req['no_comm_on_mom']: _msg = 'no comm on mom' logger.error(_msg) return _msg else: if not eff_tc_req['no_comm_on_mom']: _msg = 'no comm on server' logger.error(_msg) return _msg