예제 #1
0
class WmpTest(unittest.TestCase):
	"""
	SetUp methods:
	"""
	def setUp(self):
		self.wmpconfig = WMPConfig(url)
		self.wmpconfig.setNs(ns)
		flag = True
		self.wmpconfig.setAuth(flag)
		self.wmproxy = Wmproxy(self.wmpconfig)

	def tearDown(self):
		self.wmproxy = ""

	"""
	SANDBOX / OUTPUT
	"""
	def testgetSandboxDestURI(self):
		jobURI = self.wmproxy.getSandboxDestURI(jobid.getJobId(),protocol)
		dagURI = self.wmproxy.getSandboxDestURI(dagad.getJobId(),protocol)
		title("testgetSandboxDestURI: ", jobURI,dagURI)
		assert jobURI, "Wrong DEST URI!! (jobid)"
		assert dagURI, "Wrong DEST URI!! (dagad)"

	def testgetSandboxBulkDestURI(self):
		protocol=""
		jobURI=self.wmproxy.getSandboxBulkDestURI(jobid.getJobId(),protocol)
		#dagURI=self.wmproxy.getSandboxBulkDestURI(dagad.getJobId(),protocol)
		dagURI=""
		title("testgetSandboxBulkDestURI: ", jobURI,dagURI)
		if jobURI:
			for jid in jobURI.keys():
				uris = jobURI[jid]
				for uri in uris:
					print "URI RECEIVED: " , uri

		assert jobURI, "Wrong DEST URI!! (jobid)"
		# assert dagURI, "Wrong DEST URI!! (dagad)"
		if jobURI:
			for jid in jobURI.keys():
				uris = jobURI[jid]
				"URIS DAG", uris


	def testgetTransferProtocols(self):
		protocols = self.wmproxy.getTransferProtocols()
		title ("transferProtocols are:", protocols)

	def testgetOutputFileList(self):
		for protocol in ["https"]:
			jobFL = self.wmproxy.getOutputFileList(jobid.getJobId(),protocol)
			title("getOutputFiles with '"+protocol +"' are (both of them might be empty):",jobFL)
		#jobFL = self.wmproxy.getOutputFileList(jobid.getJobId())
		#title("getOutputFiles WITHOUT protocol are (both of them might be empty):", jobFL)

	"""
	SUBMISSION
	"""
	def testcollectionSubmit(self):
		dagadInstance=self.wmproxy.jobSubmit(jdl.getJdl(collectionjdl), delegationId)
		assert dagadInstance, "Empty DAGAD!!!"
		dagad.setJobId(dagadInstance.getJobId())

	def testcollectionSubmitOne(self):
		dagadInstance=self.wmproxy.jobSubmit(jdl.getJdl(collectionjdlUNO), delegationId)
		assert dagadInstance, "Empty DAGAD!!!"
		dagad.setJobId(dagadInstance.getJobId())

	def testdagSubmit(self):
		dagadInstance=self.wmproxy.jobSubmit(jdl.getJdl(dagjdl2), delegationId)
		assert dagadInstance, "Empty DAGAD!!!"
		dagad.setJobId(dagadInstance.getJobId())
	def testjobSubmit(self):
		jobidInstance =self.wmproxy.jobSubmit(jdl.getJdl(jobjdl), delegationId)
		assert  jobidInstance , "Empty JobId!!"
		jobid.setJobId(jobidInstance.getJobId())

	def testjobStart(self):
		jobidInstance =self.wmproxy.jobStart(jobid.getJobId())
		assert  jobidInstance , "Empty JobId!!"
		jobid.setJobId(jobidInstance.getJobId())

	def testjobListMatch(self):
		matchingCEs=self.wmproxy.jobListMatch(jdl.getJdl(jobjdl), delegationId)
		assert  matchingCEs , "Empty JobId!!"

	def testJobRegisterJSDL(self):
		for jd in [jdl.getJdl(jobjdl)]:
			jobidInstance = self.wmproxy.jobRegister(jd,delegationId)
			jobid.setJobId(jobidInstance.getJobId())
			title("testJobRegister: Registered", jobid.getJobId())

	def testJobRegister(self):
		for jd in [jdl.getJdl(jobjdl)]:
			jobidInstance = self.wmproxy.jobRegister(jd,delegationId)
			jobid.setJobId(jobidInstance.getJobId())
			title("testJobRegister: Registered", jobid.getJobId())

	def testcycleJob(self):
		for jd in [jdl.getJdl(jobjdl)]:
			title("Cycle Job: Registering..")
			jobidInstance = self.wmproxy.jobRegister(jd,delegationId)
			jobid.setJobId(jobidInstance.getJobId())
			title("Cycle Job: jobid is:" , jobid.getJobId())
			title("Cycle Job:  getSandboxDestURI...",self.wmproxy.getSandboxDestURI(jobid.getJobId()))
			title("Cycle Job:  getSandboxBulkDestURI...", self.wmproxy.getSandboxBulkDestURI(jobid.getJobId()))
			title("Cycle Job:  getFreeQuota...", self.wmproxy.getFreeQuota())
			title("Cycle Job:  Starting the job....",self.wmproxy.jobStart(jobid.getJobId()))
			title("Cycle Job: FINISH!")

	def testcycleDag(self):
		for jdl in [jdl.getJdl(dagjdl)]:
			title("Cycle Job: Registering..")
			dagid= self.wmproxy.jobRegister(jdl,delegationId)
			dagid=dagid.getJobId()
			title("Cycle Job: jobid is:" , dagid)
			title("Cycle Job:  getSandboxDestURI...")
			title(self.wmproxy.getSandboxDestURI(dagid))
			title("Cycle Job:  getSandboxBulkDestURI...")
			title(self.wmproxy.getSandboxBulkDestURI(dagid))
			title("Cycle Job:  getFreeQuota...")
			title(self.wmproxy.getFreeQuota())
			title("Cycle Job:  Starting the job....")
			self.wmproxy.jobStart(dagid)
			title("Cycle Job: FINISH!")
	"""
	TEMPLATES
	"""
	def testgetStringParametricJobTemplate(self):
		attributes  = ["Executable" , "Arguments"]
		param = ["un","dos","tres"]
		assert self.wmproxy.getStringParametricJobTemplate(attributes, param, requirements, rank), "Empty Template!!"
	def testgetIntParametricJobTemplate(self):
		attributes  = ["Executable" , "Arguments"]
		param = 4
		parameterStart=1
		parameterStep=1
		assert self.wmproxy.getIntParametricJobTemplate(attributes, param, parameterStart, parameterStep, requirements, rank), "Empty Template!!"
	def testgetCollectionTemplate(self):
		jobNumber=5
		assert  self.wmproxy.getCollectionTemplate(jobNumber, requirements, rank), "Empty Template!!"
	def testgetJobTemplate(self):
		jobType =[]
		executable ="/bin/ls"
		arguments = "/tmp/*"
		title(self.wmproxy.getJobTemplate(jobType, executable, arguments, requirements, rank))
		assert self.wmproxy.getJobTemplate(jobType, executable, arguments, requirements, rank), "Empty Template!!"
	def testgetDAGTemplate(self):
		dependencies={}
		assert  self.wmproxy.getDAGTemplate(dependencies,requirements, rank), "Empty Template!!"

	"""
	Perusal
	"""
	def testgetPerusalFiles(self):
		file="std.err"
		allChunks = True
		assert self.wmproxy.getPerusalFiles(jobid.getJobId(), file, allChunks), "No Perusal file retrieved (perhaps not yet generated)"
	def testenableFilePerusal(self):
		fileList=["std.out", "std.err"]
		self.wmproxy.enableFilePerusal(jobid.getJobId(), fileList)

	def testJobProxyInfo(self):
		pi=self.wmproxy.getJobProxyInfo(jobid.getJobId())
		return pi
	def testGetJDL(self):
		for  jdlType in [0,1]:
			pi=self.wmproxy.getJDL(jobid.getJobId(),jdlType)
			title("getJDL:", pi)
		return pi


	"""
	Proxy
	"""
	def testgetProxyReq(self):
		gpr = self.wmproxy.getProxyReq(delegationId)
		title("getProxyReq (wmp namespace)", gpr)
		assert gpr
                gpr = self.wmproxy.getProxyReq(delegationId, self.wmpconfig.getGrstNs())
		title("getProxyReq (grst namespace)", gpr)
		assert gpr
	def testSignProxyCert(self):
		import time
		import os
		result = ""
		cert = ""
		proxycert = self.wmproxy.getProxyReq(delegationId)
		print proxycert
		assert proxycert
		os.environ["PROXY_REQ"]=proxycert
		print "Executing signProxyReq...."
		#result = self.wmproxy.signProxyReqStr(proxycert)
		result = self.wmproxy.signProxyReqEnv("PROXY_REQ")
		print result
		print "Executing putProxy...."
		self.wmproxy.putProxy(delegationId,result )
		print "Executing job submission...."
		self.wmproxy.jobSubmit(jdl.DEFAULT_JDL, delegationId)
	def testputProxy(self):
		assert self.wmproxy.putProxy(delegationId,jobid.getJobId())
	"""
	GridSite
	"""

	def testgetProxyReqGrst(self):
		prg= self.wmproxy.getProxyReq(delegationId,self.wmproxy.getGrstNs())
		assert prg
		title ("testgetProxyReqGrst output:",prg)
		return prg

	def testputProxyGrst(self):
		proxy= self.wmproxy.getProxyReq(delegationId,self.wmproxy.getGrstNs())
		#title ("testputProxyGrst input:",delegationId,proxy)
		self.wmproxy.putProxy(delegationId, proxy ,self.wmproxy.getGrstNs())

	def testDelegatedProxyInfo(self):
		pi= self.wmproxy.getDelegatedProxyInfo(delegationId)
		assert pi
		title ("testDelegatedProxyInfo output:",pi)
		return pi

	def testgetTerminationTimeGrst(self):
		re=self.wmproxy.getTerminationTime(delegationId,self.wmproxy.getGrstNs())
		assert re
		title ("testgetTerminationTimeGrst output:",re)

	def testrenewProxyReqGrst(self):
		re=self.wmproxy.renewProxyReq(delegationId,self.wmproxy.getGrstNs())
		assert re
		title ("testrenewProxyReqGrst output:",re)

	def testDestroyGrst(self):
		self.wmproxy.destroy(delegationId,self.wmproxy.getGrstNs())

	def testgetNewProxyReqGrst(self):
		re = self.wmproxy.getNewProxyReq(self.wmproxy.getGrstNs())
		assert re
		title ("testgetNewProxyReqGrst output:",re)

	"""
	Other
	"""
	def testaddACLItems(self):
		items=["un", "due", "tre", "prova"]
		return self.wmproxy.addACLItems(jobid.getJobId(), items)