Search in sources :

Example 71 with InstalledProduct

use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.

the class TemporaryPoolTests method testStatusDetailsAfterAttachingUnmappedGuestsOnlySubpool.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20095", "RHEL7-51737" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "given an available unmapped_guests_only pool, attach it and verify the granted entitlement (validityNotAfter date is 24 hours after consumer's registration), installed product (Subscribed), and system status (Insufficient - Guest has not been reported on any host and is using a temporary unmapped guest subscription.)", groups = { "Tier1Tests", "blockedByBug-1362701" }, dataProvider = "getAvailableUnmappedGuestsOnlySubscriptionPoolsData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testStatusDetailsAfterAttachingUnmappedGuestsOnlySubpool(Object bugzilla, SubscriptionPool unmappedGuestsOnlyPool) throws JSONException, Exception {
    // system facts were overridden in dataProvider with factsMap to fake this system as a guest
    // make sure we are freshly registered (to discard a consumer from a former data provided iteration that has mapped guests)
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    ConsumerCert cert = clienttasks.getCurrentConsumerCert();
    // attach the unmapped guests only pool
    // File serialPemFile = clienttasks.subscribeToSubscriptionPool(unmappedGuestsOnlyPool, null, sm_clientUsername, sm_clientPassword, sm_serverUrl);
    // EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(serialPemFile);
    clienttasks.subscribe_(null, null, unmappedGuestsOnlyPool.poolId, null, null, null, null, null, null, null, null, null, null);
    // ProductSubscription consumedUnmappedGuestsOnlyProductSubscription = clienttasks.getCurrentlyConsumedProductSubscriptions().get(0);	// assumes only one consumed entitlement
    ProductSubscription consumedUnmappedGuestsOnlyProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("poolId", unmappedGuestsOnlyPool.poolId, clienttasks.getCurrentlyConsumedProductSubscriptions());
    EntitlementCert entitlementCert = clienttasks.getEntitlementCertCorrespondingToProductSubscription(consumedUnmappedGuestsOnlyProductSubscription);
    // assert the expiration is 24 hours post the consumer's registration
    int hours = 24;
    if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.1.0-1")) {
        // commit 0704a73dc0d3bf753351e87ca0b65d85a71acfbe 1450079: virt-who temporary subscription should be 7 days
        hours = 7 * /*days*/
        24;
        log.info("Due to Candlepin RFE Bug 1450079, the vailidity period for temporary subscription pools has increased from one day to one week.");
    }
    if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.30-1")) {
        // commit 9302c8f57f37dd5ec3c4020770ac1675a87d99ba 1419576: Pre-date certs to ease clock skew issues
        hours += 1;
        log.info("Due to Candlepin RFE Bug 1419576, we need to increment the expected entitlement validity for the temporary pool by one hour to '" + hours + "' hours after the consumer identity's validityNotBefore date.");
    }
    Calendar expectedEntitlementCertEndDate = (Calendar) cert.validityNotBefore.clone();
    expectedEntitlementCertEndDate.add(Calendar.HOUR, hours);
    // Assert.assertEquals(ConsumerCert.formatDateString(entitlementCert.validityNotAfter), ConsumerCert.formatDateString(expectedEntitlementCertEndDate), "The End Date of the entitlement from a temporary pool should be exactly 24 hours after the registration date of the current consumer '"+ConsumerCert.formatDateString(cert.validityNotBefore)+"'.");
    // allow for a few seconds of tolerance
    Calendar expectedEntitlementCertEndDateUpperTolerance = (Calendar) expectedEntitlementCertEndDate.clone();
    expectedEntitlementCertEndDateUpperTolerance.add(Calendar.SECOND, +25);
    Calendar expectedEntitlementCertEndDateLowerTolerance = (Calendar) expectedEntitlementCertEndDate.clone();
    expectedEntitlementCertEndDateLowerTolerance.add(Calendar.SECOND, -25);
    Assert.assertTrue(entitlementCert.validityNotAfter.before(expectedEntitlementCertEndDateUpperTolerance) && entitlementCert.validityNotAfter.after(expectedEntitlementCertEndDateLowerTolerance), "The End Date of the entitlement from a temporary pool '" + ConsumerCert.formatDateString(entitlementCert.validityNotAfter) + "' should be '" + hours + "' hours (within several seconds) after the registration date of the current consumer '" + ConsumerCert.formatDateString(cert.validityNotBefore) + "'.");
    // assert the Status Details of the attached subscription
    String expectedStatusDetailsForAnUnmappedGuestsOnlyProductSubscription = "Guest has not been reported on any host and is using a temporary unmapped guest subscription.";
    Assert.assertEquals(consumedUnmappedGuestsOnlyProductSubscription.statusDetails, Arrays.asList(new String[] { expectedStatusDetailsForAnUnmappedGuestsOnlyProductSubscription }), "Status Details of a consumed subscription from a temporary pool for unmapped guests only.");
    // assert that the temporary subscription appears in the status report
    SSHCommandResult statusResult = clienttasks.status(null, null, null, null, null);
    // 2015-08-13 18:49:28.596  FINE: ssh root@jsefler-7.usersys.redhat.com subscription-manager status
    // 2015-08-13 18:49:30.956  FINE: Stdout:
    // +-------------------------------------------+
    // System Status Details
    // +-------------------------------------------+
    // Overall Status: Insufficient
    // 
    // Red Hat Enterprise Linux for Virtual Datacenters, Premium (DERIVED SKU):
    // - Guest has not been reported on any host and is using a temporary unmapped guest subscription.
    // 
    // 2015-08-19 10:33:50.675  FINE: ssh root@ibm-p8-kvm-04-guest-06.rhts.eng.bos.redhat.com subscription-manager status
    // 2015-08-19 10:33:52.757  FINE: Stdout:
    // +-------------------------------------------+
    // System Status Details
    // +-------------------------------------------+
    // Overall Status: Invalid
    // 
    // Red Hat Enterprise Linux for Virtual Datacenters, Premium (DERIVED SKU):
    // - Guest has not been reported on any host and is using a temporary unmapped guest subscription.
    // 
    // Red Hat Enterprise Linux for Power, little endian:
    // - Not supported by a valid subscription.
    Map<String, String> statusMap = StatusTests.getProductStatusMapFromStatusResult(statusResult);
    Assert.assertTrue(statusMap.containsKey(consumedUnmappedGuestsOnlyProductSubscription.productName), "The status module reports an incompliance from temporary subscription '" + consumedUnmappedGuestsOnlyProductSubscription.productName + "'.");
    Assert.assertEquals(statusMap.get(consumedUnmappedGuestsOnlyProductSubscription.productName), expectedStatusDetailsForAnUnmappedGuestsOnlyProductSubscription, "The status module reports an incompliance from temporary subscription '" + consumedUnmappedGuestsOnlyProductSubscription.productName + "' for this reason.");
    // assert that the temporary subscription causes an overall status to be Invalid or Insufficient (either is possible and depends on what is installed and if the Temporary pool provides for what is installed)
    Assert.assertTrue(statusResult.getStdout().contains("Overall Status: Invalid") || statusResult.getStdout().contains("Overall Status: Insufficient"), "Expecting Overall Status to be 'Invalid' or 'Insufficient' when a temporary subscription for '" + consumedUnmappedGuestsOnlyProductSubscription.productName + "' is attached (actual value depends on what is installed and if the temporary pool provides for what is installed)");
    // assert the status of installed products provided by the temporary subscription
    List<String> providedProductIds = CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, unmappedGuestsOnlyPool.poolId);
    List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
    for (String providedProductId : providedProductIds) {
        InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProducts);
        if (installedProduct != null) {
            // providedProduct is installed
            // assert the status details
            // see CLOSED NOTABUG Bug 1200882 - Wrong installed product status is displayed when a unmapped_guests_only pool is attached
            Assert.assertEquals(installedProduct.status, "Subscribed", "Status of an installed product provided for by a temporary entitlement from a pool reserved for unmapped guests only.");
            Assert.assertEquals(installedProduct.statusDetails, new ArrayList<String>(), "Status Details of an installed product provided for by a temporary entitlement from a pool reserved for unmapped guests only.");
            // TODO: The above two asserts might be changed by RFE Bug 1201520 - [RFE] Usability suggestions to better identify a temporary (aka 24 hour) entitlement
            // assert the start-end dates
            // TEMPORARY WORKAROUND FOR BUG
            // Bug 1199443 - Wrong "End date" in installed list after attaching 24-hour subscription on a unmapped-guest
            String bugId = "1199443";
            boolean invokeWorkaroundWhileBugIsOpen = true;
            try {
                if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
                    log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                    SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                } else {
                    invokeWorkaroundWhileBugIsOpen = false;
                }
            } catch (BugzillaAPIException be) {
            /* ignore exception */
            } catch (RuntimeException re) {
            /* ignore exception */
            }
            if (invokeWorkaroundWhileBugIsOpen) {
                log.warning("Skipping assertion of the End Date for installed product '" + installedProduct.productName + "' provided by a temporary pool while bug '" + bugId + "' is open.");
            } else
                // assert the End Date
                // END OF WORKAROUND
                Assert.assertEquals(InstalledProduct.formatDateString(installedProduct.endDate), InstalledProduct.formatDateString(entitlementCert.validityNotAfter), "The End Date of coverage for the installed product '" + installedProduct.productName + "' should exactly match the end date from the temporary pool subscription.");
        }
    }
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) Calendar(java.util.Calendar) ProductSubscription(rhsm.data.ProductSubscription) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) InstalledProduct(rhsm.data.InstalledProduct) ConsumerCert(rhsm.data.ConsumerCert) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 72 with InstalledProduct

