Added benchmark test for Allocator::updateSlave().

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


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

Branch: refs/heads/master
Commit: ac5806779e5438e99fbe53ade57c1d09bda7485d
Parents: effc363
Author: Vinod Kone <[email protected]>
Authored: Fri Jun 19 16:58:38 2015 -0700
Committer: Vinod Kone <[email protected]>
Committed: Sun Jun 21 11:50:58 2015 -0700

----------------------------------------------------------------------
 src/tests/hierarchical_allocator_tests.cpp | 29 +++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ac580677/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp 
b/src/tests/hierarchical_allocator_tests.cpp
index d2f65d7..3258840 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -986,12 +986,12 @@ INSTANTIATE_TEST_CASE_P(
     ::testing::Values(1000U, 5000U, 10000U, 20000U, 30000U, 50000U));
 
 
-TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddSlave)
+TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddAndUpdateSlave)
 {
   Clock::pause();
 
-  // How many 'addSlave' that have been processed. This is used to
-  // determine the termination condition.
+  // Number of allocations. This is used to determine the termination
+  // condition.
   atomic<size_t> finished(0);
 
   auto offerCallback = [&finished](
@@ -1002,7 +1002,11 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddSlave)
 
   initialize({}, master::Flags(), offerCallback);
 
+  // Add a framework that can accept revocable resources.
   FrameworkInfo framework = createFrameworkInfo("*");
+  framework.add_capabilities()->set_type(
+      FrameworkInfo::Capability::REVOCABLE_RESOURCES);
+
   allocator->addFramework(framework.id(), framework, {});
 
   size_t slaveCount = GetParam();
@@ -1027,12 +1031,29 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddSlave)
     allocator->addSlave(slave.id(), slave, slave.resources(), used);
   }
 
-  // Wait for all the 'addSlave' to be processed.
+  // Wait for all the 'addSlave' operations to be processed.
   while (finished.load() != slaveCount) {
     os::sleep(Milliseconds(10));
   }
 
   cout << "Added " << slaveCount << " slaves in " << watch.elapsed() << endl;
+
+  // Oversubscribed resources on each slave.
+  Resource oversubscribed = Resources::parse("cpus", "10", "*").get();
+  oversubscribed.mutable_revocable();
+
+  watch.start(); // Reset.
+
+  foreach (const SlaveInfo& slave, slaves) {
+    allocator->updateSlave(slave.id(), oversubscribed);
+  }
+
+  // Wait for all the 'updateSlave' operations to be processed.
+  while (finished.load() != 2 * slaveCount) {
+    os::sleep(Milliseconds(10));
+  }
+
+  cout << "Updated " << slaveCount << " slaves in " << watch.elapsed() << endl;
 }
 
 } // namespace tests {

Reply via email to