added support for Collection Functions
new supported operations: min,max,sum,avg
new supported time scopes: interval,startup
added unit test to verify that each collection function returns correct
timestamp and value
Tested:
- POST/GET on telemetry features in bmcweb, no regression detected
- Using dbus API metric with collection function works as expected
Change-Id: Ib364c433915e07fd7a102f00109525362c40ab8a
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/tests/src/fakes/clock_fake.hpp b/tests/src/fakes/clock_fake.hpp
new file mode 100644
index 0000000..28c2940
--- /dev/null
+++ b/tests/src/fakes/clock_fake.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+#include "interfaces/clock.hpp"
+#include "types/duration_type.hpp"
+
+class ClockFake : public interfaces::Clock
+{
+ public:
+ time_point now() const noexcept override
+ {
+ return timePoint;
+ }
+
+ uint64_t timestamp() const noexcept override
+ {
+ return toTimestamp(now());
+ }
+
+ uint64_t advance(Milliseconds delta) noexcept
+ {
+ timePoint += delta;
+ return timestamp();
+ }
+
+ void set(Milliseconds timeSinceEpoch) noexcept
+ {
+ timePoint = time_point{timeSinceEpoch};
+ }
+
+ static uint64_t toTimestamp(Milliseconds time)
+ {
+ return time.count();
+ }
+
+ static uint64_t toTimestamp(time_point tp)
+ {
+ return std::chrono::time_point_cast<Milliseconds>(tp)
+ .time_since_epoch()
+ .count();
+ }
+
+ private:
+ time_point timePoint = std::chrono::steady_clock::now();
+};