Skip to content

Commit 458aa0d

Browse files
authored
Data Sampling: remove ConfigurationInterface usage, update tests (#6819)
1 parent 17bbb63 commit 458aa0d

4 files changed

Lines changed: 58 additions & 97 deletions

File tree

Utilities/DataSampling/include/DataSampling/DataSampling.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,31 +95,12 @@ class DataSampling
9595
static void CustomizeInfrastructure(std::vector<framework::CompletionPolicy>&);
9696
/// \brief Applies blocking/nonblocking data sampling configuration to the workflow.
9797
static void CustomizeInfrastructure(std::vector<framework::ChannelConfigurationPolicy>&);
98-
/// \brief Provides InputSpecs to receive data for given DataSamplingPolicy
99-
static std::vector<framework::InputSpec> InputSpecsForPolicy(const std::string& policiesSource, const std::string& policyName);
100-
/// \brief Provides InputSpecs to receive data for given DataSamplingPolicy
101-
/// @deprecated
102-
static std::vector<framework::InputSpec> InputSpecsForPolicy(configuration::ConfigurationInterface* const config, const std::string& policyName);
103-
/// \brief Provides InputSpecs to receive data for given DataSamplingPolicy
104-
static std::vector<framework::InputSpec> InputSpecsForPolicy(std::shared_ptr<configuration::ConfigurationInterface> config, const std::string& policyName);
10598
/// \brief Provides InputSpecs to receive data for given DataSamplingPolicy. Expects the "dataSamplingPolicies" tree.
10699
static std::vector<framework::InputSpec> InputSpecsForPolicy(const boost::property_tree::ptree& policiesTree, const std::string& policyName);
107-
/// \brief Provides OutputSpecs of given DataSamplingPolicy.
108-
static std::vector<framework::OutputSpec> OutputSpecsForPolicy(const std::string& policiesSource, const std::string& policyName);
109-
/// \brief Provides OutputSpecs of given DataSamplingPolicy.
110-
static std::vector<framework::OutputSpec> OutputSpecsForPolicy(configuration::ConfigurationInterface* const config, const std::string& policyName);
111100
/// \brief Provides OutputSpecs of given DataSamplingPolicy. Expects the "dataSamplingPolicies" tree.
112101
static std::vector<framework::OutputSpec> OutputSpecsForPolicy(const boost::property_tree::ptree& policiesTree, const std::string& policyName);
113-
/// \brief Provides the port to be used for a proxy of given DataSamplingPolicy.
114-
static std::optional<uint16_t> PortForPolicy(configuration::ConfigurationInterface* const config, const std::string& policyName);
115-
/// \brief Provides the port to be used for a proxy of given DataSamplingPolicy.
116-
static std::optional<uint16_t> PortForPolicy(const std::string& policiesSource, const std::string& policyName);
117102
/// \brief Provides the port to be used for a proxy of given DataSamplingPolicy. Expects the "dataSamplingPolicies" tree.
118103
static std::optional<uint16_t> PortForPolicy(const boost::property_tree::ptree& policiesTree, const std::string& policyName);
119-
/// \brief Provides the machines where given DataSamplingPolicy is enabled.
120-
static std::vector<std::string> MachinesForPolicy(configuration::ConfigurationInterface* const config, const std::string& policyName);
121-
/// \brief Provides the machines where given DataSamplingPolicy is enabled.
122-
static std::vector<std::string> MachinesForPolicy(const std::string& policiesSource, const std::string& policyName);
123104
/// \brief Provides the machines where given DataSamplingPolicy is enabled. Expects the "dataSamplingPolicies" tree.
124105
static std::vector<std::string> MachinesForPolicy(const boost::property_tree::ptree& policiesTree, const std::string& policyName);
125106

Utilities/DataSampling/src/DataSampling.cxx

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,6 @@ void DataSampling::CustomizeInfrastructure(std::vector<ChannelConfigurationPolic
111111
// now it cannot be done, since matching is possible only using data processors names
112112
}
113113

114-
std::vector<InputSpec> DataSampling::InputSpecsForPolicy(const std::string& policiesSource, const std::string& policyName)
115-
{
116-
std::unique_ptr<ConfigurationInterface> config = ConfigurationFactory::getConfiguration(policiesSource);
117-
return InputSpecsForPolicy(config.get(), policyName);
118-
}
119-
120-
std::vector<InputSpec> DataSampling::InputSpecsForPolicy(ConfigurationInterface* const config, const std::string& policyName)
121-
{
122-
auto policiesTree = config->getRecursive("dataSamplingPolicies");
123-
return InputSpecsForPolicy(policiesTree, policyName);
124-
}
125-
126-
std::vector<InputSpec> DataSampling::InputSpecsForPolicy(std::shared_ptr<configuration::ConfigurationInterface> config, const std::string& policyName)
127-
{
128-
auto policiesTree = config->getRecursive("dataSamplingPolicies");
129-
return InputSpecsForPolicy(policiesTree, policyName);
130-
}
131-
132114
std::vector<framework::InputSpec> DataSampling::InputSpecsForPolicy(const boost::property_tree::ptree& policiesTree, const std::string& policyName)
133115
{
134116
std::vector<InputSpec> inputs;
@@ -145,18 +127,6 @@ std::vector<framework::InputSpec> DataSampling::InputSpecsForPolicy(const boost:
145127
return inputs;
146128
}
147129

148-
std::vector<OutputSpec> DataSampling::OutputSpecsForPolicy(const std::string& policiesSource, const std::string& policyName)
149-
{
150-
std::unique_ptr<ConfigurationInterface> config = ConfigurationFactory::getConfiguration(policiesSource);
151-
return OutputSpecsForPolicy(config.get(), policyName);
152-
}
153-
154-
std::vector<OutputSpec> DataSampling::OutputSpecsForPolicy(ConfigurationInterface* const config, const std::string& policyName)
155-
{
156-
auto policiesTree = config->getRecursive("dataSamplingPolicies");
157-
return OutputSpecsForPolicy(policiesTree, policyName);
158-
}
159-
160130
std::vector<framework::OutputSpec> DataSampling::OutputSpecsForPolicy(const boost::property_tree::ptree& policiesTree, const std::string& policyName)
161131
{
162132
std::vector<OutputSpec> outputs;
@@ -172,18 +142,6 @@ std::vector<framework::OutputSpec> DataSampling::OutputSpecsForPolicy(const boos
172142
return outputs;
173143
}
174144

175-
std::optional<uint16_t> DataSampling::PortForPolicy(configuration::ConfigurationInterface* const config, const std::string& policyName)
176-
{
177-
auto policiesTree = config->getRecursive("dataSamplingPolicies");
178-
return PortForPolicy(policiesTree, policyName);
179-
}
180-
181-
std::optional<uint16_t> DataSampling::PortForPolicy(const std::string& policiesSource, const std::string& policyName)
182-
{
183-
std::unique_ptr<ConfigurationInterface> config = ConfigurationFactory::getConfiguration(policiesSource);
184-
return PortForPolicy(config.get(), policyName);
185-
}
186-
187145
std::optional<uint16_t> DataSampling::PortForPolicy(const boost::property_tree::ptree& policiesTree, const std::string& policyName)
188146
{
189147
for (auto&& policyConfig : policiesTree) {
@@ -195,18 +153,6 @@ std::optional<uint16_t> DataSampling::PortForPolicy(const boost::property_tree::
195153
throw std::runtime_error("Could not find the policy '" + policyName + "'");
196154
}
197155

198-
std::vector<std::string> DataSampling::MachinesForPolicy(configuration::ConfigurationInterface* const config, const std::string& policyName)
199-
{
200-
auto policiesTree = config->getRecursive("dataSamplingPolicies");
201-
return MachinesForPolicy(policiesTree, policyName);
202-
}
203-
204-
std::vector<std::string> DataSampling::MachinesForPolicy(const std::string& policiesSource, const std::string& policyName)
205-
{
206-
std::unique_ptr<ConfigurationInterface> config = ConfigurationFactory::getConfiguration(policiesSource);
207-
return MachinesForPolicy(config.get(), policyName);
208-
}
209-
210156
std::vector<std::string> DataSampling::MachinesForPolicy(const boost::property_tree::ptree& policiesTree, const std::string& policyName)
211157
{
212158
std::vector<std::string> machines;

Utilities/DataSampling/test/test_DataSampling.cxx

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,39 +172,72 @@ BOOST_AUTO_TEST_CASE(DataSamplingTimePipelineFlow)
172172
BOOST_AUTO_TEST_CASE(InputSpecsForPolicy)
173173
{
174174
std::string configFilePath = "json:/" + std::string(getenv("O2_ROOT")) + "/share/tests/test_DataSampling.json";
175-
std::vector<InputSpec> inputs = DataSampling::InputSpecsForPolicy(configFilePath, "tpcclusters");
175+
std::unique_ptr<ConfigurationInterface> config = ConfigurationFactory::getConfiguration(configFilePath);
176+
auto policiesTree = config->getRecursive("dataSamplingPolicies");
177+
178+
{
179+
std::vector<InputSpec> inputs = DataSampling::InputSpecsForPolicy(policiesTree, "tpcclusters");
176180

177-
BOOST_CHECK_EQUAL(inputs.size(), 2);
178-
BOOST_CHECK(DataSpecUtils::match(inputs[0], ConcreteDataTypeMatcher{"DS", "tpcclusters0"}));
179-
BOOST_CHECK_EQUAL(inputs[0].binding, "clusters");
180-
BOOST_CHECK(DataSpecUtils::match(inputs[1], ConcreteDataTypeMatcher{"DS", "tpcclusters1"}));
181-
BOOST_CHECK_EQUAL(inputs[1].binding, "clusters_p");
181+
BOOST_CHECK_EQUAL(inputs.size(), 2);
182+
BOOST_CHECK(DataSpecUtils::match(inputs[0], ConcreteDataTypeMatcher{"DS", "tpcclusters0"}));
183+
BOOST_CHECK_EQUAL(inputs[0].binding, "clusters");
184+
BOOST_CHECK(DataSpecUtils::match(inputs[1], ConcreteDataTypeMatcher{"DS", "tpcclusters1"}));
185+
BOOST_CHECK_EQUAL(inputs[1].binding, "clusters_p");
186+
}
187+
{
188+
std::vector<InputSpec> inputs = DataSampling::InputSpecsForPolicy(policiesTree, "tpcraw");
182189

190+
BOOST_CHECK_EQUAL(inputs.size(), 1);
191+
BOOST_CHECK(DataSpecUtils::match(inputs[0], ConcreteDataTypeMatcher{"TPC", "SMP_RAWDATA"}));
192+
BOOST_CHECK_EQUAL(inputs[0].binding, "clusters");
193+
}
194+
}
195+
196+
BOOST_AUTO_TEST_CASE(OutputSpecsForPolicy)
197+
{
198+
std::string configFilePath = "json:/" + std::string(getenv("O2_ROOT")) + "/share/tests/test_DataSampling.json";
183199
std::unique_ptr<ConfigurationInterface> config = ConfigurationFactory::getConfiguration(configFilePath);
184-
inputs = DataSampling::InputSpecsForPolicy(config.get(), "tpcclusters");
200+
auto policiesTree = config->getRecursive("dataSamplingPolicies");
201+
202+
{
203+
auto outputs = DataSampling::OutputSpecsForPolicy(policiesTree, "tpcclusters");
204+
205+
BOOST_REQUIRE_EQUAL(outputs.size(), 2);
206+
BOOST_CHECK(DataSpecUtils::match(outputs[0], ConcreteDataTypeMatcher{"DS", "tpcclusters0"}));
207+
BOOST_CHECK_EQUAL(outputs[0].binding.value, "clusters");
208+
BOOST_CHECK(DataSpecUtils::match(outputs[1], ConcreteDataTypeMatcher{"DS", "tpcclusters1"}));
209+
BOOST_CHECK_EQUAL(outputs[1].binding.value, "clusters_p");
210+
}
211+
{
212+
auto outputs = DataSampling::OutputSpecsForPolicy(policiesTree, "tpcraw");
185213

186-
BOOST_CHECK_EQUAL(inputs.size(), 2);
214+
BOOST_REQUIRE_EQUAL(outputs.size(), 1);
215+
BOOST_CHECK(DataSpecUtils::match(outputs[0], ConcreteDataTypeMatcher{"TPC", "SMP_RAWDATA"}));
216+
BOOST_CHECK_EQUAL(outputs[0].binding.value, "clusters");
217+
}
187218
}
188219

189220
BOOST_AUTO_TEST_CASE(MultinodeUtilities)
190221
{
191222
std::string configFilePath = "json:/" + std::string(getenv("O2_ROOT")) + "/share/tests/test_DataSampling.json";
223+
std::unique_ptr<ConfigurationInterface> config = ConfigurationFactory::getConfiguration(configFilePath);
224+
auto policiesTree = config->getRecursive("dataSamplingPolicies");
192225

193226
{
194-
BOOST_CHECK_THROW(DataSampling::PortForPolicy(configFilePath, "no such policy"), std::runtime_error);
195-
BOOST_CHECK_THROW(DataSampling::MachinesForPolicy(configFilePath, "no such policy"), std::runtime_error);
227+
BOOST_CHECK_THROW(DataSampling::PortForPolicy(policiesTree, "no such policy"), std::runtime_error);
228+
BOOST_CHECK_THROW(DataSampling::MachinesForPolicy(policiesTree, "no such policy"), std::runtime_error);
196229
}
197230
{
198-
auto port = DataSampling::PortForPolicy(configFilePath, "tpcclusters");
231+
auto port = DataSampling::PortForPolicy(policiesTree, "tpcclusters");
199232
BOOST_CHECK(!port.has_value());
200-
auto machines = DataSampling::MachinesForPolicy(configFilePath, "tpcclusters");
233+
auto machines = DataSampling::MachinesForPolicy(policiesTree, "tpcclusters");
201234
BOOST_CHECK(machines.empty());
202235
}
203236
{
204-
auto port = DataSampling::PortForPolicy(configFilePath, "tpcraw");
237+
auto port = DataSampling::PortForPolicy(policiesTree, "tpcraw");
205238
BOOST_REQUIRE(port.has_value());
206239
BOOST_CHECK_EQUAL(port.value(), 1234);
207-
auto machines = DataSampling::MachinesForPolicy(configFilePath, "tpcraw");
240+
auto machines = DataSampling::MachinesForPolicy(policiesTree, "tpcraw");
208241
BOOST_CHECK_EQUAL(machines.size(), 2);
209242
}
210243
{
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{
2-
"dataSamplingPolicies": [
2+
"dataSamplingPolicies" : [
33
{
4-
"id": "tpcclusters",
5-
"active": "true",
4+
"id" : "tpcclusters",
5+
"active" : "true",
66
"query" : "clusters:TPC/CLUSTERS;clusters_p:TPC/CLUSTERS_P",
7-
"samplingConditions": []
7+
"samplingConditions" : []
88
},
99
{
10-
"id": "tpcraw",
11-
"active": "true",
12-
"machines": [
10+
"id" : "tpcraw",
11+
"active" : "true",
12+
"machines" : [
1313
"machineA",
1414
"machineB"
1515
],
16-
"port": "1234",
17-
"query": "clusters:TPC/RAWDATA",
18-
"samplingConditions": []
16+
"port" : "1234",
17+
"query" : "clusters:TPC/RAWDATA",
18+
"outputs" : "clusters:TPC/SMP_RAWDATA",
19+
"samplingConditions" : []
1920
}
2021
]
2122
}

0 commit comments

Comments
 (0)