@@ -39,15 +39,16 @@ bool hostReachable = false;
3939struct Fixture {
4040 Fixture ()
4141 {
42- o2::ccdb::CcdbApi api ;
42+ auto & ccdbManager = o2::ccdb::BasicCCDBManager::instance () ;
4343 if (std::getenv (" ALICEO2_CCDB_HOST" )) {
4444 ccdbUrl = std::string (std::getenv (" ALICEO2_CCDB_HOST" ));
4545 }
46- api.init (ccdbUrl);
47- hostReachable = api.isHostReachable ();
46+ hostReachable = ccdbManager.getCCDBAccessor ().isHostReachable ();
4847 char hostname[_POSIX_HOST_NAME_MAX];
4948 gethostname (hostname, _POSIX_HOST_NAME_MAX);
5049 basePath = std::string (" Users/m/meide/BasicCCDBManager/" );
50+
51+ ccdbManager.setURL (ccdbUrl);
5152
5253 LOG (info) << " Path we will use in this test suite : " + basePath << std::endl;
5354 LOG (info) << " ccdb url: " << ccdbUrl << std::endl;
@@ -56,9 +57,7 @@ struct Fixture {
5657 ~Fixture ()
5758 {
5859 if (hostReachable) {
59- o2::ccdb::CcdbApi api;
60- api.init (ccdbUrl);
61- api.truncate (basePath + " *" ); // This deletes the data after test is run, disable if you want to inspect the data
60+ o2::ccdb::BasicCCDBManager::instance ().getCCDBAccessor ().truncate (basePath + " *" ); // This deletes the data after test is run, disable if you want to inspect the data
6261 LOG (info) << " Test data truncated/deleted (" << basePath << " )" << std::endl;
6362 }
6463 }
@@ -74,22 +73,6 @@ struct if_reachable {
7473 return hostReachable;
7574 }
7675};
77- /* *
78- * 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.
79- * Copied from testCcdbApi.cxx
80- */
81- struct test_fixture {
82- test_fixture ()
83- {
84- api.init (ccdbUrl);
85- metadata[" Hello" ] = " World" ;
86- LOG (info) << " *** " << boost::unit_test::framework::current_test_case ().p_name << " ***" << std::endl;
87- }
88- ~test_fixture () = default ;
89-
90- o2::ccdb::CcdbApi api;
91- std::map<std::string, std::string> metadata;
92- };
9376
9477// Only compare known and stable keys (avoid volatile ones like Date)
9578static const std::set<std::string> sStableKeys = {
@@ -112,23 +95,24 @@ BOOST_AUTO_TEST_CASE(testCachedHeaders, *boost::unit_test::precondition(if_reach
11295{
11396 // / ━━━━━━━ ARRANGE ━━━━━━━━━
11497 // First store objects to test with
115- test_fixture f;
116-
98+ auto & ccdbManager = o2::ccdb::BasicCCDBManager::instance ();
11799 std::string pathA = basePath + " CachingA" ;
118100 std::string pathB = basePath + " CachingB" ;
119101 std::string pathC = basePath + " CachingC" ;
120102 std::string ccdbObjO = " testObjectO" ;
121103 std::string ccdbObjN = " testObjectN" ;
122104 std::string ccdbObjX = " testObjectX" ;
123- std::map<std::string, std::string> md = f.metadata ;
105+ std::map<std::string, std::string> md = {
106+ {" Hello" , " World" },
107+ {" Key1" , " Value1" },
108+ {" Key2" , " Value2" },
109+ };
124110 long start = 1000 , stop = 3000 ;
125- f. api .storeAsTFileAny <std::string>(&ccdbObjO, pathA, md, start, stop);
126- f. api .storeAsTFileAny <std::string>(&ccdbObjN, pathB, md, start, stop);
127- f. api .storeAsTFileAny <std::string>(&ccdbObjX, pathC, md, start, stop);
111+ ccdbManager. getCCDBAccessor () .storeAsTFileAny <std::string>(&ccdbObjO, pathA, md, start, stop);
112+ ccdbManager. getCCDBAccessor () .storeAsTFileAny <std::string>(&ccdbObjN, pathB, md, start, stop);
113+ ccdbManager. getCCDBAccessor () .storeAsTFileAny <std::string>(&ccdbObjX, pathC, md, start, stop);
128114 // initilize the BasicCCDBManager
129- o2::ccdb::BasicCCDBManager& ccdbManager = o2::ccdb::BasicCCDBManager::instance ();
130115 ccdbManager.clearCache ();
131- ccdbManager.setURL (ccdbUrl);
132116 ccdbManager.setCaching (true ); // This is what we want to test.
133117
134118 // / ━━━━━━━━━━━ ACT ━━━━━━━━━━━━
@@ -193,20 +177,21 @@ BOOST_AUTO_TEST_CASE(testNonCachedHeaders, *boost::unit_test::precondition(if_re
193177{
194178 // / ━━━━━━━ ARRANGE ━━━━━━━━━
195179 // First store objects to test with
196- test_fixture f;
197-
180+ o2::ccdb::BasicCCDBManager& ccdbManager = o2::ccdb::BasicCCDBManager::instance ();
198181 std::string pathA = basePath + " NonCachingA" ;
199182 std::string pathB = basePath + " NonCachingB" ;
200183 std::string ccdbObjO = " testObjectO" ;
201184 std::string ccdbObjN = " testObjectN" ;
202- std::map<std::string, std::string> md = f.metadata ;
185+ std::map<std::string, std::string> md = {
186+ {" Hello" , " World" },
187+ {" Key1" , " Value1" },
188+ {" Key2" , " Value2" },
189+ };
203190 long start = 1000 , stop = 2000 ;
204- f. api .storeAsTFileAny (&ccdbObjO, pathA, md, start, stop);
205- f. api .storeAsTFileAny (&ccdbObjN, pathB, md, start, stop);
191+ ccdbManager. getCCDBAccessor () .storeAsTFileAny (&ccdbObjO, pathA, md, start, stop);
192+ ccdbManager. getCCDBAccessor () .storeAsTFileAny (&ccdbObjN, pathB, md, start, stop);
206193 // initilize the BasicCCDBManager
207- o2::ccdb::BasicCCDBManager& ccdbManager = o2::ccdb::BasicCCDBManager::instance ();
208194 ccdbManager.clearCache ();
209- ccdbManager.setURL (ccdbUrl);
210195 ccdbManager.setCaching (false ); // This is what we want to test, no caching
211196
212197 // / ━━━━━━━━━━━ ACT ━━━━━━━━━━━━
@@ -253,8 +238,8 @@ BOOST_AUTO_TEST_CASE(testNonCachedHeaders, *boost::unit_test::precondition(if_re
253238
254239BOOST_AUTO_TEST_CASE (CacheFirstRetrievalAndHeadersPersistence)
255240{
256- test_fixture f;
257241 // / ━━━━━━━ ARRANGE ━━━━━━━━━
242+ auto & mgr = o2::ccdb::BasicCCDBManager::instance ();
258243 // Prepare two validity slots for same path to test ETag change later
259244 std::string path = basePath + " ObjA" ;
260245 std::string objV1 = " ObjectVersion1" ;
@@ -268,11 +253,9 @@ BOOST_AUTO_TEST_CASE(CacheFirstRetrievalAndHeadersPersistence)
268253 long v2stop = v2start + (v1stop - v1start);
269254 long mid1 = (v1start + v1stop) / 2 ;
270255 // Store 2 versions
271- f. api .storeAsTFileAny (&objV1, path, meta1, v1start, v1stop);
272- f. api .storeAsTFileAny (&objV2, path, meta1, v2start, v2stop);
256+ mgr. getCCDBAccessor () .storeAsTFileAny (&objV1, path, meta1, v1start, v1stop);
257+ mgr. getCCDBAccessor () .storeAsTFileAny (&objV2, path, meta1, v2start, v2stop);
273258
274- auto & mgr = o2::ccdb::BasicCCDBManager::instance ();
275- mgr.setURL (ccdbUrl);
276259 mgr.clearCache ();
277260 mgr.setCaching (true );
278261 mgr.setFatalWhenNull (true );
@@ -338,15 +321,14 @@ BOOST_AUTO_TEST_CASE(CacheFirstRetrievalAndHeadersPersistence)
338321
339322BOOST_AUTO_TEST_CASE (FailedFetchDoesNotGiveMetadata)
340323{
341- test_fixture f;
342324
343325 // / ━━━━━━━ ARRANGE ━━━━━━━━━
326+ auto & mgr = o2::ccdb::BasicCCDBManager::instance ();
344327 std::string path = basePath + " FailThenRecover" ;
345328 std::string content = " ContentX" ;
346329 std::map<std::string, std::string> meta{{" Alpha" , " Beta" }};
347330 long s = 300'000 , e = 310'000 ;
348- f.api .storeAsTFileAny (&content, path, meta, s, e);
349- auto & mgr = o2::ccdb::BasicCCDBManager::instance ();
331+ mgr.getCCDBAccessor ().storeAsTFileAny (&content, path, meta, s, e);
350332 mgr.clearCache ();
351333 mgr.setCaching (true );
352334 mgr.setFatalWhenNull (false );
@@ -370,15 +352,14 @@ BOOST_AUTO_TEST_CASE(FailedFetchDoesNotGiveMetadata)
370352
371353BOOST_AUTO_TEST_CASE (FirstCallWithoutHeadersThenWithHeaders)
372354{
373- test_fixture f;
374355
356+ auto & mgr = o2::ccdb::BasicCCDBManager::instance ();
375357 std::string path = basePath + " LateHeaders" ;
376358 std::string body = " Late" ;
377359 std::map<std::string, std::string> meta{{" LateKey" , " LateVal" }};
378360 long s = 400'000 , e = 410'000 ;
379- f. api .storeAsTFileAny (&body, path, meta, s, e);
361+ mgr. getCCDBAccessor () .storeAsTFileAny (&body, path, meta, s, e);
380362
381- auto & mgr = o2::ccdb::BasicCCDBManager::instance ();
382363 mgr.clearCache ();
383364 mgr.setCaching (true );
384365 long ts = (s + e) / 2 ;
@@ -400,15 +381,14 @@ BOOST_AUTO_TEST_CASE(FirstCallWithoutHeadersThenWithHeaders)
400381
401382BOOST_AUTO_TEST_CASE (HeadersAreStableAcrossMultipleHits)
402383{
403- test_fixture f;
404384
385+ auto & mgr = o2::ccdb::BasicCCDBManager::instance ();
405386 std::string path = basePath + " StableHeaders" ;
406387 std::string body = " Stable" ;
407388 std::map<std::string, std::string> meta{{" HK" , " HV" }};
408389 long s = 500'000 , e = 510'000 ;
409- f. api .storeAsTFileAny (&body, path, meta, s, e);
390+ mgr. getCCDBAccessor () .storeAsTFileAny (&body, path, meta, s, e);
410391
411- auto & mgr = o2::ccdb::BasicCCDBManager::instance ();
412392 mgr.clearCache ();
413393 mgr.setCaching (true );
414394 long ts = (s + e) / 2 ;
0 commit comments