You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gr...@apache.org on 2018/06/28 16:27:09 UTC

[3/3] mesos git commit: Fixed a bug in `createStrippedScalarQuantity()`.

Fixed a bug in `createStrippedScalarQuantity()`.

This patch fixes `createStrippedScalarQuantity()` by
stripping the revocable field in resources.

Also added a test.

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


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

Branch: refs/heads/1.6.x
Commit: a615f36d9f10c92eaa4be95978987976dfc085e8
Parents: 1d5f83d
Author: Meng Zhu <mz...@mesosphere.io>
Authored: Thu Jun 28 08:32:47 2018 -0700
Committer: Greg Mann <gr...@gmail.com>
Committed: Thu Jun 28 08:33:19 2018 -0700

----------------------------------------------------------------------
 src/common/resources.cpp      |  1 +
 src/tests/resources_tests.cpp | 13 +++++++++++++
 src/v1/resources.cpp          |  1 +
 3 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a615f36d/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index b139201..8518abf 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -1646,6 +1646,7 @@ Resources Resources::createStrippedScalarQuantity() const
 
       scalar.clear_disk();
       scalar.clear_shared();
+      scalar.clear_revocable();
       stripped.add(scalar);
     }
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/a615f36d/src/tests/resources_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/resources_tests.cpp b/src/tests/resources_tests.cpp
index 945617f..395c458 100644
--- a/src/tests/resources_tests.cpp
+++ b/src/tests/resources_tests.cpp
@@ -2683,6 +2683,19 @@ TEST(ResourcesOperationTest, StrippedResourcesNonScalar)
 }
 
 
+TEST(ResourceOperationTest, StrippedResourcesRevocable)
+{
+  Resource plain = Resources::parse("cpus", "1", "*").get();
+
+  Resource revocable = plain;
+  revocable.mutable_revocable();
+
+  Resources stripped = Resources(revocable).createStrippedScalarQuantity();
+
+  EXPECT_EQ(Resources(plain), stripped);
+}
+
+
 TEST(ResourcesOperationTest, CreatePersistentVolumeFromMount)
 {
   Resource::DiskInfo::Source source = createDiskSourceMount("mnt");

http://git-wip-us.apache.org/repos/asf/mesos/blob/a615f36d/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index 5079327..04a45a5 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -1664,6 +1664,7 @@ Resources Resources::createStrippedScalarQuantity() const
 
       scalar.clear_disk();
       scalar.clear_shared();
+      scalar.clear_revocable();
       stripped.add(scalar);
     }
   }