9 #include <hlt/softwaretrigger/core/SoftwareTriggerDBHandler.h>
10 #include <framework/database/Configuration.h>
11 #include <framework/database/Database.h>
13 #include <framework/utilities/TestHelpers.h>
14 #include <gtest/gtest.h>
23 namespace SoftwareTrigger {
36 DataStore::Instance().setInitializeActive(
true);
38 DataStore::Instance().setInitializeActive(
false);
41 auto& conf = Conditions::Configuration::getInstance();
42 conf.setNewPayloadLocation(m_tmpDir->
getTempDir() +
"/testPayloads/TestDatabase.txt");
43 conf.prependTestingPayloadLocation(m_tmpDir->
getTempDir() +
"/testPayloads/TestDatabase.txt");
50 DBStore::Instance().reset();
51 DataStore::Instance().reset();
58 TEST_F(SoftwareTriggerDBHandlerTest, downloadAndChanged)
60 SoftwareTriggerObject preFilledObject;
65 const auto& cutOne = SoftwareTriggerCut::compile(
"1 == 1", 1);
68 SoftwareTriggerDBHandler::upload(cutOne,
"test",
"cutOne", iov);
71 SoftwareTriggerDBHandler::uploadTriggerMenu(
"test", {
"cutOne",
"cutTwo"},
true, iov);
72 EXPECT_B2FATAL(SoftwareTriggerDBHandler(
"test"));
75 SoftwareTriggerDBHandler::uploadTriggerMenu(
"test", {
"cutOne"},
true, iov);
77 SoftwareTriggerDBHandler dbHandler(
"test");
78 const auto& cutsWithNames = dbHandler.getCutsWithNames();
79 EXPECT_EQ(SoftwareTriggerCutResult::c_accept,
80 cutsWithNames.at(
"software_trigger_cut&test&cutOne")->checkPreScaled(preFilledObject));
81 EXPECT_THROW(cutsWithNames.at(
"software_trigger_cut&test&cutTwo"), std::out_of_range);
84 const auto& cutTwo = SoftwareTriggerCut::compile(
"1 == 2", 1);
87 SoftwareTriggerDBHandler::upload(cutOne,
"test2",
"cutOne", iov);
88 SoftwareTriggerDBHandler::upload(cutTwo,
"test2",
"cutTwo", iov);
91 SoftwareTriggerDBHandler::uploadTriggerMenu(
"test2", {
"cutOne",
"cutTwo"},
true, iov);
93 SoftwareTriggerDBHandler otherDBHandler(
"test2");
94 const auto& otherCutsWithNames = otherDBHandler.getCutsWithNames();
96 EXPECT_EQ(SoftwareTriggerCutResult::c_accept,
97 otherCutsWithNames.at(
"software_trigger_cut&test2&cutOne")->checkPreScaled(preFilledObject));
98 EXPECT_EQ(SoftwareTriggerCutResult::c_noResult,
99 otherCutsWithNames.at(
"software_trigger_cut&test2&cutTwo")->checkPreScaled(preFilledObject));
104 TEST_F(SoftwareTriggerDBHandlerTest, pythonUpAndDownload)
106 IntervalOfValidity iov(0, 0, -1, -1);
109 auto cutOne = SoftwareTriggerCut::compile(
"1 == 1", 1);
111 SoftwareTriggerDBHandler::upload(cutOne,
"test",
"cutOne1", iov);
112 auto downloadedCutOne = SoftwareTriggerDBHandler::download(
"test",
"cutOne1");
114 ASSERT_NE(downloadedCutOne,
nullptr);
116 EXPECT_EQ(cutOne->decompile(), downloadedCutOne->decompile());
117 EXPECT_EQ(cutOne->getPreScaleFactor(), downloadedCutOne->getPreScaleFactor());
118 EXPECT_EQ(cutOne->isRejectCut(), downloadedCutOne->isRejectCut());
121 const auto& cutTwo = SoftwareTriggerCut::compile(
"1 == 2", 1,
true);
123 SoftwareTriggerDBHandler::upload(cutTwo,
"test",
"cutTwo2", iov);
124 const auto& downloadedCutTwo = SoftwareTriggerDBHandler::download(
"test",
"cutTwo2");
126 ASSERT_NE(downloadedCutTwo,
nullptr);
128 EXPECT_EQ(cutTwo->decompile(), downloadedCutTwo->decompile());
129 EXPECT_EQ(cutTwo->getPreScaleFactor(), downloadedCutTwo->getPreScaleFactor());
130 EXPECT_EQ(cutTwo->isRejectCut(), downloadedCutTwo->isRejectCut());
A class that describes the interval of experiments/runs for which an object in the database is valid.
Class to test the down- and upload of trigger cuts to the DB.
void SetUp()
Setup the local DB and the datastore with the event meta data.
void TearDown()
Destroy the DB and the DataStore.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Type-safe access to single objects in the data store.
bool construct(Args &&... params)
Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.
changes working directory into a newly created directory, and removes it (and contents) on destructio...
std::string getTempDir() const
Returns path of temporary directory.
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
Abstract base class for different kinds of events.