Project
Loading...
Searching...
No Matches
testCcdbApi_alien.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
17
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 <TH1.h>
24#include <boost/test/unit_test.hpp>
25#include <iostream>
26
27using namespace std;
28using namespace o2::ccdb;
29namespace utf = boost::unit_test;
30namespace tt = boost::test_tools;
31
32static string ccdbUrl;
33bool hostReachable = false;
34
38struct Fixture {
40 {
41 CcdbApi api;
42 ccdbUrl = "http://alice-ccdb.cern.ch";
43 api.init(ccdbUrl);
44 cout << "ccdb url: " << ccdbUrl << endl;
46 cout << "Is host reachable ? --> " << hostReachable << endl;
47 }
48};
50
54struct if_reachable {
55 tt::assertion_result operator()(utf::test_unit_id)
56 {
57 return hostReachable;
58 }
59};
60
64struct test_fixture {
66 {
68 metadata["Hello"] = "World";
69 std::cout << "*** " << boost::unit_test::framework::current_test_case().p_name << " ***" << std::endl;
70 }
71 ~test_fixture() = default;
72
74 map<string, string> metadata;
75};
76
77// handle the case where the object comes from alien and redirect does not work with curl
78BOOST_AUTO_TEST_CASE(retrieveTemplated_ALIEN, *utf::precondition(if_reachable()))
79{
81
82 // try to retrieve an object from the production instance, including the headers
83 std::map<std::string, std::string> headers;
84 std::map<std::string, std::string> meta;
85
86 std::string path("/Users/j/jgrosseo/tutorial/efficiency/simple/1");
87 {
88 auto* object = f.api.retrieveFromTFileAny<TH1>(path, meta, -1, &headers);
89 BOOST_CHECK(object != nullptr);
90 LOG(info) << headers["Content-Location"];
91 if (object) {
92 BOOST_CHECK(headers.size() > 0);
93 LOG(info) << "Histo name " << object->GetName();
94 LOG(info) << "Number of bins " << object->GetNbinsX() << " Mean " << object->GetMean();
95 }
96 }
97
98 // it should also work without headers of course
99 {
100 auto* object = f.api.retrieveFromTFileAny<TH1>(path, meta);
101 BOOST_CHECK(object != nullptr);
102 }
103}
void init(std::string const &hosts)
Definition CcdbApi.cxx:165
bool isHostReachable() const
Definition CcdbApi.cxx:1301
GLdouble f
Definition glcorearb.h:310
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
information complementary to a CCDB object (path, metadata, startTimeValidity, endTimeValidity etc)
Defining DataPointCompositeObject explicitly as copiable.
tt::assertion_result operator()(utf::test_unit_id)
~test_fixture()=default
map< string, string > metadata
std::string ccdbUrl
bool hostReachable
bool hostReachable
BOOST_AUTO_TEST_CASE(retrieveTemplated_ALIEN, *utf::precondition(if_reachable()))
BOOST_GLOBAL_FIXTURE(Fixture)
bool hostReachable
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
BOOST_CHECK(tree)