Skip to content

Commit cd092ee

Browse files
committed
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.
1 parent ac7541b commit cd092ee

4 files changed

Lines changed: 32 additions & 5 deletions

File tree

Framework/test/testCcdbDatabase.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <DataFormatsQualityControl/FlagTypeFactory.h>
3535
#include <TROOT.h>
3636
#include <CCDB/CcdbApi.h>
37+
#include <cstdlib>
3738

3839
namespace utf = boost::unit_test;
3940

@@ -48,7 +49,13 @@ using namespace o2::quality_control::core;
4849
using namespace o2::quality_control::repository;
4950
using namespace std;
5051

51-
const std::string CCDB_ENDPOINT = "ccdb-test.cern.ch:8080";
52+
// These tests upload, so this has to be a WRITABLE instance -- ccdb-test by
53+
// default. ALICEO2_CCDB_HOST lets a network-isolated build container reach one
54+
// through a broker instead; unset, behaviour is unchanged.
55+
const std::string CCDB_ENDPOINT = [] {
56+
const char* host = std::getenv("ALICEO2_CCDB_HOST");
57+
return std::string((host && *host) ? host : "ccdb-test.cern.ch:8080");
58+
}();
5259

5360
/**
5461
* 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.

Framework/test/testCcdbDatabaseExtra.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <boost/test/unit_test.hpp>
2828
#include <TH1F.h>
29+
#include <cstdlib>
2930

3031
namespace utf = boost::unit_test;
3132

@@ -39,7 +40,13 @@ using namespace o2::quality_control::core;
3940
using namespace o2::quality_control::repository;
4041
using namespace std;
4142

42-
const std::string CCDB_ENDPOINT = "ccdb-test.cern.ch:8080";
43+
// These tests upload, so this has to be a WRITABLE instance -- ccdb-test by
44+
// default. ALICEO2_CCDB_HOST lets a network-isolated build container reach one
45+
// through a broker instead; unset, behaviour is unchanged.
46+
const std::string CCDB_ENDPOINT = [] {
47+
const char* host = std::getenv("ALICEO2_CCDB_HOST");
48+
return std::string((host && *host) ? host : "ccdb-test.cern.ch:8080");
49+
}();
4350
std::unordered_map<std::string, std::string> Objects;
4451

4552
/**

Framework/test/testReductor.cxx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@
3030
#define BOOST_TEST_DYN_LINK
3131

3232
#include <boost/test/unit_test.hpp>
33-
34-
const std::string CCDB_ENDPOINT = "ccdb-test.cern.ch:8080";
33+
#include <cstdlib>
34+
35+
// These tests upload, so this has to be a WRITABLE instance -- ccdb-test by
36+
// default. ALICEO2_CCDB_HOST lets a network-isolated build container reach one
37+
// through a broker instead; unset, behaviour is unchanged.
38+
const std::string CCDB_ENDPOINT = [] {
39+
const char* host = std::getenv("ALICEO2_CCDB_HOST");
40+
return std::string((host && *host) ? host : "ccdb-test.cern.ch:8080");
41+
}();
3542

3643
using namespace o2::quality_control;
3744
using namespace o2::quality_control::core;

Framework/test/testTriggers.cxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ using namespace o2::quality_control::postprocessing;
3737
using namespace o2::quality_control::core;
3838
using namespace o2::quality_control::repository;
3939

40-
const std::string CCDB_ENDPOINT = "ccdb-test.cern.ch:8080";
40+
// These tests upload, so this has to be a WRITABLE instance -- ccdb-test by
41+
// default. ALICEO2_CCDB_HOST lets a network-isolated build container reach one
42+
// through a broker instead; unset, behaviour is unchanged.
43+
const std::string CCDB_ENDPOINT = [] {
44+
const char* host = std::getenv("ALICEO2_CCDB_HOST");
45+
return std::string((host && *host) ? host : "ccdb-test.cern.ch:8080");
46+
}();
4147

4248
BOOST_AUTO_TEST_CASE(test_casting_triggers)
4349
{

0 commit comments

Comments
 (0)