From 82fbede3b6437615d5644c501d91a7aa9cb3a427 Mon Sep 17 00:00:00 2001
From: Scott Snyder <scott.snyder@cern.ch>
Date: Thu, 26 May 2016 21:12:06 +0200
Subject: [PATCH] 'Have each test use a unique pool file catalog, to prevent
 races when tests are run in parallel.' (LArConditionsTest-00-01-15)

	* Tagging LArConditionsTest-00-01-15.
	* Have each test use a unique pool file catalog, to prevent races
	when tests are run in parallel.

2016-05-25  scott snyder  <snyder@bnl.gov>

	* Tagging LArConditionsTest-00-01-14.
	* CMakeLists.txt: Fix test dependencies.

2016-04-28  scott snyder  <snyder@bnl.gov>

	* Tagging LArConditionsTest-00-01-13.
	* test/post.sh: More patterns to ignore for hive builds.
	* Tagging LArConditionsTest-00-01-12.
	* Move test script skeleton to test/ directory.
	* Tagging LArConditionsTest-00-01-11.
	* Get tests working in cmake build.

	* Tagging LArConditionsTest-00-01-10.
...
(Long ChangeLog diff - truncated)


Former-commit-id: c9254887c53e141963faa0cd18ffaa447e2a5ef6
---
 .../LArTest/LArConditionsTest/CMakeLists.txt  | 88 +++++++++++++++++++
 .../LArConditionsTest/cmt/requirements        | 22 ++---
 .../LArConditionsTestReadNoReg_jobOptions.py  |  7 +-
 .../LArConditionsTestWriteNoReg_jobOptions.py |  5 ++
 .../share/LArConditionsTest_jobOptions.py     |  7 +-
 .../LArConditionsTest/src/FixLArElecCalib.cxx |  6 +-
 .../LArConditionsTest/src/LisIOVList.cxx      |  7 +-
 .../test/larconditions_test.sh.in             |  9 ++
 .../{post_check_with_select.sh => post.sh}    |  6 +-
 9 files changed, 135 insertions(+), 22 deletions(-)
 create mode 100644 LArCalorimeter/LArTest/LArConditionsTest/CMakeLists.txt
 create mode 100755 LArCalorimeter/LArTest/LArConditionsTest/test/larconditions_test.sh.in
 rename LArCalorimeter/LArTest/LArConditionsTest/test/{post_check_with_select.sh => post.sh} (95%)

