You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mz...@apache.org on 2019/04/05 22:04:22 UTC

[mesos] branch master updated (3d1c435 -> 281039c)

This is an automated email from the ASF dual-hosted git repository.

mzhu pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.


    from 3d1c435  Updated Mesos version to 1.9.0.
     new a0170bb  Added a test to ensure correct headroom accounting.
     new 281039c  Added a test to ensure correct role consumed quota accounting.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/tests/hierarchical_allocator_tests.cpp | 174 +++++++++++++++++++++++++++++
 1 file changed, 174 insertions(+)


[mesos] 02/02: Added a test to ensure correct role consumed quota accounting.

Posted by mz...@apache.org.
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 281039cb1b64ea916da11a9009f2895125242fc6
Author: Meng Zhu <mz...@mesosphere.io>
AuthorDate: Thu Apr 4 16:18:19 2019 -0700

    Added a test to ensure correct role consumed quota accounting.
    
    This test ensures that a nested role's allocation is accounted
    to the top-level role's consumed quota.
    
    Review: https://reviews.apache.org/r/70396
---
 src/tests/hierarchical_allocator_tests.cpp | 77 ++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index fb22319..7221a64 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -6186,6 +6186,83 @@ TEST_F(HierarchicalAllocatorTest, QuotaWithNestedRoleReservation)
   AWAIT_EXPECT_EQ(expected, allocations.get());
 }
 
+// This test ensures that nested role's allocation is accounted
+// to top-level role's consumed quota.
+TEST_F(HierarchicalAllocatorTest, QuotaWithNestedRoleAllocation)
+{
+  // Setup:
+  // agent1: R
+  // Roles:
+  //     "a"   --> guarantee with R w/ no framework
+  //     "a/b" --> has `framework1`, allocated R on agent1
+  //
+  // Test:
+  //   Add `framework2` under "a"
+  //   Add agent2 with R
+  // Ensure:
+  //   `agent2` is allocated to `framework1` under `a/b`, even though, role
+  // `a` and `framework2` have lower shares. This is because role `a` has
+  // reached its quota limit (due to its subrole's allocation). Also,
+  // currently, subrole's allocations are not constrained by top-level
+  // role's quota (though they are tracked post factum).
+  //
+  // TODO(mzhu): Once we finish support for hierarchical quota, no allocation
+  // should be made since "a/b" will also be bound by the quota of "a".
+
+  // --- SET UP ---
+
+  Clock::pause();
+
+  initialize();
+
+  const string PARENT_ROLE{"a"};
+  const string CHILD_ROLE{"a/b"};
+
+  // Add framework1 under the child role "a/b".
+  FrameworkInfo framework1 = createFrameworkInfo({CHILD_ROLE});
+  allocator->addFramework(framework1.id(), framework1, {}, true, {});
+
+  SlaveInfo agent1 = createSlaveInfo("cpus:1;mem:1024");
+  allocator->addSlave(
+      agent1.id(),
+      agent1,
+      AGENT_CAPABILITIES(),
+      None(),
+      agent1.resources(),
+      {});
+
+  Allocation expected = Allocation(
+      framework1.id(), {{CHILD_ROLE, {{agent1.id(), agent1.resources()}}}});
+
+  AWAIT_EXPECT_EQ(expected, allocations.get());
+
+  Quota quota = createQuota(PARENT_ROLE, "cpus:1;mem:1024");
+  allocator->setQuota(PARENT_ROLE, quota);
+
+  // --- TEST ---
+
+  // Add framework2 under the parent role "a".
+  FrameworkInfo framework2 = createFrameworkInfo({PARENT_ROLE});
+  allocator->addFramework(framework2.id(), framework2, {}, true, {});
+
+  SlaveInfo agent2 = createSlaveInfo("cpus:1;mem:1024");
+  allocator->addSlave(
+      agent2.id(),
+      agent2,
+      AGENT_CAPABILITIES(),
+      None(),
+      agent2.resources(),
+      {});
+
+  // Process all events.
+  Clock::settle();
+
+  expected = Allocation(
+      framework1.id(), {{CHILD_ROLE, {{agent2.id(), agent2.resources()}}}});
+
+  AWAIT_EXPECT_EQ(expected, allocations.get());
+}
+
 
 // This test ensures that quota headroom is calculated correctly
 // in the presence of subrole's allocations.


[mesos] 01/02: Added a test to ensure correct headroom accounting.

