def __init__(self, service, component, logname=None, stop_type='AMBARI', process_user=None, process_indicator=None, stop_realization_timeout=5, verify_loop_sleep_time=2, verification_count=10, kill_realization_timeout=30, filter_component_state=None): """ Instantiate the smoketest class :param service: The HDP component name ('KNOX' for example) :param component: The HDP component name ('KNOX_GATEWAY' for example) :param logname: Log file name :param stop_type: Stop type. One of ['AMBARI', 'KILL']. Other values are ignored (process isn't stopped) :param process_user: The user that runs the component's component. required if type is 'KILL' :param process_indicator: The unique identifier of the process in the 'ps -u <user> -f | grep <indicator>' command :param stop_realization_timeout: Sleep a while to let the stopping of the component sink in :param verify_loop_sleep_time: Sleep time between verifications :param verification_count: Number of times the verification needs to take place :param kill_realization_timeout: Let ambari realize the process has been killed to prevent the start command :param filter_component_state: Filter out component by state (e.g. "ACTIVE"/"STANDBY") when picking random host to shutdown being ignored """ super().__init__(component, logname=logname, stop_type=stop_type, process_user=process_user, process_indicator=process_indicator, stop_realization_timeout=stop_realization_timeout, verify_loop_sleep_time=verify_loop_sleep_time, verification_count=verification_count) self.service = service self.kill_realization_timeout = kill_realization_timeout self.filter_component_state = filter_component_state self.ambari = api.Api(logger=self.logger)
def stop_ranger_admin(self): ambari = api.Api(logger=self.logger) ranger_admin_ambari_info = ambari.get_component_info('RANGER', 'RANGER_ADMIN') rnd_ranger_host, rnd_ranger_component = ambari.get_random_host_and_component_path(ranger_admin_ambari_info) self.logger.info("Selected random Ranger admin host for stopping: {0}, {1}" .format(rnd_ranger_host, rnd_ranger_component)) ambari.change_host_component_state_and_wait(rnd_ranger_component, state='INSTALLED')
def __init__(self, request_timeout=10, logger=logging): self.timeout = request_timeout self.logger = logger self.ambari = ambari_api.Api(logger=self.logger) yarn_resourcemanager_ambari_info = self.ambari.get_component_info( 'YARN', 'RESOURCEMANAGER') yarn_resourcemanager_hosts = [ host['HostRoles']['host_name'] for host in yarn_resourcemanager_ambari_info['host_components'] ] self.yarn_resourcemanager_urls = [ "http://{0}:8088".format(host) for host in yarn_resourcemanager_hosts ]
def __init__(self, logger): super().__init__(logger) self.component_state = "ACTIVE" self.service = "YARN" self.component = "RESOURCEMANAGER" self.ambari = api.Api(logger=self.logger)
logger.addHandler(consoleHandler) logger.addHandler(errHandler) initial_log_message = """Starting Ranger smoketest. This smoketest will: 1. Turn off Ranger admin 2. Turn off HDFS namenode 3. Turn on HDFS namenode 4. Turn on Ranger The test checks if the namenode can stop/start without dependency on Ranger """ logger.info(initial_log_message) if __name__ == "__main__": initialize_logging() ambari = api.Api(logger=logger) hdfs = hdfs.Hdfs() clustername = 'Sandbox' try: ranger_admin_ambari_info = ambari.get_component_info( 'RANGER', 'RANGER_ADMIN') hdfs_namenode_ambari_info = ambari.get_component_info( 'HDFS', 'NAMENODE') if ambari.check_if_all_components_started('RANGER', 'RANGER_ADMIN') and \ ambari.check_if_all_components_started('HDFS', 'NAMENODE'): logger.info( "Both HDFS namenodes and Ranger admin are in normal state. Starting smoke test." ) rnd_ranger_host, rnd_ranger_component = ambari.get_random_host_and_component_path(