From a3606292e4ab13f045d785ddc917731df06beb94 Mon Sep 17 00:00:00 2001
From: Rafal Bielski <rafal.bielski@cern.ch>
Date: Tue, 10 Sep 2019 23:32:07 +0200
Subject: [PATCH] Adapt Trigger Validation scripts to changes in ART

---
 .../test/exec_TrigUpgradeTest_art_athenaMT.sh |  6 ++++-
 .../TrigValTools/bin/runTrigART.py            | 22 ++++++++++---------
 .../exec_athena_art_trigger_validation.sh     |  6 ++++-
 3 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/Trigger/TrigValidation/TrigUpgradeTest/test/exec_TrigUpgradeTest_art_athenaMT.sh b/Trigger/TrigValidation/TrigUpgradeTest/test/exec_TrigUpgradeTest_art_athenaMT.sh
index de8b228b76b2..bc5fdad566ce 100755
--- a/Trigger/TrigValidation/TrigUpgradeTest/test/exec_TrigUpgradeTest_art_athenaMT.sh
+++ b/Trigger/TrigValidation/TrigUpgradeTest/test/exec_TrigUpgradeTest_art_athenaMT.sh
@@ -86,7 +86,11 @@ fi
 ######################################
 
 # Generate empty PoolFileCatalog.xml - this prevents incorrect handling of crashes on the grid
-art.py createpoolfile
+ART_AVAILABLE=`which art.py >/dev/null 2>&1; echo $?`
+if [[ $ART_AVAILABLE == "0" ]]; then
+  echo "Executing art.py createpoolfile"
+  art.py createpoolfile
+fi
 
 ######################################
 
diff --git a/Trigger/TrigValidation/TrigValTools/bin/runTrigART.py b/Trigger/TrigValidation/TrigValTools/bin/runTrigART.py
index f209afd16aa0..9de8a779113c 100755
--- a/Trigger/TrigValidation/TrigValTools/bin/runTrigART.py
+++ b/Trigger/TrigValidation/TrigValTools/bin/runTrigART.py
@@ -221,24 +221,26 @@ def main():
             target = 'test/' + os.path.basename(script_path)
             os.symlink(script_path, target)
 
-        # Run ART
-        cmd = ["art.py", "run", "-q",
-               "--max-jobs=%d" % args.maxJobs,
-               "--type=%s" % args.artType,
-               ".", "results"]
-        s = " "
-        logging.info("Executing ART command: %s", s.join(cmd))
-        subprocess.call(cmd)
+        # Set up and run ART
+        commands = [
+            'export ATLAS_LOCAL_ROOT_BASE="${ATLAS_LOCAL_ROOT_BASE:-/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase}"',
+            'source "${ATLAS_LOCAL_ROOT_BASE}"/user/atlasLocalSetup.sh --quiet',
+            'lsetup -q art']
+        art_cmd = 'art.py run -q --max-jobs={:d} --type={:s} . results'.format(args.maxJobs, args.artType)
+        commands.append(art_cmd)
+        cmd = ' && '.join(commands)
+        logging.info("Executing ART command: %s", art_cmd)
+        subprocess.call(cmd, shell=True)
         logging.info("ART finished, analysing the results\n")
 
         # Read the result summary from JSON
-        statusfile = 'results/status.json'
+        statusfile = 'results/{:s}-status.json'.format(topdir)
         if not os.path.isfile(statusfile):
             logging.error("ART status.json file is missing - likely the ART runner failed!")
             exit(1)
         with open(statusfile, 'r') as f:
             status_data = json.load(f)
-            all_test_results = status_data['.']
+            all_test_results = status_data[topdir]
             if len(all_test_results) != len(scripts):
                 logging.warning("Selected %d tests but ART executed only %d. Please check why some tests did not run!")
             failed_tests, failed_rootcomp = analyse_results(all_test_results)
diff --git a/Trigger/TrigValidation/TriggerTest/test/exec_athena_art_trigger_validation.sh b/Trigger/TrigValidation/TriggerTest/test/exec_athena_art_trigger_validation.sh
index 13c772a88d86..c01387b2d383 100755
--- a/Trigger/TrigValidation/TriggerTest/test/exec_athena_art_trigger_validation.sh
+++ b/Trigger/TrigValidation/TriggerTest/test/exec_athena_art_trigger_validation.sh
@@ -60,7 +60,11 @@ fi
 ######################################
 
 # Generate empty PoolFileCatalog.xml - this prevents incorrect handling of crashes on the grid
-art.py createpoolfile
+ART_AVAILABLE=`which art.py >/dev/null 2>&1; echo $?`
+if [[ $ART_AVAILABLE == "0" ]]; then
+  echo "Executing art.py createpoolfile"
+  art.py createpoolfile
+fi
 
 ######################################
 
-- 
GitLab