Search in sources :

Example 71 with SubscriptionPool

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

the class ContentTests method testRedHatRepoFileDoesNotContainExcessiveBlankLines_DEPRECATED.

@Test(description = "verify redhat.repo file does not contain an excessive (more than two) number of successive blank lines", groups = { "Tier2Tests", "blockedByBug-737145" }, // Disabling... this test takes too long to execute.  VerifyRedHatRepoFileIsPurgedOfBlankLinesByYumPlugin_Test effectively provides the same test coverage.
enabled = false)
@Deprecated
public // @ImplementsNitrateTest(caseId=)
void testRedHatRepoFileDoesNotContainExcessiveBlankLines_DEPRECATED() {
    // successive blank lines in redhat.repo must not exceed N
    // (\n\s*){4,}
    int N = 2;
    // (\n\s*){4,}
    String regex = "(\\n\\s*){" + (N + 2) + ",}";
    String redhatRepoFileContents = "";
    // check for excessive blank lines after a new register
    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);
    // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
    client.runCommandAndWait("yum -q repolist --disableplugin=rhnplugin");
    redhatRepoFileContents = client.runCommandAndWait("cat " + clienttasks.redhatRepoFile).getStdout();
    Assert.assertContainsNoMatch(redhatRepoFileContents, regex, null, "At most '" + N + "' successive blank are acceptable inside " + clienttasks.redhatRepoFile);
    // check for excessive blank lines after subscribing to each pool
    for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        clienttasks.subscribe_(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
        // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
        client.runCommandAndWait("yum -q repolist --disableplugin=rhnplugin");
    }
    redhatRepoFileContents = client.runCommandAndWait("cat " + clienttasks.redhatRepoFile).getStdout();
    Assert.assertContainsNoMatch(redhatRepoFileContents, regex, null, "At most '" + N + "' successive blank are acceptable inside " + clienttasks.redhatRepoFile);
    // check for excessive blank lines after unsubscribing from each serial
    List<BigInteger> serialNumbers = new ArrayList<BigInteger>();
    for (ProductSubscription productSubscription : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
        // save some time by avoiding redundant unsubscribes
        if (serialNumbers.contains(productSubscription.serialNumber))
            continue;
        clienttasks.unsubscribe_(null, productSubscription.serialNumber, null, null, null, null, null);
        serialNumbers.add(productSubscription.serialNumber);
        // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
        client.runCommandAndWait("yum -q repolist --disableplugin=rhnplugin");
    }
    redhatRepoFileContents = client.runCommandAndWait("cat " + clienttasks.redhatRepoFile).getStdout();
    Assert.assertContainsNoMatch(redhatRepoFileContents, regex, null, "At most '" + N + "' successive blank are acceptable inside " + clienttasks.redhatRepoFile);
    // assert the comment heading is present
    // Assert.assertContainsMatch(redhatRepoFileContents,"^# Red Hat Repositories$",null,"Comment heading \"Red Hat Repositories\" was found inside "+clienttasks.redhatRepoFile);
    Assert.assertContainsMatch(redhatRepoFileContents, "^# Certificate-Based Repositories$", null, "Comment heading \"Certificate-Based Repositories\" was found inside " + clienttasks.redhatRepoFile);
    Assert.assertContainsMatch(redhatRepoFileContents, "^# Managed by \\(rhsm\\) subscription-manager$", null, "Comment heading \"Managed by (rhsm) subscription-manager\" was found inside " + clienttasks.redhatRepoFile);
}
Also used : ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) BigInteger(java.math.BigInteger) SubscriptionPool(rhsm.data.SubscriptionPool) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 72 with SubscriptionPool

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

the class ContentTests method getPackageFromEnabledRepoAndSubscriptionPoolDataAsListOfLists.

