MCPcopy Create free account
hub / github.com/apache/mesos / TEST_P

Function TEST_P

src/tests/hierarchical_allocator_tests.cpp:1379–1453  ·  view source on GitHub ↗

This test verifies that the reservations should be accounted towards the quota guarantee/limit even if they are currently unallocated.

Source from the content-addressed store, hash-verified

1377// accounted towards the quota guarantee/limit even if
1378// they are currently unallocated.
1379TEST_P(HierarchicalAllocatorTestWithReservations, ReservationUnallocated)
1380{
1381 Clock::pause();
1382
1383 const string QUOTA_ROLE{"quota-role"};
1384
1385 initialize();
1386
1387 Resource::ReservationInfo reservation;
1388 reservation.set_type(GetParam());
1389 reservation.set_role(QUOTA_ROLE);
1390
1391 Resources resources = Resources::parse("cpus:1;mem:1024").get();
1392 resources = resources.pushReservation(reservation);
1393
1394 SlaveInfo agent1 = createSlaveInfo(resources);
1395 allocator->addSlave(
1396 agent1.id(),
1397 agent1,
1398 AGENT_CAPABILITIES(),
1399 None(),
1400 agent1.resources(),
1401 {});
1402
1403 Resources reserved = Resources(agent1.resources()).reserved(QUOTA_ROLE);
1404
1405 // Set a quota for 1x agent resources.
1406 const Quota quota = createQuota("cpus:1;mem:1024");
1407 allocator->updateQuota(QUOTA_ROLE, quota);
1408
1409 // Create `framework1` and set quota for its role.
1410 FrameworkInfo framework1 = createFrameworkInfo({QUOTA_ROLE});
1411 allocator->addFramework(framework1.id(), framework1, {}, true, {});
1412
1413 // Process all triggered allocation events.
1414 Clock::settle();
1415
1416 // `framework1` will be offered the reserved resources at `agent1`
1417 // because those resources are reserved for its role.
1418 Allocation expected = Allocation(
1419 framework1.id(),
1420 {{QUOTA_ROLE, {{agent1.id(), reserved}}}});
1421
1422 AWAIT_EXPECT_EQ(expected, allocations.get());
1423
1424 // Decline the reservations for the rest of the test.
1425 Filters filter1day;
1426 filter1day.set_refuse_seconds(Days(1).secs());
1427 allocator->recoverResources(
1428 framework1.id(),
1429 agent1.id(),
1430 allocatedResources(reserved, QUOTA_ROLE),
1431 filter1day,
1432 false);
1433
1434 // Add another agent with unreserved resources.
1435 // This will trigger a batch allocation.
1436 SlaveInfo agent2 = createSlaveInfo("cpus:1;mem:1024");

Callers

nothing calls this directly

Calls 15

AGENT_CAPABILITIESFunction · 0.85
NoneClass · 0.85
createQuotaFunction · 0.85
createFrameworkInfoFunction · 0.85
DaysClass · 0.85
allocatedResourcesFunction · 0.85
createDiskResourceFunction · 0.85
injectAllocationInfoFunction · 0.85
getResourceConversionsFunction · 0.85
createPersistentVolumeFunction · 0.85
MegabytesFunction · 0.85
fragmentFunction · 0.85

Tested by

no test coverage detected