This is an automated email from the ASF dual-hosted git repository. mzhu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 88ce5722c0905633fa5df51a88a0d314ea8b4ffe Author: Meng Zhu <m...@mesosphere.io> AuthorDate: Mon May 13 14:35:30 2019 +0200 Templatized two sorter tests for both random and DRF. Review: https://reviews.apache.org/r/70631 --- src/tests/sorter_tests.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/tests/sorter_tests.cpp b/src/tests/sorter_tests.cpp index 9aee2b4..5cd2a64 100644 --- a/src/tests/sorter_tests.cpp +++ b/src/tests/sorter_tests.cpp @@ -1009,9 +1009,9 @@ TEST(DRFSorterTest, AddChildToInactiveLeaf) // This test checks what happens when a sorter client is removed, // which allows a leaf node to be collapsed into its parent node. This // is basically the inverse situation to `AddChildToLeaf`. -TEST(DRFSorterTest, RemoveLeafCollapseParent) +TYPED_TEST(CommonSorterTest, RemoveLeafCollapseParent) { - DRFSorter sorter; + TypeParam sorter; SlaveID slaveId; slaveId.set_value("agentId"); @@ -1033,20 +1033,30 @@ TEST(DRFSorterTest, RemoveLeafCollapseParent) sorter.allocated( "a/c", slaveId, Resources::parse("cpus:5;mem:5").get()); - EXPECT_EQ(vector<string>({"b", "a/c", "a"}), sorter.sort()); + // We sort the `sort()` output alphabetically here since we only + // want to verify the content of elements but not their order. + vector<string> clients = sorter.sort(); + sort(clients.begin(), clients.end()); + + EXPECT_EQ(vector<string>({"a", "a/c", "b"}), clients); sorter.remove("a/c"); - EXPECT_EQ(vector<string>({"b", "a"}), sorter.sort()); + // We sort the `sort()` output alphabetically here since we only + // want to verify the content of elements but not their order. + clients = sorter.sort(); + sort(clients.begin(), clients.end()); + + EXPECT_EQ(vector<string>({"a", "b"}), clients); } // This test checks what happens when a sorter client is removed and a // leaf node can be collapsed into its parent node, we correctly // propagate the `inactive` flag from leaf -> parent. -TEST(DRFSorterTest, RemoveLeafCollapseParentInactive) +TYPED_TEST(CommonSorterTest, RemoveLeafCollapseParentInactive) { - DRFSorter sorter; + TypeParam sorter; SlaveID slaveId; slaveId.set_value("agentId"); @@ -1070,7 +1080,12 @@ TEST(DRFSorterTest, RemoveLeafCollapseParentInactive) sorter.deactivate("a"); - EXPECT_EQ(vector<string>({"b", "a/c"}), sorter.sort()); + // We sort the `sort()` output alphabetically here since we only + // want to verify the content of elements but not their order. + vector<string> clients = sorter.sort(); + sort(clients.begin(), clients.end()); + + EXPECT_EQ(vector<string>({"a/c", "b"}), clients); sorter.remove("a/c");