From cd092eed83c84b38379f67bd8c2ade855d3b002e Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Thu, 27 Aug 2026 08:59:45 +0200 Subject: [PATCH] Do not hardcode location of test CCDB The new CI setup has a test instance bound to a local port of the worker's container. --- Framework/test/testCcdbDatabase.cxx | 9 ++++++++- Framework/test/testCcdbDatabaseExtra.cxx | 9 ++++++++- Framework/test/testReductor.cxx | 11 +++++++++-- Framework/test/testTriggers.cxx | 8 +++++++- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Framework/test/testCcdbDatabase.cxx b/Framework/test/testCcdbDatabase.cxx index f90064c2e2..35e9240cee 100644 --- a/Framework/test/testCcdbDatabase.cxx +++ b/Framework/test/testCcdbDatabase.cxx @@ -34,6 +34,7 @@ #include #include #include +#include namespace utf = boost::unit_test; @@ -48,7 +49,13 @@ using namespace o2::quality_control::core; using namespace o2::quality_control::repository; using namespace std; -const std::string CCDB_ENDPOINT = "ccdb-test.cern.ch:8080"; +// These tests upload, so this has to be a WRITABLE instance -- ccdb-test by +// default. ALICEO2_CCDB_HOST lets a network-isolated build container reach one +// through a broker instead; unset, behaviour is unchanged. +const std::string CCDB_ENDPOINT = [] { + const char* host = std::getenv("ALICEO2_CCDB_HOST"); + return std::string((host && *host) ? host : "ccdb-test.cern.ch:8080"); +}(); /** * Fixture for the tests, i.e. code is ran in every test that uses it, i.e. it is like a setup and teardown for tests. diff --git a/Framework/test/testCcdbDatabaseExtra.cxx b/Framework/test/testCcdbDatabaseExtra.cxx index 25839cb79c..4426ffe4a6 100644 --- a/Framework/test/testCcdbDatabaseExtra.cxx +++ b/Framework/test/testCcdbDatabaseExtra.cxx @@ -26,6 +26,7 @@ #include #include +#include namespace utf = boost::unit_test; @@ -39,7 +40,13 @@ using namespace o2::quality_control::core; using namespace o2::quality_control::repository; using namespace std; -const std::string CCDB_ENDPOINT = "ccdb-test.cern.ch:8080"; +// These tests upload, so this has to be a WRITABLE instance -- ccdb-test by +// default. ALICEO2_CCDB_HOST lets a network-isolated build container reach one +// through a broker instead; unset, behaviour is unchanged. +const std::string CCDB_ENDPOINT = [] { + const char* host = std::getenv("ALICEO2_CCDB_HOST"); + return std::string((host && *host) ? host : "ccdb-test.cern.ch:8080"); +}(); std::unordered_map Objects; /** diff --git a/Framework/test/testReductor.cxx b/Framework/test/testReductor.cxx index f525b76ccb..7759fbcbbd 100644 --- a/Framework/test/testReductor.cxx +++ b/Framework/test/testReductor.cxx @@ -30,8 +30,15 @@ #define BOOST_TEST_DYN_LINK #include - -const std::string CCDB_ENDPOINT = "ccdb-test.cern.ch:8080"; +#include + +// These tests upload, so this has to be a WRITABLE instance -- ccdb-test by +// default. ALICEO2_CCDB_HOST lets a network-isolated build container reach one +// through a broker instead; unset, behaviour is unchanged. +const std::string CCDB_ENDPOINT = [] { + const char* host = std::getenv("ALICEO2_CCDB_HOST"); + return std::string((host && *host) ? host : "ccdb-test.cern.ch:8080"); +}(); using namespace o2::quality_control; using namespace o2::quality_control::core; diff --git a/Framework/test/testTriggers.cxx b/Framework/test/testTriggers.cxx index 91e5410b88..c2ac29c80b 100644 --- a/Framework/test/testTriggers.cxx +++ b/Framework/test/testTriggers.cxx @@ -37,7 +37,13 @@ using namespace o2::quality_control::postprocessing; using namespace o2::quality_control::core; using namespace o2::quality_control::repository; -const std::string CCDB_ENDPOINT = "ccdb-test.cern.ch:8080"; +// These tests upload, so this has to be a WRITABLE instance -- ccdb-test by +// default. ALICEO2_CCDB_HOST lets a network-isolated build container reach one +// through a broker instead; unset, behaviour is unchanged. +const std::string CCDB_ENDPOINT = [] { + const char* host = std::getenv("ALICEO2_CCDB_HOST"); + return std::string((host && *host) ? host : "ccdb-test.cern.ch:8080"); +}(); BOOST_AUTO_TEST_CASE(test_casting_triggers) {