def run_repo_setup(self, options, conf_dict): """ run async_updates repo function using threads per host. """ threads = Threader() if self.build_repo_tag: logger.log.info("BUILD_REPO_TAG found in env") threads.gather_results([threads.get_item(self.copy_build_repo, \ host, conf_dict) for host in \ self.existing_nodes]) else: logger.log.info("BUILD_REPO_TAG not found in env") if options.build_repo: logger.log.info("Manual repo to be copied to resources.") self.build_repo = options.build_repo threads.gather_results([threads.get_item(self.my_build_repo, \ host, conf_dict) for host in \ self.existing_nodes]) if "z-candidate" in self.brew_tag: logger.log.info("brew tag is for z-candidate, hence picking batched repo from conf.") threads.gather_results([threads.get_item(self.copy_async_updates_repo, \ host, conf_dict) for host in \ self.existing_nodes]) else: logger.log.info("brew tag is not for z-candidate, hence not picking any batched repo from conf.")
def run_restraint(self, options, conf_dict): """ Call restraint_setup function using threads per host. """ logger.log.info("Running restraint...") threads = Threader() self.job_name = conf_dict['jenkins']['job_name'] self.git_repo_url = conf_dict['git']['git_repo_url'] self.git_test_branch = conf_dict['git']['git_test_branch'] if options.restraint_xml is None: self.jenkins_workspace = conf_dict['jenkins']['workspace'] try: self.restraint_xml_loc = conf_dict['restraint_jobs'][self.jenkins_job_name] self.restraint_xml = os.path.join(self.jenkins_workspace, \ self.restraint_xml_loc) except KeyError: logger.log.warn("restraint xml not found in conf file, check with WHAT_TEST") self.what_test = os.environ.get("WHAT_TEST") + ".xml" self.restraint_job_xml_loc = conf_dict['restraint']['job_xml_loc'] self.restraint_xml = os.path.join(self.restraint_job_xml_loc, self.what_test) threads.gather_results([threads.get_item(self.restraint_setup, \ host, conf_dict) for host in \ self.existing_nodes]) else: self.restraint_xml = options.restraint_xml threads = Threader() threads.gather_results([threads.get_item(self.restraint_setup, \ host, conf_dict) for host in \ self.existing_nodes]) logger.log.info("Using %s" % self.restraint_xml) if len(self.existing_nodes) == 1: logger.log.info("Found single host in existing_nodes") logger.log.info("single node: %s" % self.existing_nodes) self.restraint_update_xml() self.execute_restraint() else: logger.log.info("Found multiple hosts in existing_nodes") logger.log.info("multiple nodes: %s" % self.existing_nodes) self.restraint_update_xml() self.execute_restraint()
def run_repo_setup(self, options, conf_dict): """ run async_updates repo function using threads per host. """ threads = Threader() threads.gather_results([threads.get_item(self.install_yum_utils, \ host, conf_dict) for host in \ self.existing_nodes]) if conf_dict.has_key('repos'): logger.log.info("repos section detected.") threads.gather_results([threads.get_item(self.create_repos_section, \ host, conf_dict) for host in \ self.existing_nodes]) else: logger.log.info("repos section not found.") threads.gather_results([threads.get_item(self.install_yum_utils, \ host, conf_dict) for host in \ self.existing_nodes]) if self.build_repo_tag: logger.log.info("BUILD_REPO_TAG found in env") threads.gather_results([threads.get_item(self.copy_build_repo, \ host, conf_dict) for host in \ self.existing_nodes]) else: logger.log.info("BUILD_REPO_TAG not found in env") if options.build_repo: logger.log.info("Manual repo to be copied to resources.") self.build_repo = options.build_repo threads.gather_results([threads.get_item(self.my_build_repo, \ host, conf_dict) for host in \ self.existing_nodes]) if "z-candidate" in self.brew_tag: logger.log.info("brew tag is for z-candidate, hence picking batched repo from conf.") threads.gather_results([threads.get_item(self.copy_async_updates_repo, \ host, conf_dict) for host in \ self.existing_nodes]) else: logger.log.info("brew tag is not for z-candidate, hence not picking any batched repo from conf.") if self.task_repo_urls and self.static_repo_url: logger.log.info("STATIC_REPO_URLS from env variable is %s" % self.static_repo_url) logger.log.info("TASK_REPO_URLS from env variable is %s" % self.task_repo_urls) logger.log.info("Check and copy task_repo if dist is appropriate") threads.gather_results([threads.get_item(self.copy_task_repo, \ host, conf_dict) for host in \ self.existing_nodes]) else: logger.log.info("TASK_REPO_URLS env variable not found") if self.static_repo_url: logger.log.info("Check and copy static_repo if dist is appropriate") threads.gather_results([threads.get_item(self.copy_static_repo, \ host, conf_dict) for host in \ self.existing_nodes]) else: logger.log.info("STATIC_REPO_URLS env variable not found")
def run_repo_setup(self, options, conf_dict): """ run async_updates repo function using threads per host. """ threads = Threader() if self.build_repo_tag: logger.log.info("BUILD_REPO_TAG found in env") threads.gather_results([threads.get_item(self.copy_build_repo, \ host, conf_dict) for host in \ self.existing_nodes]) else: logger.log.info("BUILD_REPO_TAG not found in env") if options.build_repo: logger.log.info("Manual repo to be copied to resources.") self.build_repo = options.build_repo threads.gather_results([threads.get_item(self.my_build_repo, \ host, conf_dict) for host in \ self.existing_nodes]) if "z-candidate" in self.brew_tag: logger.log.info( "brew tag is for z-candidate, hence picking batched repo from conf." ) threads.gather_results([threads.get_item(self.copy_async_updates_repo, \ host, conf_dict) for host in \ self.existing_nodes]) else: logger.log.info( "brew tag is not for z-candidate, hence not picking any batched repo from conf." )
def run_pytest(self, options, conf_dict): """ Run pytest command using the marker if provided """ threads = Threader() threads.gather_results([threads.get_item(self.deploy_ssh_keys, \ host, conf_dict) for host in \ self.existing_nodes]) threads.gather_results([threads.get_item(self.install_prereqs, \ host, conf_dict) for host in \ self.existing_nodes]) threads.gather_results([threads.get_item(self.copy_extras_repo, \ host, conf_dict) for host in \ self.existing_nodes]) threads.gather_results([threads.get_item(self.install_prereqs, \ host, conf_dict) for host in \ self.existing_nodes]) logger.log.info("Updating %s with existing_nodes information" % self.tests_cfg) node = 0 host_num = 1 host_recipe = [] while node < len(self.existing_nodes): host_num = str(host_num) hostname = ("hostname" + host_num); host_num = int(host_num) j = open(self.tests_cfg, 'r').read() m = j.replace(hostname, (self.existing_nodes[node])) f = open(self.tests_cfg, 'w') f.write(m) f.close() node = node + 1 host_num = host_num + 1 threads.gather_results([threads.get_item(self.pytest_setup, \ host, conf_dict) for host in \ self.existing_nodes]) if options.coverage is True: coverage = Testcoverage(options, conf_dict) coverage.run_coverage(options, conf_dict) logger.log.info("Coverage option set.") else: logger.log.info("Coverage option not set.") self.tests_to_run = conf_dict['pytest']['tests_to_run'] self.tests_cfg = conf_dict['pytest']['tests_cfg'] self.pytest_junit_loc = conf_dict['pytest']['pytest_junit_loc'] ci_msg = CI_MSG() try: ttypes = ci_msg.get_ci_msg_value('testtypes') except Exception: pass ttypes = None try: ttiers = ci_msg.get_ci_msg_value('testtiers') except Exception: pass ttiers = None patterns = [] if ttypes is None and ttiers is None: logger.log.info("Both test-tier and test-type options are none in CI_MESSAGE") pytest_cmd = "py.test -v --color=yes --junit-xml=" + self.pytest_junit_loc + \ " --multihost-config=" + self.tests_cfg + " " + self.tests_to_run logger.log.info(pytest_cmd) else: pytest_cmd = "py.test --junit-xml=" + self.pytest_junit_loc + \ " --multihost-config=" + self.tests_cfg + " " + self.tests_to_run logger.log.info(pytest_cmd) if ttypes is None: logger.log.info("test-type is none in CI_MESSAGE") else: for item in ttypes: mystr = "-m" + " " + item patterns.append(mystr) if ttiers is None: logger.log.info("test-tier is none in CI_MESSAGE") else: for item in ttiers: mystr = "-m" + " " + item patterns.append(mystr) pytest_patterns = " ".join(patterns) pytest_cmd = pytest_cmd + " " + pytest_patterns logger.log.info(pytest_cmd) host = self.existing_nodes[0] ssh_c = SSHClient(hostname = host, username = \ self.username, password = self.password) stdout,stderr,exit_status = ssh_c.ExecuteScript(pytest_cmd) output = stdout.getvalue() error = stderr.getvalue() if error: print "error running script: ", error print "Exit status : ", exit_status else: print "Script Output: ", output stdout.close() stderr.close() try: self.copy_testout_junit(options, conf_dict) except IOError: logger.log.info("Junit xml file not found.") pass