Repository: mesos
Updated Branches:
  refs/heads/master f4439c425 -> 4e1f9a9e1


Added framework capabilities to state.json.

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


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

Branch: refs/heads/master
Commit: 4e1f9a9e1823325fac0318dbd9fdb596e425c005
Parents: f4439c4
Author: Aditi Dixit <[email protected]>
Authored: Wed Jul 15 11:42:55 2015 -0700
Committer: Vinod Kone <[email protected]>
Committed: Wed Jul 15 11:57:09 2015 -0700

----------------------------------------------------------------------
 src/master/http.cpp        | 11 +++++++++++
 src/tests/master_tests.cpp | 17 ++++++++++++++---
 2 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4e1f9a9e/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 23a6d4b..6f5ca02 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -119,6 +119,17 @@ JSON::Object summarize(const Framework& framework)
   object.values["used_resources"] = model(framework.totalUsedResources);
   object.values["offered_resources"] = model(framework.totalOfferedResources);
 
+  {
+      JSON::Array array;
+      array.values.reserve(framework.info.capabilities_size());
+      foreach (const FrameworkInfo::Capability& capability,
+               framework.info.capabilities()) {
+        array.values.push_back(
+              FrameworkInfo::Capability::Type_Name(capability.type()));
+      }
+      object.values["capabilities"] = std::move(array);
+  }
+
   object.values["hostname"] = framework.info.hostname();
   object.values["webui_url"] = framework.info.webui_url();
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/4e1f9a9e/src/tests/master_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index 57721b7..767c86c 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -2946,15 +2946,18 @@ TEST_F(MasterTest, StateSummaryEndpoint)
 }
 
 
-// This test ensures that the web UI of a framework is included in the
-// state.json endpoint, if provided by the framework.
-TEST_F(MasterTest, FrameworkWebUIUrl)
+// This test ensures that the web UI and capabilities of a framework
+// are included in the state.json endpoint, if provided by the
+// framework.
+TEST_F(MasterTest, FrameworkWebUIUrlandCapabilities)
 {
   Try<PID<Master>> master = StartMaster();
   ASSERT_SOME(master);
 
   FrameworkInfo framework = DEFAULT_FRAMEWORK_INFO;
   framework.set_webui_url("http://localhost:8080/";);
+  auto capabilityType = FrameworkInfo::Capability::REVOCABLE_RESOURCES;
+  framework.add_capabilities()->set_type(capabilityType);
 
   MockScheduler sched;
   MesosSchedulerDriver driver(
@@ -2992,6 +2995,14 @@ TEST_F(MasterTest, FrameworkWebUIUrl)
 
   EXPECT_EQ("http://localhost:8080/";, webui_url.value);
 
+  EXPECT_EQ(1u, framework_.values.count("capabilities"));
+  JSON::Array capabilities =
+    framework_.values["capabilities"].as<JSON::Array>();
+  JSON::String capability = capabilities.values.front().as<JSON::String>();
+
+  EXPECT_EQ(FrameworkInfo::Capability::Type_Name(capabilityType),
+            capability.value);
+
   driver.stop();
   driver.join();
 

Reply via email to