protected List<List<Object>> getPackageFromEnabledRepoAndSubscriptionPoolDataAsListOfLists() throws JSONException, Exception {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    if (!isSetupBeforeSuiteComplete)
        return ll;
    if (clienttasks == null)
        return ll;
    if (sm_clientUsername == null)
        return ll;
    if (sm_clientPassword == null)
        return ll;
    // get the currently installed product certs to be used when checking for conditional content tagging
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    // assure we are freshly registered and process all available subscription pools
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, ConsumerType.system, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null, null);
    for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        String quantity = null;
        // when the Suggested quantity is 0, let's specify a quantity to avoid Stdout: Quantity '1' is not a multiple of instance multiplier '2'
        if (pool.suggested != null)
            if (pool.suggested < 1)
                quantity = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "instance_multiplier");
        /*if (clienttasks.isPackageVersion("subscription-manager",">=","1.10.3-1"))*/
        File entitlementCertFile = clienttasks.subscribeToSubscriptionPool_(pool, quantity);
        Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to pool: " + pool);
        EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
        for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
            if (!contentNamespace.type.equalsIgnoreCase("yum"))
                continue;
            if (contentNamespace.enabled && clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
                String repoLabel = contentNamespace.label;
                // find an available package that is uniquely provided by repo
                String pkg = clienttasks.findUniqueAvailablePackageFromRepo(repoLabel);
                if (pkg == null) {
                    log.warning("Could NOT find a unique available package from repo '" + repoLabel + "' after subscribing to SubscriptionPool: " + pool);
                }
                // String availableGroup, String installedGroup, String repoLabel, SubscriptionPool pool, String quantity
                ll.add(Arrays.asList(new Object[] { pkg, repoLabel, pool, quantity }));
            }
        }
        clienttasks.unsubscribeFromSerialNumber(clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCertFile));
        // minimize the number of dataProvided rows (useful during automated testcase development)
        if (Boolean.valueOf(getProperty("sm.debug.dataProviders.minimize", "false")))
            break;
    }
    return ll;
}
Also used : ContentNamespace(rhsm.data.ContentNamespace) EntitlementCert(rhsm.data.EntitlementCert) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JSONObject(org.json.JSONObject) ProductCert(rhsm.data.ProductCert) SubscriptionPool(rhsm.data.SubscriptionPool) File(java.io.File)

Example 73 with SubscriptionPool

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

