From e7d2ba150beabc2ded9cf11266ac8478ff13c7e7 Mon Sep 17 00:00:00 2001 From: limosani <antonio.limosani@cern.ch> Date: Wed, 3 May 2017 22:48:20 +0200 Subject: [PATCH] Update master to have the same version as that in the tier0 release, where this script is most relevant. By doing so it resolves the bug that Nick Styles found where both patched and clean tests running a job upon the patched release. --- Tools/PROCTools/python/RunTier0Tests.py | 154 ++++++++++++++---------- 1 file changed, 93 insertions(+), 61 deletions(-) diff --git a/Tools/PROCTools/python/RunTier0Tests.py b/Tools/PROCTools/python/RunTier0Tests.py index 10421ef8431..d950780fe5d 100755 --- a/Tools/PROCTools/python/RunTier0Tests.py +++ b/Tools/PROCTools/python/RunTier0Tests.py @@ -24,7 +24,7 @@ formatter = logging.Formatter('%(levelname)-8s %(message)s') console.setFormatter(formatter) logging.getLogger('').addHandler(console) -def RunCleanQTest(qtest,pwd,release,extraArg,CleanRunHeadDir,UniqID, doR2A=False): +def RunCleanQTest(qtest,pwd,release,extraArg,CleanRunHeadDir,UniqID, doR2A=False, trigConfig="2017"): q=qtest if q == 'q431' and doR2A: extraArg += " --steering='doRAWtoALL'" @@ -34,6 +34,9 @@ def RunCleanQTest(qtest,pwd,release,extraArg,CleanRunHeadDir,UniqID, doR2A=False elif q == 'q221': extraArg += " --conditionsTag all:OFLCOND-RUN12-SDR-25 " + if trigConfig == "2016": + extraArg += "--preExec \"all:from TriggerJobOpts.TriggerFlags import TriggerFlags as TF;TF.run2Config='2016'\"" + logging.info("Running clean in rel "+release+" \"Reco_tf.py --AMI "+q+" "+extraArg+"\"") #Check if CleanRunHead directory exists if not exist with a warning @@ -44,7 +47,7 @@ def RunCleanQTest(qtest,pwd,release,extraArg,CleanRunHeadDir,UniqID, doR2A=False logging.info("Finished clean \"Reco_tf.py --AMI "+q+"\"") pass -def RunPatchedQTest(qtest,pwd,release,theTestArea,extraArg, doR2A=False): +def RunPatchedQTest(qtest,pwd,release,theTestArea,extraArg, doR2A=False, trigConfig="2017"): q=qtest if q == 'q431' and doR2A: extraArg += " --steering='doRAWtoALL'" @@ -54,11 +57,15 @@ def RunPatchedQTest(qtest,pwd,release,theTestArea,extraArg, doR2A=False): elif q == 'q221': extraArg += " --conditionsTag all:OFLCOND-RUN12-SDR-25 " + if trigConfig == "2016": + extraArg += "--preExec \"all:from TriggerJobOpts.TriggerFlags import TriggerFlags as TF;TF.run2Config='2016'\"" + + logging.info("Running patched in rel "+release+" \"Reco_tf.py --AMI "+q+" "+extraArg+"\"") if 'WorkDir_DIR' in os.environ: cmake_build_dir = (os.environ['WorkDir_DIR']) - cmd = "cd "+pwd+"; source $AtlasSetup/scripts/asetup.sh "+release+" --testarea "+theTestArea+" >& /dev/null ; source "+cmake_build_dir+"/setup.sh ; mkdir -p run_"+q+"; cd run_"+q+"; Reco_tf.py --AMI="+q+" "+extraArg+" > "+q+".log 2>&1" + cmd = "cd "+pwd+"; source $AtlasSetup/scripts/asetup.sh "+release+" --testarea "+theTestArea+" >& /dev/null ; source "+cmake_build_dir+"/setup.sh ; mkdir -p run_"+q+"; cd run_"+q+"; Reco_tf.py --AMI="+q+" "+extraArg+" > "+q+".log 2>&1" subprocess.call(cmd,shell=True) else : cmd = "cd "+pwd+"; source $AtlasSetup/scripts/asetup.sh "+release+" --testarea "+theTestArea+" >& /dev/null ; mkdir -p run_"+q+"; cd run_"+q+"; Reco_tf.py --AMI="+q+" "+extraArg+" > "+q+".log 2>&1" @@ -74,39 +81,19 @@ def pwd(): def GetReleaseSetup(): - atlas_base_dir = os.environ['AtlasBaseDir'] - - if 'AtlasPatchVersion' in os.environ: - current_nightly = os.environ['AtlasPatchVersion'] - elif 'AtlasArea' in os.environ: - current_nightly = os.environ['AtlasArea'].split('/')[-1] - elif 'AtlasVersion' in os.environ: - current_nightly = os.environ['AtlasVersion'] - - if "rel" not in current_nightly: - platform = os.environ['GEANT4'].split('/')[-1] - setup="%s,%s"%(platform.replace("-", ","),current_nightly) - else : - latest_tag = "latest_copied_release" - if atlas_base_dir.split('/')[1] == 'cvmfs': - latest_tag = "latest" - latest_nightly = (os.environ['AtlasBaseDir'].split('rel')[:-1])[0]+latest_tag - elif atlas_base_dir.split('/')[1] == 'afs': - latest_nightly = (os.environ['AtlasArea'].split('rel')[:-1])[0]+latest_tag - - latest_nightly = subprocess.Popen(['/bin/bash', '-c',"ls -l "+latest_nightly], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].split()[-1] - - release = os.environ['ATLAS_RELEASE_BASE'] - if 'afs' in release.split('/'): - release = release.split('/')[-1] - elif 'cvmfs' in release.split('/'): - release = release.split('/')[-2] + current_nightly = os.environ['AtlasBuildStamp'] + release_base=os.environ['AtlasBuildBranch'] + release_head=os.environ['Athena_VERSION'] + platform=os.environ['Athena_PLATFORM'] + project=os.environ['AtlasProject'] + builds_dir='/cvmfs/atlas-nightlies.cern.ch/repo/sw/'+release_base+'/*/'+project+'/'+release_head - platform = os.environ['GEANT4'].split('/')[-1] + latest_nightly = subprocess.Popen(['/bin/bash', '-c',"ls -ltr "+builds_dir+" | grep "+release_head], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].split('/')[-3] - if current_nightly != latest_nightly: - logging.info("Please be aware that you are not testing your tags in the latest available nightly, which is "+latest_nightly ) - setup="%s,%s,%s"%(release,platform.replace("-", ","),current_nightly) + if current_nightly != latest_nightly: + logging.info("Please be aware that you are not testing your tags in the latest available nightly, which is "+latest_nightly ) + + setup="%s,%s,%s,Athena"%(release_base,platform.replace("-", ","),current_nightly) logging.info("Your tags will be tested in environment "+setup) @@ -150,7 +137,7 @@ def list_patch_packages(): ############################### ########### Was the q test successful? To check simply count the number of lines containing the string "successful run" -def QTestsFailedOrPassed(q,qTestsToRun,CleanRunHeadDir,UniqID): +def QTestsFailedOrPassed(q,qTestsToRun,CleanRunHeadDir,UniqID,RunPatchedOnly=False): logging.info("-----------------------------------------------------" ) logging.info("Did each step of the "+q+" test complete successfully?" ) @@ -159,14 +146,6 @@ def QTestsFailedOrPassed(q,qTestsToRun,CleanRunHeadDir,UniqID): _Test=True for step in qTestsToRun[q]: logging.info("") - cmd = "grep \"successful run\" " + test_dir + "/log."+str(step) - ref = subprocess.Popen(['/bin/bash', '-c',cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] - - if "successful run" in ref: - logging.info(step+" Reference test successful") - else : - logging.info(step+" Reference test failed") - _Test = False cmd = "grep \"successful run\" run_"+q+"/log."+str(step) test = subprocess.Popen(['/bin/bash', '-c',cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] @@ -177,6 +156,17 @@ def QTestsFailedOrPassed(q,qTestsToRun,CleanRunHeadDir,UniqID): logging.info(step+" Patched test failed") _Test = False + if RunPatchedOnly : continue # Skip checking reference test because in this mode the clean tests have not been run + + cmd = "grep \"successful run\" " + test_dir + "/log."+str(step) + ref = subprocess.Popen(['/bin/bash', '-c',cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] + + if "successful run" in ref: + logging.info(step+" Reference test successful") + else : + logging.info(step+" Reference test failed") + _Test = False + logging.info("") if _Test == True: logging.info("All "+q+" athena steps completed successfully") @@ -186,12 +176,15 @@ def QTestsFailedOrPassed(q,qTestsToRun,CleanRunHeadDir,UniqID): ############### Run Frozen Tier0 Policy Test -def RunFrozenTier0PolicyTest(q,inputFormat,maxEvents,CleanRunHeadDir,UniqID): +def RunFrozenTier0PolicyTest(q,inputFormat,maxEvents,CleanRunHeadDir,UniqID,RunPatchedOnly=False): logging.info("---------------------------------------------------------------------------------------" ) logging.info("Running "+q+" Frozen Tier0 Policy Test on "+inputFormat+" for "+str(maxEvents)+" events" ) clean_dir = CleanRunHeadDir+"/clean_run_"+q+"_"+UniqID + if RunPatchedOnly: #overwrite + clean_dir = '/afs/cern.ch/work/g/gencomm/public/referenceFiles/'+q + comparison_command = "acmd.py diff-root "+clean_dir+"/my"+inputFormat+".pool.root run_"+q+"/my"+inputFormat+".pool.root --error-mode resilient --ignore-leaves RecoTimingObj_p1_HITStoRDO_timings RecoTimingObj_p1_RAWtoESD_mems RecoTimingObj_p1_RAWtoESD_timings RAWtoESD_mems RAWtoESD_timings ESDtoAOD_mems ESDtoAOD_timings HITStoRDO_mems HITStoRDO_timings --entries "+str(maxEvents)+" > run_"+q+"/diff-root-"+q+"."+inputFormat+".log 2>&1" output,error = subprocess.Popen(['/bin/bash', '-c', comparison_command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() @@ -379,6 +372,10 @@ def main(): parser.add_option("-c","--cleanDir" ,type="string" ,dest="cleanDir" ,default="/tmp/" ,help="specify the head directory for running the clean Tier0 tests. The default is /tmp/${USER}") parser.add_option("-r","--ref" ,type="string" ,dest="ref" ,default=None ,help="define a particular reference release") parser.add_option("-v","--val" ,type="string" ,dest="val" ,default=None ,help="define a particular validation release") + parser.add_option("-t","--trigRun2Config", type="string", dest="trigRun2Config_flag", default="2017" ,help="specify the value of run2Config variable used by trigger. Allowed values are \"2016\" and \"2017\" (default)") + + parser.add_option("-p","--patched" ,action="store_true" ,dest="patched_flag" ,default=False ,help="patched option will run q-tests just on your patched version of packages. Be warned! File output comparisons will only be performed against pre-defined reference files stored in the directory /afs/cern.ch/work/g/gencomm/public/referenceFiles and performance comparison tests will not be run.") + (options,args)=parser.parse_args() @@ -389,12 +386,21 @@ def main(): extraArg = options.extraArgs RunFast = options.fast_flag + RunPatchedOnly = options.patched_flag CleanRunHeadDir=options.cleanDir r2aMode = options.r2a_flag + trigRun2Config = options.trigRun2Config_flag + +# tct_ESD = "root://eosatlas//eos/atlas/atlascerngroupdisk/proj-sit/rtt/prod/tct/"+latest_nightly+"/"+release+"/"+platform+"/offline/Tier0ChainTests/"+q+"/myESD.pool.root" + +########### Is TriggerFlags.run2Config defined properly? + if trigRun2Config != "2016" and trigRun2Config != "2017": + logging.info("") + logging.info("Exit. The value of trigRun2Config can be \"2016\" or \"2017\"") + logging.info("") + sys.exit(0) + -# tct_ESD = "root://eosatlas//eos/atlas/atlascerngroupdisk/proj-sit/rtt/prod/tct/"+latest_nightly+"/"+release+"/"+platform+"/offline/Tier0ChainTests/"+q+"/myESD.pool.root" - - ########### Does the clean run head directory exist? if str(CleanRunHeadDir) == "/tmp/": myUser = os.environ['USER'] @@ -402,7 +408,16 @@ def main(): if os.path.exists(CleanRunHeadDir): logging.info("") - logging.info("The head directory for the output of the clean Tier0 q-tests will be "+CleanRunHeadDir) + if RunPatchedOnly: + logging.info("You are running in patched only mode whereby only q-tests against your build are being run.") + logging.info("In this mode ESD and AOD outputs are compared with pre-defined reference files found in the directory") + logging.info("/afs/cern.ch/work/g/gencomm/public/referenceFiles") + logging.info("") + if not os.path.exists('/afs/cern.ch/work/g/gencomm/public/referenceFiles'): + logging.error("Exit. Patched only mode can only be run on nodes with access to /afs/cern.ch/work/g/gencomm/public/referenceFiles") + sys.exit(0) + else: + logging.info("The head directory for the output of the clean Tier0 q-tests will be "+CleanRunHeadDir) logging.info("") else: logging.info("") @@ -435,8 +450,6 @@ def main(): if 'AtlasPatchVersion' not in os.environ and 'AtlasArea' not in os.environ and 'AtlasBaseDir' in os.environ: logging.info("Please be aware that you are running in a base release rather than a Tier0 release, where in general q-tests are not guaranteed to work.") - - ########### Define which q-tests to run @@ -476,17 +489,16 @@ def main(): # mysetup=mysetup+",builds" logging.info("------------------ Run Athena q-test jobs---------------" ) - if RunFast: for qtest in qTestsToRun: q=str(qtest) def mycleanqtest(): - RunCleanQTest(q,mypwd,cleanSetup,extraArg,CleanRunHeadDir,UniqName, doR2A=r2aMode) + RunCleanQTest(q,mypwd,cleanSetup,extraArg,CleanRunHeadDir,UniqName, doR2A=r2aMode, trigConfig=trigRun2Config) pass - + def mypatchedqtest(): - RunPatchedQTest(q,mypwd,mysetup,myTestArea,extraArg, doR2A=r2aMode) + RunPatchedQTest(q,mypwd,mysetup,myTestArea,extraArg, doR2A=r2aMode, trigConfig=trigRun2Config) pass mythreads[q+"_clean"] = threading.Thread(target=mycleanqtest) @@ -497,16 +509,34 @@ def main(): for thread in mythreads: mythreads[thread].join() + elif RunPatchedOnly: + + for qtest in qTestsToRun: + q=str(qtest) + + + def mypatchedqtest(): + RunPatchedQTest(q,mypwd,mysetup,myTestArea,extraArg, doR2A=r2aMode, trigConfig=trigRun2Config) + pass + + mythreads[q+"_patched"] = threading.Thread(target=mypatchedqtest) + mythreads[q+"_patched"].start() + + for thread in mythreads: + mythreads[thread].join() + + + else : for qtest in qTestsToRun: q=str(qtest) def mycleanqtest(): - RunCleanQTest(q,mypwd,cleanSetup,extraArg,CleanRunHeadDir,UniqName) + RunCleanQTest(q,mypwd,cleanSetup,extraArg,CleanRunHeadDir,UniqName,trigConfig=trigRun2Config) pass def mypatchedqtest(): - RunPatchedQTest(q,mypwd,mysetup,myTestArea,extraArg) + RunPatchedQTest(q,mypwd,mysetup,myTestArea,extraArg,trigConfig=trigRun2Config) pass mythreads[q+"_clean"] = threading.Thread(target=mycleanqtest) @@ -524,15 +554,17 @@ def main(): logging.info("-----------------------------------------------------" ) logging.info("----------- Post-processing of "+q+" Test -----------" ) - QTestsFailedOrPassed(q,qTestsToRun,CleanRunHeadDir,UniqName) + QTestsFailedOrPassed(q,qTestsToRun,CleanRunHeadDir,UniqName,RunPatchedOnly) + + RunFrozenTier0PolicyTest(q,"ESD",10,CleanRunHeadDir,UniqName,RunPatchedOnly) + + RunFrozenTier0PolicyTest(q,"AOD",20,CleanRunHeadDir,UniqName,RunPatchedOnly) + if RunPatchedOnly: continue # + if 'q221' in q: RunFrozenTier0PolicyTest(q,"RDO",10,CleanRunHeadDir,UniqName) - RunFrozenTier0PolicyTest(q,"ESD",10,CleanRunHeadDir,UniqName) - - RunFrozenTier0PolicyTest(q,"AOD",20,CleanRunHeadDir,UniqName) - RunTest(q,qTestsToRun,"CPU Time" ,"evtloop_time" ,"sec/event" ,4,0.4,CleanRunHeadDir,UniqName) RunTest(q,qTestsToRun,"Physical Memory","VmRSS" ,"kBytes" ,4,0.2,CleanRunHeadDir,UniqName) -- GitLab