regulators: Retry failed sensor monitoring
If a failure occurs while trying to read voltage regulator sensors,
retry the operation 5 times before logging an error.
This provides "de-glitching" to ignore transient hardware problems.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I310c15eb0f0d36d938057d6280a12b5aef854d20
diff --git a/phosphor-regulators/test/device_tests.cpp b/phosphor-regulators/test/device_tests.cpp
index 5d9a0e4..0c43b1e 100644
--- a/phosphor-regulators/test/device_tests.cpp
+++ b/phosphor-regulators/test/device_tests.cpp
@@ -284,18 +284,18 @@
std::move(phaseFaultDetection),
std::move(rails)};
- // Create lambda that sets MockServices expectations. The lambda allows us
- // to set the same expectations twice without duplicate code.
+ // Create lambda that sets MockServices expectations. The lambda allows
+ // us to set expectations multiple times without duplicate code.
auto setExpectations = [](MockServices& services) {
// Set Journal service expectations:
- // - 3 error messages for D-Bus errors
- // - 3 error messages for inability to monitor sensors
+ // - 6 error messages for D-Bus errors
+ // - 6 error messages for inability to monitor sensors
// - 2 error messages for the N phase fault
MockJournal& journal = services.getMockJournal();
EXPECT_CALL(journal, logError(std::vector<std::string>{"DBus Error"}))
- .Times(3);
+ .Times(6);
EXPECT_CALL(journal, logError("Unable to monitor sensors for rail vdd"))
- .Times(3);
+ .Times(6);
EXPECT_CALL(
journal,
logError("n phase fault detected in regulator reg2: count=1"))
@@ -313,19 +313,19 @@
EXPECT_CALL(errorLogging, logPhaseFault).Times(1);
// Set Sensors service expections:
- // - startRail() and endRail() called 5 times
+ // - startRail() and endRail() called 10 times
MockSensors& sensors = services.getMockSensors();
- EXPECT_CALL(sensors, startRail).Times(5);
- EXPECT_CALL(sensors, endRail).Times(5);
+ EXPECT_CALL(sensors, startRail).Times(10);
+ EXPECT_CALL(sensors, endRail).Times(10);
};
- // Monitor sensors and detect phase faults 5 times. Verify errors logged.
+ // Monitor sensors and detect phase faults 10 times. Verify errors logged.
{
// Create mock services. Set expectations via lambda.
MockServices services{};
setExpectations(services);
- for (int i = 1; i <= 5; ++i)
+ for (int i = 1; i <= 10; ++i)
{
device.monitorSensors(services, *system, *chassis);
device.detectPhaseFaults(services, *system, *chassis);
@@ -335,14 +335,14 @@
// Clear error history
device.clearErrorHistory();
- // Monitor sensors and detect phase faults 5 more times. Verify errors
+ // Monitor sensors and detect phase faults 10 more times. Verify errors
// logged again.
{
// Create mock services. Set expectations via lambda.
MockServices services{};
setExpectations(services);
- for (int i = 1; i <= 5; ++i)
+ for (int i = 1; i <= 10; ++i)
{
device.monitorSensors(services, *system, *chassis);
device.detectPhaseFaults(services, *system, *chassis);