mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gilb...@apache.org
Subject [2/4] mesos git commit: Added a test for PushGauge.
Date Fri, 27 Apr 2018 23:20:48 GMT
Added a test for PushGauge.

Review: https://reviews.apache.org/r/66830/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/898ff1b2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/898ff1b2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/898ff1b2

Branch: refs/heads/master
Commit: 898ff1b20293f5d55f2c7b65d231cc52bebf9d85
Parents: 6707d39
Author: Benjamin Mahler <bmahler@apache.org>
Authored: Fri Apr 27 16:06:58 2018 -0700
Committer: Gilbert Song <songzihao1990@gmail.com>
Committed: Fri Apr 27 16:06:58 2018 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/tests/metrics_tests.cpp | 32 ++++++++++++++++++++
 1 file changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/898ff1b2/3rdparty/libprocess/src/tests/metrics_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/metrics_tests.cpp b/3rdparty/libprocess/src/tests/metrics_tests.cpp
index f2bd99b..3a68388 100644
--- a/3rdparty/libprocess/src/tests/metrics_tests.cpp
+++ b/3rdparty/libprocess/src/tests/metrics_tests.cpp
@@ -32,6 +32,7 @@
 #include <process/metrics/counter.hpp>
 #include <process/metrics/gauge.hpp>
 #include <process/metrics/metrics.hpp>
+#include <process/metrics/push_gauge.hpp>
 #include <process/metrics/timer.hpp>
 
 namespace authentication = process::http::authentication;
@@ -48,6 +49,7 @@ using http::Unauthorized;
 
 using metrics::Counter;
 using metrics::Gauge;
+using metrics::PushGauge;
 using metrics::Timer;
 
 using process::Clock;
@@ -172,6 +174,36 @@ TEST_F(MetricsTest, THREADSAFE_Gauge)
 }
 
 
+TEST_F(MetricsTest, PushGauge)
+{
+  // Gauge with a value.
+  PushGauge gauge("test/gauge");
+
+  AWAIT_READY(metrics::add(gauge));
+
+  AWAIT_EXPECT_EQ(0.0, gauge.value());
+
+  ++gauge;
+  AWAIT_EXPECT_EQ(1.0, gauge.value());
+
+  gauge += 42;
+  AWAIT_EXPECT_EQ(43.0, gauge.value());
+
+  --gauge;
+  AWAIT_EXPECT_EQ(42.0, gauge.value());
+
+  gauge -= 42;
+  AWAIT_EXPECT_EQ(0.0, gauge.value());
+
+  gauge = 42;
+  AWAIT_EXPECT_EQ(42.0, gauge.value());
+
+  EXPECT_NONE(gauge.statistics());
+
+  AWAIT_READY(metrics::remove(gauge));
+}
+
+
 TEST_F(MetricsTest, Statistics)
 {
   Counter counter("test/counter", process::TIME_SERIES_WINDOW);


Mime
View raw message