Search in sources :

Example 76 with InstalledProduct

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

the class RAMTests method testAutoHealRamBasedSubscription.

/**
 * @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-36680", "RHEL7-51525" }, 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 Heal for Ram subscription .", groups = { "Tier2Tests", "AutoHealRamBasedSubscription", "blockedByBug-907638", "blockedByBug-976867" }, enabled = true)
public void testAutoHealRamBasedSubscription() 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.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    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 product '" + installed.productName + "'.");
    }
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 77 with InstalledProduct

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

the class ServiceLevelTests method testInstalledProductsProvidedByAvailablePoolsWithExemptServiceLevelAreAutoSubscribedRegardlessOfServiceLevel.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21703", "RHEL7-51027" }, 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 = "installed products provided by available pools with an exempt service level should be auto-subscribed regardless of what service level is specified (or is not specified)", groups = { "Tier1Tests", "blockedByBug-818319", "blockedByBug-859652", "blockedByBug-919700" }, dataProvider = "getExemptInstalledProductAndServiceLevelData", enabled = true)
@ImplementsNitrateTest(caseId = 157229)
public void testInstalledProductsProvidedByAvailablePoolsWithExemptServiceLevelAreAutoSubscribedRegardlessOfServiceLevel(Object bugzilla, String installedProductId, String serviceLevel) {
    // randomize the case of the service level
    String seRvICElevEl = randomizeCaseOfCharactersInString(serviceLevel);
    log.info("This test will be conducted with a randomized serviceLevel value: " + seRvICElevEl);
    // TEMPORARY WORKAROUND FOR BUG
    if (sm_serverType.equals(CandlepinType.hosted)) {
        String bugId = "818319";
        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) {
            seRvICElevEl = serviceLevel;
            log.warning("This test will NOT be conducted with a randomized serviceLevel value.  Testing with serviceLevel: " + seRvICElevEl);
        }
    }
    // END OF WORKAROUND
    // register with autosubscribe and a randomize case serviceLevel
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, seRvICElevEl, null, (List<String>) null, null, null, null, true, false, null, null, null, null);
    // assert that the installed ProductId is "Subscribed"
    InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", installedProductId, clienttasks.getCurrentlyInstalledProducts());
    Assert.assertEquals(installedProduct.status, "Subscribed", "After registering with autosubscribe and serviceLevel '" + seRvICElevEl + "' the following installed exempt product should be subscribed: " + installedProduct);
    // EXTRA CREDIT: assert that the consumed ProductSubscription that provides the installed exempt product is among the known exempt service levels.
    // WARNING: THIS MAY NOT BE AN APPROPRIATE ASSERTION WHEN THE EXEMPT PRODUCT HAPPENS TO ALSO BE PROVIDED BY A SUBSCRIPTION THAT COINCIDENTY PROVIDES ANOTHER INSTALLED PRODUCT
    List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    for (EntitlementCert entitlementCert : clienttasks.getCurrentEntitlementCerts()) {
        for (ProductNamespace productNamespace : entitlementCert.productNamespaces) {
            if (productNamespace.id.equals(installedProductId)) {
                BigInteger serialNumber = clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCert.file);
                ProductSubscription productSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("serialNumber", serialNumber, productSubscriptions);
                Assert.assertTrue(sm_exemptServiceLevelsInUpperCase.contains(productSubscription.serviceLevel.toUpperCase()), "Installed exempt product '" + installedProduct + "' is entitled by consumed productSubscription '" + productSubscription + "' that provides one of the exempt service levels '" + sm_exemptServiceLevelsInUpperCase + "'.");
            }
        }
    }
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) InstalledProduct(rhsm.data.InstalledProduct) ProductSubscription(rhsm.data.ProductSubscription) BigInteger(java.math.BigInteger) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) ProductNamespace(rhsm.data.ProductNamespace) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

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