diff --git a/LArCalorimeter/LArTest/LArConditionsTest/CMakeLists.txt b/LArCalorimeter/LArTest/LArConditionsTest/CMakeLists.txt
new file mode 100644
index 00000000000..d5c1184e437
--- /dev/null
+++ b/LArCalorimeter/LArTest/LArConditionsTest/CMakeLists.txt
@@ -0,0 +1,88 @@
+################################################################################
+# Package: LArConditionsTest
+################################################################################
+
+# Declare the package name:
+atlas_subdir( LArConditionsTest )
+
+# Declare the package's dependencies:
+atlas_depends_on_subdirs( PUBLIC
+                          Calorimeter/CaloInterface
+                          Control/AthenaBaseComps
+                          Control/MinimalRunTime
+                          Control/StoreGate
+                          DetectorDescription/Identifier
+                          GaudiKernel
+                          LArCalorimeter/LArCabling
+                          LArCalorimeter/LArElecCalib
+                          LArCalorimeter/LArIdentifier
+                          LArCalorimeter/LArRawConditions
+                          LArCalorimeter/LArRawUtils
+                          LArCalorimeter/LArTools
+                          TestPolicy
+                          PRIVATE
+                          Calorimeter/CaloDetDescr
+                          Calorimeter/CaloEvent
+                          Calorimeter/CaloIdentifier
+                          Control/AthenaKernel
+                          Database/AthenaPOOL/AthenaPoolUtilities
+                          Event/xAOD/xAODEventInfo
+                          LArCalorimeter/LArCOOLConditions )
+
+# External dependencies:
+find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess )
+
+# Component(s) in the package:
+atlas_add_component( LArConditionsTest
+                     src/LArConditionsTest_entries.cxx
+                     src/LArConditionsTest_load.cxx
+                     src/TestLArConditionsTools.cxx
+                     src/FixLArElecCalib.cxx
+                     src/LArCondDataTest.cxx
+                     src/LArConditionsTestAlg.cxx
+                     src/LArFecLvTempDcsTest.cxx
+                     src/LArCablingTest.cxx
+                     src/LArIdMapConvert.cxx
+                     src/LArShapeToSCShape.cxx
+                     src/LArOFCtoOFC.cxx
+                     src/LArFebRodMapConvert.cxx
+                     INCLUDE_DIRS ${CORAL_INCLUDE_DIRS}
+                     LINK_LIBRARIES ${CORAL_LIBRARIES} AthenaBaseComps StoreGateLib SGtests Identifier GaudiKernel LArCablingLib LArIdentifier LArRawConditions LArRawUtilsLib LArToolsLib CaloDetDescrLib CaloEvent CaloIdentifier AthenaKernel AthenaPoolUtilities xAODEventInfo LArCOOLConditions )
+
+# Install files from the package:
+atlas_install_headers( LArConditionsTest )
+atlas_install_joboptions( share/*.py )
+
+
+
+function (larconditions_run_test testName)
+  cmake_parse_arguments( ARG "" "DEPENDS" "" ${ARGN} )
+
+  configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/test/larconditions_test.sh.in
+                  ${CMAKE_CURRENT_BINARY_DIR}/larconditions_${testName}.sh
+                  @ONLY )
+  atlas_add_test( ${testName}
+                  SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/larconditions_${testName}.sh
+                  ENVIRONMENT PATH=${CMAKE_CURRENT_SOURCE_DIR}/test:$ENV{PATH}
+                  PROPERTIES TIMEOUT 300
+                   )
+  if( ARG_DEPENDS )
+    set_tests_properties( LArConditionsTest_${testName}_ctest
+                          PROPERTIES DEPENDS LArConditionsTest_${ARG_DEPENDS}_ctest )
+  endif()
+endfunction (larconditions_run_test)
+
+
+larconditions_run_test (LArConditionsTest)
+larconditions_run_test (LArConditionsTestWriteNoReg)
+larconditions_run_test (LArConditionsTestReadNoReg DEPENDS LArConditionsTestWriteNoReg)
+
+# Remaining tests have been disabled since forever.
+# LArConditionsTestReadAndReg
+# LArConditionsTestReadTwoStep
+# LArConditionsTestWriteNoCorr
+# LArConditionsTestReadNoCorr
+# LArConditionsTestWriteCorr
+# LArConditionsTestReadCorr
+# LArConditionsTestWriteOneStep
+# LArConditionsTestReadOneStep
diff --git a/LArCalorimeter/LArTest/LArConditionsTest/cmt/requirements b/LArCalorimeter/LArTest/LArConditionsTest/cmt/requirements
index f32ce94ae4c..a37f080db85 100755
--- a/LArCalorimeter/LArTest/LArConditionsTest/cmt/requirements
+++ b/LArCalorimeter/LArTest/LArConditionsTest/cmt/requirements
@@ -70,40 +70,40 @@ macro test_pattern_opt_only "athenarun_test" \
 
 
 # Simple test, no I/O
-apply_pattern athenarun_test name="LArConditionsTest" pre_script="../test/pre_check.sh LArConditionsTest " options="LArConditionsTest/LArConditionsTest_jobOptions.py" post_script="../test/post_check_with_select.sh LArConditionsTest LArConditionsTe " 
+apply_pattern athenarun_test name="LArConditionsTest" pre_script="../test/pre_check.sh LArConditionsTest " options="LArConditionsTest/LArConditionsTest_jobOptions.py" post_script="../test/post.sh LArConditionsTest LArConditionsTe " 
 
 # Write out no registration 
-apply_pattern athenarun_test name="LArConditionsTestWriteNoReg" pre_script="../test/pre_check.sh LArConditionsTestWriteNoReg " options="LArConditionsTest/LArConditionsTestWriteNoReg_jobOptions.py" post_script="../test/post_check_with_select.sh LArConditionsTestWriteNoReg LArConditionsTe " 
+apply_pattern athenarun_test name="LArConditionsTestWriteNoReg" pre_script="../test/pre_check.sh LArConditionsTestWriteNoReg " options="LArConditionsTest/LArConditionsTestWriteNoReg_jobOptions.py" post_script="../test/post.sh LArConditionsTestWriteNoReg LArConditionsTe " 
 macro_append LArConditionsTestWriteNoReg_test_dependencies " LArConditionsTest_test "
 
 # Read back no registration 
-apply_pattern athenarun_test name="LArConditionsTestReadNoReg" pre_script="../test/pre_check.sh LArConditionsTestReadNoReg " options="LArConditionsTest/LArConditionsTestReadNoReg_jobOptions.py" post_script="../test/post_check_with_select.sh LArConditionsTestReadNoReg LArConditionsTe " 
+apply_pattern athenarun_test name="LArConditionsTestReadNoReg" pre_script="../test/pre_check.sh LArConditionsTestReadNoReg " options="LArConditionsTest/LArConditionsTestReadNoReg_jobOptions.py" post_script="../test/post.sh LArConditionsTestReadNoReg LArConditionsTe " 
 macro_append LArConditionsTestReadNoReg_test_dependencies " LArConditionsTestWriteNoReg_test "
 
 # Read back and register
-#apply_pattern athenarun_test name="LArConditionsTestReadAndReg" pre_script="../test/pre_check.sh LArConditionsTestReadAndReg  LARNOREG " options="LArConditionsTest/LArConditionsTestReadAndReg_jobOptions.py" post_script="../test/post_check_with_select.sh LArConditionsTestReadAndReg LArConditionsTe " 
+#apply_pattern athenarun_test name="LArConditionsTestReadAndReg" pre_script="../test/pre_check.sh LArConditionsTestReadAndReg  LARNOREG " options="LArConditionsTest/LArConditionsTestReadAndReg_jobOptions.py" post_script="../test/post.sh LArConditionsTestReadAndReg LArConditionsTe " 
 
 # Read back 
-#apply_pattern athenarun_test name="LArConditionsTestReadTwoStep" pre_script="../test/pre_check.sh LArConditionsTestReadTwoStep " options="LArConditionsTest/LArConditionsTestReadTwoStep_jobOptions.py" post_script="../test/post_check_with_select.sh LArConditionsTestReadTwoStep LArConditionsTe " 
+#apply_pattern athenarun_test name="LArConditionsTestReadTwoStep" pre_script="../test/pre_check.sh LArConditionsTestReadTwoStep " options="LArConditionsTest/LArConditionsTestReadTwoStep_jobOptions.py" post_script="../test/post.sh LArConditionsTestReadTwoStep LArConditionsTe " 
 
 
 # Write out without corrections
-#apply_pattern athenarun_test name="LArConditionsTestWriteNoCorr" pre_script="../test/pre_check.sh LArConditionsTestWriteNoCorr LARCORR " options="LArConditionsTest/LArConditionsTestWriteNoCorr_jobOptions.py" post_script="../test/post_check_with_select.sh LArConditionsTestWriteNoCorr LArConditionsTe " 
+#apply_pattern athenarun_test name="LArConditionsTestWriteNoCorr" pre_script="../test/pre_check.sh LArConditionsTestWriteNoCorr LARCORR " options="LArConditionsTest/LArConditionsTestWriteNoCorr_jobOptions.py" post_script="../test/post.sh LArConditionsTestWriteNoCorr LArConditionsTe " 
 
 # Read back without corrections
-#apply_pattern athenarun_test name="LArConditionsTestReadNoCorr" pre_script="../test/pre_check.sh LArConditionsTestReadNoCorr " options="LArConditionsTest/LArConditionsTestReadNoCorr_jobOptions.py" post_script="../test/post_check_with_select.sh LArConditionsTestReadNoCorr LArConditionsTe " 
+#apply_pattern athenarun_test name="LArConditionsTestReadNoCorr" pre_script="../test/pre_check.sh LArConditionsTestReadNoCorr " options="LArConditionsTest/LArConditionsTestReadNoCorr_jobOptions.py" post_script="../test/post.sh LArConditionsTestReadNoCorr LArConditionsTe " 
 
 # Write out  corrections
-#apply_pattern athenarun_test name="LArConditionsTestWriteCorr" pre_script="../test/pre_check.sh LArConditionsTestWriteCorr " options="LArConditionsTest/LArConditionsTestWriteCorr_jobOptions.py" post_script="../test/post_check_with_select.sh LArConditionsTestWriteCorr LArConditionsTe " 
+#apply_pattern athenarun_test name="LArConditionsTestWriteCorr" pre_script="../test/pre_check.sh LArConditionsTestWriteCorr " options="LArConditionsTest/LArConditionsTestWriteCorr_jobOptions.py" post_script="../test/post.sh LArConditionsTestWriteCorr LArConditionsTe " 
 
 # Read back 
-#apply_pattern athenarun_test name="LArConditionsTestReadCorr" pre_script="../test/pre_check.sh LArConditionsTestReadCorr " options="LArConditionsTest/LArConditionsTestReadCorr_jobOptions.py" post_script="../test/post_check_with_select.sh LArConditionsTestReadCorr LArConditionsTe " 
+#apply_pattern athenarun_test name="LArConditionsTestReadCorr" pre_script="../test/pre_check.sh LArConditionsTestReadCorr " options="LArConditionsTest/LArConditionsTestReadCorr_jobOptions.py" post_script="../test/post.sh LArConditionsTestReadCorr LArConditionsTe " 
 
 # Write in single step
-#apply_pattern athenarun_test name="LArConditionsTestWriteOneStep" pre_script="../test/pre_check.sh LArConditionsTestWriteOneStep LARTEST " options="LArConditionsTest/LArConditionsTestWrite_jobOptions.py" post_script="../test/post_check_with_select.sh LArConditionsTestWriteOneStep LArConditionsTe " 
+#apply_pattern athenarun_test name="LArConditionsTestWriteOneStep" pre_script="../test/pre_check.sh LArConditionsTestWriteOneStep LARTEST " options="LArConditionsTest/LArConditionsTestWrite_jobOptions.py" post_script="../test/post.sh LArConditionsTestWriteOneStep LArConditionsTe " 
 
 # Read back 
-#apply_pattern athenarun_test name="LArConditionsTestReadOneStep" pre_script="../test/pre_check.sh LArConditionsTestReadOneStep " options="LArConditionsTest/LArConditionsTestRead_jobOptions.py" post_script="../test/post_check_with_select.sh LArConditionsTestReadOneStep LArConditionsTe " 
+#apply_pattern athenarun_test name="LArConditionsTestReadOneStep" pre_script="../test/pre_check.sh LArConditionsTestReadOneStep " options="LArConditionsTest/LArConditionsTestRead_jobOptions.py" post_script="../test/post.sh LArConditionsTestReadOneStep LArConditionsTe " 
 
 #Application to dump IOV ranges and tags from the Lisbon DB 
 #use ICondDB              ICondDB-00-*              External
diff --git a/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTestReadNoReg_jobOptions.py b/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTestReadNoReg_jobOptions.py
index bb09e532251..f61460bf8a6 100755
--- a/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTestReadNoReg_jobOptions.py
+++ b/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTestReadNoReg_jobOptions.py
@@ -111,9 +111,10 @@ include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" )
 EventPersistencySvc = svcMgr.EventPersistencySvc
 EventPersistencySvc.CnvServices += [ "AthenaPoolCnvSvc" ]
 
-#Explicitly specify the output file catalog
-#PoolSvc = Service( "PoolSvc" )
-#PoolSvc.WriteCatalog = "file:Catalog1.xml"
+# Explicitly specify the output file catalog,
+# to avoid races when running tests in parallel.
+PoolSvc = Service( "PoolSvc" )
+PoolSvc.WriteCatalog = "file:Catalog2.xml"
 
 #ProxyProviderSvc = Service( "ProxyProviderSvc" )
 #ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ]
diff --git a/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTestWriteNoReg_jobOptions.py b/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTestWriteNoReg_jobOptions.py
index 1b0e48a37d0..c0901bce6bc 100755
--- a/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTestWriteNoReg_jobOptions.py
+++ b/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTestWriteNoReg_jobOptions.py
@@ -109,6 +109,11 @@ include ( "LArCondAthenaPool/LArCondAthenaPool_joboptions.py" )
 #  Use OutputConditionsAlg to write
 #--------------------------------------------------------------
 
+# Explicitly specify the output file catalog
+# to avoid races when running tests in parallel.
+PoolSvc = Service( "PoolSvc" )
+PoolSvc.WriteCatalog = "file:Catalog3.xml"
+
 from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg
 OutputConditionsAlg=OutputConditionsAlg("OutputConditionsAlg","LarCondTestNoReg.root")
 
diff --git a/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTest_jobOptions.py b/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTest_jobOptions.py
index 7876105483d..ffaae8ab125 100755
--- a/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTest_jobOptions.py
+++ b/LArCalorimeter/LArTest/LArConditionsTest/share/LArConditionsTest_jobOptions.py
@@ -113,9 +113,10 @@ AthenaSealSvc.OutputLevel     = 3
 #EventPersistencySvc = Service( "EventPersistencySvc" )
 #EventPersistencySvc.CnvServices += [ "AthenaPoolCnvSvc" ]
 
-#Explicitly specify the output file catalog
-#PoolSvc = Service( "PoolSvc" )
-#PoolSvc.WriteCatalog = "file:Catalog1.xml"
+# Explicitly specify the output file catalog
+# to avoid races when running tests in parallel.
+PoolSvc = Service( "PoolSvc" )
+PoolSvc.WriteCatalog = "file:Catalog1.xml"
 
 #ProxyProviderSvc = Service( "ProxyProviderSvc" )
 #ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ]
diff --git a/LArCalorimeter/LArTest/LArConditionsTest/src/FixLArElecCalib.cxx b/LArCalorimeter/LArTest/LArConditionsTest/src/FixLArElecCalib.cxx
index 8077f31d4cb..7af9ecc56c8 100755
--- a/LArCalorimeter/LArTest/LArConditionsTest/src/FixLArElecCalib.cxx
+++ b/LArCalorimeter/LArTest/LArConditionsTest/src/FixLArElecCalib.cxx
@@ -816,7 +816,7 @@ StatusCode FixLArElecCalib::fix5() {
        }
        
        int mod,phi,eta;
-       sscanf(ch_id, "A%d.%d.%d", &mod,&phi,&eta);
+       sscanf(ch_id, "A%80d.%80d.%80d", &mod,&phi,&eta);
        if(phi>7){
          ATH_MSG_DEBUG(" skipping phi"<<str_id<<" phi="<<phi);
           continue; 
@@ -1061,7 +1061,7 @@ StatusCode FixLArElecCalib::fix6() {
        }
 
        int mod,phi,eta;
-       sscanf(ch_id, "A%d.%d.%d", &mod,&phi,&eta);
+       sscanf(ch_id, "A%80d.%80d.%80d", &mod,&phi,&eta);
        if(phi>7){
           ATH_MSG_INFO(" skipping phi"<<str_id<<" phi="<<phi);
           continue; 
@@ -1444,7 +1444,7 @@ StatusCode FixLArElecCalib::addMphysOverMcal() {
        }
 
        int mod,phi,eta;
-       sscanf(ch_id, "A%d.%d.%d", &mod,&phi,&eta);
+       sscanf(ch_id, "A%80d.%80d.%80d", &mod,&phi,&eta);
        if(phi>7){
           ATH_MSG_INFO(" skipping phi"<<str_id<<" phi="<<phi);
           continue; 
diff --git a/LArCalorimeter/LArTest/LArConditionsTest/src/LisIOVList.cxx b/LArCalorimeter/LArTest/LArConditionsTest/src/LisIOVList.cxx
index 36fb6deb8b0..d1198866138 100755
--- a/LArCalorimeter/LArTest/LArConditionsTest/src/LisIOVList.cxx
+++ b/LArCalorimeter/LArTest/LArConditionsTest/src/LisIOVList.cxx
@@ -55,7 +55,12 @@ class LisIOVList {
 
 LisIOVList::LisIOVList(const std::string lisdb, const std::string lisfolder, 
 		     const std::string filename, const std::string tagprefix) :
-  m_lisdbstr(lisdb), m_lisfolder(lisfolder), m_filename(filename), m_tagprefix(tagprefix)
+  m_lisdbstr(lisdb), m_lisfolder(lisfolder), m_filename(filename), m_tagprefix(tagprefix),
+  m_lisdb(nullptr),
+  m_lisacc(nullptr),
+  m_lisfold(nullptr),
+  m_listag(nullptr),
+  m_runevent(false)
 {
   std::cout << "LisIOVList initialised" << std::endl;
   std::cout << "Read from Lisbon DB: " << m_lisdbstr << " folder " <<
diff --git a/LArCalorimeter/LArTest/LArConditionsTest/test/larconditions_test.sh.in b/LArCalorimeter/LArTest/LArConditionsTest/test/larconditions_test.sh.in
new file mode 100755
index 00000000000..e0d65ceb38f
--- /dev/null
+++ b/LArCalorimeter/LArTest/LArConditionsTest/test/larconditions_test.sh.in
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -e
+
+# Turn off pool verbose printing
+export POOL_OUTMSG_LEVEL=4
+
+athena.py LArConditionsTest/@testName@_jobOptions.py
+
diff --git a/LArCalorimeter/LArTest/LArConditionsTest/test/post_check_with_select.sh b/LArCalorimeter/LArTest/LArConditionsTest/test/post.sh
similarity index 95%
rename from LArCalorimeter/LArTest/LArConditionsTest/test/post_check_with_select.sh
rename to LArCalorimeter/LArTest/LArConditionsTest/test/post.sh
index 29d410033b1..beb9441299c 100755
--- a/LArCalorimeter/LArTest/LArConditionsTest/test/post_check_with_select.sh
+++ b/LArCalorimeter/LArTest/LArConditionsTest/test/post.sh
@@ -11,6 +11,9 @@
 # **/
 test=$1
 select=$2
+if [ "$select" = "" ]; then
+  select="LArConditionsTe"
+fi
 #echo "args 1> $1 2> $2 "
 #if [ -z "$status" ]
 #    then
@@ -40,7 +43,8 @@ select=$2
 	        egrep -a -v 'seal.opts' |\
 	        egrep -a -v 'release' |\
 		egrep -a -v 'getRegistryEntries' |\
-		egrep -a -v 'is not writable'
+		egrep -a -v 'is not writable' |\
+                egrep -a -v 'DEBUG input handles:|DEBUG output handles:|DEBUG Data Deps for|DEBUG Property update for OutputLevel :'
 	    else 
 #	    echo " post.sh> Now comparing output with reference"
 		diff -a -b -B  $joblog $reflog |\
-- 
GitLab