Skip to content

Commit 1ef72da

Browse files
authored
Remove all absolute url to CCDB (#2696)
Required to have it working in the CI
1 parent 7d3d3ae commit 1ef72da

7 files changed

Lines changed: 91 additions & 17 deletions

‎Framework/test/testCcdbDatabase.cxx‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ using namespace o2::quality_control::core;
5050
using namespace o2::quality_control::repository;
5151
using namespace std;
5252

53+
// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different
54+
// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is
55+
// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated
56+
// build container reach it through a broker instead; unset, behaviour is
57+
// unchanged.
58+
const std::string QCDB_ENDPOINT = [] {
59+
const char* host = std::getenv("ALICEO2_QCDB_HOST");
60+
return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083");
61+
}();
62+
5363
// These tests upload, so this has to be a WRITABLE instance -- ccdb-test by
5464
// default. ALICEO2_CCDB_HOST lets a network-isolated build container reach one
5565
// 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"))
360370
BOOST_AUTO_TEST_CASE(ccdb_test_no_thread_api)
361371
{
362372
unique_ptr<o2::ccdb::CcdbApi> api = std::make_unique<o2::ccdb::CcdbApi>();
363-
string ccdbUrl = "http://ali-qcdb-test.cern.ch:8083";
373+
string ccdbUrl = "http://" + QCDB_ENDPOINT;
364374
api->init(ccdbUrl);
365375
cout << "ccdb url: " << ccdbUrl << endl;
366376
bool hostReachable = api->isHostReachable();

‎Framework/test/testDbFactory.cxx‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,21 @@
3333
#include <QualityControl/RepoPathUtils.h>
3434
#include <QualityControl/testUtils.h>
3535
#include <TH1F.h>
36+
#include <cstdlib>
3637

3738
using namespace std;
3839
using namespace o2::quality_control::core;
3940

41+
// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different
42+
// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is
43+
// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated
44+
// build container reach it through a broker instead; unset, behaviour is
45+
// unchanged.
46+
const std::string QCDB_ENDPOINT = [] {
47+
const char* host = std::getenv("ALICEO2_QCDB_HOST");
48+
return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083");
49+
}();
50+
4051
namespace o2::quality_control::repository
4152
{
4253

@@ -68,7 +79,7 @@ BOOST_AUTO_TEST_CASE(db_ccdb_listing)
6879
auto* ccdb = dynamic_cast<CcdbDatabase*>(database3.get());
6980
BOOST_CHECK(ccdb);
7081

71-
ccdb->connect("ali-qcdb-test.cern.ch:8083", "", "", "");
82+
ccdb->connect(QCDB_ENDPOINT, "", "", "");
7283

7384
// prepare stuff in the db
7485
string prefixPath = "qc/TST/MO/";

‎Framework/test/testTaskInterface.cxx‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ o2::framework::ConfigParamRegistry createDummyRegistry()
5252
#include <Framework/ConfigParamRegistry.h>
5353
#include <Framework/ServiceRegistry.h>
5454
#include <catch_amalgamated.hpp>
55+
#include <cstdlib>
5556

5657
using namespace o2::quality_control;
5758
using namespace std;
@@ -62,6 +63,16 @@ namespace o2::quality_control
6263

6364
using namespace core;
6465

66+
// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different
67+
// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is
68+
// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated
69+
// build container reach it through a broker instead; unset, behaviour is
70+
// unchanged.
71+
const std::string QCDB_ENDPOINT = [] {
72+
const char* host = std::getenv("ALICEO2_QCDB_HOST");
73+
return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083");
74+
}();
75+
6576
namespace test
6677
{
6778
class TestTask : public TaskInterface
@@ -201,14 +212,14 @@ TEST_CASE("retrieveCondition")
201212
bad.addBadChannel(3, o2::emcal::BadChannelMap::MaskType_t::DEAD_CELL);
202213
std::map<std::string, std::string> meta;
203214
o2::ccdb::CcdbApi api;
204-
api.init("ali-qcdb-test.cern.ch:8083");
215+
api.init(QCDB_ENDPOINT);
205216
api.storeAsTFileAny<o2::emcal::BadChannelMap>(&bad, "qc/TST/conditions", meta);
206217

207218
// retrieve it
208219
TaskRunnerConfig taskConfig;
209220
auto* objectsManager = new ObjectsManager(taskConfig.name, taskConfig.className, taskConfig.detectorName, 0);
210221
test::TestTask testTask(objectsManager);
211-
testTask.setCcdbUrl("ali-qcdb-test.cern.ch:8083");
222+
testTask.setCcdbUrl(QCDB_ENDPOINT);
212223
o2::emcal::BadChannelMap* bcm = testTask.testRetrieveCondition();
213224
CHECK(bcm->getChannelStatus(1) == o2::emcal::BadChannelMap::MaskType_t::GOOD_CELL);
214225
CHECK(bcm->getChannelStatus(3) == o2::emcal::BadChannelMap::MaskType_t::DEAD_CELL);

‎Framework/test/testTimekeeper.cxx‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,21 @@
2222
#include <CommonUtils/ConfigurableParam.h>
2323

2424
#include <catch_amalgamated.hpp>
25+
#include <cstdlib>
2526

2627
using namespace o2::quality_control::core;
2728
using namespace o2::framework;
2829

30+
// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different
31+
// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is
32+
// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated
33+
// build container reach it through a broker instead; unset, behaviour is
34+
// unchanged.
35+
const std::string QCDB_ENDPOINT = [] {
36+
const char* host = std::getenv("ALICEO2_QCDB_HOST");
37+
return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083");
38+
}();
39+
2940
TEST_CASE("timekeeper_synchronous")
3041
{
3142
SECTION("defaults")
@@ -310,7 +321,7 @@ TEST_CASE("timekeeper_asynchronous")
310321
{
311322
auto tk = std::make_shared<TimekeeperAsynchronous>();
312323

313-
o2::conf::ConfigurableParam::updateFromString("NameConf.mCCDBServer=http://ali-qcdb-test.cern.ch:8083");
324+
o2::conf::ConfigurableParam::updateFromString("NameConf.mCCDBServer=http://" + QCDB_ENDPOINT);
314325

315326
// CCDB RCT first
316327
// TODO reactivate but we need the info in ali-qcdb-test (it is only in ccdb-test)

‎Framework/test/testTrendingTask.cxx‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,22 @@
3030
#include <functional>
3131

3232
#include <catch_amalgamated.hpp>
33+
#include <cstdlib>
3334

3435
using namespace o2::quality_control::core;
3536
using namespace o2::quality_control::postprocessing;
3637
using namespace o2::quality_control::repository;
3738
using namespace o2::framework;
3839

39-
const std::string CCDB_ENDPOINT = "ali-qcdb-test.cern.ch:8083";
40+
// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different
41+
// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is
42+
// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated
43+
// build container reach it through a broker instead; unset, behaviour is
44+
// unchanged.
45+
const std::string QCDB_ENDPOINT = [] {
46+
const char* host = std::getenv("ALICEO2_QCDB_HOST");
47+
return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083");
48+
}();
4049

4150
struct CleanupAtDestruction {
4251
public:
@@ -86,7 +95,8 @@ TEST_CASE("test_trending_task")
8695
"config": {
8796
"database": {
8897
"implementation": "CCDB",
89-
"host": "ali-qcdb-test.cern.ch:8083"
98+
"host": ")json"
99+
<< QCDB_ENDPOINT << R"json("
90100
},
91101
"Activity": {},
92102
"monitoring": {
@@ -105,7 +115,7 @@ TEST_CASE("test_trending_task")
105115
{
106116
"type": "repository",
107117
"path": "TST/MO/)json" +
108-
taskName + R"json(",
118+
taskName + R"json(",
109119
"name": "testHistoTrending",
110120
"reductorName": "o2::quality_control_modules::common::TH1Reductor",
111121
"reductorParameters": {
@@ -121,7 +131,7 @@ TEST_CASE("test_trending_task")
121131
"type": "repository-quality",
122132
"path": "TST/QO",
123133
"names": [ ")json" +
124-
checkName + R"json(" ],
134+
checkName + R"json(" ],
125135
"reductorName": "o2::quality_control_modules::common::QualityReductor",
126136
"moduleName": "QcCommon"
127137
}
@@ -140,7 +150,7 @@ TEST_CASE("test_trending_task")
140150
"name": "quality_histogram",
141151
"title": "Histogram of qualities",
142152
"varexp": ")json" +
143-
checkName + R"json(.level",
153+
checkName + R"json(.level",
144154
"selection": "",
145155
"option": ""
146156
}
@@ -157,7 +167,7 @@ TEST_CASE("test_trending_task")
157167

158168
// clean
159169
std::shared_ptr<DatabaseInterface> repository = DatabaseFactory::create("CCDB");
160-
repository->connect(CCDB_ENDPOINT, "", "", "");
170+
repository->connect(QCDB_ENDPOINT, "", "", "");
161171
repository->truncate("qc/TST/MO/" + taskName, "*");
162172
repository->truncate("qc/TST/QO", checkName);
163173

‎Framework/test/testTriggerHelpers.cxx‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@
1717
#include "QualityControl/TriggerHelpers.h"
1818
#include "QualityControl/PostProcessingConfig.h"
1919
#include <catch_amalgamated.hpp>
20+
#include <cstdlib>
2021

2122
using namespace o2::quality_control::postprocessing;
22-
const std::string CCDB_ENDPOINT = "ali-qcdb-test.cern.ch:8083";
23+
24+
// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different
25+
// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is
26+
// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated
27+
// build container reach it through a broker instead; unset, behaviour is
28+
// unchanged.
29+
const std::string QCDB_ENDPOINT = [] {
30+
const char* host = std::getenv("ALICEO2_QCDB_HOST");
31+
return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083");
32+
}();
2333

2434
TEST_CASE("test_factory")
2535
{
@@ -63,8 +73,8 @@ TEST_CASE("test_factory")
6373

6474
// generating new object trigger
6575
PostProcessingConfig configWithDBs;
66-
configWithDBs.repository["host"] = CCDB_ENDPOINT;
67-
configWithDBs.ccdbUrl = CCDB_ENDPOINT;
76+
configWithDBs.repository["host"] = QCDB_ENDPOINT;
77+
configWithDBs.ccdbUrl = QCDB_ENDPOINT;
6878
CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:qcdb:qc/asdf/vcxz", configWithDBs));
6979
CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:ccdb:qc/asdf/vcxz", configWithDBs));
7080
CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:QCDB:qc/asdf/vcxz", configWithDBs));

‎Framework/test/testUserCodeInterface.cxx‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,22 @@
2828

2929
#include <QualityControl/CcdbDatabase.h>
3030
#include <QualityControl/CustomParameters.h>
31+
#include <cstdlib>
3132

3233
using namespace std;
3334
using namespace o2::quality_control::repository;
3435
using namespace o2::quality_control::core;
3536

37+
// A QC-specific CCDB instance: ali-qcdb-test by default. It holds different
38+
// objects from ccdb-test -- see the TODO in testTimekeeper.cxx -- so this is
39+
// deliberately NOT ALICEO2_CCDB_HOST. ALICEO2_QCDB_HOST lets a network-isolated
40+
// build container reach it through a broker instead; unset, behaviour is
41+
// unchanged.
42+
const std::string QCDB_ENDPOINT = [] {
43+
const char* host = std::getenv("ALICEO2_QCDB_HOST");
44+
return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083");
45+
}();
46+
3647
namespace o2::quality_control
3748
{
3849

@@ -65,7 +76,7 @@ struct MyGlobalFixture {
6576
void teardown()
6677
{
6778
auto backend = std::make_unique<CcdbDatabase>();
68-
backend->connect("ali-qcdb-test.cern.ch:8083", "", "", "");
79+
backend->connect(QCDB_ENDPOINT, "", "", "");
6980
backend->truncate("qc/TST/MO/Test/pid" + std::to_string(getpid()), "*");
7081
}
7182
};
@@ -82,7 +93,7 @@ BOOST_AUTO_TEST_CASE(test_invoke_all_methods)
8293
auto taskName = "Test/pid" + pid;
8394
shared_ptr<MonitorObject> mo1 = make_shared<MonitorObject>(h1, taskName, "task", "TST");
8495
auto backend = std::make_unique<CcdbDatabase>();
85-
backend->connect("ali-qcdb-test.cern.ch:8083", "", "", "");
96+
backend->connect(QCDB_ENDPOINT, "", "", "");
8697
backend->storeMO(mo1);
8798

8899
// setting custom parameters should configure
@@ -92,7 +103,7 @@ BOOST_AUTO_TEST_CASE(test_invoke_all_methods)
92103
BOOST_CHECK_EQUAL(testInterface.configured, true);
93104
BOOST_CHECK_EQUAL(testInterface.get("test"), "asdf");
94105

95-
testInterface.setCcdbUrl("ali-qcdb-test.cern.ch:8083");
106+
testInterface.setCcdbUrl(QCDB_ENDPOINT);
96107
auto obj = testInterface.retrieveConditionAny<TObject>("qc/TST/MO/" + taskName + "/asdf");
97108
BOOST_CHECK_NE(obj, nullptr);
98109
}

0 commit comments

Comments
 (0)