From 5abe363b0f0202155ca5749678b72234b35fa585 Mon Sep 17 00:00:00 2001
From: Rosen Matev <rosen.matev@cern.ch>
Date: Wed, 5 Jun 2024 19:10:12 +0200
Subject: [PATCH 1/4] Fix odinmon test and disable some tests on detdesc

---
 .../MooreScripts/testbench/scenarios/default.py      | 12 ++++++------
 MooreScripts/scripts/testbench.py                    |  8 +++++++-
 MooreScripts/tests/qmtest/hlt2slim.qmt               |  1 +
 MooreScripts/tests/qmtest/odinmon.qmt                |  1 +
 MooreScripts/tests/qmtest/odinmon_offline.qmt        |  1 +
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/MooreScripts/python/MooreScripts/testbench/scenarios/default.py b/MooreScripts/python/MooreScripts/testbench/scenarios/default.py
index e55d9bd48..5cbba94f9 100644
--- a/MooreScripts/python/MooreScripts/testbench/scenarios/default.py
+++ b/MooreScripts/python/MooreScripts/testbench/scenarios/default.py
@@ -102,18 +102,18 @@ async def run(tasks: List[emulator.Task], args, extra_argv):
     await tasks_send_command(prod_tasks, "stop")
     await tasks_wait_for_status(prod_tasks, "READY")
 
-    # Get last published value
-    # TODO can we make it such that the number of events put in the buffer keeps being published after stop?
-    #      Markus says MDFReader may need to be Class 1 but are there side effects?
-    n_events_produced = next(
-        v for ts, v in reversed(await dim_prod_out.get_all()) if v is not None)
-
     if not args.measure_throughput > 0:
         if "HLT1" in main_tasks[0].utgid:
             log.info(f"Waiting until all events have been processed")
             await hlt1_wait_for_output(main_tasks, "Events/" + prod_counter,
                                        "MBMOutput/NProcessed")
         elif "HLT2" in main_tasks[0].utgid:
+            # Get last published value
+            # TODO can we make it such that the number of events put in the buffer keeps being published after stop?
+            #      Markus says MDFReader may need to be Class 1 but are there side effects?
+            n_events_produced = next(
+                v for ts, v in reversed(await dim_prod_out.get_all())
+                if v is not None)
             log.info(
                 f"Waiting until all {n_events_produced} events have been processed"
             )
diff --git a/MooreScripts/scripts/testbench.py b/MooreScripts/scripts/testbench.py
index 85a071b28..56ab99204 100755
--- a/MooreScripts/scripts/testbench.py
+++ b/MooreScripts/scripts/testbench.py
@@ -149,7 +149,13 @@ args.working_dir = args.working_dir.resolve()
 # Ideally, the nightlies would properly isolate test jobs.
 # Another approach would be to convince Online to be able to control
 # where the shared resources go (/tmp/... and /dev/shm/...).
-args.partition = args.partition + os.getenv("BUILD_ID", "")
+PARTITION_MAX_LEN = 16
+build_id = os.getenv("BUILD_ID", "")
+args.partition = args.partition + build_id[-(
+    PARTITION_MAX_LEN - len(args.partition)):]
+if len(args.partition) > PARTITION_MAX_LEN:
+    raise RuntimeError(f"Partition name is too long (len({args.partition!r})="
+                       + f"{len(args.partition)} > {PARTITION_MAX_LEN})")
 
 emulator.setup_logging(
     args.working_dir / args.log_file, console_level=args.log_level)
diff --git a/MooreScripts/tests/qmtest/hlt2slim.qmt b/MooreScripts/tests/qmtest/hlt2slim.qmt
index 8efcab556..429f878d5 100644
--- a/MooreScripts/tests/qmtest/hlt2slim.qmt
+++ b/MooreScripts/tests/qmtest/hlt2slim.qmt
@@ -22,6 +22,7 @@ Run an HLT2 job in the Online testbench
   <text>--test-file-db-key=2022_raw_hlt1_253597</text>
 </set></argument>
 <argument name="use_temp_dir"><enumeral>true</enumeral></argument>
+<argument name="unsupported_platforms"><set><text>detdesc</text></set></argument>
 <argument name="validator"><text>
 
 # No validator for now: only check the exit code
diff --git a/MooreScripts/tests/qmtest/odinmon.qmt b/MooreScripts/tests/qmtest/odinmon.qmt
index c1d791c45..f3ba51c43 100644
--- a/MooreScripts/tests/qmtest/odinmon.qmt
+++ b/MooreScripts/tests/qmtest/odinmon.qmt
@@ -21,6 +21,7 @@ Run an ODINMon job in the Online testbench
   <text>--test-file-db-key=2024_raw_hlt1_288877_tae</text>
 </set></argument>
 <argument name="use_temp_dir"><enumeral>true</enumeral></argument>
+<argument name="unsupported_platforms"><set><text>detdesc</text></set></argument>
 <argument name="validator"><text>
 
 # No validator for now: only check the exit code
