Skip to content

Commit d39deb0

Browse files
knopers8sawenzel
authored andcommitted
[QC-437] Do not throw if no DataSamplingPolicies are specified
1 parent 8054558 commit d39deb0

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

Utilities/DataSampling/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ o2_add_library(DataSampling
3434

3535
# tests with input data
3636

37-
o2_data_file(COPY test/test_DataSampling.json DESTINATION tests)
37+
o2_data_file(COPY test/test_DataSampling.json test/test_DataSamplingEmpty.json DESTINATION tests)
3838

3939
o2_add_test(DataSampling NAME test_DataSampling_test_DataSampling
4040
SOURCES test/test_DataSampling.cxx

Utilities/DataSampling/src/DataSampling.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ std::string DataSampling::createDispatcherName()
3838
void DataSampling::GenerateInfrastructure(WorkflowSpec& workflow, const std::string& policiesSource, size_t threads)
3939
{
4040
std::unique_ptr<ConfigurationInterface> cfg = ConfigurationFactory::getConfiguration(policiesSource);
41+
if (cfg->getRecursive("").count("dataSamplingPolicies") == 0) {
42+
LOG(WARN) << "No \"dataSamplingPolicies\" structure found in the config file. If no Data Sampling is expected, then it is completely fine.";
43+
return;
44+
}
4145
auto policiesTree = cfg->getRecursive("dataSamplingPolicies");
4246
Dispatcher dispatcher(createDispatcherName(), policiesSource);
4347
DataSampling::DoGenerateInfrastructure(dispatcher, workflow, policiesTree, threads);

Utilities/DataSampling/test/test_DataSampling.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,11 @@ BOOST_AUTO_TEST_CASE(InputSpecsForPolicy)
216216

217217
BOOST_CHECK_EQUAL(inputs.size(), 2);
218218
}
219+
220+
BOOST_AUTO_TEST_CASE(DataSamplingEmptyConfig)
221+
{
222+
std::string configFilePath = "json:/" + std::string(getenv("O2_ROOT")) + "/share/tests/test_DataSamplingEmpty.json";
223+
224+
WorkflowSpec workflow;
225+
BOOST_CHECK_NO_THROW(DataSampling::GenerateInfrastructure(workflow, configFilePath));
226+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

0 commit comments

Comments
 (0)