Project
Loading...
Searching...
No Matches
testCcdbApiMultipleUrls.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
12#define BOOST_TEST_MODULE CCDB
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15
16#include "CCDB/CcdbApi.h"
18#include <boost/test/unit_test.hpp>
19#include <cstdio>
20#include <TH1F.h>
21
22using namespace std;
23using namespace o2::ccdb;
24namespace utf = boost::unit_test;
25namespace tt = boost::test_tools;
26
27static string ccdbUrl;
28static string basePath;
29bool hostReachable = false;
30
34struct Fixture {
36 {
37 CcdbApi api;
38 ccdbUrl = "https://localhost:22,https://localhost:8080,http://ccdb-test.cern.ch:8080";
39 api.init(ccdbUrl);
40 cout << "ccdb url: " << ccdbUrl << endl;
42 cout << "Is host reachable ? --> " << hostReachable << endl;
43 basePath = string("Test/pid") + getpid() + "/";
44 cout << "Path we will use in this test suite : " + basePath << endl;
45 }
47 {
48 if (hostReachable) {
49 CcdbApi api;
50 map<string, string> metadata;
51 api.init(ccdbUrl);
52 api.truncate(basePath + "*");
53 cout << "Test data truncated (" << basePath << ")" << endl;
54 }
55 }
56};
58
62struct if_reachable {
63 tt::assertion_result operator()(utf::test_unit_id)
64 {
65 return hostReachable;
66 }
67};
68
72struct test_fixture {
74 {
76 metadata["Hello"] = "World";
77 std::cout << "*** " << boost::unit_test::framework::current_test_case().p_name << " ***" << std::endl;
78 }
79 ~test_fixture() = default;
80
82 map<string, string> metadata;
83};
84
85BOOST_AUTO_TEST_CASE(storeAndRetrieve, *utf::precondition(if_reachable()))
86{
88
89 TH1F h1("th1name", "th1name", 100, 0, 99);
90 h1.FillRandom("gaus", 10000);
91 BOOST_CHECK_EQUAL(h1.ClassName(), "TH1F");
92 cout << "ccdb/TObject/TEST" << endl;
93 long timestamp = getCurrentTimestamp();
94 f.api.storeAsTFile(&h1, "ccdb/TObject/TEST", f.metadata, timestamp);
95
96 TObject* returnResult = f.api.retrieve("ccdb/TObject/TEST/" + to_string(timestamp), f.metadata, timestamp);
97 BOOST_CHECK(returnResult != nullptr);
98}
void init(std::string const &hosts)
Definition CcdbApi.cxx:165
bool isHostReachable() const
Definition CcdbApi.cxx:1301
void truncate(std::string const &path) const
Definition CcdbApi.cxx:1270
GLsizei const GLchar *const * string
Definition glcorearb.h:809
GLdouble f
Definition glcorearb.h:310
information complementary to a CCDB object (path, metadata, startTimeValidity, endTimeValidity etc)
BOOST_AUTO_TEST_CASE(asynch_schedule_test)
long getCurrentTimestamp()
returns the timestamp in long corresponding to "now"
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)
~test_fixture()=default
map< string, string > metadata
std::string ccdbUrl
bool hostReachable
BOOST_GLOBAL_FIXTURE(Fixture)
bool hostReachable
BOOST_CHECK(tree)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())