use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method testSelectBestPoolsLotsOfContentV3Client.
@Test
public void testSelectBestPoolsLotsOfContentV3Client() {
Pool pool = createV3OnlyPool();
List<Pool> pools = new LinkedList<>();
pools.add(pool);
// Shouldn't throw an exception as we do for certv1 clients.
consumer.setFact("system.certificate_version", "3.5");
List<PoolQuantity> bestPools = autobindRules.selectBestPools(consumer, new String[] { productId }, pools, compliance, null, new HashSet<>(), false);
assertEquals(1, bestPools.size());
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method testSelectBestPoolDefaultRule.
@Test
public void testSelectBestPoolDefaultRule() {
consumer.setFact("cpu.cpu_socket(s)", "32");
Product product = TestUtil.createProduct("a-product", "A product for testing");
Pool pool1 = createPool(owner, product, 5, TestUtil.createDate(2000, 02, 26), TestUtil.createDate(2050, 02, 26));
Pool pool2 = createPool(owner, product, 5, TestUtil.createDate(2000, 02, 26), TestUtil.createDate(2060, 02, 26));
List<Pool> availablePools = Arrays.asList(new Pool[] { pool1, pool2 });
List<PoolQuantity> result = autobindRules.selectBestPools(consumer, new String[] { product.getId() }, availablePools, compliance, null, new HashSet<>(), false);
assertNotNull(result);
for (PoolQuantity pq : result) {
assertEquals(new Integer(1), pq.getQuantity());
}
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method guestLimitAutobindServerAttachedNonStackable.
/*
* If the hypervisor is already installed, and at least partially
* subscribed, autobind will be able to cover the server subscription
*/
@Test
public void guestLimitAutobindServerAttachedNonStackable() {
consumer.setFact("cpu.cpu_socket(s)", "2");
for (int i = 0; i < 5; i++) {
consumer.addGuestId(new GuestId("" + i, consumer, activeGuestAttrs));
}
Product server = mockProduct(productId, "some server", "2");
server.setAttribute(Product.Attributes.GUEST_LIMIT, "4");
Product hypervisor = mockProduct("hypervisor", "some hypervisor", "2");
hypervisor.setAttribute(Product.Attributes.GUEST_LIMIT, "-1");
Pool serverPool = TestUtil.createPool(owner, server, 10);
Pool hyperPool = TestUtil.createPool(owner, hypervisor, 10);
serverPool.setId("POOL-ID1");
hyperPool.setId("Pool-ID2");
Entitlement entitlement = TestUtil.createEntitlement();
entitlement.setPool(hyperPool);
// compliant
entitlement.setQuantity(1);
// The hypervisor must be installed and entitled on the system for autobind
// to pick up the unlimited guest_limit
compliance.addCompliantProduct(hypervisor.getId(), entitlement);
List<Pool> pools = new LinkedList<>();
pools.add(serverPool);
pools.add(hyperPool);
List<PoolQuantity> bestPools = autobindRules.selectBestPools(consumer, new String[] { server.getId() }, pools, compliance, null, new HashSet<>(), false);
assertEquals(1, bestPools.size());
assertEquals(new Integer(1), bestPools.get(0).getQuantity());
assertEquals("POOL-ID1", bestPools.get(0).getPool().getId());
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method instanceAutobindForPhysical8SocketCompletePartialStack.
@Test
public void instanceAutobindForPhysical8SocketCompletePartialStack() {
List<Pool> pools = createInstanceBasedPool();
setupConsumer("8", false);
// Create a pre-existing entitlement which only covers half of the sockets:
Entitlement mockEnt = mockEntitlement(pools.get(0), 4);
consumer.addEntitlement(mockEnt);
compliance.addPartiallyCompliantProduct(productId, mockEnt);
compliance.addPartialStack("1", mockEnt);
List<PoolQuantity> bestPools = autobindRules.selectBestPools(consumer, new String[] { productId }, pools, compliance, null, new HashSet<>(), false);
assertEquals(1, bestPools.size());
PoolQuantity q = bestPools.get(0);
assertEquals(new Integer(4), q.getQuantity());
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method autobindForPhysicalSocketPicksBestFitBalanceQuantity.
@Test
public void autobindForPhysicalSocketPicksBestFitBalanceQuantity() {
List<Pool> pools = createSocketPool(1, 100, "1");
pools.addAll(createSocketPool(5, 100, "2"));
setupConsumer("9", false);
List<PoolQuantity> bestPools = autobindRules.selectBestPools(consumer, new String[] { productId }, pools, compliance, null, new HashSet<>(), false);
// Should always pick the 2 5 socket subscriptions over 9 1 socket subscriptions
// although we're slightly overconsuming, it's better than wasting subs that may be
// used elsewhere
assertEquals(1, bestPools.size());
PoolQuantity q = bestPools.get(0);
assertEquals(new Integer(2), q.getQuantity());
}
Aggregations