Repository: mesos
Updated Branches:
  refs/heads/master ab6eca0a8 -> 00ad42728


Removed unnecessary allocator expectations in the tests.

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


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

Branch: refs/heads/master
Commit: 00ad42728db58dc7469b1a64ff2065fcaa6a8dfd
Parents: ab6eca0
Author: Benjamin Mahler <[email protected]>
Authored: Fri Jan 16 15:02:33 2015 -0800
Committer: Benjamin Mahler <[email protected]>
Committed: Wed Jan 28 22:50:00 2015 -0800

----------------------------------------------------------------------
 src/tests/master_allocator_tests.cpp | 146 +++---------------------------
 src/tests/resource_offers_tests.cpp  |   6 --
 src/tests/slave_recovery_tests.cpp   |  12 +--
 3 files changed, 18 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/00ad4272/src/tests/master_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_allocator_tests.cpp 
b/src/tests/master_allocator_tests.cpp
index ff025fa..018a6cc 100644
--- a/src/tests/master_allocator_tests.cpp
+++ b/src/tests/master_allocator_tests.cpp
@@ -128,21 +128,9 @@ TYPED_TEST(MasterAllocatorTest, SingleFramework)
   AWAIT_READY(resourceOffers);
 
   // Shut everything down.
-  EXPECT_CALL(this->allocator, recoverResources(_, _, _, _))
-    .WillRepeatedly(DoDefault());
-
-  EXPECT_CALL(this->allocator, deactivateFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(this->allocator, removeFramework(_))
-    .Times(AtMost(1));
-
   driver.stop();
   driver.join();
 
-  EXPECT_CALL(this->allocator, removeSlave(_))
-    .Times(AtMost(1));
-
   this->Shutdown();
 }
 
@@ -235,12 +223,6 @@ TYPED_TEST(MasterAllocatorTest, ResourcesUnused)
   EXPECT_CALL(this->allocator, recoverResources(_, _, _, _))
     .WillRepeatedly(DoDefault());
 
-  EXPECT_CALL(this->allocator, deactivateFramework(_))
-    .Times(AtMost(2));
-
-  EXPECT_CALL(this->allocator, removeFramework(_))
-    .Times(AtMost(2));
-
   Future<Nothing> shutdown;
   EXPECT_CALL(exec, shutdown(_))
     .WillOnce(FutureSatisfy(&shutdown));
@@ -253,9 +235,6 @@ TYPED_TEST(MasterAllocatorTest, ResourcesUnused)
 
   AWAIT_READY(shutdown); // Ensures MockExecutor can be deallocated.
 
-  EXPECT_CALL(this->allocator, removeSlave(_))
-    .Times(AtMost(1));
-
   this->Shutdown();
 }
 
@@ -372,21 +351,9 @@ TYPED_TEST(MasterAllocatorTest, OutOfOrderDispatch)
   AWAIT_READY(resourceOffers);
 
   // Shut everything down.
-  EXPECT_CALL(this->allocator, recoverResources(_, _, _, _))
-    .WillRepeatedly(DoDefault());
-
-  EXPECT_CALL(this->allocator, deactivateFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(this->allocator, removeFramework(Eq(frameworkId2)))
-    .Times(AtMost(1));
-
   driver2.stop();
   driver2.join();
 
-  EXPECT_CALL(this->allocator, removeSlave(_))
-    .Times(AtMost(1));
-
   this->Shutdown();
 }
 
@@ -497,6 +464,9 @@ TYPED_TEST(MasterAllocatorTest, SchedulerFailover)
 
   AWAIT_READY(resourceOffers);
 
+  EXPECT_CALL(exec, shutdown(_))
+    .Times(AtMost(1));
+
   // Shut everything down.
   EXPECT_CALL(this->allocator, recoverResources(_, _, _, _))
     .WillRepeatedly(DoDefault());
@@ -504,18 +474,9 @@ TYPED_TEST(MasterAllocatorTest, SchedulerFailover)
   EXPECT_CALL(this->allocator, deactivateFramework(_))
     .Times(AtMost(1));
 
-  EXPECT_CALL(this->allocator, removeFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(exec, shutdown(_))
-    .Times(AtMost(1));
-
   driver2.stop();
   driver2.join();
 
-  EXPECT_CALL(this->allocator, removeSlave(_))
-    .Times(AtMost(1));
-
   this->Shutdown();
 }
 
@@ -641,12 +602,6 @@ TYPED_TEST(MasterAllocatorTest, FrameworkExited)
   EXPECT_CALL(this->allocator, recoverResources(_, _, _, _))
     .WillRepeatedly(DoDefault());
 