diff --git a/MooreScripts/tests/qmtest/odinmon_offline.qmt b/MooreScripts/tests/qmtest/odinmon_offline.qmt
index 75221b725..367dde023 100644
--- a/MooreScripts/tests/qmtest/odinmon_offline.qmt
+++ b/MooreScripts/tests/qmtest/odinmon_offline.qmt
@@ -19,6 +19,7 @@ Run an ODINMon job in an offline way
   <text>$MOOREONLINECONFROOT/options/odin.py</text>
 </set></argument>
 <argument name="use_temp_dir"><enumeral>per-test</enumeral></argument>
+<argument name="unsupported_platforms"><set><text>detdesc</text></set></argument>
 <argument name="validator"><text>
 
 # No validator for now: only check the exit code
-- 
GitLab


From a477286bebb0bbaaa7865b1564cdd52b8d286b47 Mon Sep 17 00:00:00 2001
From: Rosen Matev <rosen.matev@cern.ch>
Date: Tue, 13 Aug 2024 15:40:14 +0200
Subject: [PATCH 2/4] Fix hlt1runchange test

---
 MooreScripts/tests/qmtest/create_hlt1_tck.qmt |  3 +++
 .../tests/qmtest/create_hlt1_tck_prepare.qmt  | 20 +++++++++++++++++++
 MooreScripts/tests/qmtest/hlt1runchange.qmt   |  2 +-
 3 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 MooreScripts/tests/qmtest/create_hlt1_tck_prepare.qmt

diff --git a/MooreScripts/tests/qmtest/create_hlt1_tck.qmt b/MooreScripts/tests/qmtest/create_hlt1_tck.qmt
index 33a1db543..6275c80c1 100644
--- a/MooreScripts/tests/qmtest/create_hlt1_tck.qmt
+++ b/MooreScripts/tests/qmtest/create_hlt1_tck.qmt
@@ -12,6 +12,9 @@
 #######################################################
 -->
 <extension class="GaudiTest.GaudiExeTest" kind="test">
+  <argument name="prerequisites"><set>
+    <tuple><text>create_hlt1_tck_prepare</text><enumeral>PASS</enumeral></tuple>
+  </set></argument>
   <argument name="program"><text>python</text></argument>
   <argument name="args"><set>
   <text>$ALLENROOT/scripts/create_hlt1_tck.py</text>
diff --git a/MooreScripts/tests/qmtest/create_hlt1_tck_prepare.qmt b/MooreScripts/tests/qmtest/create_hlt1_tck_prepare.qmt
new file mode 100644
index 000000000..daaf6dc16
--- /dev/null
+++ b/MooreScripts/tests/qmtest/create_hlt1_tck_prepare.qmt
@@ -0,0 +1,20 @@
+<?xml version="1.0" ?><!DOCTYPE extension  PUBLIC '-//QM/2.3/Extension//EN'  'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
+<!--
+    (c) Copyright 2024 CERN for the benefit of the LHCb Collaboration
+
+    This software is distributed under the terms of the GNU General Public
+    Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".
+
+    In applying this licence, CERN does not waive the privileges and immunities
+    granted to it by virtue of its status as an Intergovernmental Organization
+    or submit itself to any jurisdiction.
+-->
+<extension class="GaudiTest.GaudiExeTest" kind="test">
+  <argument name="program"><text>rm</text></argument>
+  <argument name="args"><set>
+  <text>-rf</text>
+  <text>config.git</text>
+  </set></argument>
+  <argument name="timeout"><integer>100</integer></argument>
+  <argument name="use_temp_dir"><enumeral>true</enumeral></argument>
+</extension>
diff --git a/MooreScripts/tests/qmtest/hlt1runchange.qmt b/MooreScripts/tests/qmtest/hlt1runchange.qmt
index 4094e5b62..0db592423 100644
--- a/MooreScripts/tests/qmtest/hlt1runchange.qmt
+++ b/MooreScripts/tests/qmtest/hlt1runchange.qmt
@@ -17,7 +17,7 @@ Run an HLT1 job in the Online testbench
 <argument name="args"><set>
   <text>$MOORESCRIPTSROOT/tests/options/HLT1Slim/Arch.xml</text>
   <text>--working-dir=hlt1runchange</text>
-  <text>--partition=TESTHLT1RUNCHANGE</text>
+  <text>--partition=TESTHLT1RC</text>
   <text>--test-file-db-key=2024_mep_292860_run_change_test</text>
   <text>--hlt-type=config.git:0x10000001</text>
   <text>--tck-from-odin</text>
-- 
GitLab


From 4b8ebd44c2ba19d1aaef09565157f0a16ba2a020 Mon Sep 17 00:00:00 2001
From: Rosen Matev <rosen.matev@cern.ch>
Date: Tue, 13 Aug 2024 15:50:08 +0200
Subject: [PATCH 3/4] Remove environment variable from ref path

