added property SupportedOperationTypes
- removed OperationType::single
- for backward compatibility incomming OperationType::single alted to
produce same output functionality
- added property SupportedOperationTypes to ReportManager interface
Tested:
- In cases where OperationType::single is used same MetricValues are
produced
- New property is visible on dbus
Change-Id: I838581c954abc0d8401e0ed530ce7e9c8013860b
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/tests/src/params/report_params.hpp b/tests/src/params/report_params.hpp
index 19ea519..56f619a 100644
--- a/tests/src/params/report_params.hpp
+++ b/tests/src/params/report_params.hpp
@@ -121,7 +121,7 @@
{LabeledSensorInfo{"Service",
"/xyz/openbmc_project/sensors/power/p1",
"metadata1"}},
- OperationType::single,
+ OperationType::avg,
"MetricId1",
CollectionTimeScope::point,
CollectionDuration(Milliseconds(0u))},
@@ -129,7 +129,7 @@
{LabeledSensorInfo{"Service",
"/xyz/openbmc_project/sensors/power/p2",
"metadata2"}},
- OperationType::single,
+ OperationType::avg,
"MetricId2",
CollectionTimeScope::point,
CollectionDuration(Milliseconds(0u))}}};
diff --git a/tests/src/test_metric.cpp b/tests/src/test_metric.cpp
index fcb2ded..31eabc6 100644
--- a/tests/src/test_metric.cpp
+++ b/tests/src/test_metric.cpp
@@ -173,41 +173,29 @@
}
};
-MetricParams defaultSingleParams()
+MetricParams defaultCollectionFunctionParams()
{
return MetricParams()
- .operationType(OperationType::single)
.readings(TestMetricCalculationFunctions::defaultReadings())
.expectedReading(systemTimestamp + 16ms, 7.0);
}
-INSTANTIATE_TEST_SUITE_P(
- OperationSingleReturnsLastReading, TestMetricCalculationFunctions,
- Values(
- defaultSingleParams().collectionTimeScope(CollectionTimeScope::point),
- defaultSingleParams()
- .collectionTimeScope(CollectionTimeScope::interval)
- .collectionDuration(CollectionDuration(100ms)),
- defaultSingleParams().collectionTimeScope(
- CollectionTimeScope::startup)));
-
MetricParams defaultPointParams()
{
- return defaultSingleParams().collectionTimeScope(
+ return defaultCollectionFunctionParams().collectionTimeScope(
CollectionTimeScope::point);
}
INSTANTIATE_TEST_SUITE_P(
TimeScopePointReturnsLastReading, TestMetricCalculationFunctions,
- Values(defaultPointParams().operationType(OperationType::single),
- defaultPointParams().operationType(OperationType::min),
+ Values(defaultPointParams().operationType(OperationType::min),
defaultPointParams().operationType(OperationType::max),
defaultPointParams().operationType(OperationType::sum),
defaultPointParams().operationType(OperationType::avg)));
MetricParams defaultMinParams()
{
- return defaultSingleParams().operationType(OperationType::min);
+ return defaultCollectionFunctionParams().operationType(OperationType::min);
}
INSTANTIATE_TEST_SUITE_P(
@@ -226,7 +214,7 @@
MetricParams defaultMaxParams()
{
- return defaultSingleParams().operationType(OperationType::max);
+ return defaultCollectionFunctionParams().operationType(OperationType::max);
}
INSTANTIATE_TEST_SUITE_P(
@@ -249,7 +237,7 @@
MetricParams defaultSumParams()
{
- return defaultSingleParams().operationType(OperationType::sum);
+ return defaultCollectionFunctionParams().operationType(OperationType::sum);
}
INSTANTIATE_TEST_SUITE_P(
@@ -275,7 +263,7 @@
MetricParams defaultAvgParams()
{
- return defaultSingleParams().operationType(OperationType::avg);
+ return defaultCollectionFunctionParams().operationType(OperationType::avg);
}
INSTANTIATE_TEST_SUITE_P(
diff --git a/tests/src/test_report.cpp b/tests/src/test_report.cpp
index 4e3ce8d..765f8e4 100644
--- a/tests/src/test_report.cpp
+++ b/tests/src/test_report.cpp
@@ -364,7 +364,7 @@
{tstring::Path::str(),
"/xyz/openbmc_project/sensors/power/p1"},
{tstring::Metadata::str(), "metadata1"}}}},
- {tstring::OperationType::str(), OperationType::single},
+ {tstring::OperationType::str(), OperationType::avg},
{tstring::Id::str(), "MetricId1"},
{tstring::CollectionTimeScope::str(),
CollectionTimeScope::point},
@@ -374,7 +374,7 @@
{tstring::Path::str(),
"/xyz/openbmc_project/sensors/power/p2"},
{tstring::Metadata::str(), "metadata2"}}}},
- {tstring::OperationType::str(), OperationType::single},
+ {tstring::OperationType::str(), OperationType::avg},
{tstring::Id::str(), "MetricId2"},
{tstring::CollectionTimeScope::str(),
CollectionTimeScope::point},
diff --git a/tests/src/test_report_manager.cpp b/tests/src/test_report_manager.cpp
index fca6451..f4ce184 100644
--- a/tests/src/test_report_manager.cpp
+++ b/tests/src/test_report_manager.cpp
@@ -103,6 +103,13 @@
Eq(ReportManager::maxReports));
}
+TEST_F(TestReportManager, returnsPropertySupportedOperationTypes)
+{
+ EXPECT_THAT(
+ getProperty<std::vector<std::string>>("SupportedOperationTypes"),
+ UnorderedElementsAre("Maximum", "Minimum", "Average", "Summation"));
+}
+
TEST_F(TestReportManager, addReport)
{
EXPECT_CALL(reportFactoryMock, convertMetricParams(_, _));
@@ -220,7 +227,7 @@
{LabeledSensorInfo{"Service",
"/xyz/openbmc_project/sensors/power/p1",
"Metadata1"}},
- OperationType::single,
+ OperationType::avg,
"MetricId1",
CollectionTimeScope::point,
CollectionDuration(Milliseconds(0u))}}});
@@ -254,7 +261,7 @@
{
metricParams.emplace_back(
LabeledMetricParameters{{},
- OperationType::single,
+ OperationType::avg,
"MetricId1",
CollectionTimeScope::point,
CollectionDuration(Milliseconds(0u))});
@@ -369,9 +376,8 @@
};
INSTANTIATE_TEST_SUITE_P(_, TestReportManagerWithAggregationOperationType,
- Values(OperationType::single, OperationType::max,
- OperationType::min, OperationType::avg,
- OperationType::sum));
+ Values(OperationType::max, OperationType::min,
+ OperationType::avg, OperationType::sum));
TEST_P(TestReportManagerWithAggregationOperationType,
addReportWithDifferentOperationTypes)
diff --git a/tests/src/test_transform.cpp b/tests/src/test_transform.cpp
index 66fa855..3f7c5f9 100644
--- a/tests/src/test_transform.cpp
+++ b/tests/src/test_transform.cpp
@@ -13,7 +13,8 @@
std::vector<int> input = {1, 2, 3};
std::vector<std::string> output =
utils::transform(input, [](int v) { return std::to_string(v); });
- EXPECT_TRUE(utils::detail::has_member_reserve_v<std::vector<std::string>>);
+ EXPECT_TRUE(utils::detail::has_member_reserve<decltype(input)>);
+ EXPECT_TRUE(utils::detail::has_member_reserve<decltype(output)>);
ASSERT_THAT(output, ElementsAre("1", "2", "3"));
}
@@ -22,6 +23,18 @@
std::set<int> input = {1, 2, 3};
std::set<std::string> output =
utils::transform(input, [](int v) { return std::to_string(v); });
- EXPECT_FALSE(utils::detail::has_member_reserve_v<std::set<std::string>>);
+ EXPECT_FALSE(utils::detail::has_member_reserve<decltype(input)>);
+ EXPECT_FALSE(utils::detail::has_member_reserve<decltype(output)>);
+ ASSERT_THAT(output, ElementsAre("1", "2", "3"));
+}
+
+TEST(TestTransform, transformsArrayToVector)
+{
+ std::array<int, 3> input = {1, 2, 3};
+ std::vector<std::string> output =
+ utils::transform<std::vector<std::string>>(
+ input, [](int v) { return std::to_string(v); });
+ EXPECT_FALSE(utils::detail::has_member_reserve<decltype(input)>);
+ EXPECT_TRUE(utils::detail::has_member_reserve<decltype(output)>);
ASSERT_THAT(output, ElementsAre("1", "2", "3"));
}