-  EXPECT_CALL(this->allocator, deactivateFramework(_))
-    .Times(AtMost(2)); // Once for each framework.
-
-  EXPECT_CALL(this->allocator, removeFramework(_))
-    .Times(AtMost(2)); // Once for each framework.
-
   // After we stop framework 1, all of it's resources should
   // have been returned, but framework 2 should still have a
   // task with 1 cpu and 256 mem, leaving 2 cpus and 768 mem.
@@ -668,9 +623,6 @@ TYPED_TEST(MasterAllocatorTest, FrameworkExited)
   driver2.stop();
   driver2.join();
 
-  EXPECT_CALL(this->allocator, removeSlave(_))
-    .Times(AtMost(1));
-
   this->Shutdown();
 }
 
@@ -777,12 +729,6 @@ TYPED_TEST(MasterAllocatorTest, SlaveLost)
   EXPECT_CALL(this->allocator, recoverResources(_, _, _, _))
     .WillRepeatedly(DoDefault());
 
-  EXPECT_CALL(this->allocator, deactivateFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(this->allocator, removeFramework(_))
-    .Times(AtMost(1));
-
   driver.stop();
   driver.join();
 
@@ -872,25 +818,16 @@ TYPED_TEST(MasterAllocatorTest, SlaveAdded)
 
   AWAIT_READY(resourceOffers);
 
+  EXPECT_CALL(exec, shutdown(_))
+    .Times(AtMost(1));
+
   // Shut everything down.
   EXPECT_CALL(this->allocator, recoverResources(_, _, _, _))
     .WillRepeatedly(DoDefault());
 
-  EXPECT_CALL(this->allocator, deactivateFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(this->allocator, removeFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(exec, shutdown(_))
-    .Times(AtMost(1));
-
   driver.stop();
   driver.join();
 
-  EXPECT_CALL(this->allocator, removeSlave(_))
-    .Times(AtMost(2));
-
   this->Shutdown();
 }
 
@@ -980,25 +917,16 @@ TYPED_TEST(MasterAllocatorTest, TaskFinished)
 
   AWAIT_READY(resourceOffers);
 
+  EXPECT_CALL(exec, shutdown(_))
+    .Times(AtMost(1));
+
   // Shut everything down.
   EXPECT_CALL(this->allocator, recoverResources(_, _, _, _))
     .WillRepeatedly(DoDefault());
 
-  EXPECT_CALL(this->allocator, deactivateFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(this->allocator, removeFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(exec, shutdown(_))
-    .Times(AtMost(1));
-
   driver.stop();
   driver.join();
 
-  EXPECT_CALL(this->allocator, removeSlave(_))
-    .Times(AtMost(1));
-
   this->Shutdown();
 }
 
@@ -1033,9 +961,6 @@ TYPED_TEST(MasterAllocatorTest, 
CpusOnlyOfferedAndTaskLaunched)
 
   EXPECT_CALL(sched, registered(_, _, _));
 
-  EXPECT_CALL(this->allocator, recoverResources(_, _, _, _))
-    .WillRepeatedly(DoDefault());
-
   // Launch a cpus only task.
   EXPECT_CALL(sched, resourceOffers(_, OfferEq(2, 0)))
     .WillOnce(LaunchTasks(DEFAULT_EXECUTOR_INFO, 1, 2, 0, "*"));
@@ -1071,22 +996,13 @@ TYPED_TEST(MasterAllocatorTest, 
CpusOnlyOfferedAndTaskLaunched)
 
   AWAIT_READY(resourceOffers);
 
-  // Shut everything down.
-  EXPECT_CALL(this->allocator, deactivateFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(this->allocator, removeFramework(_))
-    .Times(AtMost(1));
-
   EXPECT_CALL(exec, shutdown(_))
     .Times(AtMost(1));
 
+  // Shut everything down.
   driver.stop();
   driver.join();
 
-  EXPECT_CALL(this->allocator, removeSlave(_))
-    .Times(AtMost(1));
-
   this->Shutdown();
 }
 
@@ -1121,9 +1037,6 @@ TYPED_TEST(MasterAllocatorTest, 
MemoryOnlyOfferedAndTaskLaunched)
 
   EXPECT_CALL(sched, registered(_, _, _));
 
-  EXPECT_CALL(this->allocator, recoverResources(_, _, _, _))
-    .WillRepeatedly(DoDefault());
-
   // Launch a memory only task.
   EXPECT_CALL(sched, resourceOffers(_, OfferEq(0, 200)))
     .WillOnce(LaunchTasks(DEFAULT_EXECUTOR_INFO, 1, 0, 200, "*"));
@@ -1159,22 +1072,13 @@ TYPED_TEST(MasterAllocatorTest, 
MemoryOnlyOfferedAndTaskLaunched)
 
   AWAIT_READY(resourceOffers);
 
-  // Shut everything down.
-  EXPECT_CALL(this->allocator, deactivateFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(this->allocator, removeFramework(_))
-    .Times(AtMost(1));
-
   EXPECT_CALL(exec, shutdown(_))
     .Times(AtMost(1));
 
+  // Shut everything down.
   driver.stop();
   driver.join();
 
-  EXPECT_CALL(this->allocator, removeSlave(_))
-    .Times(AtMost(1));
-
   this->Shutdown();
 }
 
@@ -1411,25 +1315,13 @@ TYPED_TEST(MasterAllocatorTest, 
FrameworkReregistersFirst)
   // should only be offered the resources not being used by the task.
   EXPECT_THAT(resourceOffers2.get(), OfferEq(1, 524));
 
-  // Shut everything down.
-  EXPECT_CALL(allocator2, recoverResources(_, _, _, _))
-    .WillRepeatedly(DoDefault());
-
-  EXPECT_CALL(allocator2, deactivateFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(allocator2, removeFramework(_))
-    .Times(AtMost(1));
-
   EXPECT_CALL(exec, shutdown(_))
     .Times(AtMost(1));
 
+  // Shut everything down.
   driver.stop();
   driver.join();
 
-  EXPECT_CALL(allocator2, removeSlave(_))
-    .Times(AtMost(1));
-
   this->Shutdown();
 }
 
@@ -1536,24 +1428,12 @@ TYPED_TEST(MasterAllocatorTest, SlaveReregistersFirst)
   // should only be offered the resources not being used by the task.
   EXPECT_THAT(resourceOffers2.get(), OfferEq(1, 524));
 
-  // Shut everything down.
-  EXPECT_CALL(allocator2, recoverResources(_, _, _, _))
-    .WillRepeatedly(DoDefault());
-
-  EXPECT_CALL(allocator2, deactivateFramework(_))
-    .Times(AtMost(1));
-
-  EXPECT_CALL(allocator2, removeFramework(_))
-    .Times(AtMost(1));
-
   EXPECT_CALL(exec, shutdown(_))
     .Times(AtMost(1));
 
+  // Shut everything down.
   driver.stop();
   driver.join();
 
-  EXPECT_CALL(allocator2, removeSlave(_))
-    .Times(AtMost(1));
-
   this->Shutdown();
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/00ad4272/src/tests/resource_offers_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/resource_offers_tests.cpp 
b/src/tests/resource_offers_tests.cpp
index ec86e3d..24a7eab 100644
--- a/src/tests/resource_offers_tests.cpp
+++ b/src/tests/resource_offers_tests.cpp
@@ -1363,12 +1363,6 @@ TEST_F(ResourceOffersTest, Request)
   EXPECT_NE(0u, received.get().size());
   EXPECT_EQ(request.slave_id(), received.get()[0].slave_id());
 
-  EXPECT_CALL(allocator, deactivateFramework(_))
-    .Times(AtMost(1)); // Races with shutting down the cluster.
-
-  EXPECT_CALL(allocator, removeFramework(_))
-    .Times(AtMost(1)); // Races with shutting down the cluster.
-
   driver.stop();
   driver.join();
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/00ad4272/src/tests/slave_recovery_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_recovery_tests.cpp 
b/src/tests/slave_recovery_tests.cpp
index 0b0f306..7e2e63d 100644
--- a/src/tests/slave_recovery_tests.cpp
+++ b/src/tests/slave_recovery_tests.cpp
@@ -67,6 +67,10 @@ using namespace process;
 
 using google::protobuf::RepeatedPtrField;
 
+using mesos::internal::master::allocator::HierarchicalDRFAllocatorProcess;
+
+using mesos::internal::master::Master;
+
 using mesos::internal::master::Master;
 using mesos::internal::slave::Containerizer;
 using mesos::internal::slave::Fetcher;
@@ -2255,8 +2259,7 @@ TYPED_TEST(SlaveRecoveryTest, ReconcileShutdownFramework)
 // using an explicit executor.
 TYPED_TEST(SlaveRecoveryTest, ReconcileTasksMissingFromSlave)
 {
-  TestAllocatorProcess<master::allocator::HierarchicalDRFAllocatorProcess>
-    allocator;
+  TestAllocatorProcess<HierarchicalDRFAllocatorProcess> allocator;
 
   EXPECT_CALL(allocator, initialize(_, _, _));
 
@@ -2409,11 +2412,6 @@ TYPED_TEST(SlaveRecoveryTest, 
ReconcileTasksMissingFromSlave)
 
   Clock::resume();
 
-  EXPECT_CALL(allocator, deactivateFramework(_))
-    .WillRepeatedly(Return());
-  EXPECT_CALL(allocator, removeFramework(_))
-    .WillRepeatedly(Return());
-
   // If there was an outstanding offer, we can get a call to
   // recoverResources when we stop the scheduler.
   EXPECT_CALL(allocator, recoverResources(_, _, _, _))

Reply via email to