You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2014/04/23 02:35:56 UTC

git commit: Fixed some flaky tests.

Repository: mesos
Updated Branches:
  refs/heads/master 27221fd51 -> 4e2d39445


Fixed some flaky tests.


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

Branch: refs/heads/master
Commit: 4e2d39445d85871858acbdc2f78c7fb0bc8b749b
Parents: 27221fd
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Tue Apr 22 17:35:28 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Tue Apr 22 17:35:47 2014 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/tests/metrics_tests.cpp | 28 ++++++--------------
 1 file changed, 8 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4e2d3944/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 aef9ff4..6f3795b 100644
--- a/3rdparty/libprocess/src/tests/metrics_tests.cpp
+++ b/3rdparty/libprocess/src/tests/metrics_tests.cpp
@@ -102,9 +102,14 @@ TEST(Metrics, Statistics)
 {
   Counter counter("test/counter", process::TIME_SERIES_WINDOW);
 
+  // We have to pause the clock to ensure the time series
+  // entries are unique.
+  Clock::pause();
+
   AWAIT_READY(metrics::add(counter));
 
   for (size_t i = 0; i < 10; ++i) {
+    Clock::advance(Seconds(1));
     ++counter;
   }
 
@@ -214,7 +219,7 @@ TEST(Metrics, SnapshotStatistics)
 }
 
 
-TEST(MetricsTest, Timer)
+TEST(Metrics, Timer)
 {
   metrics::Timer timer("test/timer");
 
@@ -224,30 +229,13 @@ TEST(MetricsTest, Timer)
   timer.stop();
 
   // Time a no-op.
-  Time started = Clock::now();
-
   timer.start();
+  os::sleep(Microseconds(1));
   timer.stop();
 
-  Time stopped = Clock::now();
-
   Future<double> value = timer.value();
   AWAIT_READY(value);
-  EXPECT_LE(value.get(), (stopped - started).ms());
-
-  // Make sure that re-starting a timer records the correct value.
-  timer.start();
-
-  started = Clock::now();
-
-  timer.start();
-  timer.stop();
-
-  stopped = Clock::now();
-
-  value = timer.value();
-  AWAIT_READY(value);
-  EXPECT_LE(value.get(), (stopped - started).ms());
+  EXPECT_GE(value.get(), Microseconds(1).ms());
 
   // It is not an error to stop a timer that has already been stopped.
   timer.stop();