2020#define BOOST_TEST_DYN_LINK
2121
2222#include " CCDB/CcdbApi.h"
23- #include " CCDB/IdPath.h" // just as test object
23+ #include " CCDB/IdPath.h" // just as test object
2424#include " CommonUtils/RootChain.h" // just as test object
2525#include " CCDB/CCDBTimeStampUtils.h"
2626#include < boost/test/unit_test.hpp>
2727#include < filesystem>
2828#include < iostream>
2929#include < TH1F.h>
3030#include < chrono>
31+ #include < cstdlib>
3132#include < CommonUtils/StringUtils.h>
3233#include < TStreamerInfo.h>
3334#include < TGraph.h>
@@ -45,7 +46,7 @@ using namespace o2::ccdb;
4546namespace utf = boost::unit_test;
4647namespace tt = boost::test_tools;
4748
48- static std::string ccdbUrl;
49+ static std::string ccdbUrl = " http://ccdb-test.cern.ch:8080 " ;
4950static std::string basePath;
5051bool hostReachable = false ;
5152
@@ -56,7 +57,11 @@ struct Fixture {
5657 Fixture ()
5758 {
5859 CcdbApi api;
59- ccdbUrl = " http://ccdb-test.cern.ch:8080" ;
60+ // These suites upload, so they need a WRITABLE instance -- ccdb-test by
61+ // default, not the official CCDB.
62+ if (const char * host = std::getenv (" ALICEO2_CCDB_HOST" )) {
63+ ccdbUrl = host;
64+ }
6065 api.init (ccdbUrl);
6166 cout << " ccdb url: " << ccdbUrl << endl;
6267 hostReachable = api.isHostReachable ();
@@ -65,7 +70,7 @@ struct Fixture {
6570 gethostname (hostname, _POSIX_HOST_NAME_MAX);
6671 basePath = std::string (" Test/TestCcdbApi/" ) + hostname + " /pid" + getpid () + " /" ;
6772 // Replace dashes by underscores to avoid problems in the creation of local directories
68- std::replace (basePath.begin (), basePath.end (), ' -' ,' _' );
73+ std::replace (basePath.begin (), basePath.end (), ' -' , ' _' );
6974 cout << " Path we will use in this test suite : " + basePath << endl;
7075 }
7176 ~Fixture ()
@@ -446,13 +451,13 @@ BOOST_AUTO_TEST_CASE(TestFetchingHeaders, *utf::precondition(if_reachable()))
446451 std::vector<std::string> headers;
447452 std::vector<std::string> pfns;
448453 std::string path = objectPath + " /" + std::to_string (getCurrentTimestamp ());
449- auto updated = CcdbApi::getCCDBEntryHeaders (" http://ccdb-test.cern.ch:8080 /" + path, etag, headers);
454+ auto updated = CcdbApi::getCCDBEntryHeaders (ccdbUrl + " /" + path, etag, headers);
450455 BOOST_CHECK_EQUAL (updated, true );
451456 BOOST_REQUIRE (headers.size () != 0 );
452457 CcdbApi::parseCCDBHeaders (headers, pfns, etag);
453458 BOOST_REQUIRE (etag != " " );
454459 BOOST_REQUIRE (pfns.size ());
455- updated = CcdbApi::getCCDBEntryHeaders (" http://ccdb-test.cern.ch:8080 /" + path, etag, headers);
460+ updated = CcdbApi::getCCDBEntryHeaders (ccdbUrl + " /" + path, etag, headers);
456461 BOOST_CHECK_EQUAL (updated, false );
457462}
458463
@@ -557,7 +562,7 @@ BOOST_AUTO_TEST_CASE(TestUpdateMetadata, *utf::precondition(if_reachable()))
557562BOOST_AUTO_TEST_CASE (multi_host_test)
558563{
559564 CcdbApi api;
560- api.init (" http://bogus-host.cern.ch,http://ccdb-test.cern.ch:8080 " );
565+ api.init (" http://bogus-host.cern.ch," + ccdbUrl );
561566 std::map<std::string, std::string> metadata;
562567 std::map<std::string, std::string> headers;
563568 o2::pmr::vector<char > dst;
@@ -569,7 +574,7 @@ BOOST_AUTO_TEST_CASE(multi_host_test)
569574BOOST_AUTO_TEST_CASE (vectored)
570575{
571576 CcdbApi api;
572- api.init (" http://ccdb-test.cern.ch:8080 " );
577+ api.init (ccdbUrl );
573578
574579 int TEST_SAMPLE_SIZE = 5 ;
575580 std::vector<o2::pmr::vector<char >> dests (TEST_SAMPLE_SIZE );
0 commit comments