def _copy_logs(self): """ Copy logs from remote machines to local destination """ if "LOGS_DIRECTORY" in self.master_config.mapping: logs_dir = self.master_config.mapping.get("LOGS_DIRECTORY") else: logs_dir = self.dynamic_config_module.LOGS_DIRECTORY utils.makedirs(logs_dir) for deployer in runtime.get_deployers(): for process in deployer.get_processes(): logs = [] if (hasattr(self.dynamic_config_module, "process_logs")): logs += self.dynamic_config_module.process_logs( process.servicename) if (hasattr(self.dynamic_config_module, "machine_logs")): logs += self.dynamic_config_module.machine_logs().get( process.unique_id, []) if (hasattr(self.dynamic_config_module, "naarad_logs")): logs += self.dynamic_config_module.naarad_logs().get( process.unique_id, []) if hasattr(self.dynamic_config_module, 'log_patterns'): pattern = self.dynamic_config_module.log_patterns().get( process.unique_id, '^$') else: pattern = '^$' deployer.get_logs(process.unique_id, logs, logs_dir, pattern)
def _copy_logs(self): """ Copy logs from remote machines to local destination """ if "LOGS_DIRECTORY" in self.master_config.mapping: logs_dir = self.master_config.mapping.get("LOGS_DIRECTORY") else: logs_dir = self.dynamic_config_module.LOGS_DIRECTORY utils.makedirs(logs_dir) for deployer in runtime.get_deployers(): for process in deployer.get_processes(): logs = self.dynamic_config_module.machine_logs()[process.unique_id] + self.dynamic_config_module.naarad_logs()[process.unique_id] deployer.get_logs(process.unique_id, logs, logs_dir)
def _copy_logs(self): """ Copy logs from remote machines to local destination """ should_fetch_logs = runtime.get_active_config("should_fetch_logs", True) if should_fetch_logs: for deployer in runtime.get_deployers(): for process in deployer.get_processes(): logs = self.dynamic_config_module.process_logs( process.servicename) or [] logs += self.dynamic_config_module.machine_logs( process.unique_id) logs += self.dynamic_config_module.naarad_logs( process.unique_id) pattern = self.dynamic_config_module.log_patterns(process.unique_id) or constants.FILTER_NAME_ALLOW_ALL #now copy logs filtered on given pattern to local machine: deployer.fetch_logs(process.unique_id, logs, self._logs_dir, pattern)
def _copy_logs(self): """ Copy logs from remote machines to local destination """ should_fetch_logs = runtime.get_active_config("should_fetch_logs", True) if should_fetch_logs: for deployer in runtime.get_deployers(): for process in deployer.get_processes(): logs = self.dynamic_config_module.process_logs( process.servicename) or [] logs += self.dynamic_config_module.machine_logs( process.unique_id) logs += self.dynamic_config_module.naarad_logs( process.unique_id) pattern = self.dynamic_config_module.log_patterns(process.unique_id) or constants.FILTER_NAME_ALLOW_NONE #now copy logs filtered on given pattern to local machine: deployer.fetch_logs(process.unique_id, logs, self._logs_dir, pattern)
def _copy_logs(self): """ Copy logs from remote machines to local destination """ if "LOGS_DIRECTORY" in self.master_config.mapping: logs_dir = self.master_config.mapping.get("LOGS_DIRECTORY") else: logs_dir = self.dynamic_config_module.LOGS_DIRECTORY utils.makedirs(logs_dir) for deployer in runtime.get_deployers(): for process in deployer.get_processes(): logs = self.dynamic_config_module.machine_logs( )[process.unique_id] + self.dynamic_config_module.naarad_logs( )[process.unique_id] deployer.get_logs(process.unique_id, logs, logs_dir)
def _copy_logs(self): """ Copy logs from remote machines to local destination """ if "LOGS_DIRECTORY" in self.master_config.mapping: logs_dir = self.master_config.mapping.get("LOGS_DIRECTORY") else: logs_dir = self.dynamic_config_module.LOGS_DIRECTORY utils.makedirs(logs_dir) for deployer in runtime.get_deployers(): for process in deployer.get_processes(): logs = [] if (hasattr(self.dynamic_config_module, "process_logs")): logs += self.dynamic_config_module.process_logs(process.servicename) if (hasattr(self.dynamic_config_module, "machine_logs")): logs += self.dynamic_config_module.machine_logs().get(process.unique_id, []) if (hasattr(self.dynamic_config_module, "naarad_logs")): logs += self.dynamic_config_module.naarad_logs().get(process.unique_id, []) if hasattr(self.dynamic_config_module, 'log_patterns'): pattern = self.dynamic_config_module.log_patterns().get(process.unique_id, '^$') else: pattern = '^$' deployer.get_logs(process.unique_id, logs, logs_dir, pattern)
def run(self): """ This is the main executable function that will run the test """ self._setup() failure_handler = FailureHandler(self.master_config.mapping.get("max_suite_failures_before_abort")) naarad_obj = Naarad() for config in self.configs: config.mapping.iterkeys() self._reset_tests() if not failure_handler.get_abort_status(): config.result = constants.SKIPPED config.message += error_messages.CONFIG_ABORT self._skip_all_tests() logger.debug("Skipping " + config.name + "due to too many setup_suite/teardown_suite failures") else: runtime.set_active_config(config) setup_fail = False if not self.master_config.mapping.get("no_perf", False): try: naarad_config_file = self.dynamic_config_module.naarad_config() except TypeError: # Support backwards compatability naarad_config_file = self.dynamic_config_module.naarad_config(config.mapping) config.naarad_id = naarad_obj.signal_start(naarad_config_file) config.start_time = time.time() logger.info("Setting up configuration: " + config.name) try: if hasattr(self.deployment_module, 'setup_suite'): self.deployment_module.setup_suite() except BaseException: config.result = constants.SKIPPED config.message += error_messages.SETUP_SUITE_FAILED + traceback.format_exc() self._skip_all_tests() setup_fail = True failure_handler.notify_failure() logger.error("Aborting {0} due to setup_suite failure:\n{1}".format(config.name, traceback.format_exc())) else: try: logger.debug("Running tests for configuration: " + config.name) self._execute_run(config, naarad_obj) logger.debug("Tearing down configuration: " + config.name) finally: try: if hasattr(self.deployment_module, 'teardown_suite'): self.deployment_module.teardown_suite() if not setup_fail: failure_handler.notify_success() except BaseException: config.message += error_messages.TEARDOWN_SUITE_FAILED + traceback.format_exc() if not setup_fail: failure_handler.notify_failure() logger.error("{0} failed teardown_suite(). {1}".format(config.name, traceback.format_exc())) finally: # kill all orphaned process for deployer in runtime.get_deployers(): deployer.kill_all_process() config.end_time = time.time() logger.info("Execution of configuration: {0} complete".format(config.name)) tests = [test for test in self.tests if not isinstance(test, list)] +\ [individual_test for test in self.tests if isinstance(test, list) for individual_test in test] runtime.get_collector().collect(config, tests) # log results of tests so that it can be used easily via command-line self._log_results(tests) # analysis.generate_diff_reports() self.reporter.data_source.end_time = time.time() self.reporter.generate() if not self.master_config.mapping.get("no-display", False): self._display_results()
def run(self): """ This is the main executable function that will run the test """ self._setup() failure_handler = FailureHandler(self.master_config.mapping.get("max_suite_failures_before_abort")) naarad_obj = Naarad() for config in self.configs: config.mapping.iterkeys() self._reset_tests() if not failure_handler.get_abort_status(): config.result = constants.SKIPPED config.message += error_messages.CONFIG_ABORT self._skip_all_tests() logger.debug("Skipping " + config.name + "due to too many setup_suite/teardown_suite failures") else: runtime.set_active_config(config) setup_fail = False if not self.master_config.mapping.get("no_perf", False): try: naarad_config_file = self.dynamic_config_module.naarad_config() except TypeError: # Support backwards compatability naarad_config_file = self.dynamic_config_module.naarad_config(config.mapping) config.naarad_id = naarad_obj.signal_start(naarad_config_file) config.start_time = time.time() logger.info("Setting up configuration: " + config.name) try: if hasattr(self.deployment_module, 'setup_suite'): self.deployment_module.setup_suite() except BaseException: config.result = constants.SKIPPED config.message += error_messages.SETUP_SUITE_FAILED + traceback.format_exc() self._skip_all_tests() setup_fail = True failure_handler.notify_failure() logger.error("Aborting {0} due to setup_suite failure:\n{1}".format(config.name, traceback.format_exc())) else: try: logger.debug("Running tests for configuration: " + config.name) self._execute_run(config, naarad_obj) logger.debug("Tearing down configuration: " + config.name) finally: try: if hasattr(self.deployment_module, 'teardown_suite'): self.deployment_module.teardown_suite() if not setup_fail: failure_handler.notify_success() except BaseException: config.message += error_messages.TEARDOWN_SUITE_FAILED + traceback.format_exc() if not setup_fail: failure_handler.notify_failure() logger.error("{0} failed teardown_suite(). {1}".format(config.name, traceback.format_exc())) finally: # kill all orphaned process for deployer in runtime.get_deployers(): deployer.kill_all_process() config.end_time = time.time() logger.info("Execution of configuration: {0} complete".format(config.name)) tests = [test for test in self.tests if not isinstance(test, list)] +\ [individual_test for test in self.tests if isinstance(test, list) for individual_test in test] runtime.get_collector().collect(config, tests) # log results of tests so that it can be used easily via command-line self._log_results(tests) # analysis.generate_diff_reports() self.reporter.data_source.end_time = time.time() self.reporter.generate() if self.master_config.mapping.get("display", False) and not self.master_config.mapping.get("junit_reporter", False): self._display_results()