Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 50 additions & 47 deletions Framework/CCDBSupport/src/CCDBHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
#include "CCDB/CcdbApi.h"
#include "CommonConstants/LHCConstants.h"
#include "Framework/Signpost.h"
#include <typeinfo>
#include <TError.h>
#include <TMemFile.h>
#include <functional>

O2_DECLARE_DYNAMIC_LOG(ccdb);

Expand Down Expand Up @@ -159,6 +157,55 @@ CCDBHelpers::ParserResult CCDBHelpers::parseRemappings(char const* str)
}
}

void initialiseHelper(CCDBFetcherHelper& helper, ConfigParamRegistry const& options, std::vector<o2::framework::OutputRoute> const& outputRoutes)
{
std::unordered_map<std::string, bool> accountedSpecs;
auto defHost = options.get<std::string>("condition-backend");
auto checkRate = options.get<int>("condition-tf-per-query");
auto checkMult = options.get<int>("condition-tf-per-query-multiplier");
helper.timeToleranceMS = options.get<int64_t>("condition-time-tolerance");
helper.queryPeriodGlo = checkRate > 0 ? checkRate : std::numeric_limits<int>::max();
helper.queryPeriodFactor = checkMult > 0 ? checkMult : 1;
LOGP(info, "CCDB Backend at: {}, validity check for every {} TF{}", defHost, helper.queryPeriodGlo, helper.queryPeriodFactor == 1 ? std::string{} : fmt::format(", (query for high-rate objects downscaled by {})", helper.queryPeriodFactor));
LOGP(info, "Hook to enable signposts for CCDB messages at {}", (void*)&private_o2_log_ccdb->stacktrace);
auto remapString = options.get<std::string>("condition-remap");
CCDBHelpers::ParserResult result = CCDBHelpers::parseRemappings(remapString.c_str());
if (!result.error.empty()) {
throw runtime_error_f("Error while parsing remapping string %s", result.error.c_str());
}
helper.remappings = result.remappings;
helper.apis[""].init(defHost); // default backend
LOGP(info, "Initialised default CCDB host {}", defHost);
//
for (auto& entry : helper.remappings) { // init api instances for every host seen in the remapping
if (helper.apis.find(entry.second) == helper.apis.end()) {
helper.apis[entry.second].init(entry.second);
LOGP(info, "Initialised custom CCDB host {}", entry.second);
}
LOGP(info, "{} is remapped to {}", entry.first, entry.second);
}
helper.createdNotBefore = std::to_string(options.get<int64_t>("condition-not-before"));
helper.createdNotAfter = std::to_string(options.get<int64_t>("condition-not-after"));

for (auto& route : outputRoutes) {
if (route.matcher.lifetime != Lifetime::Condition) {
continue;
}
auto specStr = DataSpecUtils::describe(route.matcher);
if (accountedSpecs.find(specStr) != accountedSpecs.end()) {
continue;
}
accountedSpecs[specStr] = true;
helper.routes.push_back(route);
LOGP(info, "The following route is a condition {}", DataSpecUtils::describe(route.matcher));
for (auto& metadata : route.matcher.metadata) {
if (metadata.type == VariantType::String) {
LOGP(info, "- {}: {}", metadata.name, metadata.defaultValue.asString());
}
}
}
}

