Add ReportManager and Report unit tests
Introduced ReportFactory to seperate Report and ReportManager
unit tests. Implemented mocks for Report, ReportManager and
ReportFactory classes. Added tests for DBus Properties and Methods
provided by telemetry service.
Tested:
- Ran unit-tests with success
Change-Id: I1860e280d26ee4becc52de98dd65e5697d26b376
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
diff --git a/src/report.hpp b/src/report.hpp
index 7f74d49..fb40614 100644
--- a/src/report.hpp
+++ b/src/report.hpp
@@ -1,30 +1,26 @@
#pragma once
+#include "interfaces/report.hpp"
+#include "interfaces/report_manager.hpp"
+#include "interfaces/types.hpp"
+
#include <boost/asio/io_context.hpp>
#include <sdbusplus/asio/object_server.hpp>
#include <chrono>
#include <memory>
-using Readings = std::tuple<
- uint64_t,
- std::vector<std::tuple<std::string, std::string, double, uint64_t>>>;
-using ReadingParameters =
- std::vector<std::tuple<std::vector<sdbusplus::message::object_path>,
- std::string, std::string, std::string>>;
-
-class ReportManager;
-
-class Report
+class Report : public interfaces::Report
{
public:
Report(boost::asio::io_context& ioc,
const std::shared_ptr<sdbusplus::asio::object_server>& objServer,
- const std::string& name, const std::string& reportingType,
+ const std::string& reportName, const std::string& reportingType,
const bool emitsReadingsSignal,
const bool logToMetricReportsCollection,
const std::chrono::milliseconds period,
- const ReadingParameters& metricParams, ReportManager& reportManager);
+ const ReadingParameters& metricParams,
+ interfaces::ReportManager& reportManager);
~Report() = default;
Report(Report&) = delete;
@@ -32,12 +28,29 @@
Report& operator=(Report&) = delete;
Report& operator=(Report&&) = delete;
- const std::string name;
- const std::string path;
+ std::string getName() const override
+ {
+ return name;
+ }
+
+ std::string getPath() const override
+ {
+ return path;
+ }
private:
+ const std::string name;
+ const std::string path;
std::chrono::milliseconds interval;
std::shared_ptr<sdbusplus::asio::object_server> objServer;
std::unique_ptr<sdbusplus::asio::dbus_interface> reportIface;
std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface;
+
+ public:
+ static constexpr const char* reportIfaceName =
+ "xyz.openbmc_project.Telemetry.Report";
+ static constexpr const char* reportDir =
+ "/xyz/openbmc_project/Telemetry/Reports/";
+ static constexpr const char* deleteIfaceName =
+ "xyz.openbmc_project.Object.Delete";
};