---
 AllenOnline/tests/qmtest/test_lumi.qmt                | 2 +-
 AllenOnline/tests/qmtest/test_mep_banks.qmt           | 2 +-
 AllenOnline/tests/qmtest/test_mep_banks_transpose.qmt | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/AllenOnline/tests/qmtest/test_lumi.qmt b/AllenOnline/tests/qmtest/test_lumi.qmt
index 5c508b7dd..5595597f8 100644
--- a/AllenOnline/tests/qmtest/test_lumi.qmt
+++ b/AllenOnline/tests/qmtest/test_lumi.qmt
@@ -23,7 +23,7 @@ Run lumi decoding and encoding on Allen MDF output created from MEP input
   <argument name="unsupported_platforms"><set>
     <text>detdesc</text>
   </set></argument>
-  <argument name="reference"><text>${ALLENONLINEROOT}/tests/refs/test_lumi.ref</text></argument>
+  <argument name="reference"><text>../refs/test_lumi.ref</text></argument>
   <argument name="use_temp_dir"><enumeral>true</enumeral></argument>
   <argument name="validator"><text>
 
diff --git a/AllenOnline/tests/qmtest/test_mep_banks.qmt b/AllenOnline/tests/qmtest/test_mep_banks.qmt
index 46061228c..fa7b9e116 100644
--- a/AllenOnline/tests/qmtest/test_mep_banks.qmt
+++ b/AllenOnline/tests/qmtest/test_mep_banks.qmt
@@ -24,7 +24,7 @@
   <argument name="prerequisites"><set>
     <tuple><text>mep_passthrough_no_ut</text><enumeral>PASS</enumeral></tuple>
   </set></argument>
-  <argument name="reference"><text>${ALLENONLINEROOT}/tests/refs/test_mep_banks.ref</text></argument>
+  <argument name="reference"><text>../refs/test_mep_banks.ref</text></argument>
   <argument name="timeout"><integer>600</integer></argument>
   <argument name="validator"><text>
 
diff --git a/AllenOnline/tests/qmtest/test_mep_banks_transpose.qmt b/AllenOnline/tests/qmtest/test_mep_banks_transpose.qmt
index 703501e72..06badf12d 100644
--- a/AllenOnline/tests/qmtest/test_mep_banks_transpose.qmt
+++ b/AllenOnline/tests/qmtest/test_mep_banks_transpose.qmt
@@ -25,7 +25,7 @@
   <argument name="prerequisites"><set>
     <tuple><text>mep_passthrough_no_ut</text><enumeral>PASS</enumeral></tuple>
   </set></argument>
-  <argument name="reference"><text>${ALLENONLINEROOT}/tests/refs/test_mep_banks_transpose-SYMLINK-DO_NOT_UPDATE_WITH_NEW.ref</text></argument>
+  <argument name="reference"><text>../refs/test_mep_banks_transpose-SYMLINK-DO_NOT_UPDATE_WITH_NEW.ref</text></argument>
   <argument name="timeout"><integer>600</integer></argument>
   <argument name="validator"><text>
 
-- 
GitLab


From 3019f5de02c7c6f93fb49189e97d2479b46a8621 Mon Sep 17 00:00:00 2001
From: Rosen Matev <rosen.matev@cern.ch>
Date: Tue, 13 Aug 2024 23:57:42 +0200
Subject: [PATCH 4/4] Disable run change test on detdesc

---
 MooreScripts/tests/qmtest/check_run_change.qmt | 3 +++
 MooreScripts/tests/qmtest/hlt1runchange.qmt    | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/MooreScripts/tests/qmtest/check_run_change.qmt b/MooreScripts/tests/qmtest/check_run_change.qmt
index 05305e520..64e27a680 100644
--- a/MooreScripts/tests/qmtest/check_run_change.qmt
+++ b/MooreScripts/tests/qmtest/check_run_change.qmt
@@ -24,4 +24,7 @@
   </set></argument>
   <argument name="timeout"><integer>200</integer></argument>
   <argument name="use_temp_dir"><enumeral>true</enumeral></argument>
+  <argument name="unsupported_platforms"><set>
+    <text>detdesc</text>
+  </set></argument>
 </extension>
diff --git a/MooreScripts/tests/qmtest/hlt1runchange.qmt b/MooreScripts/tests/qmtest/hlt1runchange.qmt
index 0db592423..c1e1cb5c3 100644
--- a/MooreScripts/tests/qmtest/hlt1runchange.qmt
+++ b/MooreScripts/tests/qmtest/hlt1runchange.qmt
@@ -38,4 +38,7 @@ for fn in glob.glob(workdir + "/hlt1runchange/*.*"):
         result[os.path.basename(fn)] = open(fn).read()
 
 </text></argument>
+<argument name="unsupported_platforms"><set>
+  <text>detdesc</text>
+</set></argument>
 </extension>
-- 
GitLab