Fixed issue with wrong timestamp
Telemetry service used steady_clock for generating timestamps, but it
produced incorrect time. This change makes telemetry service use
steady_clock for intervals and system_clock for timestamps.
Changed readings timestamp to display current timestamp instead of a
time when reading was received.
Tested:
- correct timestamp is visible on dbus
- other telemetry service features are still working
Change-Id: Ic49f45640532cfffaeff5e0bd5591e6d99e5def5
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/tests/src/dbus_environment.hpp b/tests/src/dbus_environment.hpp
index 087daef..86d7007 100644
--- a/tests/src/dbus_environment.hpp
+++ b/tests/src/dbus_environment.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "types/duration_type.hpp"
+#include "types/duration_types.hpp"
#include "utils/set_exception.hpp"
#include <sdbusplus/asio/object_server.hpp>
diff --git a/tests/src/fakes/clock_fake.hpp b/tests/src/fakes/clock_fake.hpp
index 3871a3b..b65b82f 100644
--- a/tests/src/fakes/clock_fake.hpp
+++ b/tests/src/fakes/clock_fake.hpp
@@ -1,49 +1,64 @@
#pragma once
#include "interfaces/clock.hpp"
-#include "types/duration_type.hpp"
+#include "types/duration_types.hpp"
class ClockFake : public interfaces::Clock
{
public:
- time_point now() const noexcept override
+ template <class ClockType>
+ struct InternalClock
{
- return timePoint;
- }
+ using clock = ClockType;
+ using time_point = typename clock::time_point;
- uint64_t timestamp() const noexcept override
- {
- return toTimestamp(now());
- }
+ Milliseconds timestamp() const noexcept
+ {
+ return ClockFake::toTimestamp(now);
+ }
- uint64_t advance(Milliseconds delta) noexcept
- {
- timePoint += delta;
- return timestamp();
- }
+ void advance(Milliseconds delta) noexcept
+ {
+ now += delta;
+ }
- void set(Milliseconds timeSinceEpoch) noexcept
- {
- timePoint = time_point{timeSinceEpoch};
- }
+ void set(Milliseconds timeSinceEpoch) noexcept
+ {
+ now = time_point{timeSinceEpoch};
+ }
- void reset(void) noexcept
- {
- set(Milliseconds(0));
- }
+ void reset() noexcept
+ {
+ now = time_point{Milliseconds{0u}};
+ }
- static uint64_t toTimestamp(Milliseconds time)
- {
- return time.count();
- }
+ private:
+ time_point now = clock::now();
+ };
- static uint64_t toTimestamp(time_point tp)
+ template <class TimePoint>
+ static Milliseconds toTimestamp(TimePoint tp)
{
return std::chrono::time_point_cast<Milliseconds>(tp)
- .time_since_epoch()
- .count();
+ .time_since_epoch();
}
- private:
- time_point timePoint = std::chrono::steady_clock::now();
+ Milliseconds steadyTimestamp() const noexcept override
+ {
+ return steady.timestamp();
+ }
+
+ Milliseconds systemTimestamp() const noexcept override
+ {
+ return system.timestamp();
+ }
+
+ void advance(Milliseconds delta) noexcept
+ {
+ steady.advance(delta);
+ system.advance(delta);
+ }
+
+ InternalClock<std::chrono::steady_clock> steady;
+ InternalClock<std::chrono::system_clock> system;
};
diff --git a/tests/src/helpers.hpp b/tests/src/helpers.hpp
index c12c610..8ae0b7f 100644
--- a/tests/src/helpers.hpp
+++ b/tests/src/helpers.hpp
@@ -4,3 +4,4 @@
#include "helpers/interfaces/sensor_id_helpers.hpp"
#include "helpers/labeled_tuple_helpers.hpp"
#include "helpers/metric_value_helpers.hpp"
+#include "helpers/types/duration_types_helpers.hpp"
diff --git a/tests/src/helpers/types/duration_types_helpers.hpp b/tests/src/helpers/types/duration_types_helpers.hpp
new file mode 100644
index 0000000..be4886c
--- /dev/null
+++ b/tests/src/helpers/types/duration_types_helpers.hpp
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "types/duration_types.hpp"
+
+#include <gmock/gmock.h>
+
+template <class Ratio>
+inline void PrintTo(const std::chrono::duration<uint64_t, Ratio>& o,
+ std::ostream* os)
+{
+ (*os) << std::chrono::duration_cast<Milliseconds>(o).count() << "us";
+}
diff --git a/tests/src/mocks/sensor_listener_mock.hpp b/tests/src/mocks/sensor_listener_mock.hpp
index 3a61519..a5c0331 100644
--- a/tests/src/mocks/sensor_listener_mock.hpp
+++ b/tests/src/mocks/sensor_listener_mock.hpp
@@ -18,10 +18,10 @@
.WillByDefault(InvokeWithoutArgs([this] { sensorUpdated(); }));
}
- MOCK_METHOD(void, sensorUpdated, (interfaces::Sensor&, uint64_t),
+ MOCK_METHOD(void, sensorUpdated, (interfaces::Sensor&, Milliseconds),
(override));
- MOCK_METHOD(void, sensorUpdated, (interfaces::Sensor&, uint64_t, double),
- (override));
+ MOCK_METHOD(void, sensorUpdated,
+ (interfaces::Sensor&, Milliseconds, double), (override));
MOCK_METHOD(void, sensorUpdated, (), ());
};
diff --git a/tests/src/mocks/trigger_action_mock.hpp b/tests/src/mocks/trigger_action_mock.hpp
index 586ac21..65585d8 100644
--- a/tests/src/mocks/trigger_action_mock.hpp
+++ b/tests/src/mocks/trigger_action_mock.hpp
@@ -7,6 +7,6 @@
class TriggerActionMock : public interfaces::TriggerAction
{
public:
- MOCK_METHOD(void, commit, (const std::string&, uint64_t, double),
+ MOCK_METHOD(void, commit, (const std::string&, Milliseconds, double),
(override));
};
diff --git a/tests/src/params/trigger_params.hpp b/tests/src/params/trigger_params.hpp
index ea309e6..886cf78 100644
--- a/tests/src/params/trigger_params.hpp
+++ b/tests/src/params/trigger_params.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "types/milliseconds.hpp"
+#include "types/duration_types.hpp"
#include "types/trigger_types.hpp"
#include <sdbusplus/message.hpp>
diff --git a/tests/src/test_discrete_threshold.cpp b/tests/src/test_discrete_threshold.cpp
index 47b6179..3dd2baa 100644
--- a/tests/src/test_discrete_threshold.cpp
+++ b/tests/src/test_discrete_threshold.cpp
@@ -3,7 +3,7 @@
#include "helpers.hpp"
#include "mocks/sensor_mock.hpp"
#include "mocks/trigger_action_mock.hpp"
-#include "types/milliseconds.hpp"
+#include "types/duration_types.hpp"
#include "utils/conv_container.hpp"
#include <gmock/gmock.h>
@@ -66,11 +66,11 @@
struct UpdateParams
{
size_t sensor;
- uint64_t timestamp;
+ Milliseconds timestamp;
double value;
Milliseconds sleepAfter;
- UpdateParams(size_t sensor, uint64_t timestamp, double value,
+ UpdateParams(size_t sensor, Milliseconds timestamp, double value,
Milliseconds sleepAfter = 0ms) :
sensor(sensor),
timestamp(timestamp), value(value), sleepAfter(sleepAfter)
@@ -80,11 +80,11 @@
struct ExpectedParams
{
size_t sensor;
- uint64_t timestamp;
+ Milliseconds timestamp;
double value;
Milliseconds waitMin;
- ExpectedParams(size_t sensor, uint64_t timestamp, double value,
+ ExpectedParams(size_t sensor, Milliseconds timestamp, double value,
Milliseconds waitMin = 0ms) :
sensor(sensor),
timestamp(timestamp), value(value), waitMin(waitMin)
@@ -122,16 +122,16 @@
*os << ", Updates: ";
for (const auto& [index, timestamp, value, sleepAfter] : o.updates)
{
- *os << "{ SensorIndex: " << index << ", Timestamp: " << timestamp
- << ", Value: " << value
+ *os << "{ SensorIndex: " << index
+ << ", Timestamp: " << timestamp.count() << ", Value: " << value
<< ", SleepAfter: " << sleepAfter.count() << "ms }, ";
}
*os << "Expected: ";
for (const auto& [index, timestamp, value, waitMin] : o.expected)
{
- *os << "{ SensorIndex: " << index << ", Timestamp: " << timestamp
- << ", Value: " << value << ", waitMin: " << waitMin.count()
- << "ms }, ";
+ *os << "{ SensorIndex: " << index
+ << ", Timestamp: " << timestamp.count() << ", Value: " << value
+ << ", waitMin: " << waitMin.count() << "ms }, ";
}
*os << " }";
}
@@ -204,21 +204,26 @@
}
};
-INSTANTIATE_TEST_SUITE_P(
- _, TestDiscreteThresholdNoDwellTime,
- Values(
- DiscreteParams()
- .ThresholdValue(90.0)
- .Updates({{0, 1, 80.0}, {0, 2, 89.0}})
- .Expected({}),
- DiscreteParams()
- .ThresholdValue(90.0)
- .Updates({{0, 1, 80.0}, {0, 2, 90.0}, {0, 3, 80.0}, {0, 4, 90.0}})
- .Expected({{0, 2, 90.0}, {0, 4, 90.0}}),
- DiscreteParams()
- .ThresholdValue(90.0)
- .Updates({{0, 1, 90.0}, {0, 2, 99.0}, {1, 3, 100.0}, {1, 4, 90.0}})
- .Expected({{0, 1, 90.0}, {1, 4, 90.0}})));
+INSTANTIATE_TEST_SUITE_P(_, TestDiscreteThresholdNoDwellTime,
+ Values(DiscreteParams()
+ .ThresholdValue(90.0)
+ .Updates({{0, 1ms, 80.0}, {0, 2ms, 89.0}})
+ .Expected({}),
+ DiscreteParams()
+ .ThresholdValue(90.0)
+ .Updates({{0, 1ms, 80.0},
+ {0, 2ms, 90.0},
+ {0, 3ms, 80.0},
+ {0, 4ms, 90.0}})
+ .Expected({{0, 2ms, 90.0}, {0, 4ms, 90.0}}),
+ DiscreteParams()
+ .ThresholdValue(90.0)
+ .Updates({{0, 1ms, 90.0},
+ {0, 2ms, 99.0},
+ {1, 3ms, 100.0},
+ {1, 4ms, 90.0}})
+ .Expected({{0, 1ms, 90.0},
+ {1, 4ms, 90.0}})));
TEST_P(TestDiscreteThresholdNoDwellTime, senorsIsUpdatedMultipleTimes)
{
@@ -239,31 +244,31 @@
Values(DiscreteParams()
.DwellTime(200ms)
.ThresholdValue(90.0)
- .Updates({{0, 1, 90.0, 100ms}, {0, 2, 91.0}, {0, 3, 90.0}})
- .Expected({{0, 3, 90.0, 300ms}}),
+ .Updates({{0, 1ms, 90.0, 100ms}, {0, 2ms, 91.0}, {0, 3ms, 90.0}})
+ .Expected({{0, 3ms, 90.0, 300ms}}),
DiscreteParams()
.DwellTime(100ms)
.ThresholdValue(90.0)
- .Updates({{0, 1, 90.0, 100ms}})
- .Expected({{0, 1, 90.0, 100ms}}),
+ .Updates({{0, 1ms, 90.0, 100ms}})
+ .Expected({{0, 1ms, 90.0, 100ms}}),
DiscreteParams()
.DwellTime(1000ms)
.ThresholdValue(90.0)
- .Updates({{0, 1, 90.0, 700ms},
- {0, 1, 91.0, 100ms},
- {0, 1, 90.0, 300ms},
- {0, 1, 91.0, 100ms}})
+ .Updates({{0, 1ms, 90.0, 700ms},
+ {0, 1ms, 91.0, 100ms},
+ {0, 1ms, 90.0, 300ms},
+ {0, 1ms, 91.0, 100ms}})
.Expected({}),
DiscreteParams()
.DwellTime(200ms)
.ThresholdValue(90.0)
- .Updates({{0, 1, 90.0},
- {1, 2, 89.0, 100ms},
- {1, 3, 90.0, 100ms},
- {1, 4, 89.0, 100ms},
- {1, 5, 90.0, 300ms},
- {1, 6, 89.0, 100ms}})
- .Expected({{0, 1, 90, 200ms}, {1, 5, 90, 500ms}})));
+ .Updates({{0, 1ms, 90.0},
+ {1, 2ms, 89.0, 100ms},
+ {1, 3ms, 90.0, 100ms},
+ {1, 4ms, 89.0, 100ms},
+ {1, 5ms, 90.0, 300ms},
+ {1, 6ms, 89.0, 100ms}})
+ .Expected({{0, 1ms, 90, 200ms}, {1, 5ms, 90, 500ms}})));
TEST_P(TestDiscreteThresholdWithDwellTime, senorsIsUpdatedMultipleTimes)
{
diff --git a/tests/src/test_metric.cpp b/tests/src/test_metric.cpp
index e19446c..bd1d8c4 100644
--- a/tests/src/test_metric.cpp
+++ b/tests/src/test_metric.cpp
@@ -14,11 +14,17 @@
namespace tstring = utils::tstring;
-using Timestamp = uint64_t;
+constexpr Milliseconds systemTimestamp = 42ms;
class TestMetric : public Test
{
public:
+ TestMetric()
+ {
+ clockFake.steady.reset();
+ clockFake.system.set(systemTimestamp);
+ }
+
static std::vector<std::shared_ptr<SensorMock>>
makeSensorMocks(size_t amount)
{
@@ -102,18 +108,23 @@
TEST_F(TestMetricAfterInitialization, updatesMetricValuesOnSensorUpdate)
{
- sut->sensorUpdated(*sensorMocks.front(), Timestamp{18}, 31.2);
+ sut->sensorUpdated(*sensorMocks.front(), Milliseconds{18}, 31.2);
- ASSERT_THAT(sut->getReadings(),
- ElementsAre(MetricValue{"id", "metadata", 31.2, 18u}));
+ ASSERT_THAT(
+ sut->getReadings(),
+ ElementsAre(MetricValue{"id", "metadata", 31.2,
+ std::chrono::duration_cast<Milliseconds>(
+ clockFake.system.timestamp())
+ .count()}));
}
TEST_F(TestMetricAfterInitialization,
throwsWhenUpdateIsPerformedOnUnknownSensor)
{
auto sensor = std::make_shared<StrictMock<SensorMock>>();
- EXPECT_THROW(sut->sensorUpdated(*sensor, Timestamp{10}), std::out_of_range);
- EXPECT_THROW(sut->sensorUpdated(*sensor, Timestamp{10}, 20.0),
+ EXPECT_THROW(sut->sensorUpdated(*sensor, Milliseconds{10}),
+ std::out_of_range);
+ EXPECT_THROW(sut->sensorUpdated(*sensor, Milliseconds{10}, 20.0),
std::out_of_range);
}
@@ -146,7 +157,6 @@
public:
void SetUp() override
{
- clockFake.reset();
sut = makeSut(params.operationType(GetParam().operationType())
.collectionTimeScope(GetParam().collectionTimeScope())
.collectionDuration(GetParam().collectionDuration()));
@@ -168,7 +178,7 @@
return MetricParams()
.operationType(OperationType::single)
.readings(TestMetricCalculationFunctions::defaultReadings())
- .expectedReading(11ms, 7.0);
+ .expectedReading(systemTimestamp + 16ms, 7.0);
}
INSTANTIATE_TEST_SUITE_P(
@@ -205,14 +215,14 @@
Values(defaultMinParams()
.collectionTimeScope(CollectionTimeScope::interval)
.collectionDuration(CollectionDuration(100ms))
- .expectedReading(10ms, 3.0),
+ .expectedReading(systemTimestamp + 16ms, 3.0),
defaultMinParams()
.collectionTimeScope(CollectionTimeScope::interval)
.collectionDuration(CollectionDuration(3ms))
- .expectedReading(13ms, 7.0),
+ .expectedReading(systemTimestamp + 16ms, 7.0),
defaultMinParams()
.collectionTimeScope(CollectionTimeScope::startup)
- .expectedReading(10ms, 3.0)));
+ .expectedReading(systemTimestamp + 16ms, 3.0)));
MetricParams defaultMaxParams()
{
@@ -224,18 +234,18 @@
Values(defaultMaxParams()
.collectionTimeScope(CollectionTimeScope::interval)
.collectionDuration(CollectionDuration(100ms))
- .expectedReading(0ms, 14.0),
+ .expectedReading(systemTimestamp + 16ms, 14.0),
defaultMaxParams()
.collectionTimeScope(CollectionTimeScope::interval)
.collectionDuration(CollectionDuration(6ms))
- .expectedReading(10ms, 14.0),
+ .expectedReading(systemTimestamp + 16ms, 14.0),
defaultMaxParams()
.collectionTimeScope(CollectionTimeScope::interval)
.collectionDuration(CollectionDuration(5ms))
- .expectedReading(11ms, 7.0),
+ .expectedReading(systemTimestamp + 16ms, 7.0),
defaultMaxParams()
.collectionTimeScope(CollectionTimeScope::startup)
- .expectedReading(0ms, 14.0)));
+ .expectedReading(systemTimestamp + 16ms, 14.0)));
MetricParams defaultSumParams()
{
@@ -247,18 +257,21 @@
Values(defaultSumParams()
.collectionTimeScope(CollectionTimeScope::interval)
.collectionDuration(CollectionDuration(100ms))
- .expectedReading(16ms, 14. * 10 + 3. * 1 + 7 * 5),
+ .expectedReading(systemTimestamp + 16ms,
+ 14. * 0.01 + 3. * 0.001 + 7. * 0.005),
defaultSumParams()
.collectionTimeScope(CollectionTimeScope::interval)
.collectionDuration(CollectionDuration(8ms))
- .expectedReading(16ms, 14. * 2 + 3. * 1 + 7 * 5),
+ .expectedReading(systemTimestamp + 16ms,
+ 14. * 0.002 + 3. * 0.001 + 7 * 0.005),
defaultSumParams()
.collectionTimeScope(CollectionTimeScope::interval)
.collectionDuration(CollectionDuration(6ms))
- .expectedReading(16ms, 3. * 1 + 7 * 5),
+ .expectedReading(systemTimestamp + 16ms, 3. * 0.001 + 7 * 0.005),
defaultSumParams()
.collectionTimeScope(CollectionTimeScope::startup)
- .expectedReading(16ms, 14. * 10 + 3. * 1 + 7 * 5)));
+ .expectedReading(systemTimestamp + 16ms,
+ 14. * 0.01 + 3. * 0.001 + 7 * 0.005)));
MetricParams defaultAvgParams()
{
@@ -270,24 +283,27 @@
Values(defaultAvgParams()
.collectionTimeScope(CollectionTimeScope::interval)
.collectionDuration(CollectionDuration(100ms))
- .expectedReading(16ms, (14. * 10 + 3. * 1 + 7 * 5) / 16.),
+ .expectedReading(systemTimestamp + 16ms,
+ (14. * 10 + 3. * 1 + 7 * 5) / 16.),
defaultAvgParams()
.collectionTimeScope(CollectionTimeScope::interval)
.collectionDuration(CollectionDuration(8ms))
- .expectedReading(16ms, (14. * 2 + 3. * 1 + 7 * 5) / 8.),
+ .expectedReading(systemTimestamp + 16ms,
+ (14. * 2 + 3. * 1 + 7 * 5) / 8.),
defaultAvgParams()
.collectionTimeScope(CollectionTimeScope::interval)
.collectionDuration(CollectionDuration(6ms))
- .expectedReading(16ms, (3. * 1 + 7 * 5) / 6.),
+ .expectedReading(systemTimestamp + 16ms, (3. * 1 + 7 * 5) / 6.),
defaultAvgParams()
.collectionTimeScope(CollectionTimeScope::startup)
- .expectedReading(16ms, (14. * 10 + 3. * 1 + 7 * 5) / 16.)));
+ .expectedReading(systemTimestamp + 16ms,
+ (14. * 10 + 3. * 1 + 7 * 5) / 16.)));
TEST_P(TestMetricCalculationFunctions, calculatesReadingValue)
{
for (auto [timestamp, reading] : GetParam().readings())
{
- sut->sensorUpdated(*sensorMocks.front(), clockFake.timestamp(),
+ sut->sensorUpdated(*sensorMocks.front(), clockFake.steadyTimestamp(),
reading);
clockFake.advance(timestamp);
}
@@ -296,9 +312,9 @@
GetParam().expectedReading();
const auto readings = sut->getReadings();
- EXPECT_THAT(readings, ElementsAre(MetricValue{
- "id", "metadata", expectedReading,
- ClockFake::toTimestamp(expectedTimestamp)}));
+ EXPECT_THAT(readings,
+ ElementsAre(MetricValue{"id", "metadata", expectedReading,
+ expectedTimestamp.count()}));
}
TEST_P(TestMetricCalculationFunctions,
@@ -306,7 +322,7 @@
{
for (auto [timestamp, reading] : GetParam().readings())
{
- sut->sensorUpdated(*sensorMocks.front(), clockFake.timestamp(),
+ sut->sensorUpdated(*sensorMocks.front(), clockFake.steadyTimestamp(),
reading);
clockFake.advance(timestamp);
sut->getReadings();
@@ -316,7 +332,7 @@
GetParam().expectedReading();
const auto readings = sut->getReadings();
- EXPECT_THAT(readings, ElementsAre(MetricValue{
- "id", "metadata", expectedReading,
- ClockFake::toTimestamp(expectedTimestamp)}));
+ EXPECT_THAT(readings,
+ ElementsAre(MetricValue{"id", "metadata", expectedReading,
+ expectedTimestamp.count()}));
}
diff --git a/tests/src/test_numeric_threshold.cpp b/tests/src/test_numeric_threshold.cpp
index bda31a0..851d4a9 100644
--- a/tests/src/test_numeric_threshold.cpp
+++ b/tests/src/test_numeric_threshold.cpp
@@ -69,14 +69,14 @@
}
NumericParams&
- Updates(std::vector<std::tuple<size_t, uint64_t, double>> val)
+ Updates(std::vector<std::tuple<size_t, Milliseconds, double>> val)
{
updates = std::move(val);
return *this;
}
NumericParams&
- Expected(std::vector<std::tuple<size_t, uint64_t, double>> val)
+ Expected(std::vector<std::tuple<size_t, Milliseconds, double>> val)
{
expected = std::move(val);
return *this;
@@ -88,21 +88,23 @@
<< ", Updates: ";
for (const auto& [index, timestamp, value] : o.updates)
{
- *os << "{ SensorIndex: " << index << ", Timestamp: " << timestamp
- << ", Value: " << value << " }, ";
+ *os << "{ SensorIndex: " << index
+ << ", Timestamp: " << timestamp.count() << ", Value: " << value
+ << " }, ";
}
*os << "Expected: ";
for (const auto& [index, timestamp, value] : o.expected)
{
- *os << "{ SensorIndex: " << index << ", Timestamp: " << timestamp
- << ", Value: " << value << " }, ";
+ *os << "{ SensorIndex: " << index
+ << ", Timestamp: " << timestamp.count() << ", Value: " << value
+ << " }, ";
}
*os << " }";
}
numeric::Direction direction;
- std::vector<std::tuple<size_t, uint64_t, double>> updates;
- std::vector<std::tuple<size_t, uint64_t, double>> expected;
+ std::vector<std::tuple<size_t, Milliseconds, double>> updates;
+ std::vector<std::tuple<size_t, Milliseconds, double>> expected;
};
class TestNumericThresholdNoDwellTime :
@@ -116,53 +118,70 @@
}
};
-INSTANTIATE_TEST_SUITE_P(
- _, TestNumericThresholdNoDwellTime,
- Values(
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {0, 2, 89.0}})
- .Expected({}),
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {0, 2, 91.0}})
- .Expected({{0, 2, 91.0}}),
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {0, 2, 99.0}, {0, 3, 80.0}, {0, 4, 98.0}})
- .Expected({{0, 2, 99.0}, {0, 4, 98.0}}),
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {0, 2, 99.0}, {1, 3, 100.0}, {1, 4, 98.0}})
- .Expected({{0, 2, 99.0}}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 91.0}})
- .Expected({}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}})
- .Expected({{0, 2, 80.0}}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}, {0, 3, 99.0}, {0, 4, 85.0}})
- .Expected({{0, 2, 80.0}, {0, 4, 85.0}}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}, {1, 3, 99.0}, {1, 4, 88.0}})
- .Expected({{0, 2, 80.0}, {1, 4, 88.0}}),
- NumericParams()
- .Direction(numeric::Direction::either)
- .Updates({{0, 1, 98.0}, {0, 2, 91.0}})
- .Expected({}),
- NumericParams()
- .Direction(numeric::Direction::either)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}, {0, 3, 85.0}, {0, 4, 91.0}})
- .Expected({{0, 2, 80.0}, {0, 4, 91.0}}),
- NumericParams()
- .Direction(numeric::Direction::either)
- .Updates({{0, 1, 100.0}, {1, 2, 80.0}, {0, 3, 85.0}, {1, 4, 91.0}})
- .Expected({{0, 3, 85.0}, {1, 4, 91.0}})));
+INSTANTIATE_TEST_SUITE_P(_, TestNumericThresholdNoDwellTime,
+ Values(NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0}, {0, 2ms, 89.0}})
+ .Expected({}),
+ NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0}, {0, 2ms, 91.0}})
+ .Expected({{0, 2ms, 91.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0},
+ {0, 2ms, 99.0},
+ {0, 3ms, 80.0},
+ {0, 4ms, 98.0}})
+ .Expected({{0, 2ms, 99.0}, {0, 4ms, 98.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0},
+ {0, 2ms, 99.0},
+ {1, 3ms, 100.0},
+ {1, 4ms, 98.0}})
+ .Expected({{0, 2ms, 99.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0}, {0, 2ms, 91.0}})
+ .Expected({}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0}, {0, 2ms, 80.0}})
+ .Expected({{0, 2ms, 80.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0},
+ {0, 2ms, 80.0},
+ {0, 3ms, 99.0},
+ {0, 4ms, 85.0}})
+ .Expected({{0, 2ms, 80.0}, {0, 4ms, 85.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0},
+ {0, 2ms, 80.0},
+ {1, 3ms, 99.0},
+ {1, 4ms, 88.0}})
+ .Expected({{0, 2ms, 80.0}, {1, 4ms, 88.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::either)
+ .Updates({{0, 1ms, 98.0}, {0, 2ms, 91.0}})
+ .Expected({}),
+ NumericParams()
+ .Direction(numeric::Direction::either)
+ .Updates({{0, 1ms, 100.0},
+ {0, 2ms, 80.0},
+ {0, 3ms, 85.0},
+ {0, 4ms, 91.0}})
+ .Expected({{0, 2ms, 80.0}, {0, 4ms, 91.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::either)
+ .Updates({{0, 1ms, 100.0},
+ {1, 2ms, 80.0},
+ {0, 3ms, 85.0},
+ {1, 4ms, 91.0}})
+ .Expected({{0, 3ms, 85.0},
+ {1, 4ms, 91.0}})));
TEST_P(TestNumericThresholdNoDwellTime, senorsIsUpdatedMultipleTimes)
{
@@ -195,53 +214,70 @@
}
};
-INSTANTIATE_TEST_SUITE_P(
- _, TestNumericThresholdWithDwellTime,
- Values(
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {0, 2, 89.0}})
- .Expected({}),
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {0, 2, 91.0}})
- .Expected({{0, 2, 91.0}}),
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {0, 2, 99.0}, {0, 3, 80.0}, {0, 4, 98.0}})
- .Expected({{0, 2, 99.0}, {0, 4, 98.0}}),
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {1, 2, 99.0}, {0, 3, 100.0}, {1, 4, 86.0}})
- .Expected({{0, 3, 100.0}}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 91.0}})
- .Expected({}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}})
- .Expected({{0, 2, 80.0}}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}, {0, 3, 99.0}, {0, 4, 85.0}})
- .Expected({{0, 2, 80.0}, {0, 4, 85.0}}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}, {1, 3, 99.0}, {1, 4, 88.0}})
- .Expected({{0, 2, 80.0}, {1, 4, 88.0}}),
- NumericParams()
- .Direction(numeric::Direction::either)
- .Updates({{0, 1, 98.0}, {0, 2, 91.0}})
- .Expected({}),
- NumericParams()
- .Direction(numeric::Direction::either)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}, {0, 3, 85.0}, {0, 4, 91.0}})
- .Expected({{0, 2, 80.0}, {0, 4, 91.0}}),
- NumericParams()
- .Direction(numeric::Direction::either)
- .Updates({{0, 1, 100.0}, {1, 2, 80.0}, {0, 3, 85.0}, {1, 4, 91.0}})
- .Expected({{0, 3, 85.0}, {1, 4, 91.0}})));
+INSTANTIATE_TEST_SUITE_P(_, TestNumericThresholdWithDwellTime,
+ Values(NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0}, {0, 2ms, 89.0}})
+ .Expected({}),
+ NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0}, {0, 2ms, 91.0}})
+ .Expected({{0, 2ms, 91.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0},
+ {0, 2ms, 99.0},
+ {0, 3ms, 80.0},
+ {0, 4ms, 98.0}})
+ .Expected({{0, 2ms, 99.0}, {0, 4ms, 98.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0},
+ {1, 2ms, 99.0},
+ {0, 3ms, 100.0},
+ {1, 4ms, 86.0}})
+ .Expected({{0, 3ms, 100.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0}, {0, 2ms, 91.0}})
+ .Expected({}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0}, {0, 2ms, 80.0}})
+ .Expected({{0, 2ms, 80.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0},
+ {0, 2ms, 80.0},
+ {0, 3ms, 99.0},
+ {0, 4ms, 85.0}})
+ .Expected({{0, 2ms, 80.0}, {0, 4ms, 85.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0},
+ {0, 2ms, 80.0},
+ {1, 3ms, 99.0},
+ {1, 4ms, 88.0}})
+ .Expected({{0, 2ms, 80.0}, {1, 4ms, 88.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::either)
+ .Updates({{0, 1ms, 98.0}, {0, 2ms, 91.0}})
+ .Expected({}),
+ NumericParams()
+ .Direction(numeric::Direction::either)
+ .Updates({{0, 1ms, 100.0},
+ {0, 2ms, 80.0},
+ {0, 3ms, 85.0},
+ {0, 4ms, 91.0}})
+ .Expected({{0, 2ms, 80.0}, {0, 4ms, 91.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::either)
+ .Updates({{0, 1ms, 100.0},
+ {1, 2ms, 80.0},
+ {0, 3ms, 85.0},
+ {1, 4ms, 91.0}})
+ .Expected({{0, 3ms, 85.0},
+ {1, 4ms, 91.0}})));
TEST_P(TestNumericThresholdWithDwellTime,
senorsIsUpdatedMultipleTimesSleepAfterEveryUpdate)
@@ -276,53 +312,70 @@
}
};
-INSTANTIATE_TEST_SUITE_P(
- _, TestNumericThresholdWithDwellTime2,
- Values(
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {0, 2, 89.0}})
- .Expected({}),
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {0, 2, 91.0}})
- .Expected({{0, 2, 91.0}}),
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {0, 2, 99.0}, {0, 3, 80.0}, {0, 4, 98.0}})
- .Expected({{0, 4, 98.0}}),
- NumericParams()
- .Direction(numeric::Direction::increasing)
- .Updates({{0, 1, 80.0}, {1, 2, 99.0}, {0, 3, 100.0}, {1, 4, 98.0}})
- .Expected({{0, 3, 100.0}}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 91.0}})
- .Expected({}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}})
- .Expected({{0, 2, 80.0}}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}, {0, 3, 99.0}, {0, 4, 85.0}})
- .Expected({{0, 4, 85.0}}),
- NumericParams()
- .Direction(numeric::Direction::decreasing)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}, {1, 3, 99.0}, {1, 4, 88.0}})
- .Expected({{0, 2, 80.0}, {1, 4, 88.0}}),
- NumericParams()
- .Direction(numeric::Direction::either)
- .Updates({{0, 1, 98.0}, {0, 2, 91.0}})
- .Expected({}),
- NumericParams()
- .Direction(numeric::Direction::either)
- .Updates({{0, 1, 100.0}, {0, 2, 80.0}, {0, 3, 85.0}, {0, 4, 91.0}})
- .Expected({{0, 4, 91.0}}),
- NumericParams()
- .Direction(numeric::Direction::either)
- .Updates({{0, 1, 100.0}, {1, 2, 80.0}, {0, 3, 85.0}, {1, 4, 91.0}})
- .Expected({{0, 3, 85.0}, {1, 4, 91.0}})));
+INSTANTIATE_TEST_SUITE_P(_, TestNumericThresholdWithDwellTime2,
+ Values(NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0}, {0, 2ms, 89.0}})
+ .Expected({}),
+ NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0}, {0, 2ms, 91.0}})
+ .Expected({{0, 2ms, 91.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0},
+ {0, 2ms, 99.0},
+ {0, 3ms, 80.0},
+ {0, 4ms, 98.0}})
+ .Expected({{0, 4ms, 98.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::increasing)
+ .Updates({{0, 1ms, 80.0},
+ {1, 2ms, 99.0},
+ {0, 3ms, 100.0},
+ {1, 4ms, 98.0}})
+ .Expected({{0, 3ms, 100.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0}, {0, 2ms, 91.0}})
+ .Expected({}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0}, {0, 2ms, 80.0}})
+ .Expected({{0, 2ms, 80.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0},
+ {0, 2ms, 80.0},
+ {0, 3ms, 99.0},
+ {0, 4ms, 85.0}})
+ .Expected({{0, 4ms, 85.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::decreasing)
+ .Updates({{0, 1ms, 100.0},
+ {0, 2ms, 80.0},
+ {1, 3ms, 99.0},
+ {1, 4ms, 88.0}})
+ .Expected({{0, 2ms, 80.0}, {1, 4ms, 88.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::either)
+ .Updates({{0, 1ms, 98.0}, {0, 2ms, 91.0}})
+ .Expected({}),
+ NumericParams()
+ .Direction(numeric::Direction::either)
+ .Updates({{0, 1ms, 100.0},
+ {0, 2ms, 80.0},
+ {0, 3ms, 85.0},
+ {0, 4ms, 91.0}})
+ .Expected({{0, 4ms, 91.0}}),
+ NumericParams()
+ .Direction(numeric::Direction::either)
+ .Updates({{0, 1ms, 100.0},
+ {1, 2ms, 80.0},
+ {0, 3ms, 85.0},
+ {1, 4ms, 91.0}})
+ .Expected({{0, 3ms, 85.0},
+ {1, 4ms, 91.0}})));
TEST_P(TestNumericThresholdWithDwellTime2,
senorsIsUpdatedMultipleTimesSleepAfterLastUpdate)
diff --git a/tests/src/test_on_change_threshold.cpp b/tests/src/test_on_change_threshold.cpp
index 20819c5..75a63c5 100644
--- a/tests/src/test_on_change_threshold.cpp
+++ b/tests/src/test_on_change_threshold.cpp
@@ -54,8 +54,8 @@
struct OnChangeParams
{
- using UpdateParams = std::tuple<size_t, uint64_t, double>;
- using ExpectedParams = std::tuple<size_t, uint64_t, double>;
+ using UpdateParams = std::tuple<size_t, Milliseconds, double>;
+ using ExpectedParams = std::tuple<size_t, Milliseconds, double>;
OnChangeParams& Updates(std::vector<UpdateParams> val)
{
@@ -74,14 +74,16 @@
*os << "{ Updates: ";
for (const auto& [index, timestamp, value] : o.updates)
{
- *os << "{ SensorIndex: " << index << ", Timestamp: " << timestamp
- << ", Value: " << value << " }, ";
+ *os << "{ SensorIndex: " << index
+ << ", Timestamp: " << timestamp.count() << ", Value: " << value
+ << " }, ";
}
*os << "Expected: ";
for (const auto& [index, timestamp, value] : o.expected)
{
- *os << "{ SensorIndex: " << index << ", Timestamp: " << timestamp
- << ", Value: " << value << " }, ";
+ *os << "{ SensorIndex: " << index
+ << ", Timestamp: " << timestamp.count() << ", Value: " << value
+ << " }, ";
}
*os << " }";
}
@@ -98,20 +100,25 @@
INSTANTIATE_TEST_SUITE_P(
_, TestOnChangeThresholdUpdates,
Values(
- OnChangeParams().Updates({{0, 1, 80.0}}).Expected({{0, 1, 80.0}}),
+ OnChangeParams().Updates({{0, 1ms, 80.0}}).Expected({{0, 1ms, 80.0}}),
OnChangeParams()
- .Updates({{0, 1, 80.0}, {1, 2, 81.0}})
- .Expected({{0, 1, 80.0}, {1, 2, 81.0}}),
+ .Updates({{0, 1ms, 80.0}, {1, 2ms, 81.0}})
+ .Expected({{0, 1ms, 80.0}, {1, 2ms, 81.0}}),
OnChangeParams()
- .Updates({{0, 1, 80.0}, {0, 2, 90.0}})
- .Expected({{0, 1, 80.0}, {0, 2, 90.0}}),
+ .Updates({{0, 1ms, 80.0}, {0, 2ms, 90.0}})
+ .Expected({{0, 1ms, 80.0}, {0, 2ms, 90.0}}),
OnChangeParams()
- .Updates({{0, 1, 80.0}, {1, 2, 90.0}, {0, 3, 90.0}})
- .Expected({{0, 1, 80.0}, {1, 2, 90.0}, {0, 3, 90.0}}),
+ .Updates({{0, 1ms, 80.0}, {1, 2ms, 90.0}, {0, 3ms, 90.0}})
+ .Expected({{0, 1ms, 80.0}, {1, 2ms, 90.0}, {0, 3ms, 90.0}}),
OnChangeParams()
- .Updates({{0, 1, 80.0}, {1, 2, 80.0}, {1, 3, 90.0}, {0, 4, 90.0}})
- .Expected(
- {{0, 1, 80.0}, {1, 2, 80.0}, {1, 3, 90.0}, {0, 4, 90.0}})));
+ .Updates({{0, 1ms, 80.0},
+ {1, 2ms, 80.0},
+ {1, 3ms, 90.0},
+ {0, 4ms, 90.0}})
+ .Expected({{0, 1ms, 80.0},
+ {1, 2ms, 80.0},
+ {1, 3ms, 90.0},
+ {0, 4ms, 90.0}})));
TEST_P(TestOnChangeThresholdUpdates, senorsIsUpdatedMultipleTimes)
{
diff --git a/tests/src/test_report.cpp b/tests/src/test_report.cpp
index dc08630..675171a 100644
--- a/tests/src/test_report.cpp
+++ b/tests/src/test_report.cpp
@@ -1,4 +1,5 @@
#include "dbus_environment.hpp"
+#include "fakes/clock_fake.hpp"
#include "helpers.hpp"
#include "mocks/json_storage_mock.hpp"
#include "mocks/metric_mock.hpp"
@@ -19,6 +20,8 @@
using namespace std::chrono_literals;
namespace tstring = utils::tstring;
+constexpr Milliseconds systemTimestamp = 55ms;
+
class TestReport : public Test
{
public:
@@ -28,10 +31,17 @@
std::make_unique<NiceMock<ReportManagerMock>>();
testing::NiceMock<StorageMock> storageMock;
std::vector<std::shared_ptr<MetricMock>> metricMocks;
+ std::unique_ptr<ClockFake> clockFakePtr = std::make_unique<ClockFake>();
+ ClockFake& clockFake = *clockFakePtr;
std::unique_ptr<Report> sut;
MockFunction<void()> checkPoint;
+ TestReport()
+ {
+ clockFake.system.set(systemTimestamp);
+ }
+
void initMetricMocks(
const std::vector<LabeledMetricParameters>& metricParameters)
{
@@ -76,7 +86,7 @@
params.reportUpdates(), *reportManagerMock, storageMock,
utils::convContainer<std::shared_ptr<interfaces::Metric>>(
metricMocks),
- params.enabled());
+ params.enabled(), std::move(clockFakePtr));
}
template <class T>
@@ -396,7 +406,7 @@
TEST_P(TestReportAllReportTypes, updateReadingsCallEnabledPropertyOff)
{
- const uint64_t expectedTime = Clock().timestamp();
+ clockFake.system.advance(10ms);
setProperty(sut->getPath(), "Enabled", false);
sut->updateReadings();
@@ -404,19 +414,19 @@
getProperty<Readings>(sut->getPath(), "Readings");
EXPECT_THAT(getProperty<bool>(sut->getPath(), "Enabled"), Eq(false));
- EXPECT_THAT(timestamp, Lt(expectedTime));
+ EXPECT_THAT(Milliseconds{timestamp}, Eq(0ms));
}
TEST_P(TestReportAllReportTypes, updateReadingsCallEnabledPropertyOn)
{
- const uint64_t expectedTime = Clock().timestamp();
+ clockFake.system.advance(10ms);
sut->updateReadings();
const auto [timestamp, readings] =
getProperty<Readings>(sut->getPath(), "Readings");
EXPECT_THAT(getProperty<bool>(sut->getPath(), "Enabled"), Eq(true));
- EXPECT_THAT(timestamp, Ge(expectedTime));
+ EXPECT_THAT(Milliseconds{timestamp}, Eq(systemTimestamp + 10ms));
}
class TestReportOnRequestType : public TestReport
@@ -430,14 +440,14 @@
TEST_F(TestReportOnRequestType, updatesReadingTimestamp)
{
- const uint64_t expectedTime = Clock().timestamp();
+ clockFake.system.advance(10ms);
ASSERT_THAT(update(sut->getPath()), Eq(boost::system::errc::success));
const auto [timestamp, readings] =
getProperty<Readings>(sut->getPath(), "Readings");
- EXPECT_THAT(timestamp, Ge(expectedTime));
+ EXPECT_THAT(Milliseconds{timestamp}, Eq(systemTimestamp + 10ms));
}
TEST_F(TestReportOnRequestType, updatesReadingWhenUpdateIsCalled)
@@ -509,13 +519,13 @@
TEST_F(TestReportPeriodicReport, readingTimestampIsUpdatedAfterIntervalExpires)
{
- const uint64_t expectedTime = Clock().timestamp();
+ clockFake.system.advance(10ms);
DbusEnvironment::sleepFor(ReportManager::minInterval + 1ms);
const auto [timestamp, readings] =
getProperty<Readings>(sut->getPath(), "Readings");
- EXPECT_THAT(timestamp, Ge(expectedTime));
+ EXPECT_THAT(Milliseconds{timestamp}, Eq(systemTimestamp + 10ms));
}
TEST_F(TestReportPeriodicReport, readingsAreUpdatedAfterIntervalExpires)
diff --git a/tests/src/test_sensor.cpp b/tests/src/test_sensor.cpp
index ffa73b1..0eae668 100644
--- a/tests/src/test_sensor.cpp
+++ b/tests/src/test_sensor.cpp
@@ -52,7 +52,7 @@
std::unique_ptr<stubs::DbusSensorObject> sensorObject = makeSensorObject();
SensorCache sensorCache;
- uint64_t timestamp = Clock().timestamp();
+ Milliseconds timestamp = Clock().steadyTimestamp();
std::shared_ptr<Sensor> sut = sensorCache.makeSensor<Sensor>(
DbusEnvironment::serviceName(), sensorObject->path(), "metadata",
DbusEnvironment::getIoc(), DbusEnvironment::getBus());
diff --git a/tests/src/test_trigger_actions.cpp b/tests/src/test_trigger_actions.cpp
index 7a65fa2..1c36326 100644
--- a/tests/src/test_trigger_actions.cpp
+++ b/tests/src/test_trigger_actions.cpp
@@ -46,7 +46,7 @@
TEST_P(TestLogToJournalNumeric, commitAnActionDoesNotThrow)
{
- EXPECT_NO_THROW(sut->commit("Test", 100'000, commmitValue));
+ EXPECT_NO_THROW(sut->commit("Test", Milliseconds{100'000}, commmitValue));
}
class TestLogToJournalNumericThrow : public TestLogToJournalNumeric
@@ -56,7 +56,7 @@
TEST_P(TestLogToJournalNumericThrow, commitAnActionExpectThrow)
{
- EXPECT_THROW(sut->commit("Test", 100'000, commmitValue),
+ EXPECT_THROW(sut->commit("Test", Milliseconds{100'000}, commmitValue),
std::runtime_error);
}
@@ -79,7 +79,7 @@
TEST_P(TestLogToRedfishNumeric, commitExpectNoThrow)
{
- EXPECT_NO_THROW(sut->commit("Test", 100'000, commmitValue));
+ EXPECT_NO_THROW(sut->commit("Test", Milliseconds{100'000}, commmitValue));
}
class TestLogToRedfishNumericThrow : public TestLogToRedfishNumeric
@@ -89,7 +89,7 @@
TEST_P(TestLogToRedfishNumericThrow, commitExpectToThrow)
{
- EXPECT_THROW(sut->commit("Test", 100'000, commmitValue),
+ EXPECT_THROW(sut->commit("Test", Milliseconds{100'000}, commmitValue),
std::runtime_error);
}
@@ -130,7 +130,7 @@
TEST_P(TestLogToJournalDiscrete, commitAnActionDoesNotThrow)
{
- EXPECT_NO_THROW(sut->commit("Test", 100'000, 90.0));
+ EXPECT_NO_THROW(sut->commit("Test", Milliseconds{100'000}, 90.0));
}
class TestLogToJournalDiscreteThrow : public TestLogToJournalDiscrete
@@ -141,7 +141,8 @@
TEST_P(TestLogToJournalDiscreteThrow, commitAnActionExpectThrow)
{
- EXPECT_THROW(sut->commit("Test", 100'000, 90.0), std::runtime_error);
+ EXPECT_THROW(sut->commit("Test", Milliseconds{100'000}, 90.0),
+ std::runtime_error);
}
class TestLogToRedfishDiscrete :
@@ -163,7 +164,7 @@
TEST_P(TestLogToRedfishDiscrete, commitExpectNoThrow)
{
- EXPECT_NO_THROW(sut->commit("Test", 100'000, 90.0));
+ EXPECT_NO_THROW(sut->commit("Test", Milliseconds{100'000}, 90.0));
}
class TestLogToRedfishDiscreteThrow : public TestLogToRedfishDiscrete
@@ -174,7 +175,8 @@
TEST_P(TestLogToRedfishDiscreteThrow, commitExpectToThrow)
{
- EXPECT_THROW(sut->commit("Test", 100'000, 90.0), std::runtime_error);
+ EXPECT_THROW(sut->commit("Test", Milliseconds{100'000}, 90.0),
+ std::runtime_error);
}
namespace onChange
@@ -192,7 +194,7 @@
TEST_F(TestLogToJournalDiscreteOnChange, commitExpectNoThrow)
{
- EXPECT_NO_THROW(sut->commit("Test", 100'000, 90.0));
+ EXPECT_NO_THROW(sut->commit("Test", Milliseconds{100'000}, 90.0));
}
class TestLogToRedfishDiscreteOnChange : public Test
@@ -208,7 +210,7 @@
TEST_F(TestLogToRedfishDiscreteOnChange, commitExpectNoThrow)
{
- EXPECT_NO_THROW(sut->commit("Test", 100'000, 90.0));
+ EXPECT_NO_THROW(sut->commit("Test", Milliseconds{100'000}, 90.0));
}
} // namespace onChange
} // namespace discrete
@@ -230,7 +232,7 @@
EXPECT_CALL(reportManager, updateReport(_)).Times(0);
make({});
- sut->commit("Test", 100'000, 90.0);
+ sut->commit("Test", Milliseconds{100'000}, 90.0);
}
TEST_F(TestUpdateReport, commitExpectReportUpdate)
@@ -242,7 +244,7 @@
}
make(names);
- sut->commit("Test", 100'000, 90.0);
+ sut->commit("Test", Milliseconds{100'000}, 90.0);
}
} // namespace action