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