You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ne...@apache.org on 2017/05/24 22:20:53 UTC
[2/8] mesos git commit: Added a new sorter test case,
`HierarchicalIterationOrder`.
Added a new sorter test case, `HierarchicalIterationOrder`.
This behavior is covered by existing test cases to an extent, but some
additional test coverage seems warranted.
Review: https://reviews.apache.org/r/59482/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c19ad9a0
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c19ad9a0
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c19ad9a0
Branch: refs/heads/1.3.x
Commit: c19ad9a0ad99d5fb6f6cb75a4f2161481491007d
Parents: 7a8cd22
Author: Neil Conway <ne...@gmail.com>
Authored: Tue May 23 10:36:13 2017 -0700
Committer: Neil Conway <ne...@gmail.com>
Committed: Wed May 24 14:46:55 2017 -0700
----------------------------------------------------------------------
src/tests/sorter_tests.cpp | 48 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/c19ad9a0/src/tests/sorter_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/sorter_tests.cpp b/src/tests/sorter_tests.cpp
index d8d6140..4891806 100644
--- a/src/tests/sorter_tests.cpp
+++ b/src/tests/sorter_tests.cpp
@@ -605,6 +605,54 @@ TEST(SorterTest, HierarchicalAllocation)
}
+// This test checks that the sorted list of clients returned by the
+// sorter iterates over the client tree in the correct order.
+TEST(SorterTest, HierarchicalIterationOrder)
+{
+ DRFSorter sorter;
+
+ SlaveID slaveId;
+ slaveId.set_value("agentId");
+
+ Resources totalResources = Resources::parse("cpus:100;mem:100").get();
+ sorter.add(slaveId, totalResources);
+
+ sorter.add("a/b");
+ sorter.add("c");
+ sorter.add("d");
+ sorter.add("d/e");
+
+ sorter.activate("a/b");
+ sorter.activate("c");
+ sorter.activate("d");
+ sorter.activate("d/e");
+
+ // Shares: a/b = 0, c = 0, d = 0, d/e = 0
+ EXPECT_EQ(vector<string>({"a/b", "c", "d", "d/e"}), sorter.sort());
+
+ Resources cResources = Resources::parse("cpus:8;mem:8").get();
+ sorter.allocated("c", slaveId, cResources);
+
+ // Shares: a/b = 0, d = 0, d/e = 0, c = 0.08.
+ EXPECT_EQ(vector<string>({"a/b", "d", "d/e", "c"}), sorter.sort());
+
+ Resources dResources = Resources::parse("cpus:3;mem:3").get();
+ sorter.allocated("d", slaveId, dResources);
+
+ Resources deResources = Resources::parse("cpus:2;mem:2").get();
+ sorter.allocated("d/e", slaveId, deResources);
+
+ // Shares: a/b = 0, d/e = 0.02, d = 0.03, c = 0.08.
+ EXPECT_EQ(vector<string>({"a/b", "d/e", "d", "c"}), sorter.sort());
+
+ Resources abResources = Resources::parse("cpus:6;mem:6").get();
+ sorter.allocated("a/b", slaveId, abResources);
+
+ // Shares: d/e = 0.02, d = 0.03, a/b = 0.06, c = 0.08.
+ EXPECT_EQ(vector<string>({"d/e", "d", "a/b", "c"}), sorter.sort());
+}
+
+
// This test checks what happens when a new sorter client is added as
// a child of what was previously a leaf node.
TEST(SorterTest, AddChildToLeaf)