def testPerfMon(jobOptName="PerfMonTests/test_perfMonSvc_noopalg.py", perfMonFileName="perfmon.noopalg.root", evtMax=50000): print("") print("#" * 80) print("## testing PerfMonSvc [%s]" % jobOptName) print(" ==> [%s]... (%i)" % (perfMonFileName, evtMax)) perfMonFileName = workDir(perfMonFileName) refPerfMonFileName = "ref." + os.path.basename(perfMonFileName) chkPerfMonFileName = "chk." + os.path.basename(perfMonFileName) outPerfMonFileName = "ana." + os.path.basename(perfMonFileName) refPerfMonFileName = refPerfMonFileName.replace(".root", ".pmon.gz") chkPerfMonFileName = chkPerfMonFileName.replace(".root", ".pmon.gz") ## create the reference file athena = ChapPy.Athena(jobOptions=[ ChapPy.JobOptions(jobOptName), ChapPy.JobOptionsCmd("jobproperties.PerfMonFlags.OutputFile = '%s'" % refPerfMonFileName) ], checkLeak=False, logFile=refPerfMonFileName + ".log") athena.EvtMax = evtMax sc = athena.run() if sc != 0: print("ERROR: could not create the 'ref' perfmon file !!") return ScOutput(sc, "ERROR") ## create the to-be-checked file athena = ChapPy.Athena(jobOptions=[ ChapPy.JobOptions(jobOptName), ChapPy.JobOptionsCmd("jobproperties.PerfMonFlags.OutputFile = '%s'" % chkPerfMonFileName) ], checkLeak=False, logFile=chkPerfMonFileName + ".log") athena.EvtMax = evtMax sc = athena.run() if sc != 0: print("ERROR: could not create the 'chk' perfmon file !!") return ScOutput(sc, "ERROR") #outPerfMonFileName = "ana." + os.path.basename( perfMonFileName ) print(" :::running [perfmon.py]...") cmd = "perfmon.py %s %s -o %s" % \ ( chkPerfMonFileName, refPerfMonFileName, outPerfMonFileName ) sc, out = subprocess.getstatusoutput(cmd) if sc != 0: print("## Problem while doing [perfmon] !!") print(out) out = "ERROR" return ScOutput(sc, out) out = "OK" print("## [DONE]") return ScOutput(sc, out)
def testPerfMon(jobOptName="PerfMonTests/test_perfMonSvc_noopalg.py", perfMonFileName="perfmon.noopalg.pmon.gz", evtMax=50000): print "" print "#" * 80 print "## testing PerfMonSvc [%s]" % jobOptName print " ==> [%s]... (%i)" % (perfMonFileName, evtMax) refPerfMonFileName = "ref." + os.path.basename(perfMonFileName) chkPerfMonFileName = "chk." + os.path.basename(perfMonFileName) outPerfMonFileName = "ana." + os.path.basename(perfMonFileName) ## create the reference file athena = ChapPy.Athena(jobOptions=[ChapPy.JobOptions(jobOptName)], checkLeak=False, logFile=refPerfMonFileName + ".log") athena.EvtMax = evtMax athena.run() os.rename("perfmon.pmon.gz", refPerfMonFileName) ## create the to-be-checked file athena = ChapPy.Athena(jobOptions=[ChapPy.JobOptions(jobOptName)], checkLeak=False, logFile=chkPerfMonFileName + ".log") athena.EvtMax = evtMax athena.run() os.rename("perfmon.pmon.gz", chkPerfMonFileName) print " :::running [perfmon.py]..." cmd = "perfmon.py -o %s %s %s --labels 'chk,ref'" % \ ( outPerfMonFileName, chkPerfMonFileName, refPerfMonFileName ) sc, out = commands.getstatusoutput(cmd) if sc != 0: print "## Problem while doing [perfmon] !!" print out else: print "## [DONE]" return sc
installRefFiles([ "mc.aod.symlinks.ref", "mc.aod.pysymlinks.ref", ]) evtMax = 5 ###----------------------------------------------------- print("## Testing [writing]...") jobOptions = [ ChapPy.JobOptionsCmd("OUTPUT=\"%s\"" % workDir("mc.aod.symlinks.pool")), ChapPy.JobOptions("McParticleTests/symlinkTest_mcAod_jobOptions.py"), ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=workDir("mc.aod.symlinks.pool.log"), checkLeak=False) athena.EvtMax = evtMax athena.run() ###----------------------------------------------------- print("\n") print("#" * 80) bench += doPostCheck("McAod symlinks", workDir("mc.aod.symlinks.ref"), workDir("mc.aod.symlinks.pool.log"), "grep \"^McAodSymLinkTests\"") ###----------------------------------------------------- print("") print("#" * 80) print("## testing py-symlinks for TruthParticleContainer...")
def doReadWriteTest(genName="TruthParticles", evtMax=100): ###----------------------------------------------------- print("\n") print("#" * 80) print("## Preparing input data... [%s]" % genName) templateJobO = """ OUTPUT='%(OutputFile)s'; DUMP=True; include( 'McParticleTests/iotest_WriteGenEvent_jobOptions.py' ); """ jobOptions = [ ChapPy.JobOptionsCmd(templateJobO % { 'OutputFile': workDir("mc.event.%s.pool" % uuid), }) ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=workDir("mc.event.%s.pool.log" % uuid), checkLeak=False) athena.EvtMax = evtMax sc = athena.run() if sc != 0: return ScOutput(sc, "ERROR") ###----------------------------------------------------- print("\n") print("#" * 80) print("## Testing [writing-%s]..." % genName) templateJobO = """ INPUT=['%(InputFile)s']; OUTPUT= '%(OutputFile)s'; DUMPTUPLE=True; TUPLEFILENAME='%(TupleFile)s'; include( 'McParticleTests/iotest_WriteTruthParticles_jobOptions.py' ); jobproperties.PerfMonFlags.OutputFile = '%(PmonFile)s'; """ jobOptions = [ ChapPy.JobOptionsCmd( templateJobO % { 'InputFile': workDir("mc.event.%s.pool" % uuid), 'OutputFile': outFiles['ref'], 'TupleFile': outFiles['ref'].replace(".pool", ".tuple.root"), 'PmonFile': workDir("write.mcaod.%s.%s.perfmon.pmon.gz" % (genName, uuid)), }) ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=outFiles['ref'] + ".log", checkLeak=False) athena.EvtMax = evtMax sc = athena.run() if sc != 0: return ScOutput(sc, "ERROR") else: inFile = workDir("write.mcaod.%s.%s.perfmon.pmon.gz" % (genName, uuid)) outFile = workDir("out.write.mcaod.%s.%s.perfmon.root" % (genName, uuid)) subprocess.getoutput("perfmon.py %s -o %s" % (inFile, outFile)) ###----------------------------------------------------- print("\n") print("#" * 80) print("## Testing [reading-%s]..." % genName) templateJobO = """ INPUT=['%(InputFile)s']; OUTPUT= '%(OutputFile)s'; DUMPTUPLE=True; TUPLEFILENAME='%(TupleFile)s'; include( 'McParticleTests/iotest_ReadTruthParticles_jobOptions.py' ); jobproperties.PerfMonFlags.OutputFile = '%(PmonFile)s'; """ jobOptions = [ ChapPy.JobOptionsCmd( templateJobO % { 'InputFile': outFiles['ref'], 'OutputFile': outFiles['chk'], 'TupleFile': outFiles['chk'].replace(".pool", ".tuple.root"), 'PmonFile': workDir("read.mcaod.%s.%s.perfmon.pmon.gz" % (genName, uuid)), }) ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=outFiles['chk'] + ".log", checkLeak=False) athena.EvtMax = evtMax sc = athena.run() if sc != 0: return ScOutput(sc, "ERROR") else: inFile = workDir("read.mcaod.%s.%s.perfmon.pmong.gz" % (genName, uuid)) outFile = workDir("out.read.mcaod.%s.%s.perfmon.root" % (genName, uuid)) subprocess.getoutput("perfmon.py %s -o %s" % (inFile, outFile)) ###----------------------------------------------------- print("\n") print("#" * 80) return doMcAodTupleValidation( outFiles['ref'].replace(".pool", ".tuple.root"), outFiles['chk'].replace(".pool", ".tuple.root"))
"pyWriteSlimmedData.ref", "ReadSlimmedData.ref", "ReadNonSlimmedData.ref", ]) ###----------------------------------------------------- print "\n" print "#" * 80 print "## Preparing input data..." jobOptions = [ ChapPy.JobOptionsCmd("OUTPUT=\"%s\"" % workDir("my.pydata.toslim.pool")), ChapPy.JobOptions("AthExThinning/AthExThinning_makeData.py"), ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=workDir("my.pydata.toslim.pool.log"), checkLeak=False) athena.EvtMax = EVTMAX athena.run() ###----------------------------------------------------- print "\n" print "#" * 80 sc, out = doValidation("Input Data", workDir("AthExThinning_makeData.ref"), workDir("my.pydata.toslim.pool.log"), "grep '^CreateData' | grep INFO ") if sc != 0: raise SystemExit("ERROR") ###----------------------------------------------------- print "\n"
print "#"*80 print "## testing TruthParticleContainer I/O..." print "## Job uuid:",uuid benchSequence = BenchSequence( "TruthParticleContainer I/O" ) ###----------------------------------------------------- if os.path.exists(genEventFile): print "## Re-using input data..." else: print "## Preparing input data..." jobOptions = [ ChapPy.JobOptionsCmd( "OUTPUT=\"%s\"" % genEventFile ), ChapPy.JobOptionsCmd( "DUMP=False" ), ChapPy.JobOptions( "McParticleTests/iotest_WriteGenEvent_jobOptions.py" ), ] athena = ChapPy.Athena( jobOptions = jobOptions, checkLeak = False ) athena.EvtMax = EVTMAX athena.run() pass ###----------------------------------------------------- print "\n\n" print "#"*80 print "## Testing [writing]..." jobOptions = [ ChapPy.JobOptionsCmd( "INPUT=[\"%s\"]" % genEventFile ), ChapPy.JobOptionsCmd( "OUTPUT=\"%s\"" % mcAodFile ), ChapPy.JobOptionsCmd( "DUMP=False" ), ChapPy.JobOptions( "McParticleTests/iotest_WriteTruthParticles_jobOptions.py" ), ]
if 0: ###----------------------------------------------------- print "\n" print "#" * 80 print "## Testing [reading 12.0.4 data]..." jobOptions = [ ChapPy.JobOptionsCmd( templateJobO % { 'InputFile': asciiFiles['rel_1204']['in'], 'OutputFile': workDir("reaccessed.mc.events_rel12.pool"), 'AsciiChk': asciiFiles['rel_1204']['chk'], }) ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=workDir("read.genevent.rel_1204.log"), checkLeak=False) athena.EvtMax = 10 athena.run() ###----------------------------------------------------- print "\n" print "#" * 80 bench += doValidation(asciiFiles, 'rel_1204') pass print "" print "#" * 80 bench.printStatus() print "## Bye." print "#" * 80
def doReadWriteTest(genName="pythia", evtMax=100): """A simple wrapper around the read/write tests...""" genName = genName.lower() ###----------------------------------------------------- print "" print "#" * 80 print "## Testing [writing-%s]..." % genName templateJobO = """ OUTPUT='%(OutputFile)s'; DUMPTUPLE=True; GENERATOR='%(Generator)s'; TUPLEFILENAME='%(TupleFile)s'; include( 'McParticleTests/iotest_WriteGenEvent_jobOptions.py' ); jobproperties.PerfMonFlags.OutputFile = '%(PmonFile)s'; """ jobOptions = [ ChapPy.JobOptionsCmd( templateJobO % { 'OutputFile' : workDir("mc.event.%s.pool" % genName), 'Generator' : genName.upper(), 'TupleFile' : outFiles['gen_%s' % genName]['ref']\ .replace(".pool",".tuple.root"), 'PmonFile' : workDir("write.genevent.%s.pmon.gz" % genName), } ) ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=workDir("write.genevent.%s.log" % genName), checkLeak=False) athena.EvtMax = evtMax sc = athena.run() if sc != 0: return ScOutput(sc, "ERROR") else: inFile = workDir("write.genevent.%s.pmon.gz" % genName) outFile = workDir("out.write.genevent.%s.pmon.root" % genName) print commands.getoutput("perfmon.py %s -o %s" % (inFile, outFile)) ###----------------------------------------------------- print "" print "#" * 80 print "## Testing [ASCII-writing-%s (1)]..." % genName templateJobO = """ INPUT=%(InputFile)s; OUTPUT='%(OutputFile)s'; DUMPTUPLE=True; GENERATOR='%(Generator)s'; include( 'McParticleAlgs/GenEventAsciiWriter_jobOptions.py' ); """ jobOptions = [ ChapPy.JobOptionsCmd( templateJobO % { 'InputFile': [ workDir("mc.event.%s.pool" % genName), ], 'OutputFile': workDir("mc.event.%s.1.ascii" % genName), 'Generator': genName.upper(), }) ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=workDir("write.genevent.ascii.1.%s.log" % genName), checkLeak=False) athena.EvtMax = evtMax sc = athena.run() if sc != 0: return ScOutput(sc, "ERROR") ###----------------------------------------------------- print "" print "#" * 80 print "## Testing [ASCII-writing-%s (2)]..." % genName templateJobO = """ INPUT=%(InputFile)s; OUTPUT='%(OutputFile)s'; DUMPTUPLE=True; GENERATOR='%(Generator)s'; include( 'McParticleAlgs/GenEventAsciiWriter_jobOptions.py' ); """ jobOptions = [ ChapPy.JobOptionsCmd( templateJobO % { 'InputFile': [ workDir("mc.event.%s.pool" % genName), ], 'OutputFile': workDir("mc.event.%s.2.ascii" % genName), 'Generator': genName.upper(), }) ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=workDir("write.genevent.ascii.2.%s.log" % genName), checkLeak=False) athena.EvtMax = evtMax sc = athena.run() if sc != 0: return ScOutput(sc, "ERROR") ###----------------------------------------------------- print "\n" print "#" * 80 print "## Testing [ASCII-reading-%s]..." % genName templateJobO = """ INPUT=%(InputFiles)s; include( 'McAsciiEventSelector/Example_McAsciiReader_jobOptions.py' ); """ jobOptions = [ ChapPy.JobOptionsCmd( templateJobO % { 'InputFiles' : [ workDir("mc.event.%s.1.ascii" % genName), workDir("mc.event.%s.2.ascii" % genName),], 'TupleFile' : outFiles['gen_%s' % genName]['chk']\ .replace(".pool",".tuple.root"), 'PmonFile' : workDir("read.genevent.%s.pmon.gz" % genName), } ) ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=workDir("read.genevent.%s.log" % genName), checkLeak=False) athena.EvtMax = evtMax sc = athena.run() if sc != 0: return ScOutput(sc, "ERROR") ###----------------------------------------------------- print "\n" print "#" * 80 return ScOutput(0, "OK")
benchSequence = BenchSequence("McEventCollection I/O") EVTMAX = 100 NTIMES = 1 ###----------------------------------------------------- print("## Testing [writing]...") jobOptions = [ ChapPy.JobOptionsCmd("OUTPUT=\"%s\"" % workDir("mc.io.event.%s.pool" % uuid)), ChapPy.JobOptionsCmd("DUMP=False"), ChapPy.JobOptions("McParticleTests/iotest_WriteGenEvent_jobOptions.py"), ] athena = ChapPy.Athena( jobOptions=jobOptions, #logFile = "/dev/stdout", checkLeak=False) athena.EvtMax = EVTMAX bench = iobench.AthBench( athena, nTimes=NTIMES, logFile=workDir("write.%s.log" % os.path.basename(workDir("mc.io.event.%s.pool" % uuid)))) ## print ("## bench:") ## print (bench.athena) bench.run() #bench.ioStats( [ "McEventCollection#GEN_EVENT" ], "w" ) bench.save("iobench-genevent-%ievts.write.%slog" % (athena.EvtMax, uuid))
def doReadWriteTest(genName="pythia", evtMax=100): """A simple wrapper around the read/write tests...""" genName = genName.lower() ###----------------------------------------------------- print("") print("#" * 80) print("## Testing [writing-%s]..." % genName) templateJobO = """ OUTPUT='%(OutputFile)s'; DUMPTUPLE=True; GENERATOR='%(Generator)s'; TUPLEFILENAME='%(TupleFile)s'; include( 'McParticleTests/iotest_WriteGenEvent_jobOptions.py' ); jobproperties.PerfMonFlags.OutputFile = '%(PmonFile)s'; """ jobOptions = [ ChapPy.JobOptionsCmd( templateJobO % { 'OutputFile' : workDir("mc.event.%s.%s.pool" % (genName,uuid)), 'Generator' : genName.upper(), 'TupleFile' : outFiles['gen_%s' % genName]['ref']\ .replace(".pool",".tuple.root"), 'PmonFile' : workDir("write.genevent.%s.%s.pmon.gz"%(genName,uuid)), } ) ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=workDir("write.genevent.%s.%s.log" % (genName, uuid)), checkLeak=False) athena.EvtMax = evtMax sc = athena.run() if sc != 0: return ScOutput(sc, "ERROR") else: inFile = workDir("write.genevent.%s.%s.pmon.gz" % (genName, uuid)) outFile = workDir("out.write.genevent.%s.%s.pmon.root" % (genName, uuid)) print(subprocess.getoutput("perfmon.py %s -o %s" % (inFile, outFile))) ###----------------------------------------------------- print("\n") print("#" * 80) print("## Testing [reading-%s]..." % genName) templateJobO = """ INPUT=['%(InputFile)s']; DUMPTUPLE=True; TUPLEFILENAME='%(TupleFile)s'; include( 'McParticleTests/iotest_ReadGenEvent_jobOptions.py' ); jobproperties.PerfMonFlags.OutputFile = '%(PmonFile)s'; """ jobOptions = [ ChapPy.JobOptionsCmd( templateJobO % { 'InputFile' : workDir("mc.event.%s.%s.pool" % (genName,uuid)), 'TupleFile' : outFiles['gen_%s' % genName]['chk']\ .replace(".pool",".tuple.root"), 'PmonFile' : workDir("read.genevent.%s.%s.pmon.gz" % (genName,uuid)), } ) ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=workDir("read.genevent.%s.%s.log" % (genName, uuid)), checkLeak=False) athena.EvtMax = evtMax sc = athena.run() if sc != 0: return ScOutput(sc, "ERROR") else: inFile = workDir("read.genevent.%s.%s.pmon.gz" % (genName, uuid)) outFile = workDir("out.read.genevent.%s.%s.pmon.root" % (genName, uuid)) print(subprocess.getoutput("perfmon.py %s -o %s" % (inFile, outFile))) ###----------------------------------------------------- print("\n") print("#" * 80) return doTupleValidation( outFiles['gen_%s' % genName]['ref'].replace(".pool", ".tuple.root"), outFiles['gen_%s' % genName]['chk'].replace(".pool", ".tuple.root"))
###----------------------------------------------------- ## For compatibility with ATN tests from TestTools.iobench import workDir ###----------------------------------------------------- ## Little helper to validate output of jobs from TestTools.iobench import ScOutput from TestTools.iobench import BenchSequence print "#" * 80 print "## StoreGate test... [producer/consumer-DataPool-bench]" print "#" * 80 print "::: No DataPool ", athena = ChapPy.Athena(jobOptions=[ ChapPy.JobOptionsCmd("SGDATAPOOL=False"), ChapPy.JobOptions("StoreGateTests/test_sgProducerConsumer_jobOptions.py"), ChapPy.JobOptionsCmd("jp.PerfMonFlags.OutputFile = 'nodatapool.pmon.gz'"), ]) athena.EvtMax = 100 sc = athena.run() if sc != 0: print "ERROR" sys.exit(sc) print "::: With DataPool ", athena = ChapPy.Athena(jobOptions=[ ChapPy.JobOptionsCmd("SGDATAPOOL=True"), ChapPy.JobOptions("StoreGateTests/test_sgProducerConsumer_jobOptions.py"), ChapPy.JobOptionsCmd( "jp.PerfMonFlags.OutputFile = 'withdatapool.pmon.gz'"), ])
"WriteThinnedData.ref", "ReadThinnedData.ref", "ReadNonThinnedData.ref", ]) ###----------------------------------------------------- print("\n") print("#" * 80) print("## Preparing input data...") jobOptions = [ ChapPy.JobOptionsCmd("OUTPUT=\"%s\"" % workDir("my.data.tothin.pool")), ChapPy.JobOptions("AthExThinning/AthExThinning_makeData.py"), ] athena = ChapPy.Athena(jobOptions=jobOptions, logFile=workDir("my.data.tothin.pool.log"), checkLeak=False) athena.EvtMax = EVTMAX athena.run() ###----------------------------------------------------- print("\n") print("#" * 80) sc, out = doValidation("Input Data", workDir("AthExThinning_makeData.ref"), workDir("my.data.tothin.pool.log"), "grep '^CreateData' | grep INFO ") if sc != 0: raise SystemExit("ERROR") ###----------------------------------------------------- print("\n")
import commands from AthenaCommon import ChapPy ###----------------------------------------------------- ## For compatibility with ATN tests from TestTools.iobench import workDir ###----------------------------------------------------- ## Little helper to validate output of jobs from TestTools.iobench import ScOutput from TestTools.iobench import BenchSequence print "#" * 80 print "## StoreGate test... [producer/consumer-bench]" print "#" * 80 athena = ChapPy.Athena(jobOptions=[ ChapPy.JobOptions("StoreGateTests/test_sgProducerConsumer_jobOptions.py") ]) athena.EvtMax = 100 sc = athena.run() if sc != 0: print "ERROR" else: commands.getstatusoutput("perfmon.py %s -o %s" % ("perfmon.pmon.gz", "out.sg.perfmon.root")) print "All tests SUCCESSFULLY completed" print "" print "#" * 80 print "## Bye." print "#" * 80
# @date: July 2006 import user import sys from TestTools import iobench from AthenaCommon import ChapPy if __name__ == "__main__": print "#" * 80 print "## testing iobench ..." jobOptions = [ ChapPy.JobOptionsCmd("OUTPUT=\"/tmp/slimmed.aod.pool\""), ChapPy.JobOptions("McParticleAlgs/test_WriteMcAod_jobOptions.py") ] athena = ChapPy.Athena(jobOptions=jobOptions, checkLeak=True) athena.EvtMax = 100 bench = iobench.AthBench(athena, nTimes=10) print "## bench:" print bench.athena bench.run() bench.ioStats(["GEN_AOD", "GEN_EVENT", "SpclMC"], "w") bench.save("iobench-%ievts.log" % athena.EvtMax) bench.stats() print "" print "## Bye." print "#" * 80