the class ContentTests method testSubscribabilityOfSKUProvidingA185ContentSetProduct.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36652", "RHEL7-51484" }, 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 that a 185 content set product subscription is always subscribable", groups = { "Tier2Tests", "SubscribabilityOfContentSetProduct_Tests", "blockedByBug-871146", "blockedByBug-905546" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSubscribabilityOfSKUProvidingA185ContentSetProduct() {
    Map<String, String> factsMap = new HashMap<String, String>();
    File entitlementCertFile;
    EntitlementCert entitlementCert;
    String systemCertificateVersionFactValue;
    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);
    SubscriptionPool pool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", subscriptionSKUProvidingA185ContentSetProduct, clienttasks.getCurrentlyAvailableSubscriptionPools());
    Assert.assertNotNull(pool, "Found an available pool to subscribe to productId '" + subscriptionSKUProvidingA185ContentSetProduct + "': " + pool);
    // test that it IS subscribable when system.certificate_version: None
    factsMap.put("system.certificate_version", null);
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.facts(null, true, null, null, null, null);
    Assert.assertEquals(clienttasks.getFactValue("system.certificate_version"), "None", "When the system.certificate_version fact is null, its fact value is reported as 'None'.");
    // entitlementCertFile = clienttasks.subscribeToProductId(skuTo185ContentSetProduct);
    // entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
    clienttasks.subscribe(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
    entitlementCert = clienttasks.getEntitlementCertCorrespondingToSubscribedPool(pool);
    entitlementCertFile = clienttasks.getEntitlementCertFileFromEntitlementCert(entitlementCert);
    Assert.assertEquals(entitlementCert.version, "1.0", "When the system.certificate_version fact is null, the version of the entitlement certificate granted by candlepin is '1.0'.");
    Assert.assertEquals(entitlementCert.contentNamespaces.size(), 185, "The number of content sets provided in the version 1.0 entitlement cert parsed using the rct cat-cert tool.");
    entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFileUsingOpensslX509(entitlementCertFile);
    Assert.assertEquals(entitlementCert.contentNamespaces.size(), 185, "The number of content sets provided in this version '" + entitlementCert.version + "' entitlement cert parsed using the openssl x509 tool.");
    clienttasks.assertEntitlementCertsInYumRepolist(Arrays.asList(entitlementCert), true);
    // clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    clienttasks.unsubscribeFromSerialNumber(clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCertFile));
    // test that it IS subscribable when system.certificate_version: 1.0
    factsMap.put("system.certificate_version", "1.0");
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.facts(null, true, null, null, null, null);
    Assert.assertEquals(clienttasks.getFactValue("system.certificate_version"), "1.0", "When the system.certificate_version fact is 1.0, its fact value is reported as '1.0'.");
    // entitlementCertFile = clienttasks.subscribeToProductId(skuTo185ContentSetProduct);
    // entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
    clienttasks.subscribe(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
    entitlementCert = clienttasks.getEntitlementCertCorrespondingToSubscribedPool(pool);
    entitlementCertFile = clienttasks.getEntitlementCertFileFromEntitlementCert(entitlementCert);
    Assert.assertEquals(entitlementCert.version, "1.0", "When the system.certificate_version fact is 1.0, the version of the entitlement certificate granted by candlepin is '1.0'.");
    Assert.assertEquals(entitlementCert.contentNamespaces.size(), 185, "The number of content sets provided in the version 1.0 entitlement cert parsed using the rct cat-cert tool.");
    entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFileUsingOpensslX509(entitlementCertFile);
    Assert.assertEquals(entitlementCert.contentNamespaces.size(), 185, "The number of content sets provided in this version '" + entitlementCert.version + "' entitlement cert parsed using the openssl x509 tool.");
    clienttasks.assertEntitlementCertsInYumRepolist(Arrays.asList(entitlementCert), true);
    // clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    clienttasks.unsubscribeFromSerialNumber(clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCertFile));
    // test that it IS subscribable when system.certificate_version is the system's default value (should be >=3.0)
    clienttasks.deleteFactsFileWithOverridingValues();
    systemCertificateVersionFactValue = clienttasks.getFactValue("system.certificate_version");
    Assert.assertTrue(Float.valueOf(systemCertificateVersionFactValue) >= 3.0, "The actual default system.certificate_version fact '" + systemCertificateVersionFactValue + "' is >= 3.0.");
    // entitlementCertFile = clienttasks.subscribeToProductId(skuTo185ContentSetProduct);
    // entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
    clienttasks.subscribe(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
    entitlementCert = clienttasks.getEntitlementCertCorrespondingToSubscribedPool(pool);
    entitlementCertFile = clienttasks.getEntitlementCertFileFromEntitlementCert(entitlementCert);
    // TOO ASSERTIVE  Assert.assertTrue(Float.valueOf(entitlementCert.version)<=Float.valueOf(systemCertificateVersionFactValue),"The version of the entitlement certificate '"+entitlementCert.version+"' granted by candlepin is less than or equal to the system.certificate_version '"+systemCertificateVersionFactValue+"' which indicates the maximum certificate version this system knows how to handle.");	// This assert was too assertive according to https://bugzilla.redhat.com/show_bug.cgi?id=1425236#c2
    // Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1425236#c2
    Assert.assertEquals(Float.valueOf(entitlementCert.version).intValue(), Float.valueOf(systemCertificateVersionFactValue).intValue(), "The major value of the entitlement certificate '" + entitlementCert.version + "' granted by candlepin matches the major value of the system.certificate_version '" + systemCertificateVersionFactValue + "' which indicates certificate compatibility.");
    Assert.assertEquals(entitlementCert.contentNamespaces.size(), 185, "The number of content sets provided in this version '" + entitlementCert.version + "' entitlement cert parsed using the rct cat-cert tool.");
    clienttasks.assertEntitlementCertsInYumRepolist(Arrays.asList(entitlementCert), true);
    // clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    clienttasks.unsubscribeFromSerialNumber(clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCertFile));
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) HashMap(java.util.HashMap) File(java.io.File) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 74 with SubscriptionPool

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

the class ContentTests method testRhelSubscriptionContentIsAvailable.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20084", "RHEL7-55189" }, 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 = "Verify that all there is at least one available RHEL subscription and that yum content is available for the installed RHEL product cert", groups = { "Tier1Tests", "FipsTests", "blockedByBug-1156638" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRhelSubscriptionContentIsAvailable() throws JSONException, Exception {
    // TEMPORARY WORKAROUND
    if (clienttasks.arch.equals("ppc64le")) {
        boolean invokeWorkaroundWhileBugIsOpen = true;
        // Bug 1156638 - "Red Hat Enterprise Linux for IBM POWER" subscriptions need to provide content for arch "ppc64le"
        String bugId = "1156638";
        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) {
            throw new SkipException("Skipping this test on arch '" + clienttasks.arch + "' while blocking bug '" + bugId + "' is open.");
        }
    }
    // END OF WORKAROUND
    // get the currently installed RHEL product cert
    ProductCert rhelProductCert = clienttasks.getCurrentRhelProductCert();
    Assert.assertNotNull(rhelProductCert, "Expecting a RHEL Product Cert to be installed.");
    log.info("RHEL product cert installed: " + rhelProductCert);
    // register and make sure autoheal is off
    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);
    // verify that NO yum content is available since no entitlements have been granted
    Integer yumRepolistPackageCount = clienttasks.getYumRepolistPackageCount("enabled");
    // added only for debugging a failure
    if (yumRepolistPackageCount > 0)
        clienttasks.list_(null, null, true, null, null, null, null, null, null, null, null, null, null, null);
    Assert.assertEquals(yumRepolistPackageCount, new Integer(0), "Expecting no available packages (actual='" + yumRepolistPackageCount + "') because no RHEL subscription have been explicitly attached.");
    // loop through the available pools looking for those that provide content for this rhelProductCert
    boolean rhelYumContentIsAvailable = true;
    boolean rhelSubscriptionIsAvailable = false;
    for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        if (CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId).contains(rhelProductCert.productId)) {
            // subscribe
            EntitlementCert rhelEntitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(clienttasks.subscribeToSubscriptionPool(pool, sm_clientUsername, sm_clientPassword, sm_serverUrl));
            // Brand Name:
            if (rhelProductCert.productId.equals("261") && clienttasks.arch.equals("aarch64")) {
                boolean invokeWorkaroundWhileBugIsOpen = true;
                String bugId = "1174966";
                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) {
                    String enablerepo = "rhel-server-for-arm-development-preview-rpms";
                    log.info("Explicitly enabling repo '" + enablerepo + "' to gain access to ARM content.");
                    clienttasks.repos(null, null, null, enablerepo, null, null, null, null, null);
                }
            }
            // WORKAROUND FOR RHEL-ALT-7.5 aarch64
            if (clienttasks.redhatReleaseXY.equals("7.5") && rhelProductCert.productId.equals("433")) {
                // Red Hat Enterprise Linux for IBM System z (Structure A) Beta
                String repo = "rhel-7-for-system-z-a-beta-rpms";
                log.info("WORKAROUND: Enabling beta repo '" + repo + "' for installed product '" + rhelProductCert.productName + "' (" + rhelProductCert.productId + ") because this is the debut release for this product.  No GA content from repo rhel-7-for-system-z-a-rpms is available yet.");
                clienttasks.repos(null, null, null, repo, null, null, null, null, null);
            }
            // END OF WORKAROUND
            // verify that rhel yum content is available
            yumRepolistPackageCount = clienttasks.getYumRepolistPackageCount("enabled");
            if (yumRepolistPackageCount > 0) {
                Assert.assertTrue(yumRepolistPackageCount > 0, "Expecting many available packages (actual='" + yumRepolistPackageCount + "') of enabled repo content because RHEL subscription '" + pool.subscriptionName + "' SKU '" + pool.productId + "' was just attached.");
            } else {
                log.warning("No enabled yum repo content packages are available after attaching RHEL subscription '" + pool.subscriptionName + "'. (This can happen when the RHEL product is brand new and content has not yet been pushed to '" + clienttasks.baseurl + "')");
                rhelYumContentIsAvailable = false;
            }
            // unsubscribe
            clienttasks.unsubscribe(null, rhelEntitlementCert.serialNumber, null, null, null, null, null);
            rhelSubscriptionIsAvailable = true;
            if (rhelYumContentIsAvailable)
                break;
        }
    }
    if (!rhelSubscriptionIsAvailable && sm_serverType.equals(CandlepinType.standalone))
        throw new SkipException("Skipping this test against a standalone Candlepin server that has no RHEL subscriptions available.");
    // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1090058
    if (clienttasks.redhatReleaseX.equals("5") && clienttasks.arch.startsWith("ppc")) {
        boolean invokeWorkaroundWhileBugIsOpen = true;
        String bugId = "1090058";
        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) {
            if (!rhelSubscriptionIsAvailable)
                throw new SkipException("skipping this test while bug '" + bugId + "' is open");
        }
    }
    if (!rhelSubscriptionIsAvailable) {
        clienttasks.facts_(true, null, null, null, null, null);
        log.warning("This test is about to fail and may be due to the lack of an available subscription with enough socket/ram/core support to cover this system.  Visually confirm by reviewing the system facts above.");
    }
    Assert.assertTrue(rhelSubscriptionIsAvailable, "Successfully subscribed to at least one available RHEL subscription that provided for our installed RHEL product cert: " + rhelProductCert);
    Assert.assertTrue(rhelYumContentIsAvailable, "All of the RHEL subscriptions subscribed provided at least one enabled yum content package applicable for our installed RHEL product cert: " + rhelProductCert + " (See WARNINGS logged above for failed subscriptions)");
}
Also used : BigInteger(java.math.BigInteger) EntitlementCert(rhsm.data.EntitlementCert) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 75 with SubscriptionPool

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

