def check_nodes_info(utils,ssh,nodes_prefix,nodes_dir): x=0 for ndprefix in nodes_prefix: output=SSH_utils.execute_remote_cmd_failed(utils,ssh,"ls -l /var/SandboxDir/%s/%s"%(ndprefix,nodes_dir[x])) if output.find("No such file or directory")==-1: utils.log_info("Command failed for some other reason. Expected reason 'No such file or directory'") raise GeneralError("Execute command ls -l /var/SandboxDir/%s/%s"%(ndprefix,nodes_dir[x]),"Command failed for some other reason. Expected reasaon 'No such file or directory'") x=x+1
def test8(utils, ssh, title): utils.show_progress(title) utils.info(title) try: utils.set_dag_jdl(utils.get_jdl_file()) utils.info("Submit a DAG job") JOBID = utils.run_command_continue_on_error( "glite-wms-job-submit %s --config %s --nomsg %s" % (utils.get_delegation_options(), utils.get_config_file(), utils.get_jdl_file()) ) utils.info("Job submitted successfuly. Returned JOBID: %s" % (JOBID)) output = utils.run_command_continue_on_error( "glite-wms-job-status -c %s %s" % (utils.get_config_file(), JOBID) ).split("\n") nodes_prefix = [] nodes_dir = [] for line in output: if line.find("https://") != -1 and line.find(JOBID) == -1: id = line.split("Status info for the Job : ")[1] ndprefix = id.split("https://%s:9000/" % (utils.get_WMS()))[1][0:2] nodes_prefix.append(ndprefix) nodes_dir.append(SSH_utils.execute_remote_cmd(ssh, "ls /var/SandboxDir/%s" % (ndprefix))) prefix = JOBID.split("https://%s:9000/" % (utils.get_WMS()))[1][0:2] utils.info("Purge a DAG job") # WARNING EXECUTE COMMAND AS root INSTEAD OF glite USER utils.info("Execute '/usr/sbin/glite-wms-purgeStorage.sh -p /var/SandboxDir/%s -s' on remote host" % (prefix)) output = SSH_utils.execute_remote_cmd( ssh, "/usr/sbin/glite-wms-purgeStorage.sh -p /var/SandboxDir/%s -s" % (prefix) ) utils.info("Check glite-wms-purgeStorage.sh output") if output.find("%s: 3/3 nodes removed" % (JOBID)) != -1: utils.info("glite-wms-purgeStorage.sh successfully remove all the nodes of job %s" % (JOBID)) else: utils.error("glite-wms-purgeStorage.sh didn't remove successfully all the nodes of job %s" % (JOBID)) raise GeneralError( "Check glite-wms-purgeStorage.sh", "glite-wms-purgeStorage.sh didn't remove successfully all the nodes of job %s" % (JOBID), ) if output.find("%s: removed" % (JOBID)) != -1: utils.info("glite-wms-purgeStorage.sh successfully remove the job %s" % (JOBID)) else: utils.error("glite-wms-purgeStorage.sh didn't remove successfully the job %s" % (JOBID)) raise GeneralError( "Check glite-wms-purgeStorage.sh", "glite-wms-purgeStorage.sh didn't remove successfully the job %s" % (JOBID), ) utils.info("Check the SandBoxDir of nodes") x = 0 for ndprefix in nodes_prefix: output = SSH_utils.execute_remote_cmd_failed(ssh, "ls -l /var/SandboxDir/%s/%s1" % (ndprefix, nodes_dir[x])) if output.find("No such file or directory") == -1: utils.error("Command failed for some other reason. Expected reasaon 'No such file or directory'") raise GeneralError( "Execute command ls -l /var/SandboxDir/%s/%s" % (ndprefix, nodes_dir[x]), "Command failed for some other reason. Expected reasaon 'No such file or directory'", ) x = x + 1 utils.info("Check job's final status") utils.job_status(JOBID) if utils.get_job_status().find("Cleared") != -1: utils.info("Job's final status after purge is Cleared") else: utils.error("Job's final status after purge is not Cleared , instead we get %s" % (utils.get_job_status())) raise GeneralError( "Check job final status after purge", "Job's final status after purge is not Cleared , instead we get %s" % (utils.get_job_status()), ) utils.info("TEST OK") except (RunCommandError, GeneralError, TimeOutError), e: utils.log_error("%s" % (utils.get_current_test())) utils.log_error("Command: %s" % (e.expression)) utils.log_error("Message: %s" % (e.message)) utils.log_traceback("%s" % (utils.get_current_test())) utils.log_traceback(traceback.format_exc()) return 1