Implement Report persistency
Now Report properties are stored in non-volatile memory. It allows
to restore Report after system restart. Persistency of a report is
controlled by Persistency property in Report interface.
Tested:
- Passed unit tests
- Verified that report is stored in /var/lib/telemetry dir
- Verified that report is restored from storage after telemetry
service start
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
Change-Id: Iccfe21603eecffc4e174a4403f699b03de320db9
diff --git a/tests/src/mocks/json_storage_mock.hpp b/tests/src/mocks/json_storage_mock.hpp
index 99ecd41..ab76459 100644
--- a/tests/src/mocks/json_storage_mock.hpp
+++ b/tests/src/mocks/json_storage_mock.hpp
@@ -10,8 +10,8 @@
MOCK_METHOD(void, store, (const FilePath&, const nlohmann::json&),
(override));
MOCK_METHOD(bool, remove, (const FilePath&), (override));
+ MOCK_METHOD(bool, exist, (const FilePath&), (const, override));
MOCK_METHOD(std::optional<nlohmann::json>, load, (const FilePath&),
(const, override));
- MOCK_METHOD(std::vector<FilePath>, list, (const DirectoryPath&),
- (const, override));
+ MOCK_METHOD(std::vector<FilePath>, list, (), (const, override));
};
diff --git a/tests/src/mocks/metric_mock.hpp b/tests/src/mocks/metric_mock.hpp
index 6150455..d3d9e64 100644
--- a/tests/src/mocks/metric_mock.hpp
+++ b/tests/src/mocks/metric_mock.hpp
@@ -17,4 +17,5 @@
MOCK_METHOD(const std::vector<MetricValue>&, getReadings, (),
(const, override));
+ MOCK_METHOD(nlohmann::json, to_json, (), (const, override));
};
diff --git a/tests/src/mocks/report_factory_mock.hpp b/tests/src/mocks/report_factory_mock.hpp
index 24cc23e..fcb9b7e 100644
--- a/tests/src/mocks/report_factory_mock.hpp
+++ b/tests/src/mocks/report_factory_mock.hpp
@@ -13,16 +13,19 @@
using namespace testing;
ON_CALL(*this, make)
- .WillByDefault(WithArgs<0>(Invoke([](const std::string& name) {
+ .WillByDefault(WithArgs<1>(Invoke([](const std::string& name) {
return std::make_unique<NiceMock<ReportMock>>(name);
})));
}
- MOCK_METHOD(std::unique_ptr<interfaces::Report>, make,
- (const std::string& name, const std::string& reportingType,
- bool emitsReadingsSignal, bool logToMetricReportsCollection,
- std::chrono::milliseconds period,
- const ReadingParameters& metricParams,
- interfaces::ReportManager& reportManager),
- (const, override));
+ MOCK_METHOD(
+ std::unique_ptr<interfaces::Report>, make,
+ (std::optional<std::reference_wrapper<boost::asio::yield_context>>,
+ const std::string& name, const std::string& reportingType,
+ bool emitsReadingsSignal, bool logToMetricReportsCollection,
+ std::chrono::milliseconds period,
+ const ReadingParameters& metricParams,
+ interfaces::ReportManager& reportManager,
+ interfaces::JsonStorage& reportStorage),
+ (const, override));
};
diff --git a/tests/src/mocks/report_manager_mock.hpp b/tests/src/mocks/report_manager_mock.hpp
index 17d0a06..872a6e6 100644
--- a/tests/src/mocks/report_manager_mock.hpp
+++ b/tests/src/mocks/report_manager_mock.hpp
@@ -7,8 +7,5 @@
class ReportManagerMock : public interfaces::ReportManager
{
public:
- ReportManagerMock()
- {}
-
MOCK_METHOD(void, removeReport, (const interfaces::Report*), (override));
};