use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class ComplianceRulesTest method virtualSingleEntOnlyUsesVcpuAndRam.
@Test
public void virtualSingleEntOnlyUsesVcpuAndRam() {
Consumer c = mockConsumer(PRODUCT_1);
c.setFact("virt.is_guest", "true");
c.setFact("cpu.core(s)_per_socket", "8");
c.setFact("cpu.cpu_socket(s)", "10");
// 8GB RAM
c.setFact("memory.memtotal", "8000000");
List<Entitlement> ents = new LinkedList<>();
Entitlement ent = mockEntitlement(c, TestUtil.createProduct("Awesome Product"), PRODUCT_1);
ent.getPool().getProduct().setAttribute(Product.Attributes.CORES, "1");
ent.getPool().getProduct().setAttribute(Product.Attributes.RAM, "1");
ent.getPool().getProduct().setAttribute(Product.Attributes.SOCKETS, "1");
ent.getPool().getProduct().setAttribute(Product.Attributes.VCPU, "1");
ents.add(ent);
ents.get(0).setQuantity(1);
mockEntCurator(c, ents);
ComplianceStatus status = compliance.getStatus(c, TestUtil.createDate(2011, 8, 30));
assertEquals(ComplianceStatus.YELLOW, status.getStatus());
assertEquals(0, status.getNonCompliantProducts().size());
assertEquals(1, status.getPartiallyCompliantProducts().size());
assertEquals(0, status.getCompliantProducts().size());
assertTrue(status.getPartiallyCompliantProducts().keySet().contains(PRODUCT_1.getId()));
// We should be partial because of ram and vcpus, nothing else
assertEquals(2, status.getReasons().size());
List<String> reasonKeys = new LinkedList<>();
for (ComplianceReason r : status.getReasons()) {
reasonKeys.add(r.getKey());
}
assertTrue(reasonKeys.contains("RAM"));
assertTrue(reasonKeys.contains("VCPU"));
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class ComplianceRulesTest method fullyCompliantVirtLimitStackWithInactiveGuests.
@Test
public void fullyCompliantVirtLimitStackWithInactiveGuests() {
Consumer c = mockConsumer(PRODUCT_1, PRODUCT_2);
for (int i = 0; i < 5; i++) {
c.addGuestId(new GuestId("" + i, c));
}
List<Entitlement> ents = new LinkedList<>();
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
for (Entitlement ent : ents) {
ent.getPool().getProduct().setAttribute(Product.Attributes.GUEST_LIMIT, "4");
}
mockEntCurator(c, ents);
ComplianceStatus status = compliance.getStatus(c, TestUtil.createDate(2011, 8, 30));
assertEquals(0, status.getNonCompliantProducts().size());
assertEquals(0, status.getPartiallyCompliantProducts().size());
assertEquals(2, status.getCompliantProducts().size());
assertTrue(status.getCompliantProducts().keySet().contains(PRODUCT_1.getId()));
assertTrue(status.getCompliantProducts().keySet().contains(PRODUCT_2.getId()));
assertEquals(4, status.getCompliantProducts().get(PRODUCT_1.getId()).size());
assertEquals(4, status.getCompliantProducts().get(PRODUCT_2.getId()).size());
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class ComplianceRulesTest method regularEntsBothLackingSocketCoverage.
/*
* Test an installed product with two normal non-stacked entitlements, both of which
* do not provide enough sockets for the system. Note that these entitlements
* are not stacked together.
*/
@Test
public void regularEntsBothLackingSocketCoverage() {
// Consumer with 8 sockets:
Consumer c = mockConsumer(PRODUCT_1);
List<Entitlement> ents = new LinkedList<>();
// One entitlement that only provides four sockets:
ents.add(mockEntitlement(c, TestUtil.createProduct("Awesome Product"), PRODUCT_1));
ents.get(0).getPool().getProduct().setAttribute(Product.Attributes.SOCKETS, "4");
// One entitlement that provides 6 sockets:
ents.add(mockEntitlement(c, TestUtil.createProduct("Awesome Product"), PRODUCT_1));
ents.get(1).getPool().getProduct().setAttribute(Product.Attributes.SOCKETS, "6");
mockEntCurator(c, ents);
ComplianceStatus status = compliance.getStatus(c, TestUtil.createDate(2011, 8, 30));
assertEquals(0, status.getNonCompliantProducts().size());
assertEquals(1, status.getPartiallyCompliantProducts().size());
assertEquals(0, status.getCompliantProducts().size());
assertEquals(0, status.getPartialStacks().size());
assertTrue(status.getPartiallyCompliantProducts().keySet().contains(PRODUCT_1.getId()));
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class ComplianceRulesTest method fullyCompliantVirtLimitStackAllUnlimited.
@Test
public void fullyCompliantVirtLimitStackAllUnlimited() {
Consumer c = mockConsumer(PRODUCT_1, PRODUCT_2);
for (int i = 0; i < 5; i++) {
c.addGuestId(new GuestId("" + i, c, activeGuestAttrs));
}
List<Entitlement> ents = new LinkedList<>();
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
for (Entitlement ent : ents) {
ent.getPool().getProduct().setAttribute(Product.Attributes.GUEST_LIMIT, "-1");
}
mockEntCurator(c, ents);
ComplianceStatus status = compliance.getStatus(c, TestUtil.createDate(2011, 8, 30));
assertEquals(0, status.getNonCompliantProducts().size());
assertEquals(2, status.getCompliantProducts().size());
assertEquals(0, status.getPartiallyCompliantProducts().size());
assertTrue(status.getCompliantProducts().keySet().contains(PRODUCT_1.getId()));
assertTrue(status.getCompliantProducts().keySet().contains(PRODUCT_2.getId()));
assertEquals(4, status.getCompliantProducts().get(PRODUCT_1.getId()).size());
assertEquals(4, status.getCompliantProducts().get(PRODUCT_2.getId()).size());
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class ComplianceRulesTest method compliantStack.
// Test a fully stacked scenario:
@Test
public void compliantStack() {
Consumer c = mockConsumer(PRODUCT_1, PRODUCT_2);
List<Entitlement> ents = new LinkedList<>();
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
mockEntCurator(c, ents);
ComplianceStatus status = compliance.getStatus(c, TestUtil.createDate(2011, 8, 30));
assertEquals(0, status.getNonCompliantProducts().size());
assertEquals(0, status.getPartiallyCompliantProducts().size());
assertEquals(2, status.getCompliantProducts().size());
assertTrue(status.getCompliantProducts().keySet().contains(PRODUCT_1.getId()));
assertTrue(status.getCompliantProducts().keySet().contains(PRODUCT_2.getId()));
assertEquals(4, status.getCompliantProducts().get(PRODUCT_1.getId()).size());
assertEquals(4, status.getCompliantProducts().get(PRODUCT_2.getId()).size());
}
Aggregations