|
11 | 11 | /// |
12 | 12 | /// \file testCcdbDatabase.cxx |
13 | 13 | /// \author Adam Wegrzynek |
| 14 | +/// \author Bartheley von Haller |
14 | 15 | /// |
15 | 16 |
|
16 | 17 | #include <QualityControl/DatabaseFactory.h> |
17 | 18 | #include <unordered_map> |
| 19 | +#include <QualityControl/CcdbDatabase.h> |
18 | 20 |
|
19 | 21 | #define BOOST_TEST_MODULE CcdbDatabase test |
20 | 22 | #define BOOST_TEST_MAIN |
|
26 | 28 | #include <TH1F.h> |
27 | 29 | #include <TFile.h> |
28 | 30 |
|
| 31 | +namespace utf = boost::unit_test; |
| 32 | + |
29 | 33 | namespace o2::quality_control::core |
30 | 34 | { |
31 | 35 |
|
@@ -83,7 +87,7 @@ BOOST_AUTO_TEST_CASE(ccdb_store) |
83 | 87 | f.backend->store(mo1); |
84 | 88 | } |
85 | 89 |
|
86 | | -BOOST_AUTO_TEST_CASE(ccdb_retrieve) |
| 90 | +BOOST_AUTO_TEST_CASE(ccdb_retrieve, *utf::depends_on("ccdb_store")) |
87 | 91 | { |
88 | 92 | test_fixture f; |
89 | 93 | MonitorObject* mo = f.backend->retrieve("my/task", "asdf/asdf"); |
@@ -124,5 +128,37 @@ BOOST_AUTO_TEST_CASE(ccdb_retrievejson) |
124 | 128 | } |
125 | 129 | } |
126 | 130 |
|
| 131 | +BOOST_AUTO_TEST_CASE(ccdb_retrieve_former_versions, *utf::depends_on("ccdb_store")) |
| 132 | +{ |
| 133 | + // store a new object |
| 134 | + long initialTimestamp = CcdbDatabase::getCurrentTimestamp(); |
| 135 | + test_fixture f; |
| 136 | + TH1F* h1 = new TH1F("asdf/asdf", "asdf", 100, 0, 99); |
| 137 | + h1->FillRandom("gaus", 10001); |
| 138 | + shared_ptr<MonitorObject> mo1 = make_shared<MonitorObject>(h1, "my/task"); |
| 139 | + f.backend->store(mo1); |
| 140 | + |
| 141 | + // Retrieve old object stored at timestampStorage |
| 142 | + MonitorObject* mo = f.backend->retrieve("my/task", "asdf/asdf", initialTimestamp); |
| 143 | + BOOST_CHECK_NE(mo, nullptr); |
| 144 | + TH1F* old = dynamic_cast<TH1F*>(mo->getObject()); |
| 145 | + BOOST_CHECK_NE(old, nullptr); |
| 146 | + BOOST_CHECK_EQUAL(old->GetEntries(), 10000); |
| 147 | + |
| 148 | + // Retrieve latest object with timestamp |
| 149 | + MonitorObject* mo2 = f.backend->retrieve("my/task", "asdf/asdf", CcdbDatabase::getCurrentTimestamp()); |
| 150 | + BOOST_CHECK_NE(mo2, nullptr); |
| 151 | + TH1F* latest = dynamic_cast<TH1F*>(mo2->getObject()); |
| 152 | + BOOST_CHECK_NE(latest, nullptr); |
| 153 | + BOOST_CHECK_EQUAL(latest->GetEntries(), 10001); |
| 154 | + |
| 155 | + // Retrieve latest object without timetsamp |
| 156 | + MonitorObject* mo3 = f.backend->retrieve("my/task", "asdf/asdf"); |
| 157 | + BOOST_CHECK_NE(mo3, nullptr); |
| 158 | + TH1F* latest2 = dynamic_cast<TH1F*>(mo3->getObject()); |
| 159 | + BOOST_CHECK_NE(latest2, nullptr); |
| 160 | + BOOST_CHECK_EQUAL(latest2->GetEntries(), 10001); |
| 161 | +} |
| 162 | + |
127 | 163 | } // namespace |
128 | 164 | } // namespace o2::quality_control::core |
0 commit comments