Repository: mesos
Updated Branches:
  refs/heads/1.5.x ee0fb5908 -> 9840ae195


Added `Event::Update` and `v1::scheduler::TaskStatus` ostream operators.

This operators make gtest print a human-readable representation of the
protos on test failures.

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


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

Branch: refs/heads/1.5.x
Commit: 5c6e757f1962ef74fb1356631787791ceaa4106e
Parents: ee0fb59
Author: Gaston Kleiman <gas...@mesosphere.io>
Authored: Wed Feb 14 14:34:50 2018 +0800
Committer: Qian Zhang <zhq527...@gmail.com>
Committed: Wed Feb 14 20:58:09 2018 +0800

----------------------------------------------------------------------
 include/mesos/v1/mesos.hpp               |  3 +++
 include/mesos/v1/scheduler/scheduler.hpp | 10 ++++++++
 src/v1/mesos.cpp                         | 37 +++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5c6e757f/include/mesos/v1/mesos.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.hpp b/include/mesos/v1/mesos.hpp
index d4c354a..f16568e 100644
--- a/include/mesos/v1/mesos.hpp
+++ b/include/mesos/v1/mesos.hpp
@@ -395,6 +395,9 @@ std::ostream& operator<<(
     const ResourceProviderInfo& resourceProviderInfo);
 
 
+std::ostream& operator<<(std::ostream& stream, const TaskStatus& status);
+
+
 std::ostream& operator<<(std::ostream& stream, const AgentID& agentId);
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/5c6e757f/include/mesos/v1/scheduler/scheduler.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/v1/scheduler/scheduler.hpp 
b/include/mesos/v1/scheduler/scheduler.hpp
index 2fdd8f2..ab94462 100644
--- a/include/mesos/v1/scheduler/scheduler.hpp
+++ b/include/mesos/v1/scheduler/scheduler.hpp
@@ -19,6 +19,8 @@
 
 #include <ostream>
 
+#include <mesos/v1/mesos.hpp>
+
 // ONLY USEFUL AFTER RUNNING PROTOC.
 #include <mesos/v1/scheduler/scheduler.pb.h>
 
@@ -37,6 +39,14 @@ inline std::ostream& operator<<(std::ostream& stream, const 
Event::Type& type)
   return stream << Event::Type_Name(type);
 }
 
+
+inline std::ostream& operator<<(
+    std::ostream& stream,
+    const Event::Update& update)
+{
+  return stream << update.status();
+}
+
 } // namespace scheduler {
 } // namespace v1 {
 } // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/5c6e757f/src/v1/mesos.cpp
----------------------------------------------------------------------
diff --git a/src/v1/mesos.cpp b/src/v1/mesos.cpp
index 8abeae0..576f367 100644
--- a/src/v1/mesos.cpp
+++ b/src/v1/mesos.cpp
@@ -17,6 +17,7 @@
 #include <ostream>
 
 #include <stout/protobuf.hpp>
+#include <stout/uuid.hpp>
 
 #include <mesos/v1/attributes.hpp>
 #include <mesos/v1/mesos.hpp>
@@ -600,6 +601,42 @@ ostream& operator<<(ostream& stream, const RLimitInfo& 
limits)
 }
 
 
+ostream& operator<<(ostream& stream, const TaskStatus& status)
+{
+  stream << status.state();
+
+  if (status.has_uuid()) {
+    stream << " (Status UUID: "
+           << stringify(id::UUID::fromBytes(status.uuid()).get()) << ")";
+  }
+
+  if (status.has_source()) {
+    stream << " Source: " << TaskStatus::Source_Name(status.source());
+  }
+
+  if (status.has_reason()) {
+    stream << " Reason: " << TaskStatus::Reason_Name(status.reason());
+  }
+
+  if (status.has_message()) {
+    stream << " Message: '" << status.message() << "'";
+  }
+
+  stream << " for task '" << status.task_id() << "'";
+
+  if (status.has_agent_id()) {
+    stream << " on agent: " << status.agent_id() << "";
+  }
+
+  if (status.has_healthy()) {
+    stream << " in health state "
+           << (status.healthy() ? "healthy" : "unhealthy");
+  }
+
+  return stream;
+}
+
+
 ostream& operator<<(ostream& stream, const AgentID& agentId)
 {
   return stream << agentId.value();

Reply via email to