simplified appendLimit implementation
AppendLimit is now set to max value by default. This simplifies the code
while keeping most of the feature functionality. This change increases
report version and will cause older report to be deleted.
Tested:
- AppendLimit is set by default to max value
- Telemetry features are working as expected
Change-Id: I94c85393a9601c90c00776bf0bc814d85cbf006a
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/tests/src/mocks/metric_mock.hpp b/tests/src/mocks/metric_mock.hpp
index 6dfe660..dc0309b 100644
--- a/tests/src/mocks/metric_mock.hpp
+++ b/tests/src/mocks/metric_mock.hpp
@@ -13,7 +13,7 @@
ON_CALL(*this, getUpdatedReadings())
.WillByDefault(ReturnRefOfCopy(std::vector<MetricValue>()));
- ON_CALL(*this, sensorCount).WillByDefault(InvokeWithoutArgs([this] {
+ ON_CALL(*this, metricCount).WillByDefault(InvokeWithoutArgs([this] {
return getUpdatedReadings().size();
}));
}
@@ -24,7 +24,7 @@
(override));
MOCK_METHOD(LabeledMetricParameters, dumpConfiguration, (),
(const, override));
- MOCK_METHOD(uint64_t, sensorCount, (), (const, override));
+ MOCK_METHOD(uint64_t, metricCount, (), (const, override));
MOCK_METHOD(void, registerForUpdates, (interfaces::MetricListener&),
(override));
MOCK_METHOD(void, unregisterFromUpdates, (interfaces::MetricListener&),
diff --git a/tests/src/test_report.cpp b/tests/src/test_report.cpp
index ea3b4f8..875bd4b 100644
--- a/tests/src/test_report.cpp
+++ b/tests/src/test_report.cpp
@@ -109,7 +109,7 @@
metricMocks.emplace_back(std::make_shared<NiceMock<MetricMock>>());
ON_CALL(*metricMocks[i], dumpConfiguration())
.WillByDefault(Return(metricParameters[i]));
- ON_CALL(*metricMocks[i], sensorCount())
+ ON_CALL(*metricMocks[i], metricCount())
.WillByDefault(Return(metricParameters[i]
.at_label<tstring::SensorPath>()
.size()));
@@ -285,34 +285,6 @@
Eq(newParams));
}
-TEST_F(TestReport, setReadingParametersWithNewParamsUpdatesSensorCount)
-{
- auto report =
- makeReport(ReportParams()
- .appendLimit(std::numeric_limits<uint64_t>::max())
- .reportId("DefaultAppendLimit"));
-
- ReadingParameters newParams = toReadingParameters(
- std::vector<LabeledMetricParameters>{{LabeledMetricParameters{
- {LabeledSensorInfo{"Service",
- "/xyz/openbmc_project/sensors/power/psu",
- "NewMetadata123"}},
- OperationType::avg,
- "NewMetricId123",
- CollectionTimeScope::startup,
- CollectionDuration(250ms)}}});
- auto metrics = getMetricsFromReadingParams(newParams);
-
- EXPECT_CALL(*reportFactoryMock, updateMetrics(_, _, _))
- .WillOnce(SetArgReferee<0>(metrics));
- EXPECT_THAT(setProperty(report->getPath(), "ReadingParametersFutureVersion",
- newParams)
- .value(),
- Eq(boost::system::errc::success));
- EXPECT_THAT(getProperty<uint64_t>(report->getPath(), "AppendLimit"),
- Eq(1ull));
-}
-
TEST_F(TestReport, setReadingParametersWithTooLongMetricId)
{
const ReadingParameters currentValue =
@@ -707,7 +679,7 @@
_, TestReportStore,
Values(
std::make_pair("Enabled"s, nlohmann::json(defaultParams().enabled())),
- std::make_pair("Version"s, nlohmann::json(6)),
+ std::make_pair("Version"s, nlohmann::json(7)),
std::make_pair("Id"s, nlohmann::json(defaultParams().reportId())),
std::make_pair("Name"s, nlohmann::json(defaultParams().reportName())),
std::make_pair("ReportingType",
@@ -965,6 +937,7 @@
void SetUp() override
{
sut = makeReport(defaultParams()
+ .appendLimit(2u)
.reportingType(ReportingType::periodic)
.interval(ReportManager::minInterval));
}
@@ -1125,7 +1098,7 @@
ReportUpdatesReportParams{
defaultParams()
.reportUpdates(ReportUpdates::appendStopsWhenFull)
- .appendLimit(std::numeric_limits<uint64_t>::max()),
+ .appendLimit(2u),
std::vector<ReadingData>{
{std::make_tuple("a"s, "b"s, 17.1, 114u),
std::make_tuple("aa"s, "bb"s, 42.0, 74u)}},
@@ -1149,6 +1122,7 @@
appendLimitIsRespectedAfterChangingToPeriodic)
{
sut = makeReport(ReportParams(GetParam().reportParams)
+ .appendLimit(GetParam().expectedReadings.size())
.reportingType(ReportingType::onRequest)
.interval(std::chrono::hours(0)));
@@ -1305,23 +1279,6 @@
DbusEnvironment::sleepFor(defaultParams().interval() * 2);
}
-TEST_F(TestReportInitialization, appendLimitDeducedProperly)
-{
- sut = makeReport(
- defaultParams().appendLimit(std::numeric_limits<uint64_t>::max()));
- auto appendLimit = getProperty<uint64_t>(sut->getPath(), "AppendLimit");
- EXPECT_EQ(appendLimit, 2ull);
-}
-
-TEST_F(TestReportInitialization, appendLimitSetToUintMaxIsStoredCorrectly)
-{
- sut = makeReport(
- ReportParams().appendLimit(std::numeric_limits<uint64_t>::max()));
-
- ASSERT_THAT(storedConfiguration.at("AppendLimit"),
- Eq(std::numeric_limits<uint64_t>::max()));
-}
-
TEST_F(TestReportInitialization, triggerIdsPropertyIsInitialzed)
{
for (const auto& triggerId : {"trigger1", "trigger2"})