auto getOrbitResetTime(std::pmr::vector<char> const& v) -> Long64_t
{
Int_t previousErrorLevel = gErrorIgnoreLevel;
Expand Down Expand Up @@ -307,51 +354,7 @@ AlgorithmSpec CCDBHelpers::fetchFromCCDB()
{
return adaptStateful([](CallbackService& callbacks, ConfigParamRegistry const& options, DeviceSpec const& spec) {
std::shared_ptr<CCDBFetcherHelper> helper = std::make_shared<CCDBFetcherHelper>();
std::unordered_map<std::string, bool> accountedSpecs;
auto defHost = options.get<std::string>("condition-backend");
auto checkRate = options.get<int>("condition-tf-per-query");
auto checkMult = options.get<int>("condition-tf-per-query-multiplier");
helper->timeToleranceMS = options.get<int64_t>("condition-time-tolerance");
helper->queryPeriodGlo = checkRate > 0 ? checkRate : std::numeric_limits<int>::max();
helper->queryPeriodFactor = checkMult > 0 ? checkMult : 1;
LOGP(info, "CCDB Backend at: {}, validity check for every {} TF{}", defHost, helper->queryPeriodGlo, helper->queryPeriodFactor == 1 ? std::string{} : fmt::format(", (query for high-rate objects downscaled by {})", helper->queryPeriodFactor));
LOGP(info, "Hook to enable signposts for CCDB messages at {}", (void*)&private_o2_log_ccdb->stacktrace);
auto remapString = options.get<std::string>("condition-remap");
ParserResult result = CCDBHelpers::parseRemappings(remapString.c_str());
if (!result.error.empty()) {
throw runtime_error_f("Error while parsing remapping string %s", result.error.c_str());
}
helper->remappings = result.remappings;
helper->apis[""].init(defHost); // default backend
LOGP(info, "Initialised default CCDB host {}", defHost);
//
for (auto& entry : helper->remappings) { // init api instances for every host seen in the remapping
if (helper->apis.find(entry.second) == helper->apis.end()) {
helper->apis[entry.second].init(entry.second);
LOGP(info, "Initialised custom CCDB host {}", entry.second);
}
LOGP(info, "{} is remapped to {}", entry.first, entry.second);
}
helper->createdNotBefore = std::to_string(options.get<int64_t>("condition-not-before"));
helper->createdNotAfter = std::to_string(options.get<int64_t>("condition-not-after"));

for (auto &route : spec.outputs) {
if (route.matcher.lifetime != Lifetime::Condition) {
continue;
}
auto specStr = DataSpecUtils::describe(route.matcher);
if (accountedSpecs.find(specStr) != accountedSpecs.end()) {
continue;
}
accountedSpecs[specStr] = true;
helper->routes.push_back(route);
LOGP(info, "The following route is a condition {}", DataSpecUtils::describe(route.matcher));
for (auto& metadata : route.matcher.metadata) {
if (metadata.type == VariantType::String) {
LOGP(info, "- {}: {}", metadata.name, metadata.defaultValue.asString());
}
}
}
initialiseHelper(*helper, options, spec.outputs);
/// Add a callback on stop which dumps the statistics for the caching per
/// path
callbacks.set<CallbackService::Id::Stop>([helper]() {
Expand Down
13 changes: 8 additions & 5 deletions Framework/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,14 @@ set_property(TARGET o2-test-framework-root PROPERTY RUNTIME_OUTPUT_DIRECTORY ${o
add_test(NAME framework:root COMMAND o2-test-framework-root --skip-benchmarks)
add_test(NAME framework:crash COMMAND sh -e -c "PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}:$PATH ${CMAKE_CURRENT_LIST_DIR}/test/test_AllCrashTypes.sh")

o2_add_test(InfoLogger NAME test_Framework_test_InfoLogger
SOURCES test/test_InfoLogger.cxx
COMPONENT_NAME Framework
LABELS framework
PUBLIC_LINK_LIBRARIES O2::Framework AliceO2::InfoLogger)
add_executable(o2-test-framework-infologger
test/test_InfoLogger.cxx)
target_link_libraries(o2-test-framework-infologger PRIVATE O2::Framework)
target_link_libraries(o2-test-framework-infologger PRIVATE AliceO2::InfoLogger)
target_link_libraries(o2-test-framework-infologger PRIVATE O2::Catch2)
set_property(TARGET o2-test-framework-infologger
PROPERTY RUNTIME_OUTPUT_DIRECTORY ${outdir})
add_test(NAME framework:infologger COMMAND o2-test-framework-infologger)

o2_add_executable(dpl-null-sink
SOURCES src/o2NullSink.cxx
Expand Down
2 changes: 0 additions & 2 deletions Framework/Core/test/test_HTTPParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#include <boost/test/tools/old/interface.hpp>

#include "../src/HTTPParser.h"
#include <catch_amalgamated.hpp>

Expand Down
10 changes: 3 additions & 7 deletions Framework/Core/test/test_InfoLogger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#define BOOST_TEST_MODULE Test Framework InfoLoggerTest
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK

#include <boost/test/unit_test.hpp>
#include <catch_amalgamated.hpp>

#include <InfoLogger/InfoLogger.hxx>
using namespace AliceO2::InfoLogger;

BOOST_AUTO_TEST_CASE(InfoLoggerTest)
TEST_CASE("InfoLoggerTest")
{

// define infologger output to stdout, as we don't want to use the default infoLoggerD pipe which might not be running here
Expand All @@ -27,5 +23,5 @@ BOOST_AUTO_TEST_CASE(InfoLoggerTest)
InfoLogger theLog;

// log a test message
BOOST_CHECK(theLog.log("This is a log message test to stdout") == 0);
CHECK(theLog.log("This is a log message test to stdout") == 0);
}
2 changes: 0 additions & 2 deletions Framework/Core/test/test_Parallel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#include "Framework/ParallelContext.h"
#include "Framework/runDataProcessing.h"

#include <boost/algorithm/string.hpp>

using namespace o2::framework;

struct FakeCluster {
Expand Down
7 changes: 0 additions & 7 deletions Framework/Core/test/test_RegionInfoCallbackService.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include <boost/algorithm/string.hpp>

#include "Framework/InputSpec.h"
#include "Framework/CallbackService.h"
#include "Framework/ControlService.h"
#include "Framework/DataProcessorSpec.h"
#include "Framework/ParallelContext.h"
#include "Framework/runDataProcessing.h"
#include "Framework/Logger.h"

#include <chrono>
#include <thread>

using namespace o2::framework;
using DataHeader = o2::header::DataHeader;

Expand Down
2 changes: 0 additions & 2 deletions Framework/Core/test/test_Services.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include <boost/test/tools/old/interface.hpp>

#include "Framework/ServiceHandle.h"
#include "Framework/ServiceRegistry.h"
#include "Framework/CallbackService.h"
Expand Down
6 changes: 2 additions & 4 deletions Framework/Core/test/test_TimePipeline.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/InputSpec.h"

#include "Framework/DataProcessorSpec.h"
#include "Framework/ParallelContext.h"
#include "Framework/runDataProcessing.h"

#include <boost/algorithm/string.hpp>

#include <thread>
#include <chrono>

using namespace o2::framework;
Expand Down