Fixed handling maxAppendLimit
maxLimit prevented using numeric_limits<uint64_t>::max as a way to let
telemetry service deduce appendLimit. This commit fixes constrain to
allow passing this special value.
Tested:
- Added new unit tests that confirm numeric_limits<uint64_t>::max is
correctly handled in telemetry service
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: I5d67e83475cdfcbb58a71b783ac9eef1e5ad7010
diff --git a/tests/src/test_report.cpp b/tests/src/test_report.cpp
index 675171a..af22166 100644
--- a/tests/src/test_report.cpp
+++ b/tests/src/test_report.cpp
@@ -280,6 +280,8 @@
}))),
std::make_pair("Interval",
nlohmann::json(ReportParams().interval().count())),
+ std::make_pair("AppendLimit",
+ nlohmann::json(ReportParams().appendLimit())),
std::make_pair(
"ReadingParameters",
nlohmann::json(
@@ -766,3 +768,17 @@
auto appendLimit = getProperty<uint64_t>(sut->getPath(), "AppendLimit");
EXPECT_EQ(appendLimit, 2ull);
}
+
+TEST_F(TestReportInitialization, appendLimitSetToUintMaxIsStoredCorrectly)
+{
+ nlohmann::json storedConfiguration;
+
+ EXPECT_CALL(storageMock, store(to_file_path(ReportParams().reportId()), _))
+ .WillOnce(SaveArg<1>(&storedConfiguration));
+
+ sut = makeReport(
+ ReportParams().appendLimit(std::numeric_limits<uint64_t>::max()));
+
+ ASSERT_THAT(storedConfiguration.at("AppendLimit"),
+ Eq(std::numeric_limits<uint64_t>::max()));
+}
diff --git a/tests/src/test_report_manager.cpp b/tests/src/test_report_manager.cpp
index 9af5c57..a18579c 100644
--- a/tests/src/test_report_manager.cpp
+++ b/tests/src/test_report_manager.cpp
@@ -279,6 +279,19 @@
EXPECT_THAT(path, Eq(std::string()));
}
+TEST_F(TestReportManager, addReportWithAppendLimitEqualToUint64MaxIsAllowed)
+{
+ reportParams.appendLimit(std::numeric_limits<uint64_t>::max());
+
+ EXPECT_CALL(reportFactoryMock, convertMetricParams(_, _));
+ reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock))
+ .WillOnce(Return(ByMove(std::move(reportMockPtr))));
+
+ auto [ec, path] = addReport(reportParams);
+ EXPECT_THAT(ec.value(), Eq(boost::system::errc::success));
+ EXPECT_THAT(path, Eq(reportMock.getPath()));
+}
+
TEST_F(TestReportManager, DISABLED_failToAddReportWhenMaxReportIsReached)
{
reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock))