Skip to content

Commit d00fd47

Browse files
awegrzynBarthelemy
authored andcommitted
Add CCDB optional test (#161)
1 parent 8f51dd8 commit d00fd47

2 files changed

Lines changed: 93 additions & 1 deletion

File tree

Framework/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ set(
222222
test/testQCTask.cxx
223223
test/testQuality.cxx
224224
test/testObjectsManager.cxx
225+
test/testCcdbDatabase.cxx
225226
)
226227

227228
foreach(test ${TEST_SRCS})
@@ -332,4 +333,4 @@ install(
332333
script/RepoCleaner/config.yaml
333334
DESTINATION
334335
etc
335-
)
336+
)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
///
12+
/// \file testCcdbDatabase.cxx
13+
/// \author Adam Wegrzynek
14+
///
15+
16+
#include <QualityControl/DatabaseFactory.h>
17+
#include <unordered_map>
18+
19+
#define BOOST_TEST_MODULE CcdbDatabase test
20+
#define BOOST_TEST_MAIN
21+
#define BOOST_TEST_DYN_LINK
22+
23+
#include <boost/test/unit_test.hpp>
24+
#include <boost/property_tree/ptree.hpp>
25+
#include <boost/property_tree/json_parser.hpp>
26+
27+
namespace o2::quality_control::core
28+
{
29+
30+
namespace
31+
{
32+
33+
using namespace o2::quality_control::core;
34+
using namespace o2::quality_control::repository;
35+
36+
const std::string CCDB_ENDPOINT = "ccdb-test.cern.ch:8080";
37+
std::unique_ptr<DatabaseInterface> BackendInstance;
38+
std::unordered_map<std::string, std::string> Objects;
39+
40+
BOOST_AUTO_TEST_SUITE(optionalTest, *boost::unit_test::disabled())
41+
42+
BOOST_AUTO_TEST_CASE(ccdb_create)
43+
{
44+
BackendInstance = DatabaseFactory::create("CCDB");
45+
BackendInstance->connect(CCDB_ENDPOINT, "", "", "");
46+
}
47+
48+
BOOST_AUTO_TEST_CASE(ccdb_getobjects)
49+
{
50+
auto tasks = BackendInstance->getListOfTasksWithPublications();
51+
for (auto& task : tasks) {
52+
auto objects = BackendInstance->getPublishedObjectNames(task);
53+
for (auto& object : objects) {
54+
Objects.insert({ task, object });
55+
}
56+
}
57+
}
58+
59+
BOOST_AUTO_TEST_CASE(ccdb_retrieve)
60+
{
61+
for (auto const& [task, object] : Objects) {
62+
std::cout << "[RETRIEVE]: " << task << "/" << object << std::endl;
63+
BackendInstance->retrieve(task, object);
64+
}
65+
}
66+
67+
BOOST_AUTO_TEST_CASE(ccdb_retrievejson)
68+
{
69+
for (auto const& [task, object] : Objects) {
70+
std::cout << "[JSON RETRIEVE]: " << task << "/" << object << std::endl;
71+
auto json = BackendInstance->retrieveJson(task, object);
72+
if (json.empty()) {
73+
std::cout << "skipping empty object..." << std::endl;
74+
continue;
75+
}
76+
std::stringstream ss;
77+
ss << json;
78+
boost::property_tree::ptree pt;
79+
boost::property_tree::read_json(ss, pt);
80+
}
81+
}
82+
83+
BOOST_AUTO_TEST_SUITE_END()
84+
85+
BOOST_AUTO_TEST_CASE(Dummy)
86+
{
87+
BOOST_CHECK(true);
88+
}
89+
90+
} // namespace
91+
} // namespace o2::quality_control::core

0 commit comments

Comments
 (0)