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/03/09 16:53:29 UTC

[2/5] mesos git commit: Cleaned up sorter test cases.

Cleaned up sorter test cases.

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


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

Branch: refs/heads/master
Commit: d686f616346f10ddf9d7840b59b23c680bb45c2c
Parents: a0eb379
Author: Neil Conway <ne...@gmail.com>
Authored: Thu Mar 9 11:47:20 2017 -0500
Committer: Neil Conway <ne...@gmail.com>
Committed: Thu Mar 9 11:48:01 2017 -0500

----------------------------------------------------------------------
 src/tests/sorter_tests.cpp | 30 +++++++-----------------------
 1 file changed, 7 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d686f616/src/tests/sorter_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/sorter_tests.cpp b/src/tests/sorter_tests.cpp
index c93d236..eaf2a26 100644
--- a/src/tests/sorter_tests.cpp
+++ b/src/tests/sorter_tests.cpp
@@ -438,10 +438,7 @@ TEST(SorterTest, UpdateTotal)
   sorter.allocated(
       "b", slaveId, Resources::parse("cpus:1;mem:2").get());
 
-  vector<string> sorted = sorter.sort();
-  ASSERT_EQ(2u, sorted.size());
-  EXPECT_EQ("b", sorted.front());
-  EXPECT_EQ("a", sorted.back());
+  EXPECT_EQ(vector<string>({"b", "a"}), sorter.sort());
 
   // Update the total resources by removing the previous total and
   // adding back the new total.
@@ -450,10 +447,7 @@ TEST(SorterTest, UpdateTotal)
 
   // Now the dominant share of "a" is 0.1 (mem) and "b" is 0.2 (mem),
   // which should change the sort order.
-  sorted = sorter.sort();
-  ASSERT_EQ(2u, sorted.size());
-  EXPECT_EQ("a", sorted.front());
-  EXPECT_EQ("b", sorted.back());
+  EXPECT_EQ(vector<string>({"a", "b"}), sorter.sort());
 }
 
 
@@ -483,10 +477,7 @@ TEST(SorterTest, MultipleSlavesUpdateTotal)
   sorter.allocated(
       "b", slaveB, Resources::parse("cpus:1;mem:3").get());
 
-  vector<string> sorted = sorter.sort();
-  ASSERT_EQ(2u, sorted.size());
-  EXPECT_EQ("b", sorted.front());
-  EXPECT_EQ("a", sorted.back());
+  EXPECT_EQ(vector<string>({"b", "a"}), sorter.sort());
 
   // Update the total resources of slaveA by removing the previous
   // total and adding the new total.
@@ -495,10 +486,7 @@ TEST(SorterTest, MultipleSlavesUpdateTotal)
 
   // Now the dominant share of "a" is 0.02 (cpus) and "b" is 0.03
   // (mem), which should change the sort order.
-  sorted = sorter.sort();
-  ASSERT_EQ(2u, sorted.size());
-  EXPECT_EQ("a", sorted.front());
-  EXPECT_EQ("b", sorted.back());
+  EXPECT_EQ(vector<string>({"a", "b"}), sorter.sort());
 }
 
 
@@ -533,18 +521,14 @@ TEST(SorterTest, RevocableResources)
   sorter.allocated("b", slaveId, b);
 
   // Check that the allocations are correct.
-  ASSERT_EQ(a, sorter.allocation("a", slaveId));
-  ASSERT_EQ(b, sorter.allocation("b", slaveId));
+  EXPECT_EQ(a, sorter.allocation("a", slaveId));
+  EXPECT_EQ(b, sorter.allocation("b", slaveId));
 
   // Check that the sort is correct.
-  vector<string> sorted = sorter.sort();
-  ASSERT_EQ(2u, sorted.size());
-  EXPECT_EQ("a", sorted.front());
-  EXPECT_EQ("b", sorted.back());
+  EXPECT_EQ(vector<string>({"a", "b"}), sorter.sort());
 }
 
 
-
 // This test verifies that shared resources are properly accounted for in
 // the DRF sorter.
 TEST(SorterTest, SharedResources)