Posted by mz...@apache.org.
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 a0170bb17656089ce07b6ccb30e7d23062d729d1
Author: Meng Zhu <mz...@mesosphere.io>
AuthorDate: Wed Apr 3 12:31:27 2019 -0700

    Added a test to ensure correct headroom accounting.
    
    This test verifies that the headroom accounting is correct in the
    presence of subrole allocation. In particular, we need to ensure
    that a subrole's allocation is accounted only once (not multiple
    times in itself as well as all of its ancestors) when calculating
    available the quota headroom.
    
    Review: https://reviews.apache.org/r/70390
---
 src/tests/hierarchical_allocator_tests.cpp | 97 ++++++++++++++++++++++++++++++
 1 file changed, 97 insertions(+)

diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index 30c0c3e..fb22319 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -6187,6 +6187,103 @@ TEST_F(HierarchicalAllocatorTest, QuotaWithNestedRoleReservation)
 }
 
 
+// This test ensures that quota headroom is calculated correctly
+// in the presence of subrole's allocations.
+TEST_F(HierarchicalAllocatorTest, QuotaHeadroomWithNestedRoleAllocation)
+{
+  // Setup:
+  //   agents: 2 * R
+  //    roles: "a"   --> allocated R
+  //           "a/b" --> allocated R
+  //           "quota-role" --> guarantee R w/ no framework
+  //
+  // Test: Add 1 more agent with R.
+  //       Ensure agent is held back for "quota-role".
+  //       Add 1 more agent with R.
+  //       Ensure only 1 of the two extra agents goes to "a" or "a/b"
+  //         (since there is enough headroom for "quota-role")
+
+  Clock::pause();
+
+  initialize();
+
+  const string PARENT_ROLE = "a";
+  const string CHILD_ROLE = "a/b";
+
+  // Add framework1 under the parent role "a/b".
+  FrameworkInfo framework1 = createFrameworkInfo({CHILD_ROLE});
+  allocator->addFramework(framework1.id(), framework1, {}, true, {});
+
+  SlaveInfo agent1 = createSlaveInfo("cpus:1;mem:100");
+  allocator->addSlave(
+      agent1.id(),
+      agent1,
+      AGENT_CAPABILITIES(),
+      None(),
+      agent1.resources(),
+      {});
+
+  // All the resources of agent1 are offered to framework1.
+  Allocation expected = Allocation(
+      framework1.id(), {{CHILD_ROLE, {{agent1.id(), agent1.resources()}}}});
+
+  AWAIT_EXPECT_EQ(expected, allocations.get());
+
+  // Add framework2 under the child role "a".
+  FrameworkInfo framework2 = createFrameworkInfo({PARENT_ROLE});
+  allocator->addFramework(framework2.id(), framework2, {}, true, {});
+
+  // Add `agent2` which will be allocated to `framework2`.
+  SlaveInfo agent2 = createSlaveInfo("cpus:1;mem:100");
+  allocator->addSlave(
+      agent2.id(),
+      agent2,
+      AGENT_CAPABILITIES(),
+      None(),
+      agent2.resources(),
+      {});
+
+  // All the resources of agent2 are offered to framework2.
+  expected = Allocation(
+      framework2.id(), {{PARENT_ROLE, {{agent2.id(), agent2.resources()}}}});
+
+  AWAIT_EXPECT_EQ(expected, allocations.get());
+
+  const string QUOTA_ROLE{"quota-role"};
+
+  Quota quota = createQuota(QUOTA_ROLE, "cpus:1;mem:100");
+  allocator->setQuota(QUOTA_ROLE, quota);
+
+  SlaveInfo agent3 = createSlaveInfo("cpus:1;mem:100");
+  allocator->addSlave(
+      agent3.id(),
+      agent3,
+      AGENT_CAPABILITIES(),
+      None(),
+      agent3.resources(),
+      {});
+
+  Future<Allocation> allocation = allocations.get();
+  EXPECT_TRUE(allocation.isPending());
+
+  SlaveInfo agent4 = createSlaveInfo("cpus:1;mem:100");
+  allocator->addSlave(
+      agent4.id(),
+      agent4,
+      AGENT_CAPABILITIES(),
+      None(),
+      agent4.resources(),
+      {});
+
+  Clock::settle();
+
+  // There should be one allocation made. Either agent3 or agent4 is
+  // allocated and the other agent is set aside for the quota headroom.
+  AWAIT_READY(allocation);
+  EXPECT_TRUE(allocations.get().isPending());
+}
+
+
 // This test checks that quota guarantees work as expected when a
 // nested role is created as a child of an existing quota'd role.
 //