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/05/28 23:41:59 UTC

git commit: Added error message to system metrics failures.

Repository: mesos
Updated Branches:
  refs/heads/master a3170e0a9 -> 4ef409dee


Added error message to system metrics failures.

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


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

Branch: refs/heads/master
Commit: 4ef409dee94c5c39c1dfd479f1d7d50388549463
Parents: a3170e0
Author: Dominic Hamon <dh...@twopensource.com>
Authored: Wed May 28 14:04:38 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Wed May 28 14:41:30 2014 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/system.hpp  | 12 +++++------
 3rdparty/libprocess/src/tests/metrics_tests.cpp | 21 +++++++++++++-------
 2 files changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4ef409de/3rdparty/libprocess/include/process/system.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/system.hpp b/3rdparty/libprocess/include/process/system.hpp
index 366a4b2..48a02f0 100644
--- a/3rdparty/libprocess/include/process/system.hpp
+++ b/3rdparty/libprocess/include/process/system.hpp
@@ -95,7 +95,7 @@ private:
     if (load.isSome()) {
       return load.get().one;
     }
-    return Failure("loadavg not available.");
+    return Failure("Failed to get loadavg: " + load.error());
   }
 
 
@@ -105,7 +105,7 @@ private:
     if (load.isSome()) {
       return load.get().five;
     }
-    return Failure("loadavg not available.");
+    return Failure("Failed to get loadavg: " + load.error());
   }
 
 
@@ -115,7 +115,7 @@ private:
     if (load.isSome()) {
       return load.get().fifteen;
     }
-    return Failure("loadavg not available.");
+    return Failure("Failed to get loadavg: " + load.error());
   }
 
 
@@ -125,7 +125,7 @@ private:
     if (cpus.isSome()) {
       return cpus.get();
     }
-    return Failure("cpus not available.");
+    return Failure("Failed to get cpus: " + cpus.error());
   }
 
 
@@ -135,7 +135,7 @@ private:
     if (memory.isSome()) {
       return memory.get().total.bytes();
     }
-    return Failure("memory not available.");
+    return Failure("Failed to get memory: " + memory.error());
   }
 
 
@@ -145,7 +145,7 @@ private:
     if (memory.isSome()) {
       return memory.get().free.bytes();
     }
-    return Failure("memory not available.");
+    return Failure("Failed to get memory: " + memory.error());
   }
 
   // HTTP endpoints.

http://git-wip-us.apache.org/repos/asf/mesos/blob/4ef409de/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 a822bc7..33539e4 100644
--- a/3rdparty/libprocess/src/tests/metrics_tests.cpp
+++ b/3rdparty/libprocess/src/tests/metrics_tests.cpp
@@ -270,6 +270,9 @@ TEST(Metrics, SnapshotTimeout)
       JSON::parse<JSON::Object>(response.get().body);
   ASSERT_SOME(responseJSON);
 
+  // We can't use simple JSON equality testing here as initializing
+  // libprocess adds metrics to the system. We want to only check if
+  // the metrics from this test are correctly handled.
   map<string, JSON::Value> values = responseJSON.get().values;
 
   EXPECT_EQ(1u, values.count("test/counter"));
@@ -330,7 +333,10 @@ TEST(Metrics, SnapshotStatistics)
     ++counter;
   }
 
-  hashmap<std::string, double> expected;
+  // We can't use simple JSON equality testing here as initializing
+  // libprocess adds metrics to the system. We want to only check if
+  // the metrics from this test are correctly handled.
+  hashmap<string, double> expected;
 
   expected["test/counter"] = 10.0;
 
@@ -356,8 +362,8 @@ TEST(Metrics, SnapshotStatistics)
   ASSERT_SOME(responseJSON);
 
   // Pull the response values into a map.
-  hashmap<std::string, double> responseValues;
-  foreachpair (const std::string& key,
+  hashmap<string, double> responseValues;
+  foreachpair (const string& key,
                const JSON::Value& value,
                responseJSON.get().values) {
     if (value.is<JSON::Number>()) {
@@ -367,7 +373,7 @@ TEST(Metrics, SnapshotStatistics)
 
   // Ensure the expected keys are in the response and that the values match
   // expectations.
-  foreachkey (const std::string& key, expected) {
+  foreachkey (const string& key, expected) {
     EXPECT_FLOAT_EQ(expected[key], responseValues[key]);
   }
 
@@ -416,9 +422,10 @@ TEST(Metrics, AsyncTimer)
 
   AWAIT_READY(metrics::add(t));
 
-  // Time a Future that returns immediately. Even though the method advances the
-  // clock and we advance the clock here, the Future should be timed as if it
-  // takes 0 time. Ie, we're not timing the method call but the Future.
+  // Time a Future that returns immediately. Even though the method
+  // advances the clock and we advance the clock here, the Future
+  // should be timed as if it takes 0 time. Ie, we're not timing the
+  // method call but the Future.
   Clock::pause();
   Future<int> result = t.time(advanceAndReturn());
   Clock::advance(Seconds(1));