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 2018/03/02 01:10:13 UTC

[1/2] mesos git commit: Added `upgradeResource` to some resource parsing functions.

Repository: mesos
Updated Branches:
  refs/heads/master 9bd5d8f9b -> 5db8e1d84


Added `upgradeResource` to some resource parsing functions.

Currently only `Resources::parse()` calls `upgradeResource()`,
but other parsing functions `Resources::fromJSON()` and
`Resources::fromSimpleString()` which are also public utilities
do not, this may produce invalid resource objects.

This patch moves the `upgradeResource()` to the two internal
parsing functions, so that all resource objects parsed are
valid.

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


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

Branch: refs/heads/master
Commit: 6630eb66125f6d6572591b0eadb7ff709cb89e36
Parents: 9bd5d8f
Author: Meng Zhu <mz...@mesosphere.io>
Authored: Thu Mar 1 16:53:52 2018 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Mar 1 16:55:26 2018 -0800

----------------------------------------------------------------------
 src/common/resources.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6630eb66/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index a0c2924..8cb7417 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -726,8 +726,7 @@ Try<Resources> Resources::parse(
 
   Resources result;
 
-  // Validate the Resource objects and convert them
-  // to the "post-reservation-refinement" format.
+  // Validate the Resource objects.
   foreach (Resource resource, resources.get()) {
     // If invalid, propgate error instead of skipping the resource.
     Option<Error> error = Resources::validate(resource);
@@ -735,8 +734,6 @@ Try<Resources> Resources::parse(
       return error.get();
     }
 
-    upgradeResource(&resource);
-
     result.add(resource);
   }
 
@@ -776,6 +773,8 @@ Try<vector<Resource>> Resources::fromJSON(
       resource.set_role(defaultRole);
     }
 
+    upgradeResource(&resource);
+
     // We add the Resource object even if it is empty or invalid.
     result.push_back(resource);
   }
@@ -824,6 +823,8 @@ Try<vector<Resource>> Resources::fromSimpleString(
       return Error(resource.error());
     }
 
+    upgradeResource(&(resource.get()));
+
     // We add the Resource object even if it is empty or invalid.
     resources.push_back(resource.get());
   }


[2/2] mesos git commit: Fixed `PersistentVolumeEndpointsTest.SlavesEndpointFullResources`.

Posted by bm...@apache.org.
Fixed `PersistentVolumeEndpointsTest.SlavesEndpointFullResources`.

The test relies on the order of the JSON array output and is prone
to break if the ordering changes. This patch fixes this test by
parsing the JSON array to resources, so that the comparison is
order agnostic.

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


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

Branch: refs/heads/master
Commit: 5db8e1d844e50044a86cd26e5a170953dd8f700b
Parents: 6630eb6
Author: Meng Zhu <mz...@mesosphere.io>
Authored: Thu Mar 1 16:46:08 2018 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Mar 1 17:00:51 2018 -0800

----------------------------------------------------------------------
 src/tests/persistent_volume_endpoints_tests.cpp | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5db8e1d8/src/tests/persistent_volume_endpoints_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/persistent_volume_endpoints_tests.cpp b/src/tests/persistent_volume_endpoints_tests.cpp
index 94b8caa..ebdc409 100644
--- a/src/tests/persistent_volume_endpoints_tests.cpp
+++ b/src/tests/persistent_volume_endpoints_tests.cpp
@@ -2349,13 +2349,25 @@ TEST_F(PersistentVolumeEndpointsTest, SlavesEndpointFullResources)
   EXPECT_EQ(expectedReserved.get(), reservedValue);
 
   JSON::Value unreservedValue = slaveObject.values["unreserved_resources_full"];
-  EXPECT_EQ(expectedUnreserved.get(), unreservedValue);
+  EXPECT_EQ(
+      Resources(CHECK_NOTERROR(
+          Resources::fromJSON(expectedUnreserved->as<JSON::Array>()))),
+      Resources(CHECK_NOTERROR(
+          Resources::fromJSON(unreservedValue.as<JSON::Array>()))));
 
   JSON::Value usedValue = slaveObject.values["used_resources_full"];
-  EXPECT_EQ(expectedUsed.get(), usedValue);
+  EXPECT_EQ(
+      Resources(CHECK_NOTERROR(
+          Resources::fromJSON(expectedUsed->as<JSON::Array>()))),
+      Resources(CHECK_NOTERROR(
+          Resources::fromJSON(usedValue.as<JSON::Array>()))));
 
   JSON::Value offeredValue = slaveObject.values["offered_resources_full"];
-  EXPECT_EQ(expectedOffered.get(), offeredValue);
+  EXPECT_EQ(
+      Resources(CHECK_NOTERROR(
+          Resources::fromJSON(expectedOffered.get().as<JSON::Array>()))),
+      Resources(CHECK_NOTERROR(
+          Resources::fromJSON(offeredValue.as<JSON::Array>()))));
 
   driver.stop();
   driver.join();