diff --git a/Framework/test/testCcdbDatabase.cxx b/Framework/test/testCcdbDatabase.cxx index b716b99b4a..fb045b3a4f 100644 --- a/Framework/test/testCcdbDatabase.cxx +++ b/Framework/test/testCcdbDatabase.cxx @@ -50,6 +50,16 @@ using namespace o2::quality_control::core; using namespace o2::quality_control::repository; using namespace std; +// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different +// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is +// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated +// build container reach it through a broker instead; unset, behaviour is +// unchanged. +const std::string QCDB_ENDPOINT = [] { + const char* host = std::getenv("ALICEO2_QCDB_HOST"); + return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083"); +}(); + // 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. @@ -360,7 +370,7 @@ BOOST_AUTO_TEST_CASE(ccdb_test_thread_api, *utf::depends_on("ccdb_store")) BOOST_AUTO_TEST_CASE(ccdb_test_no_thread_api) { unique_ptr api = std::make_unique(); - string ccdbUrl = "http://ali-qcdb-test.cern.ch:8083"; + string ccdbUrl = "http://" + QCDB_ENDPOINT; api->init(ccdbUrl); cout << "ccdb url: " << ccdbUrl << endl; bool hostReachable = api->isHostReachable(); diff --git a/Framework/test/testDbFactory.cxx b/Framework/test/testDbFactory.cxx index 2d567032bc..bfa60b012d 100644 --- a/Framework/test/testDbFactory.cxx +++ b/Framework/test/testDbFactory.cxx @@ -33,10 +33,21 @@ #include #include #include +#include using namespace std; using namespace o2::quality_control::core; +// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different +// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is +// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated +// build container reach it through a broker instead; unset, behaviour is +// unchanged. +const std::string QCDB_ENDPOINT = [] { + const char* host = std::getenv("ALICEO2_QCDB_HOST"); + return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083"); +}(); + namespace o2::quality_control::repository { @@ -68,7 +79,7 @@ BOOST_AUTO_TEST_CASE(db_ccdb_listing) auto* ccdb = dynamic_cast(database3.get()); BOOST_CHECK(ccdb); - ccdb->connect("ali-qcdb-test.cern.ch:8083", "", "", ""); + ccdb->connect(QCDB_ENDPOINT, "", "", ""); // prepare stuff in the db string prefixPath = "qc/TST/MO/"; diff --git a/Framework/test/testTaskInterface.cxx b/Framework/test/testTaskInterface.cxx index e955ecf29c..89b65e3eda 100644 --- a/Framework/test/testTaskInterface.cxx +++ b/Framework/test/testTaskInterface.cxx @@ -52,6 +52,7 @@ o2::framework::ConfigParamRegistry createDummyRegistry() #include #include #include +#include using namespace o2::quality_control; using namespace std; @@ -62,6 +63,16 @@ namespace o2::quality_control using namespace core; +// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different +// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is +// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated +// build container reach it through a broker instead; unset, behaviour is +// unchanged. +const std::string QCDB_ENDPOINT = [] { + const char* host = std::getenv("ALICEO2_QCDB_HOST"); + return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083"); +}(); + namespace test { class TestTask : public TaskInterface @@ -201,14 +212,14 @@ TEST_CASE("retrieveCondition") bad.addBadChannel(3, o2::emcal::BadChannelMap::MaskType_t::DEAD_CELL); std::map meta; o2::ccdb::CcdbApi api; - api.init("ali-qcdb-test.cern.ch:8083"); + api.init(QCDB_ENDPOINT); api.storeAsTFileAny(&bad, "qc/TST/conditions", meta); // retrieve it TaskRunnerConfig taskConfig; auto* objectsManager = new ObjectsManager(taskConfig.name, taskConfig.className, taskConfig.detectorName, 0); test::TestTask testTask(objectsManager); - testTask.setCcdbUrl("ali-qcdb-test.cern.ch:8083"); + testTask.setCcdbUrl(QCDB_ENDPOINT); o2::emcal::BadChannelMap* bcm = testTask.testRetrieveCondition(); CHECK(bcm->getChannelStatus(1) == o2::emcal::BadChannelMap::MaskType_t::GOOD_CELL); CHECK(bcm->getChannelStatus(3) == o2::emcal::BadChannelMap::MaskType_t::DEAD_CELL); diff --git a/Framework/test/testTimekeeper.cxx b/Framework/test/testTimekeeper.cxx index 45b40bae9c..ef8f46df60 100644 --- a/Framework/test/testTimekeeper.cxx +++ b/Framework/test/testTimekeeper.cxx @@ -22,10 +22,21 @@ #include #include +#include using namespace o2::quality_control::core; using namespace o2::framework; +// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different +// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is +// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated +// build container reach it through a broker instead; unset, behaviour is +// unchanged. +const std::string QCDB_ENDPOINT = [] { + const char* host = std::getenv("ALICEO2_QCDB_HOST"); + return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083"); +}(); + TEST_CASE("timekeeper_synchronous") { SECTION("defaults") @@ -310,7 +321,7 @@ TEST_CASE("timekeeper_asynchronous") { auto tk = std::make_shared(); - o2::conf::ConfigurableParam::updateFromString("NameConf.mCCDBServer=http://ali-qcdb-test.cern.ch:8083"); + o2::conf::ConfigurableParam::updateFromString("NameConf.mCCDBServer=http://" + QCDB_ENDPOINT); // CCDB RCT first // TODO reactivate but we need the info in ali-qcdb-test (it is only in ccdb-test) diff --git a/Framework/test/testTrendingTask.cxx b/Framework/test/testTrendingTask.cxx index 0bb1ae38b6..0c3872483d 100644 --- a/Framework/test/testTrendingTask.cxx +++ b/Framework/test/testTrendingTask.cxx @@ -30,13 +30,22 @@ #include #include +#include using namespace o2::quality_control::core; using namespace o2::quality_control::postprocessing; using namespace o2::quality_control::repository; using namespace o2::framework; -const std::string CCDB_ENDPOINT = "ali-qcdb-test.cern.ch:8083"; +// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different +// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is +// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated +// build container reach it through a broker instead; unset, behaviour is +// unchanged. +const std::string QCDB_ENDPOINT = [] { + const char* host = std::getenv("ALICEO2_QCDB_HOST"); + return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083"); +}(); struct CleanupAtDestruction { public: @@ -86,7 +95,8 @@ TEST_CASE("test_trending_task") "config": { "database": { "implementation": "CCDB", - "host": "ali-qcdb-test.cern.ch:8083" + "host": ")json" + << QCDB_ENDPOINT << R"json(" }, "Activity": {}, "monitoring": { @@ -105,7 +115,7 @@ TEST_CASE("test_trending_task") { "type": "repository", "path": "TST/MO/)json" + - taskName + R"json(", + taskName + R"json(", "name": "testHistoTrending", "reductorName": "o2::quality_control_modules::common::TH1Reductor", "reductorParameters": { @@ -121,7 +131,7 @@ TEST_CASE("test_trending_task") "type": "repository-quality", "path": "TST/QO", "names": [ ")json" + - checkName + R"json(" ], + checkName + R"json(" ], "reductorName": "o2::quality_control_modules::common::QualityReductor", "moduleName": "QcCommon" } @@ -140,7 +150,7 @@ TEST_CASE("test_trending_task") "name": "quality_histogram", "title": "Histogram of qualities", "varexp": ")json" + - checkName + R"json(.level", + checkName + R"json(.level", "selection": "", "option": "" } @@ -157,7 +167,7 @@ TEST_CASE("test_trending_task") // clean std::shared_ptr repository = DatabaseFactory::create("CCDB"); - repository->connect(CCDB_ENDPOINT, "", "", ""); + repository->connect(QCDB_ENDPOINT, "", "", ""); repository->truncate("qc/TST/MO/" + taskName, "*"); repository->truncate("qc/TST/QO", checkName); diff --git a/Framework/test/testTriggerHelpers.cxx b/Framework/test/testTriggerHelpers.cxx index 35eb4ebb78..15ad755491 100644 --- a/Framework/test/testTriggerHelpers.cxx +++ b/Framework/test/testTriggerHelpers.cxx @@ -17,9 +17,19 @@ #include "QualityControl/TriggerHelpers.h" #include "QualityControl/PostProcessingConfig.h" #include +#include using namespace o2::quality_control::postprocessing; -const std::string CCDB_ENDPOINT = "ali-qcdb-test.cern.ch:8083"; + +// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different +// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is +// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated +// build container reach it through a broker instead; unset, behaviour is +// unchanged. +const std::string QCDB_ENDPOINT = [] { + const char* host = std::getenv("ALICEO2_QCDB_HOST"); + return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083"); +}(); TEST_CASE("test_factory") { @@ -63,8 +73,8 @@ TEST_CASE("test_factory") // generating new object trigger PostProcessingConfig configWithDBs; - configWithDBs.repository["host"] = CCDB_ENDPOINT; - configWithDBs.ccdbUrl = CCDB_ENDPOINT; + configWithDBs.repository["host"] = QCDB_ENDPOINT; + configWithDBs.ccdbUrl = QCDB_ENDPOINT; CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:qcdb:qc/asdf/vcxz", configWithDBs)); CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:ccdb:qc/asdf/vcxz", configWithDBs)); CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:QCDB:qc/asdf/vcxz", configWithDBs)); diff --git a/Framework/test/testUserCodeInterface.cxx b/Framework/test/testUserCodeInterface.cxx index 4835986571..7aed577c89 100644 --- a/Framework/test/testUserCodeInterface.cxx +++ b/Framework/test/testUserCodeInterface.cxx @@ -28,11 +28,22 @@ #include #include +#include using namespace std; using namespace o2::quality_control::repository; using namespace o2::quality_control::core; +// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different +// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is +// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated +// build container reach it through a broker instead; unset, behaviour is +// unchanged. +const std::string QCDB_ENDPOINT = [] { + const char* host = std::getenv("ALICEO2_QCDB_HOST"); + return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083"); +}(); + namespace o2::quality_control { @@ -65,7 +76,7 @@ struct MyGlobalFixture { void teardown() { auto backend = std::make_unique(); - backend->connect("ali-qcdb-test.cern.ch:8083", "", "", ""); + backend->connect(QCDB_ENDPOINT, "", "", ""); backend->truncate("qc/TST/MO/Test/pid" + std::to_string(getpid()), "*"); } }; @@ -82,7 +93,7 @@ BOOST_AUTO_TEST_CASE(test_invoke_all_methods) auto taskName = "Test/pid" + pid; shared_ptr mo1 = make_shared(h1, taskName, "task", "TST"); auto backend = std::make_unique(); - backend->connect("ali-qcdb-test.cern.ch:8083", "", "", ""); + backend->connect(QCDB_ENDPOINT, "", "", ""); backend->storeMO(mo1); // setting custom parameters should configure @@ -92,7 +103,7 @@ BOOST_AUTO_TEST_CASE(test_invoke_all_methods) BOOST_CHECK_EQUAL(testInterface.configured, true); BOOST_CHECK_EQUAL(testInterface.get("test"), "asdf"); - testInterface.setCcdbUrl("ali-qcdb-test.cern.ch:8083"); + testInterface.setCcdbUrl(QCDB_ENDPOINT); auto obj = testInterface.retrieveConditionAny("qc/TST/MO/" + taskName + "/asdf"); BOOST_CHECK_NE(obj, nullptr); }