You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2016/09/06 17:37:41 UTC
mesos git commit: Added a `createSlaveInfo()` overload that takes a
`Resources`.
Repository: mesos
Updated Branches:
refs/heads/master ea1469fd5 -> 2f0a74088
Added a `createSlaveInfo()` overload that takes a `Resources`.
Also changed the benchmarks to use it because it's unnecessary
to recreate the same Resources objects for each agent.
Review: https://reviews.apache.org/r/50693/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2f0a7408
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2f0a7408
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2f0a7408
Branch: refs/heads/master
Commit: 2f0a740881eae38c02ac131f65b800cb0ed5e4ad
Parents: ea1469f
Author: Guangya Liu <gy...@gmail.com>
Authored: Tue Sep 6 10:35:24 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Tue Sep 6 10:35:24 2016 -0700
----------------------------------------------------------------------
src/tests/hierarchical_allocator_tests.cpp | 39 ++++++++++++++++++-------
1 file changed, 28 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/2f0a7408/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index d960b75..24698ff 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -236,19 +236,25 @@ protected:
flags.fair_sharing_excluded_resource_names);
}
- SlaveInfo createSlaveInfo(const string& resources)
+ SlaveInfo createSlaveInfo(const Resources& resources)
{
SlaveID slaveId;
slaveId.set_value("agent" + stringify(nextSlaveId++));
SlaveInfo slave;
- *(slave.mutable_resources()) = Resources::parse(resources).get();
+ *(slave.mutable_resources()) = resources;
*(slave.mutable_id()) = slaveId;
slave.set_hostname(slaveId.value());
return slave;
}
+ SlaveInfo createSlaveInfo(const string& resources)
+ {
+ const Resources agentResources = Resources::parse(resources).get();
+ return createSlaveInfo(agentResources);
+ }
+
FrameworkInfo createFrameworkInfo(
const string& role,
const vector<FrameworkInfo::Capability::Type>& capabilities = {})
@@ -3375,9 +3381,11 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddAndUpdateSlave)
vector<FrameworkInfo> frameworks;
frameworks.reserve(frameworkCount);
+ const Resources agentResources = Resources::parse(
+ "cpus:2;mem:1024;disk:4096;ports:[31000-32000]").get();
+
for (size_t i = 0; i < slaveCount; i++) {
- slaves.push_back(createSlaveInfo(
- "cpus:2;mem:1024;disk:4096;ports:[31000-32000]"));
+ slaves.push_back(createSlaveInfo(agentResources));
}
for (size_t i = 0; i < frameworkCount; i++) {
@@ -3524,6 +3532,9 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, DeclineOffers)
cout << "Added " << frameworkCount << " frameworks in "
<< watch.elapsed() << endl;
+ const Resources agentResources = Resources::parse(
+ "cpus:24;mem:4096;disk:4096;ports:[31000-32000]").get();
+
Resources resources = Resources::parse(
"cpus:16;mem:2014;disk:1024").get();
@@ -3536,8 +3547,7 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, DeclineOffers)
watch.start();
for (size_t i = 0; i < slaveCount; i++) {
- slaves.push_back(createSlaveInfo(
- "cpus:24;mem:4096;disk:4096;ports:[31000-32000]"));
+ slaves.push_back(createSlaveInfo(agentResources));
// Add some used resources on each slave. Let's say there are 16 tasks, each
// is allocated 1 cpu and a random port from the port range.
@@ -3664,6 +3674,9 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, ResourceLabels)
cout << "Added " << frameworkCount << " frameworks in "
<< watch.elapsed() << endl;
+ const Resources agentResources = Resources::parse(
+ "cpus:24;mem:4096;disk:4096;ports:[31000-32000]").get();
+
// Create the used resources at each slave. We use three blocks of
// resources: unreserved mem/disk/ports, and two different labeled
// reservations with distinct labels. We choose the labels so that
@@ -3682,8 +3695,7 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, ResourceLabels)
watch.start();
for (size_t i = 0; i < slaveCount; i++) {
- slaves.push_back(createSlaveInfo(
- "cpus:24;mem:4096;disk:4096;ports:[31000-32000]"));
+ slaves.push_back(createSlaveInfo(agentResources));
Resources agentResources = resources;
@@ -3831,6 +3843,9 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, SuppressOffers)
vector<SlaveInfo> agents;
agents.reserve(agentCount);
+ const Resources agentResources = Resources::parse(
+ "cpus:24;mem:4096;disk:4096;ports:[31000-32000]").get();
+
// Each agent has a portion of it's resources allocated to a single
// framework. We round-robin through the frameworks when allocating.
Resources allocation = Resources::parse("cpus:16;mem:1024;disk:1024").get();
@@ -3844,8 +3859,7 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, SuppressOffers)
watch.start();
for (size_t i = 0; i < agentCount; i++) {
- agents.push_back(createSlaveInfo(
- "cpus:24;mem:4096;disk:4096;ports:[31000-32000]"));
+ agents.push_back(createSlaveInfo(agentResources));
hashmap<FrameworkID, Resources> used;
used[frameworks[i % frameworkCount].id()] = allocation;
@@ -3963,10 +3977,13 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, Metrics)
cout << "Added " << frameworkCount << " frameworks in "
<< watch.elapsed() << endl;
+ const Resources agentResources = Resources::parse(
+ "cpus:16;mem:2048;disk:1024").get();
+
watch.start();
for (size_t i = 0; i < slaveCount; i++) {
- SlaveInfo slave = createSlaveInfo("cpus:16;mem:2048;disk:1024");
+ SlaveInfo slave = createSlaveInfo(agentResources);
allocator->addSlave(slave.id(), slave, None(), slave.resources(), {});
}