use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method instanceAutobindForPhysical8Socket.
@Test
public void instanceAutobindForPhysical8Socket() {
List<Pool> pools = createInstanceBasedPool();
setupConsumer("8", false);
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(8), q.getQuantity());
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method hostRestrictedAutobindForVirt8Vcpu.
@Test
public void hostRestrictedAutobindForVirt8Vcpu() {
List<Pool> pools = createHostRestrictedVirtLimitPool();
setupConsumer("8", true);
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(1), q.getQuantity());
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method testFindBestWillNotCompleteAPartialStackFromAnotherId.
@Test
public void testFindBestWillNotCompleteAPartialStackFromAnotherId() {
consumer.setFact("cpu.cpu_socket(s)", "8");
String productId1 = "A";
String productId2 = "B";
String productId3 = "C";
Product product1 = mockStackingProduct(productId1, "Test Stack product", "1", "2");
Product product2 = mockStackingProduct(productId2, "Test Stack product 2", "2", "2");
Product product3 = mockProduct(productId3, "Test Provided product");
Pool pool1 = mockPool(product1);
pool1.setId("DEAD-BEEF");
pool1.addProvidedProduct(product3);
Pool pool2 = mockPool(product2);
pool2.setId("DEAD-BEEF2");
pool2.addProvidedProduct(product3);
List<Pool> pools = new LinkedList<>();
// pools.add(pool1);
pools.add(pool2);
Entitlement entitlement = TestUtil.createEntitlement();
entitlement.setPool(pool1);
entitlement.setQuantity(2);
compliance.addPartialStack("1", entitlement);
List<PoolQuantity> result = autobindRules.selectBestPools(consumer, new String[] { productId2, productId3 }, pools, compliance, null, new HashSet<>(), false);
assertNotNull(result);
// We can make sure the partial stack wasn't completed
for (PoolQuantity pq : result) {
if (pq.getPool().getId().equals(pool1.getId())) {
fail("Should not complete this stack");
}
}
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method testPoolQuantityCompareNullPool.
@Test
public void testPoolQuantityCompareNullPool() {
Product prod = mockProduct(productId, "some prod", "2");
Pool pool1 = TestUtil.createPool(owner, prod, 10);
pool1.setId("1234");
Pool pool2 = TestUtil.createPool(owner, prod, 10);
pool2.setId(null);
PoolQuantity pq1 = new PoolQuantity(pool1, 5);
PoolQuantity pq2 = new PoolQuantity(pool2, 5);
assertTrue(pq1.compareTo(pq2) != 0);
assertEquals(pq1.compareTo(pq2), -pq2.compareTo(pq1));
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method autobindForPhysicalSocketPicksBestFit.
@Test
public void autobindForPhysicalSocketPicksBestFit() {
List<Pool> pools = createSocketPool(1, 100, "1");
pools.addAll(createSocketPool(2, 100, "2"));
setupConsumer("32", false);
List<PoolQuantity> bestPools = autobindRules.selectBestPools(consumer, new String[] { productId }, pools, compliance, null, new HashSet<>(), false);
// Should always pick the 2 socket subscriptions because less are required
assertEquals(1, bestPools.size());
PoolQuantity q = bestPools.get(0);
assertEquals(new Integer(16), q.getQuantity());
}
Aggregations