Implement NumericThreshold for Trigger
Implemented NumericThreshold for Trigger that allows to set
expected threshold value for collection of sensors and monitors
if this value is crossed. Implemented detection of direction
when threshold value is crossed. Added initial interface that
is used to commit an action when threshold value is crossed.
Moved Sensor Cache from Report Factory to Telemetry class, now
Sensor Cache is shared between Report Factory and Trigger Factory.
Moved fetching sensor from Dbus to seperate header to have single
implementation for factories.
Disabled tests that uses boost coroutine because of false positive
that is catched by address sanitizer.
Tested:
- Passed unit tests
- Built in yocto envrionment with success
- Telemetry service started successfully in OpenBMC
Change-Id: I1ff7ab96174a27576786f0b9a71554fe1eeff436
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
diff --git a/tests/src/mocks/trigger_factory_mock.hpp b/tests/src/mocks/trigger_factory_mock.hpp
index b714a44..cf1be55 100644
--- a/tests/src/mocks/trigger_factory_mock.hpp
+++ b/tests/src/mocks/trigger_factory_mock.hpp
@@ -13,39 +13,42 @@
{
using namespace testing;
- ON_CALL(*this, make(_, _, _, _, _, _, _, _, _))
- .WillByDefault(WithArgs<0>(Invoke([](const std::string& name) {
+ ON_CALL(*this, make(_, _, _, _, _, _, _, _, _, _))
+ .WillByDefault(WithArgs<1>(Invoke([](const std::string& name) {
return std::make_unique<NiceMock<TriggerMock>>(name);
})));
}
- MOCK_METHOD(std::unique_ptr<interfaces::Trigger>, make,
- (const std::string& name, bool isDiscrete, bool logToJournal,
- bool logToRedfish, bool updateReport,
- (const std::vector<std::pair<sdbusplus::message::object_path,
- std::string>>& sensors),
- const std::vector<std::string>& reportNames,
- const TriggerThresholdParams& thresholds,
- interfaces::TriggerManager& triggerManager),
- (const, override));
+ MOCK_METHOD(
+ std::unique_ptr<interfaces::Trigger>, make,
+ (boost::asio::yield_context&, const std::string& name, bool isDiscrete,
+ bool logToJournal, bool logToRedfish, bool updateReport,
+ (const std::vector<
+ std::pair<sdbusplus::message::object_path, std::string>>& sensors),
+ const std::vector<std::string>& reportNames,
+ const TriggerThresholdParams& thresholdParams,
+ interfaces::TriggerManager& triggerManager),
+ (const, override));
auto& expectMake(
std::optional<std::reference_wrapper<const TriggerParams>> paramsOpt,
const testing::Matcher<interfaces::TriggerManager&>& tm)
{
+ using namespace testing;
+
if (paramsOpt)
{
const TriggerParams& params = *paramsOpt;
return EXPECT_CALL(
- *this, make(params.name(), params.isDiscrete(),
- params.logToJournal(), params.logToRedfish(),
- params.updateReport(), params.sensors(),
- params.reportNames(), params.thresholds(), tm));
+ *this,
+ make(_, params.name(), params.isDiscrete(),
+ params.logToJournal(), params.logToRedfish(),
+ params.updateReport(), params.sensors(),
+ params.reportNames(), params.thresholdParams(), tm));
}
else
{
- using testing::_;
- return EXPECT_CALL(*this, make(_, _, _, _, _, _, _, _, tm));
+ return EXPECT_CALL(*this, make(_, _, _, _, _, _, _, _, _, tm));
}
}
};