the class ContentTests method getAllAvailableSubscriptionPoolsProvidingArchBasedContentDataAsListOfLists.

protected List<List<Object>> getAllAvailableSubscriptionPoolsProvidingArchBasedContentDataAsListOfLists() throws JSONException, Exception {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    String ownerKey = null;
    JSONObject jsonStatus = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(/*authenticator*/
    null, /*password*/
    null, sm_serverUrl, "/status"));
    for (List<Object> l : getAllAvailableSubscriptionPoolsDataAsListOfLists()) {
        SubscriptionPool pool = (SubscriptionPool) l.get(0);
        if (ownerKey == null)
            ownerKey = clienttasks.getCurrentlyRegisteredOwnerKey();
        for (String providedProductId : CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId)) {
            // get the product
            String path = "/products/" + providedProductId;
            // starting with candlepin-2.0.11 /products/<ID> are requested by /owners/<KEY>/products/<ID> OR /products/<UUID>
            if (SubscriptionManagerTasks.isVersion(jsonStatus.getString("version"), ">=", "2.0.11"))
                path = "/owners/" + ownerKey + path;
            JSONObject jsonProduct = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, path));
            // get the provided product contents
            JSONArray jsonProductContents = jsonProduct.getJSONArray("productContent");
            for (int j = 0; j < jsonProductContents.length(); j++) {
                JSONObject jsonProductContent = (JSONObject) jsonProductContents.get(j);
                JSONObject jsonContent = jsonProductContent.getJSONObject("content");
                // is this arch-based content?
                if (jsonContent.has("arches") && !jsonContent.isNull("arches")) {
                    if (!ll.contains(l)) {
                        // add this row only once
                        ll.add(l);
                    }
                    break;
                }
            }
        }
    }
    return ll;
}
Also used : JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) List(java.util.List) JSONObject(org.json.JSONObject) SubscriptionPool(rhsm.data.SubscriptionPool)

Aggregations

SubscriptionPool (rhsm.data.SubscriptionPool)195 Test (org.testng.annotations.Test)155 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)137 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)112 SkipException (org.testng.SkipException)90 ArrayList (java.util.ArrayList)87 JSONObject (org.json.JSONObject)66 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)53 ProductSubscription (rhsm.data.ProductSubscription)38 BigInteger (java.math.BigInteger)37 File (java.io.File)34 List (java.util.List)33 EntitlementCert (rhsm.data.EntitlementCert)33 HashMap (java.util.HashMap)32 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)28 InstalledProduct (rhsm.data.InstalledProduct)25 ProductCert (rhsm.data.ProductCert)24 JSONArray (org.json.JSONArray)22 Calendar (java.util.Calendar)12 GregorianCalendar (java.util.GregorianCalendar)11