use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.

the class ReleaseTests method testReleaseListExcludes60OnRHEL6System.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6 }, testCaseID = { "RHEL6-20004" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "register to a RHEL subscription and verify that release --list excludes 6.0", groups = { "Tier1Tests", "blockedByBug-802245" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReleaseListExcludes60OnRHEL6System() throws JSONException, Exception {
    if (!clienttasks.redhatReleaseX.equals("6"))
        throw new SkipException("This test is only applicable on RHEL6.");
    // make sure we are newly registered with autosubscribe
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (List<String>) null, null, null, null, true, null, null, null, null, null);
    // get the current base RHEL product cert
    /* this block of logic does not account for the presence of a /etc/pki/product-default/ cert
		String providingTag = "rhel-"+clienttasks.redhatReleaseX;
		List<ProductCert> rhelProductCerts = clienttasks.getCurrentProductCerts(providingTag);
		Assert.assertEquals(rhelProductCerts.size(), 1, "Only one product cert is installed that provides RHEL tag '"+providingTag+"'");
		ProductCert rhelProductCert = rhelProductCerts.get(0);
		*/
    ProductCert rhelProductCert = clienttasks.getCurrentRhelProductCert();
    // assert that it was autosubscribed
    InstalledProduct rhelInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductCert.productId, clienttasks.getCurrentlyInstalledProducts());
    Assert.assertNotNull(rhelInstalledProduct, "Our base installed RHEL product was autosubscribed during registration.");
    // get the actual release listing
    List<String> actualReleases = clienttasks.getCurrentlyAvailableReleases(null, null, null, null);
    // assert that the list excludes 6.0, but includes the current X.Y release
    String release60 = "6.0";
    Assert.assertTrue(!actualReleases.contains(release60), "The subscription-manager releases list should exclude '" + release60 + "' since '" + clienttasks.command + "' did not exist in RHEL Release '" + release60 + "'.");
// NOT PRACTICAL SINCE CONTENT FROM THIS Y-STREAM MAY NOT BE AVAILABLE UNTIL GA Assert.assertTrue(actualReleases.contains(clienttasks.redhatReleaseXY), "The subscription-manager releases list should include '"+clienttasks.redhatReleaseXY+"' since it is the current RHEL Release under test.");
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 73 with InstalledProduct

use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.

the class RAMTests method testPartiallySubscribedRamBasedProducts.

// Test methods ***********************************************************************
/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36684", "RHEL7-51529" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "verify status of partially covered Ram based products", groups = { "Tier2Tests", "PartiallySubscribedRamBasedProducts" }, enabled = true)
public void testPartiallySubscribedRamBasedProducts() throws JSONException, Exception {
    // GB
    Integer ram = 20;
    factsMap.clear();
    factsMap.put("uname.machine", "x86_64");
    factsMap.put("memory.memtotal", String.valueOf(GBToKBConverter(ram)));
    factsMap.put("cpu.cpu_socket(s)", "1");
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    clienttasks.autoheal(null, null, true, null, null, null, null);
    List<String> ramSubscriptionNames = new ArrayList<String>();
    for (SubscriptionPool pool : getRamBasedSubscriptions()) {
        clienttasks.subscribe(null, null, pool.poolId, null, null, "1", null, null, null, null, null, null, null);
        ramSubscriptionNames.add(pool.subscriptionName);
    }
    for (InstalledProduct installed : getRamBasedProducts()) {
        Assert.assertEquals(installed.status.trim(), "Partially Subscribed", "Status of installed product '" + installed.productName + "' on a '" + ram + "' GB system after attaching 1 quantity of each of these subscriptions: " + ramSubscriptionNames);
    }
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ArrayList(java.util.ArrayList) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 74 with InstalledProduct

use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.

the class RAMTests method testAutoSubscribeRamBasedProducts.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36681", "RHEL7-51526" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "verify Auto-attach for Ram based subscription", groups = { "Tier2Tests", "AutoSubscribeRamBasedProducts" }, enabled = true)
public void testAutoSubscribeRamBasedProducts() throws JSONException, Exception {
    factsMap.clear();
    factsMap.put("uname.machine", "x86_64");
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    getRamBasedSubscriptions();
    clienttasks.subscribe(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
    for (InstalledProduct installed : getRamBasedProducts()) {
        Assert.assertEquals(installed.status.trim(), "Subscribed", "Status of installed product '" + installed.productName + "'.");
    }
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 75 with InstalledProduct

use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.

the class RAMTests method testHealingPartiallySubscribedRamBasedProducts.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36682", "RHEL7-51527" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "verify healing of partially subscribed RAM products covered by stackable RAM-based subscriptions", groups = { "Tier2Tests", "HealingPartiallySubscribedRamBasedProducts", "blockedByBug-907638" }, enabled = true)
public void testHealingPartiallySubscribedRamBasedProducts() throws JSONException, Exception {
    testPartiallySubscribedRamBasedProducts();
    clienttasks.autoheal(null, true, null, null, null, null, null);
    clienttasks.run_rhsmcertd_worker(true);
    for (InstalledProduct installed : getRamBasedProducts()) {
        Assert.assertEquals(installed.status.trim(), "Subscribed", "Status of installed ram product '" + installed.productName + "' after auto-healing a partially subscribed ram product.");
    }
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Aggregations

InstalledProduct (rhsm.data.InstalledProduct)77 Test (org.testng.annotations.Test)71 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)66 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)33 SkipException (org.testng.SkipException)27 SubscriptionPool (rhsm.data.SubscriptionPool)25 ArrayList (java.util.ArrayList)22 ProductCert (rhsm.data.ProductCert)21 ProductSubscription (rhsm.data.ProductSubscription)16 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)15 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)14 HashMap (java.util.HashMap)13 BigInteger (java.math.BigInteger)12 JSONObject (org.json.JSONObject)10 File (java.io.File)9 Calendar (java.util.Calendar)7 HashSet (java.util.HashSet)7 EntitlementCert (rhsm.data.EntitlementCert)6 GregorianCalendar (java.util.GregorianCalendar)5 JSONArray (org.json.JSONArray)5