Project
Loading...
Searching...
No Matches
testCcdbApi.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17#define BOOST_BIND_GLOBAL_PLACEHOLDERS
18#define BOOST_TEST_MODULE CCDB
19#define BOOST_TEST_MAIN
20#define BOOST_TEST_DYN_LINK
21
22#include "CCDB/CcdbApi.h"
23#include "CCDB/IdPath.h" // just as test object
24#include "CommonUtils/RootChain.h" // just as test object
26#include <boost/test/unit_test.hpp>
27#include <filesystem>
28#include <iostream>
29#include <TH1F.h>
30#include <chrono>
32#include <TStreamerInfo.h>
33#include <TGraph.h>
34#include <TTree.h>
35#include <TString.h>
36#include <unistd.h>
37
38#include <boost/property_tree/json_parser.hpp>
39#include <boost/property_tree/ptree.hpp>
40#include <boost/foreach.hpp>
41#include <boost/optional/optional.hpp>
42
43using namespace std;
44using namespace o2::ccdb;
45namespace utf = boost::unit_test;
46namespace tt = boost::test_tools;
47
48static string ccdbUrl;
49static string basePath;
50bool hostReachable = false;
51
55struct Fixture {
57 {
58 CcdbApi api;
59 ccdbUrl = "http://ccdb-test.cern.ch:8080";
60 api.init(ccdbUrl);
61 cout << "ccdb url: " << ccdbUrl << endl;
63 cout << "Is host reachable ? --> " << hostReachable << endl;
64 char hostname[_POSIX_HOST_NAME_MAX];
65 gethostname(hostname, _POSIX_HOST_NAME_MAX);
66 basePath = string("Test/TestCcdbApi/") + hostname + "/pid" + getpid() + "/";
67 // Replace dashes by underscores to avoid problems in the creation of local directories
68 std::replace(basePath.begin(), basePath.end(), '-','_');
69 cout << "Path we will use in this test suite : " + basePath << endl;
70 }
72 {
73 if (hostReachable) {
74 CcdbApi api;
75 map<string, string> metadata;
76 api.init(ccdbUrl);
77 api.truncate(basePath + "*");
78 cout << "Test data truncated (" << basePath << ")" << endl;
79 }
80 }
81};
83
88 tt::assertion_result operator()(utf::test_unit_id)
89 {
90 return hostReachable;
91 }
92};
93
99 {
101 metadata["Hello"] = "World";
102 std::cout << "*** " << boost::unit_test::framework::current_test_case().p_name << " ***" << std::endl;
103 }
104 ~test_fixture() = default;
105
107 map<string, string> metadata;
108};
109
110BOOST_AUTO_TEST_CASE(storeTMemFile_test, *utf::precondition(if_reachable()))
111{
113
114 TH1F h1("th1name", "th1name", 100, 0, 99);
115 h1.FillRandom("gaus", 10000);
116 BOOST_CHECK_EQUAL(h1.ClassName(), "TH1F");
117 cout << basePath + "th1" << endl;
118 f.api.storeAsTFile(&h1, basePath + "th1", f.metadata);
119
120 TGraph graph(10);
121 graph.SetPoint(0, 2, 3);
122 f.api.storeAsTFile(&graph, basePath + "graph", f.metadata);
123
124 TTree tree("mytree", "mytree");
125 int a = 4;
126 tree.Branch("det", &a, "a/I");
127 tree.Fill();
128 f.api.storeAsTFile(&tree, basePath + "tree", f.metadata);
129}
130
131BOOST_AUTO_TEST_CASE(store_retrieve_TMemFile_templated_test, *utf::precondition(if_reachable()))
132{
134
135 // try to store a user defined class
136 // since we don't depend on anything, we are putting an object known to CCDB
138 path.setPath("HelloWorld");
139
140 f.api.storeAsTFileAny(&path, basePath + "CCDBPath", f.metadata);
141
142 // try to retrieve strongly typed user defined class
143 // since we don't depend on anything, we are using an object known to CCDB
144 o2::ccdb::IdPath* path2 = nullptr;
145
146 path2 = f.api.retrieveFromTFileAny<o2::ccdb::IdPath>(basePath + "CCDBPath", f.metadata);
147 BOOST_CHECK_NE(path2, nullptr);
148
149 // check some non-trivial data content
150 BOOST_CHECK(path2 && path2->getPathString().CompareTo("HelloWorld") == 0);
151
152 // try to query with different type and verify that we get nullptr
153 BOOST_CHECK(f.api.retrieveFromTFileAny<o2::utils::RootChain>(basePath + "CCDBPath", f.metadata) == nullptr);
154
155 // try to get the headers back and to find the metadata
156 map<string, string> md;
157 path2 = f.api.retrieveFromTFileAny<o2::ccdb::IdPath>(basePath + "CCDBPath", f.metadata, -1, &md);
158 BOOST_CHECK_EQUAL(md.count("Hello"), 1);
159 BOOST_CHECK_EQUAL(md["Hello"], "World");
160
161 //-----------------------------------------------------------------------------------------------
162 // test if writing/reading complicated objects like TTree works (because of particular ownership)
163 // ----------------------------------------------------------------------------------------------
164 auto tree = new TTree("tree123", "tree123");
165 int a = 4;
166 tree->Branch("det", &a, "a/I");
167 tree->Fill();
168 f.api.storeAsTFileAny(tree, basePath + "tree2", f.metadata);
169 delete tree;
170
171 // read back
172 tree = f.api.retrieveFromTFileAny<TTree>(basePath + "tree2", f.metadata);
173 BOOST_CHECK(tree != nullptr);
174 BOOST_CHECK(tree != nullptr && std::strcmp(tree->GetName(), "tree123") == 0);
175 BOOST_CHECK(tree != nullptr && tree->GetEntries() == 1);
176
177 // ---------------------------
178 // test the snapshot mechanism
179 // ---------------------------
180 // a) create a local snapshot of the Test folder
181 // std::filesystem does not yet provide boost::filesystem::unique_path() equivalent, and usin tmpnam generate a warning
182 auto ph = o2::utils::Str::create_unique_path(std::filesystem::temp_directory_path().native());
183 std::filesystem::create_directories(ph);
184 std::cout << "Creating snapshot at " << ph << "\n";
185 f.api.snapshot(basePath, ph, o2::ccdb::getCurrentTimestamp());
186 std::cout << "Creating snapshot at " << ph << "\n";
187
188 // b) init a new instance from the snapshot and query something from it
189 o2::ccdb::CcdbApi snapshot;
190 snapshot.init(o2::utils::Str::concat_string("file://", ph));
191
192 // c) query from the snapshot
193 BOOST_CHECK(snapshot.retrieveFromTFileAny<o2::ccdb::IdPath>(basePath + "CCDBPath", f.metadata) != nullptr);
194
195 {
196 auto tree = snapshot.retrieveFromTFileAny<TTree>(basePath + "tree2", f.metadata);
197 BOOST_CHECK(tree != nullptr);
198 BOOST_CHECK(tree != nullptr && std::strcmp(tree->GetName(), "tree123") == 0);
199 BOOST_CHECK(tree != nullptr && tree->GetEntries() == 1);
200 }
201
202 // d) cleanup local snapshot
203 if (std::filesystem::exists(ph)) {
204 std::filesystem::remove_all(ph);
205 }
206}
207
208BOOST_AUTO_TEST_CASE(store_max_size_test, *utf::precondition(if_reachable()))
209{
211
212 // try to store a user defined class
213 // since we don't depend on anything, we are putting an object known to CCDB
215 path.setPath("HelloWorld");
216
217 int result = f.api.storeAsTFileAny(&path, basePath + "CCDBPath", f.metadata); // ok
219 result = f.api.storeAsTFileAny(&path, basePath + "CCDBPath", f.metadata, -1, -1, 1 /* bytes */); // we know this will fail
221}
222
224BOOST_AUTO_TEST_CASE(timestamptest, *utf::precondition(if_reachable()))
225{
227
228 // try to store a user defined class
229 // since we don't depend on anything, we are putting an object known to CCDB
231 path.setPath("HelloWorld");
232
233 const long timestamp = 1000; // inclusive start of validity
234 const long endvalidity = timestamp + 10; // exclusive end of validitiy
235 f.api.storeAsTFileAny(&path, basePath + "CCDBPathUnitTest", f.metadata, timestamp, endvalidity);
236
237 // try to retrieve strongly typed user defined class
238 // since we don't depend on anything, we are using an object known to CCDB
239 o2::ccdb::IdPath* path2 = nullptr;
240
241 path2 = f.api.retrieveFromTFileAny<o2::ccdb::IdPath>(basePath + "CCDBPathUnitTest", f.metadata, timestamp);
242 BOOST_CHECK_NE(path2, nullptr);
243
244 // check that we get something for the whole time range
245 for (int t = timestamp; t < endvalidity; ++t) {
246 auto p = f.api.retrieveFromTFileAny<o2::ccdb::IdPath>(basePath + "CCDBPathUnitTest", f.metadata, t);
247 BOOST_CHECK_NE(p, nullptr);
248 }
249
250 // check that answer is null for anything outside
251 auto plower = f.api.retrieveFromTFileAny<o2::ccdb::IdPath>(basePath + "CCDBPathUnitTest", f.metadata, timestamp - 1);
252 BOOST_CHECK(plower == nullptr);
253
254 auto pupper = f.api.retrieveFromTFileAny<o2::ccdb::IdPath>(basePath + "CCDBPathUnitTest", f.metadata, endvalidity);
255 BOOST_CHECK(pupper == nullptr);
256}
257
258BOOST_AUTO_TEST_CASE(retrieveTemplatedWithHeaders, *utf::precondition(if_reachable()))
259{
261
262 // first store something
264 path.setPath("HelloWorld");
265 long from = o2::ccdb::getCurrentTimestamp();
266 long to = o2::ccdb::getFutureTimestamp(60 * 60 * 24 * 365 * 10);
267 f.api.storeAsTFileAny(&path, basePath + "CCDBPathUnitTest", f.metadata, from, to);
268
269 // then try to retrieve, including the headers
270 std::map<std::string, std::string> headers;
271 std::map<std::string, std::string> meta;
272 cout << "basePath + \"CCDBPathUnitTest\" : " << basePath + "CCDBPathUnitTest" << endl;
273 cout << "from+1 : " << from + 1 << endl;
274 auto* object = f.api.retrieveFromTFileAny<o2::ccdb::IdPath>(basePath + "CCDBPathUnitTest", meta, from + 1, &headers);
275 BOOST_CHECK(headers.count("Hello") == 1);
276 BOOST_CHECK(headers["Hello"] == "World");
277}
278
279BOOST_AUTO_TEST_CASE(retrieveTMemFile_test, *utf::precondition(if_reachable()))
280{
282
283 TObject* obj = f.api.retrieveFromTFileAny<TObject>(basePath + "th1", f.metadata);
284 BOOST_CHECK_NE(obj, nullptr);
285 BOOST_CHECK_EQUAL(obj->ClassName(), "TH1F");
286 auto h1 = dynamic_cast<TH1F*>(obj);
287 BOOST_CHECK_NE(h1, nullptr);
288 BOOST_CHECK_EQUAL(obj->GetName(), "th1name");
289 delete obj;
290
291 obj = f.api.retrieveFromTFileAny<TObject>(basePath + "graph", f.metadata);
292 BOOST_CHECK_NE(obj, nullptr);
293 BOOST_CHECK_EQUAL(obj->ClassName(), "TGraph");
294 auto graph = dynamic_cast<TGraph*>(obj);
295 BOOST_CHECK_NE(graph, nullptr);
296 double x, y;
297 int ret = graph->GetPoint(0, x, y);
298 BOOST_CHECK_EQUAL(ret, 0);
300 BOOST_CHECK_EQUAL(graph->GetN(), 10);
301 delete graph;
302
303 std::map<std::string, std::string> headers;
304 obj = f.api.retrieveFromTFileAny<TObject>(basePath + "tree", f.metadata, -1, &headers);
305 BOOST_CHECK_NE(obj, nullptr);
306 BOOST_CHECK_EQUAL(obj->ClassName(), "TTree");
307 auto tree = dynamic_cast<TTree*>(obj);
308 BOOST_CHECK_NE(tree, nullptr);
309 BOOST_CHECK_EQUAL(tree->GetName(), "mytree");
310 delete obj;
311 // make sure we got the correct metadata
312 BOOST_CHECK(headers.count("Hello") == 1);
313 BOOST_CHECK_EQUAL(headers["Hello"], "World");
314
315 // wrong url
316 obj = f.api.retrieveFromTFileAny<TObject>("Wrong/wrong", f.metadata);
317 BOOST_CHECK_EQUAL(obj, nullptr);
318}
319
320BOOST_AUTO_TEST_CASE(truncate_test, *utf::precondition(if_reachable()))
321{
323
324 TH1F h("object1", "object1", 100, 0, 99);
325 f.api.storeAsTFile(&h, basePath + "Detector", f.metadata); // test with explicit dates
326 auto h1 = f.api.retrieveFromTFileAny<TH1F>(basePath + "Detector", f.metadata);
327 BOOST_CHECK(h1 != nullptr);
328 f.api.truncate(basePath + "Detector");
329 h1 = f.api.retrieveFromTFileAny<TH1F>(basePath + "Detector", f.metadata);
330 BOOST_CHECK(h1 == nullptr);
331}
332
333BOOST_AUTO_TEST_CASE(delete_test, *utf::precondition(if_reachable()))
334{
336
337 TH1F h1("object1", "object1", 100, 0, 99);
338 long from = o2::ccdb::getCurrentTimestamp();
339 long to = o2::ccdb::getFutureTimestamp(60 * 60 * 24 * 365 * 10);
340 f.api.storeAsTFile(&h1, basePath + "Detector", f.metadata, from, to); // test with explicit dates
341 auto h2 = f.api.retrieveFromTFileAny<TH1F>(basePath + "Detector", f.metadata);
342 BOOST_CHECK(h2 != nullptr);
343 f.api.deleteObject(basePath + "Detector");
344 h2 = f.api.retrieveFromTFileAny<TH1F>(basePath + "Detector", f.metadata);
345 BOOST_CHECK(h2 == nullptr);
346}
347
348void countItems(const string& s, int& countObjects, int& countSubfolders)
349{
350 countObjects = 0;
351 countSubfolders = 0;
352 std::stringstream ss(s);
353
354 boost::property_tree::ptree pt;
355 boost::property_tree::read_json(ss, pt);
356
357 if (pt.count("objects") > 0) {
358 countObjects = pt.get_child("objects").size();
359 }
360
361 if (pt.count("subfolders") > 0) {
362 countSubfolders = pt.get_child("subfolders").size();
363 }
364}
365
366BOOST_AUTO_TEST_CASE(list_test, *utf::precondition(if_reachable()))
367{
369
370 // test non-empty top dir
371 string s = f.api.list("", "application/json"); // top dir
372 long nbLines = std::count(s.begin(), s.end(), '\n') + 1;
373 BOOST_CHECK(nbLines > 5);
374
375 // test empty dir
376 f.api.truncate(basePath + "Detector*");
377 s = f.api.list(basePath + "Detector", false, "application/json");
378 int countObjects = 0;
379 int countSubfolders = 0;
380 countItems(s, countObjects, countSubfolders);
381 BOOST_CHECK_EQUAL(countObjects, 0);
382
383 // more complex tree
384 TH1F h1("object1", "object1", 100, 0, 99);
385 cout << "storing object 2 in Test/Detector" << endl;
386 f.api.storeAsTFile(&h1, basePath + "Detector", f.metadata);
387 cout << "storing object 3 in Test/Detector" << endl;
388 f.api.storeAsTFile(&h1, basePath + "Detector", f.metadata);
389 cout << "storing object 4 in Test/Detector" << endl;
390 f.api.storeAsTFile(&h1, basePath + "Detector", f.metadata);
391 cout << "storing object 5 in Test/Detector/Sub/abc" << endl;
392 f.api.storeAsTFile(&h1, basePath + "Detector/Sub/abc", f.metadata);
393
394 s = f.api.list(basePath + "Detector", false, "application/json");
395 countItems(s, countObjects, countSubfolders);
396 BOOST_CHECK_EQUAL(countObjects, 3);
397 BOOST_CHECK_EQUAL(countSubfolders, 1);
398
399 s = f.api.list(basePath + "Detector*", false, "application/json");
400 countItems(s, countObjects, countSubfolders);
401 BOOST_CHECK_EQUAL(countObjects, 4);
402 BOOST_CHECK_EQUAL(countSubfolders, 0);
403
404 s = f.api.list(basePath + "Detector", true, "application/json");
405 countItems(s, countObjects, countSubfolders);
406 BOOST_CHECK_EQUAL(countObjects, 1);
407}
408
409BOOST_AUTO_TEST_CASE(TestHeaderParsing)
410{
411 std::vector<std::string> headers = {
412 "HTTP/1.1 200",
413 "Content-Location: /download/6dcb77c0-ca56-11e9-a807-200114580202",
414 "Date: Thu, 26 Sep 2019 08:09:20 GMT",
415 "Valid-Until: 1567771311999",
416 "Valid-From: 1567080816927",
417 "InitialValidityLimit: 1598616816927",
418 "Created: 1567080816956",
419 "ETag: \"6dcb77c0-ca56-11e9-a807-200114580202\"",
420 "Last-Modified: Thu, 29 Aug 2019 12:13:36 GMT",
421 "UpdatedFrom: 2001:1458:202:28:0:0:100:35",
422 "partName: send",
423 "Content-Disposition: inline;filename=\"o2::dataformats::CalibLHCphaseTOF_1567080816916.root\"",
424 "Accept-Ranges: bytes",
425 "Content-MD5: 9481c9d036660f80e21dae5943c2096f",
426 "Content-Type: application/octet-stream",
427 "Content-Length: 2097152"};
428 std::vector<std::string> results;
429 std::string etag;
430 CcdbApi::parseCCDBHeaders(headers, results, etag);
431 BOOST_CHECK_EQUAL(etag, "\"6dcb77c0-ca56-11e9-a807-200114580202\"");
432 BOOST_REQUIRE_EQUAL(results.size(), 1);
433 BOOST_CHECK_EQUAL(results[0], "/download/6dcb77c0-ca56-11e9-a807-200114580202");
434}
435
436BOOST_AUTO_TEST_CASE(TestFetchingHeaders, *utf::precondition(if_reachable()))
437{
438 // first store the object
439 string objectPath = basePath + "objectETag";
441 TH1F h1("objectETag", "objectETag", 100, 0, 99);
442 f.api.storeAsTFile(&h1, objectPath, f.metadata);
443
444 // then get the headers
445 std::string etag;
446 std::vector<std::string> headers;
447 std::vector<std::string> pfns;
448 string path = objectPath + "/" + std::to_string(getCurrentTimestamp());
449 auto updated = CcdbApi::getCCDBEntryHeaders("http://ccdb-test.cern.ch:8080/" + path, etag, headers);
450 BOOST_CHECK_EQUAL(updated, true);
451 BOOST_REQUIRE(headers.size() != 0);
452 CcdbApi::parseCCDBHeaders(headers, pfns, etag);
453 BOOST_REQUIRE(etag != "");
454 BOOST_REQUIRE(pfns.size());
455 updated = CcdbApi::getCCDBEntryHeaders("http://ccdb-test.cern.ch:8080/" + path, etag, headers);
456 BOOST_CHECK_EQUAL(updated, false);
457}
458
459BOOST_AUTO_TEST_CASE(TestRetrieveHeaders, *utf::precondition(if_reachable()))
460{
462
463 TH1F h1("object1", "object1", 100, 0, 99);
464 cout << "storing object 1 in " << basePath << "Test" << endl;
465 map<string, string> metadata;
466 metadata["custom"] = "whatever";
467 f.api.storeAsTFile(&h1, basePath + "Test", metadata);
468
469 std::map<std::string, std::string> headers = f.api.retrieveHeaders(basePath + "Test", metadata);
470 BOOST_CHECK_NE(headers.size(), 0);
471 std::string h = headers["custom"];
472 BOOST_CHECK_EQUAL(h, "whatever");
473
474 int i = 0;
475 for (auto h : headers) {
476 cout << i++ << " : " << h.first << " -> " << h.second << endl;
477 }
478
479 headers = f.api.retrieveHeaders(basePath + "Test", metadata);
480 BOOST_CHECK_NE(headers.size(), 0);
481 h = headers["custom"];
482 BOOST_CHECK_EQUAL(h, "whatever");
483
484 metadata["custom"] = "something";
485 headers = f.api.retrieveHeaders(basePath + "Test", metadata);
486
487 i = 0;
488 for (auto h : headers) {
489 cout << i++ << " : " << h.first << " -> " << h.second << endl;
490 }
491 BOOST_CHECK_EQUAL(headers.size(), 0);
492}
493
494BOOST_AUTO_TEST_CASE(TestUpdateMetadata, *utf::precondition(if_reachable()))
495{
497
498 // upload an object
499 TH1F h1("object1", "object1", 100, 0, 99);
500 cout << "storing object 1 in " << basePath << "Test" << endl;
501 map<string, string> metadata;
502 metadata["custom"] = "whatever";
503 metadata["id"] = "first";
504 f.api.storeAsTFile(&h1, basePath + "Test", metadata);
505
506 // retrieve the headers just to be sure
507 std::map<std::string, std::string> headers = f.api.retrieveHeaders(basePath + "Test", metadata);
508 BOOST_CHECK(headers.count("custom") > 0);
509 BOOST_CHECK(headers.at("custom") == "whatever");
510 string firstID = headers.at("ETag");
511 firstID.erase(std::remove(firstID.begin(), firstID.end(), '"'), firstID.end());
512
513 map<string, string> newMetadata;
514 newMetadata["custom"] = "somethingelse";
515
516 // update the metadata and check
517 f.api.updateMetadata(basePath + "Test", newMetadata, o2::ccdb::getCurrentTimestamp());
518 headers = f.api.retrieveHeaders(basePath + "Test", newMetadata);
519 BOOST_CHECK(headers.count("custom") > 0);
520 BOOST_CHECK(headers.at("custom") == "somethingelse");
521
522 // add a second object
523 cout << "storing object 2 in " << basePath << "Test" << endl;
524 metadata.clear();
525 metadata["custom"] = "whatever";
526 metadata["id"] = "second";
527 f.api.storeAsTFile(&h1, basePath + "Test", metadata);
528
529 // get id
530 cout << "get id" << endl;
531 headers = f.api.retrieveHeaders(basePath + "Test", metadata);
532 string secondID = headers.at("ETag");
533 secondID.erase(std::remove(secondID.begin(), secondID.end(), '"'), secondID.end());
534
535 // update the metadata by id
536 cout << "update the metadata by id" << endl;
537 newMetadata.clear();
538 newMetadata["custom"] = "first";
539 f.api.updateMetadata(basePath + "Test", newMetadata, o2::ccdb::getCurrentTimestamp(), firstID);
540 newMetadata.clear();
541 newMetadata["custom"] = "second";
542 f.api.updateMetadata(basePath + "Test", newMetadata, o2::ccdb::getCurrentTimestamp(), secondID);
543
544 // check
545 metadata.clear();
546 metadata["id"] = "first";
547 headers = f.api.retrieveHeaders(basePath + "Test", metadata);
548 BOOST_CHECK(headers.count("custom") > 0);
549 BOOST_CHECK(headers.at("custom") == "first");
550 metadata.clear();
551 metadata["id"] = "second";
552 headers = f.api.retrieveHeaders(basePath + "Test", metadata);
553 BOOST_CHECK(headers.count("custom") > 0);
554 BOOST_CHECK(headers.at("custom") == "second");
555}
556
557BOOST_AUTO_TEST_CASE(multi_host_test)
558{
559 CcdbApi api;
560 api.init("http://bogus-host.cern.ch,http://ccdb-test.cern.ch:8080");
561 std::map<std::string, std::string> metadata;
562 std::map<std::string, std::string> headers;
564 std::string url = "Analysis/ALICE3/Centrality";
565 api.loadFileToMemory(dst, url, metadata, 1645780010602, &headers, "", "", "", true);
566 BOOST_CHECK(dst.size() != 0);
567}
568
570{
571 CcdbApi api;
572 api.init("http://ccdb-test.cern.ch:8080");
573
574 int TEST_SAMPLE_SIZE = 5;
575 std::vector<o2::pmr::vector<char>> dests(TEST_SAMPLE_SIZE);
576 std::vector<std::map<std::string, std::string>> metadatas(TEST_SAMPLE_SIZE);
577 std::vector<std::map<std::string, std::string>> headers(TEST_SAMPLE_SIZE);
578
579 std::vector<CcdbApi::RequestContext> contexts;
580 for (int i = 0; i < TEST_SAMPLE_SIZE; i++) {
581 contexts.push_back(CcdbApi::RequestContext(dests.at(i), metadatas.at(i), headers.at(i)));
582 contexts.at(i).path = "Analysis/ALICE3/Centrality";
583 contexts.at(i).timestamp = 1645780010602;
584 contexts.at(i).considerSnapshot = true;
585 }
586
587 api.vectoredLoadFileToMemory(contexts);
588
589 for (auto context : contexts) {
590 BOOST_CHECK(context.dest.size() != 0);
591 }
592}
int32_t i
Class for time synchronization of RawReader instances.
void init(std::string const &hosts)
Definition CcdbApi.cxx:165
bool isHostReachable() const
Definition CcdbApi.cxx:1301
void loadFileToMemory(std::vector< char > &dest, std::string const &path, std::map< std::string, std::string > const &metadata, long timestamp, std::map< std::string, std::string > *headers, std::string const &etag, const std::string &createdNotAfter, const std::string &createdNotBefore, bool considerSnapshot=true) const
Definition CcdbApi.cxx:1873
void vectoredLoadFileToMemory(std::vector< RequestContext > &requestContext) const
Definition CcdbApi.cxx:1941
static bool getCCDBEntryHeaders(std::string const &url, std::string const &etag, std::vector< std::string > &headers, const std::string &agentID="")
Definition CcdbApi.cxx:1496
void truncate(std::string const &path) const
Definition CcdbApi.cxx:1270
static void parseCCDBHeaders(std::vector< std::string > const &headers, std::vector< std::string > &pfns, std::string &etag)
Definition CcdbApi.cxx:1531
const TString & getPathString() const
Definition IdPath.h:43
GLsizei const GLchar *const * string
Definition glcorearb.h:809
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint64EXT * result
Definition glcorearb.h:5662
GLdouble f
Definition glcorearb.h:310
GLint y
Definition glcorearb.h:270
GLenum GLenum dst
Definition glcorearb.h:1767
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
information complementary to a CCDB object (path, metadata, startTimeValidity, endTimeValidity etc)
long getCurrentTimestamp()
returns the timestamp in long corresponding to "now"
long getFutureTimestamp(int secondsInFuture)
returns the timestamp in long corresponding to "now + secondsInFuture"
std::vector< T, o2::pmr::polymorphic_allocator< T > > vector
Defining DataPointCompositeObject explicitly as copiable.
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
tt::assertion_result operator()(utf::test_unit_id)
static std::string concat_string(Ts const &... ts)
static std::string create_unique_path(const std::string_view prefix="", int length=16)
~test_fixture()=default
map< string, string > metadata
std::string ccdbUrl
bool hostReachable
bool hostReachable
BOOST_AUTO_TEST_CASE(storeTMemFile_test, *utf::precondition(if_reachable()))
BOOST_GLOBAL_FIXTURE(Fixture)
bool hostReachable
void countItems(const string &s, int &countObjects, int &countSubfolders)
BOOST_CHECK(tree)
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())