Search in sources :

Example 11 with ProductNamespace

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

the class ListTests method EnsureListConsumedMatchesProductsListedInTheEntitlementCerts_Test_DEPRECATED.

@Test(description = "subscription-manager: list of consumed entitlements should display consumed product marketing name", groups = { "Tier2Tests" }, dataProvider = "getAllEntitlementCertsData", // this test implementation is no longer valid after the change in format for consumed product subscriptions (from many to one) - see bug 806986
enabled = false)
@Deprecated
@ImplementsNitrateTest(caseId = 48092, fromPlan = 2481)
public void EnsureListConsumedMatchesProductsListedInTheEntitlementCerts_Test_DEPRECATED(EntitlementCert entitlementCert) {
    // assert: The list of consumed products matches the products listed in the entitlement cert
    List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    List<ProductSubscription> productSubscriptionsWithMatchingSerialNumber = ProductSubscription.findAllInstancesWithMatchingFieldFromList("serialNumber", entitlementCert.serialNumber, productSubscriptions);
    // Assert.assertTrue(productSubscriptionsWithMatchingSerialNumber.size()>0, "Found consumed product subscription(s) whose SerialNumber matches this entitlement cert: "+entitlementCert);
    // Assert.assertEquals(productSubscriptionsWithMatchingSerialNumber.size(),entitlementCert.productNamespaces.size(), "Found consumed product subscription(s) for each of the bundleProducts (total of '"+entitlementCert.productNamespaces.size()+"' expected) whose SerialNumber matches this entitlement cert: "+entitlementCert);
    // when there are 0 bundledProducts, we are still consuming 1 ProductSubscription
    int productSubscriptionsWithMatchingSerialNumberSizeExpected = entitlementCert.productNamespaces.size() == 0 ? 1 : entitlementCert.productNamespaces.size();
    Assert.assertEquals(productSubscriptionsWithMatchingSerialNumber.size(), productSubscriptionsWithMatchingSerialNumberSizeExpected, "Found consumed product subscription(s) for each of the bundleProducts (total of '" + productSubscriptionsWithMatchingSerialNumberSizeExpected + "' expected) whose SerialNumber matches this entitlement cert: " + entitlementCert);
    for (ProductNamespace productNamespace : entitlementCert.productNamespaces) {
        List<ProductSubscription> matchingProductSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("productName", productNamespace.name, productSubscriptionsWithMatchingSerialNumber);
        Assert.assertEquals(matchingProductSubscriptions.size(), 1, "Found one bundledProduct name '" + productNamespace.name + "' in the list of consumed product subscriptions whose SerialNumber matches this entitlement cert: " + entitlementCert);
        ProductSubscription correspondingProductSubscription = matchingProductSubscriptions.get(0);
        log.info("We are about to assert that this consumed Product Subscription: " + correspondingProductSubscription);
        log.info("...represents this ProductNamespace: " + productNamespace);
        log.info("...corresponding to this OrderNamespace: " + entitlementCert.orderNamespace);
        log.info("...from this EntitlementCert: " + entitlementCert);
        Assert.assertEquals(correspondingProductSubscription.productName, productNamespace.name, "productName from ProductSubscription in list --consumed matches productName from ProductNamespace in EntitlementCert.");
        Assert.assertEquals(correspondingProductSubscription.contractNumber, entitlementCert.orderNamespace.contractNumber, "contractNumber from ProductSubscription in list --consumed matches contractNumber from OrderNamespace in EntitlementCert.");
        Assert.assertEquals(correspondingProductSubscription.accountNumber, entitlementCert.orderNamespace.accountNumber, "accountNumber from ProductSubscription in list --consumed matches accountNumber from OrderNamespace in EntitlementCert.");
        Assert.assertEquals(correspondingProductSubscription.serialNumber, entitlementCert.serialNumber, "serialNumber from ProductSubscription in list --consumed matches serialNumber from EntitlementCert.");
        Calendar now = Calendar.getInstance();
        if (now.after(entitlementCert.orderNamespace.startDate) && now.before(entitlementCert.orderNamespace.endDate)) {
            Assert.assertTrue(correspondingProductSubscription.isActive, "isActive is True when the current time (" + EntitlementCert.formatDateString(now) + ") is between the start/end dates in the EntitlementCert: " + entitlementCert);
        } else {
            Assert.assertFalse(correspondingProductSubscription.isActive, "isActive is False when the current time (" + EntitlementCert.formatDateString(now) + ") is NOT between the start/end dates in the EntitlementCert: " + entitlementCert);
        }
        // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=660713 - jsefler 12/12/2010
        Boolean invokeWorkaroundWhileBugIsOpen = true;
        try {
            String bugId = "660713";
            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("The workaround while this bug is open is to skip the assertion that: startDates and endDates match");
        } else {
            // END OF WORKAROUND
            Assert.assertEquals(ProductSubscription.formatDateString(correspondingProductSubscription.startDate), ProductSubscription.formatDateString(entitlementCert.orderNamespace.startDate), "startDate from ProductSubscription in list --consumed matches startDate from OrderNamespace (" + OrderNamespace.formatDateString(entitlementCert.orderNamespace.startDate) + ") after conversion from GMT in EntitlementCert to local time.");
            Assert.assertEquals(ProductSubscription.formatDateString(correspondingProductSubscription.endDate), ProductSubscription.formatDateString(entitlementCert.orderNamespace.endDate), "endDate from ProductSubscription in list --consumed matches endDate from OrderNamespace (" + OrderNamespace.formatDateString(entitlementCert.orderNamespace.endDate) + ") after conversion from GMT in EntitlementCert to local time.");
        }
    }
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ProductSubscription(rhsm.data.ProductSubscription) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) ProductNamespace(rhsm.data.ProductNamespace) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 12 with ProductNamespace

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

the class ManifestTests method verifyRCTCatManifestWithOptions.

protected void verifyRCTCatManifestWithOptions(File manifestFile, List<String> options) throws Exception {
    // flatten the list of options into a single string for the runCommand
    String optionsAsString = " ";
    if (options != null)
        for (String option : options) optionsAsString += option + " ";
    // execute and assert rct cat-manifest MANIFEST_FILE
    SSHCommandResult catManifestResult = RemoteFileTasks.runCommandAndAssert(client, "rct cat-manifest" + optionsAsString + manifestFile, 0);
    // parse the output from catManifestResult into a Manifest object
    List<Manifest> catManifests = Manifest.parse(catManifestResult.getStdout());
    Assert.assertEquals(catManifests.size(), 1, "Parsed one manifest from '" + manifestFile + "'.");
    Manifest catManifest = catManifests.get(0);
    // create EntitlementCert objects representing the source for all of the entitlements provided by this manifest
    if (manifestFileContentMap.get(manifestFile) == null)
        throw new SkipException("Cannot execute this test until manifest file '" + manifestFile + "' has been successfully dumped.");
    client.runCommandAndWaitWithoutLogging("find " + manifestFileContentMap.get(manifestFile).get(0).getParent() + "/export/entitlement_certificates" + " -regex \"/.+/[0-9]+.pem\" -exec rct cat-cert {} \\;");
    String rawCertificates = client.getStdout();
    List<EntitlementCert> entitlementCerts = EntitlementCert.parse(rawCertificates);
    if (entitlementCerts.isEmpty())
        Assert.fail("Manifest file '" + manifestFile + "' does not provide any entitlements.");
    // loop through the manifest's entitlement certs and assert as much as possible...
    // [root@jsefler-7 test-manifests]# rct cat-manifest manifest_SYS0395_RH0197181.zip
    // 
    // +-------------------------------------------+
    // Manifest
    // +-------------------------------------------+
    String bannerRegex = "\\+-+\\+\\n\\s*Manifest\\s*\\n\\+-+\\+";
    Assert.assertTrue(Pattern.compile(".*" + bannerRegex + ".*", Pattern.DOTALL).matcher(catManifestResult.getStdout()).matches(), "stdout from rct cat-manifest contains a banner matching regex '" + bannerRegex + "'.");
    if (catManifest.server == null) {
        log.warning("Skipping assertion of non-null General and Consumer for what appears to be a manifest from an older candlepin server");
    } else {
        // 
        // General:
        // Server: access.stage.redhat.com/management/distributors/
        // Server Version: 0.7.13.10-1
        // Date Created: 2013-01-21T21:24:16.193+0000
        // Creator: qa@redhat.com
        Assert.assertNotNull(catManifest.server, "General Server value is not null.");
        Assert.assertNotNull(catManifest.serverVersion, "General Server Version value is not null.");
        Assert.assertNotNull(catManifest.dateCreated, "General Date Created value is not null.");
        Assert.assertNotNull(catManifest.creator, "General Creator value is not null.");
        // 
        // Consumer:
        // Name: jsefler
        // UUID: b2837b9a-d2d9-4b41-acd9-34bdcf72af66
        // Type: sam
        Assert.assertNotNull(catManifest.consumerName, "Consumer Name value is not null.");
        Assert.assertNotNull(catManifest.consumerUUID, "Consumer UUID value is not null.");
        String consumerUUIDRegex = "[a-f,0-9,\\-]{36}";
        Assert.assertTrue(Pattern.compile(consumerUUIDRegex).matcher(catManifest.consumerUUID).matches(), "Consumer UUID format matches the expected regex '" + consumerUUIDRegex + "'.");
        Assert.assertNotNull(catManifest.consumerType, "Consumer Type value is not null.");
        // TODO learn why there is a type distinction
        Assert.assertTrue(catManifest.consumerType.equals("sam") || catManifest.consumerType.equals("cloudforms") || catManifest.consumerType.equals("satellite"), "Actual Consumer Type value '" + catManifest.consumerType + "' equals \"sam\" or \"cloudforms' or \"satellite\".");
        // Content Access Mode: entitlement
        if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.19.6-1")) {
            Assert.assertNotNull(catManifest.consumerContentAccessMode, "Consumer Content Access Mode value is not null.");
            Assert.assertTrue(catManifest.consumerContentAccessMode.equals("entitlement") || catManifest.consumerContentAccessMode.equals("org_environment"), "Actual Consumer Content Access Mode value '" + catManifest.consumerContentAccessMode + "' equals \"entitlement\" or \"org_environment\".");
            if (SubscriptionManagerTasks.isVersion(catManifest.serverVersion, "<", "2.0.22-1")) {
                // candlepin commit 18c20d0a1530910d5ca45fecb59f8f7db5e9a04f Golden Ticket
                Assert.assertEquals(catManifest.consumerContentAccessMode, "entitlement", "Since this manifest was created by candlepin version prior to \"2.0.22-1\", the Consumer's Content Access Mode value must be the default value.");
            }
        }
    }
    // /content/beta/rhel/power/5/$releasever/$basearch/highavailability/source/SRPMS
    for (EntitlementCert entitlementCert : entitlementCerts) {
        ManifestSubscription manifestSubscription = ManifestSubscription.findFirstInstanceWithMatchingFieldFromList("certificateFile", entitlementCert.file.toString().replace(manifestFileContentMap.get(manifestFile).get(0).getParent() + File.separator, ""), catManifest.subscriptions);
        if (manifestSubscription == null)
            Assert.fail("Could not find the ManifestSubscription corresponding to Entitlement '" + entitlementCert.file + "'.");
        Assert.assertEquals(manifestSubscription.name, entitlementCert.orderNamespace.productName, "Subscription Name value comes from entitlementCert.orderNamespace.productName");
        Assert.assertEquals(manifestSubscription.quantity, entitlementCert.orderNamespace.quantityUsed, "Subscription Quantity value comes from entitlementCert.orderNamespace.quantityUsed (ASSUMING NO OTHER UPSTREAM CONSUMERS)");
        // TODO assert Created:
        Assert.assertEquals(manifestSubscription.startDate, entitlementCert.validityNotBefore, "Subscription Start Date comes from entitlementCert.validityNotBefore");
        Assert.assertEquals(manifestSubscription.endDate, entitlementCert.validityNotAfter, "Subscription End Date comes from entitlementCert.validityNotAfter");
        Assert.assertEquals(manifestSubscription.supportLevel, entitlementCert.orderNamespace.supportLevel, "Subscription Service Level value comes from entitlementCert.orderNamespace.supportLevel");
        Assert.assertEquals(manifestSubscription.supportType, entitlementCert.orderNamespace.supportType, "Subscription Service Type value comes from entitlementCert.orderNamespace.supportType");
        List<String> actualArchitectures = new ArrayList<String>();
        if (manifestSubscription.architectures != null)
            actualArchitectures.addAll(Arrays.asList(manifestSubscription.architectures.split("\\s*,\\s*")));
        List<String> expectedArchitectures = new ArrayList<String>();
        for (ProductNamespace productNamespace : entitlementCert.productNamespaces) if (productNamespace.arch != null)
            expectedArchitectures.addAll(Arrays.asList(productNamespace.arch.split("\\s*,\\s*")));
        // BAD ASSERT SEE https://bugzilla.redhat.com/show_bug.cgi?id=914799#c3 Assert.assertTrue(actualArchitectures.containsAll(expectedArchitectures)&&expectedArchitectures.containsAll(actualArchitectures), "Subscription Architectures contains the union of providedProduct arches: "+expectedArchitectures);
        Assert.assertEquals(manifestSubscription.productId, entitlementCert.orderNamespace.productId, "Subscription SKU value comes from entitlementCert.orderNamespace.productId");
        Assert.assertEquals(manifestSubscription.contract, entitlementCert.orderNamespace.contractNumber, "Subscription Contract value comes from entitlementCert.orderNamespace.contractNumber");
        Assert.assertEquals(manifestSubscription.subscriptionId, entitlementCert.orderNamespace.orderNumber, "Subscription Order Number value comes from entitlementCert.orderNamespace.orderNumber");
        // TODO assert Entitlement File in json format
        Assert.assertTrue(entitlementCert.file.toString().endsWith(manifestSubscription.certificateFile), "Subscription Certificate File exists");
        Assert.assertEquals(manifestSubscription.certificateVersion, entitlementCert.version, "Subscription Certificate Version value comes from entitlementCert.version");
        List<String> actualProvidedProducts = manifestSubscription.providedProducts;
        List<String> actualDerivedProducts = manifestSubscription.derivedProducts;
        if (false) {
            // This assertion was valid prior to the invention of data center skus that provide no products but do provide derived products to be added to a sub-pool
            List<String> expectedProvidedProducts = new ArrayList<String>();
            for (ProductNamespace productNamespace : entitlementCert.productNamespaces) expectedProvidedProducts.add(String.format("%s: %s", productNamespace.id, productNamespace.name));
            Assert.assertTrue(actualProvidedProducts.containsAll(expectedProvidedProducts) && expectedProvidedProducts.containsAll(actualProvidedProducts), "Manifest Subscription '" + manifestSubscription.name + "' Provided Products " + actualProvidedProducts + " contains all entitlementCert.productNamespaces=>\"id: name\": " + expectedProvidedProducts);
        } else {
            // Instead, let's assume the following assertion is correct... TODO confirm with dev
            // Note: this assertion can only be tested against manifests with data center skus using subscription-manager-1.18.6-1 and higher
            List<String> expectedProducts = new ArrayList<String>();
            for (ProductNamespace productNamespace : entitlementCert.productNamespaces) expectedProducts.add(String.format("%s: %s", productNamespace.id, productNamespace.name));
            if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.18.6-1")) {
                // subscription-manager commit 23c149907852767e51e7ddea8edf506697827203  Bug 1388207 - [RFE] rct cat-manifest command should show derived products
                List<String> actualProvidedAndDerivedProducts = new ArrayList<String>();
                for (String product : actualProvidedProducts) if (!actualProvidedAndDerivedProducts.contains(product))
                    actualProvidedAndDerivedProducts.add(product);
                for (String product : actualDerivedProducts) if (!actualProvidedAndDerivedProducts.contains(product))
                    actualProvidedAndDerivedProducts.add(product);
                Assert.assertTrue(actualProvidedAndDerivedProducts.containsAll(expectedProducts) && expectedProducts.containsAll(actualProvidedAndDerivedProducts), "The union of all Provided Products " + actualProvidedProducts + " and Derived Products " + actualDerivedProducts + " from manifest Subscription '" + manifestSubscription.name + "' contains all entitlementCert.productNamespaces=>\"id: name\": " + expectedProducts);
            } else {
                log.info("Cannot assert that the union of all provided and derived products from manifest Subscription '" + manifestSubscription.name + "' are represented in this entitlementCert.productNamespaces=>\"id: name\": " + expectedProducts + " because RFE Bug 1388207 is not present in this version of subscription-manager.");
                log.info("We can only assert that the provided products from manifest Subscription '" + manifestSubscription.name + "' are a subset of this entitlementCert.productNamespaces=>\"id: name\": " + expectedProducts + " because RFE Bug 1388207 is not present in this version of subscription-manager to account for derived products.");
                Assert.assertTrue(expectedProducts.containsAll(actualProvidedProducts), "The Provided Products " + actualProvidedProducts + " from manifest Subscription '" + manifestSubscription.name + "' are a subset of all entitlementCert.productNamespaces=>\"id: name\": " + expectedProducts);
            }
        }
        List<String> actualContentSets = new ArrayList<String>();
        if (manifestSubscription.contentSets != null)
            actualContentSets.addAll(manifestSubscription.contentSets);
        List<String> expectedContentSets = new ArrayList<String>();
        for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) expectedContentSets.add(contentNamespace.downloadUrl);
        if (options != null && options.contains("--no-content")) {
            Assert.assertNull(manifestSubscription.contentSets, "The cat-manifest report does not include any Subscription Content Sets when the '--no-content' option is specified.");
        } else {
            Assert.assertTrue(actualContentSets.containsAll(expectedContentSets) && expectedContentSets.containsAll(actualContentSets), "Subscription Content Sets contains all entitlementCert.contentNamespaces=>downloadUrl: (too long to print)");
        }
    }
}
Also used : ContentNamespace(rhsm.data.ContentNamespace) EntitlementCert(rhsm.data.EntitlementCert) ManifestSubscription(rhsm.data.ManifestSubscription) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) SkipException(org.testng.SkipException) Manifest(rhsm.data.Manifest) ProductNamespace(rhsm.data.ProductNamespace)

Example 13 with ProductNamespace

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

the class SubscribeTests method testSubscribeToSubscriptionPoolProductId.

// Test methods ***********************************************************************
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19980", "RHEL7-33092" }, 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")
@// ; and assert the subscription pool is not available when it does not match the system hardware.",
Test(// ; and assert the subscription pool is not available when it does not match the system hardware.",
description = "subscription-manager-cli: subscribe consumer to subscription pool product id", dataProvider = "getAllSystemSubscriptionPoolProductData", groups = { "Tier1Tests", "blockedByBug-660713", "blockedByBug-806986", "blockedByBug-878986", "blockedByBug-962520", "blockedByBug-1008647", "blockedByBug-1009600", "blockedByBug-996993" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSubscribeToSubscriptionPoolProductId(String productId, JSONArray bundledProductDataAsJSONArray) throws Exception {
    // /*debugTesting*/ if (!productId.equals("awesomeos-ul-quantity-virt")) throw new SkipException("debugTesting - Automator should comment out this line.");
    // /*debugTesting*/ if (!productId.equals("awesomeos-onesocketib")) throw new SkipException("debugTesting - Automator should comment out this line.");
    // /*debugTesting*/ if (!productId.equals("awesomeos-virt-4")) throw new SkipException("debugTesting - Automator should comment out this line.");
    // /*debugTesting*/ if (!productId.equals("awesomeos-virt-4")&&!productId.equals("awesomeos-ul-quantity-virt")&&!productId.equals("awesomeos-onesocketib")&&!productId.equals("awesomeos-instancebased")) throw new SkipException("debugTesting - Automator should comment out this line.");
    // /*debugTesting*/ if (!productId.equals("2cores-2ram-multiattr")) throw new SkipException("debugTesting - Automator should comment out this line.");
    // /*debugTesting*/ if (!productId.equals("RH0380468")) throw new SkipException("debugTesting - Automator should comment out this line.");
    // /*debugTesting*/ if (!productId.equals("RH00284")) throw new SkipException("debugTesting - Automator should comment out this line.");
    // /*debugTesting*/ if (!productId.equals("awesomeos-super-hypervisor")) throw new SkipException("debugTesting - Automator should comment out this line.");
    // /*debugTesting*/ if (!productId.equals("MCT3115")) throw new SkipException("debugTesting - Automator should comment out this line.");
    // is this system a virtual guest system or a physical system
    boolean systemIsGuest = Boolean.valueOf(clienttasks.getFactValue("virt.is_guest"));
    // begin test with a fresh register
    clienttasks.unregister(null, null, null, null);
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    // assert the subscription pool with the matching productId is available
    // clienttasks.getCurrentlyAvailableSubscriptionPools() is tested at the conclusion of this test
    SubscriptionPool pool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", productId, clienttasks.getCurrentlyAllAvailableSubscriptionPools());
    // special case...
    if (pool == null) {
        // when pool is null, another likely cause is that all of the available subscriptions from the pools are being consumed, let's check...
        for (String poolId : CandlepinTasks.getPoolIdsForProductId(sm_clientUsername, sm_clientPassword, sm_serverUrl, clienttasks.getCurrentlyRegisteredOwnerKey(), productId)) {
            int quantity = (Integer) CandlepinTasks.getPoolValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, poolId, "quantity");
            int consumed = (Integer) CandlepinTasks.getPoolValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, poolId, "consumed");
            if (consumed >= quantity) {
                throw new SkipException("The total quantity '" + quantity + "' of subscriptions from poolId '" + poolId + "' for product '" + productId + "' are being consumed; hence this product subscription is appropriately not available to subscribe.");
            }
        }
    }
    Assert.assertNotNull(pool, "Expected SubscriptionPool with ProductId '" + productId + "' is available for subscribing.");
    // assemble a list of expected bundled product names
    List<String> bundledProductNames = new ArrayList<String>();
    for (int j = 0; j < bundledProductDataAsJSONArray.length(); j++) {
        JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductDataAsJSONArray.get(j);
        String bundledProductId = bundledProductAsJSONObject.getString("productId");
        String bundledProductName = bundledProductAsJSONObject.getString("productName");
        bundledProductNames.add(bundledProductName);
    }
    // TEMPORARY WORKAROUND
    boolean invokeWorkaroundWhileBugIsOpen = true;
    // Bug 1016300 - the "Provides:" field in subscription-manager list --available should exclude "MKT" products.
    String bugId = "1016300";
    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("While bug '" + bugId + "' is open, skip assertion that the actual list of SubscriptionPool provided product names " + pool.provides + " matches the expected list of bundledProductDataNames " + bundledProductNames + ".");
    } else /*if (clienttasks.isPackageVersion("subscription-manager",">=","1.10.3-1"))*/
    if (pool.provides != null) {
        // TEMPORARY WORKAROUND
        invokeWorkaroundWhileBugIsOpen = true;
        // Bug 1394401 - The list of provided products for Temporary Subscriptions is empty
        bugId = "1394401";
        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 && !bundledProductNames.isEmpty() && pool.provides.isEmpty() && pool.subscriptionType.contains("Temporary")) {
            log.warning("While bug '" + bugId + "' is open, skip assertion that the actual list of SubscriptionPool provided product names " + pool.provides + " matches the expected list of bundledProductDataNames " + bundledProductNames + ".");
        } else
            // END OF WORKAROUND
            // assert that the pool's list of Provides matches the list of bundled product names after implementation of Bug 996993 - [RFE] Search for or list matching providedProducts; subscription-manager commit b8738a74c1109975e387fc51105c8ff58eaa8f01
            Assert.assertTrue(bundledProductNames.containsAll(pool.provides) && pool.provides.containsAll(bundledProductNames), "The actual list of SubscriptionPool provided product names " + pool.provides + " matches the expected list of bundledProductDataNames " + bundledProductNames + ".  (If this fails due to provided Product Names changes by Release Engineering, refresh pools for account '" + sm_clientUsername + "' is needed.)");
    }
    List<ProductCert> currentlyInstalledProductCerts = clienttasks.getCurrentProductCerts();
    List<InstalledProduct> currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
    // assert the installed status of the bundled products
    for (int j = 0; j < bundledProductDataAsJSONArray.length(); j++) {
        JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductDataAsJSONArray.get(j);
        String bundledProductId = bundledProductAsJSONObject.getString("productId");
        // assert the status of the installed products listed
        for (ProductCert productCert : ProductCert.findAllInstancesWithMatchingFieldFromList("productId", bundledProductId, currentlyInstalledProductCerts)) {
            InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productName", productCert.productName, currentlyInstalledProducts);
            Assert.assertNotNull(installedProduct, "The status of installed product cert with ProductName '" + productCert.productName + "' is reported in the list of installed products.");
            Assert.assertEquals(installedProduct.status, "Not Subscribed", "Before subscribing to pool for ProductId '" + productId + "', the status of Installed Product '" + productCert.productName + "' is Not Subscribed.");
        }
    }
    // when the Suggested quantity is 0, let's specify a quantity to avoid Stdout: Quantity '1' is not a multiple of instance multiplier '2'
    // adjust quantity for instance_multiplier pools
    String instance_multiplier = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "instance_multiplier");
    String quantity = null;
    /*if (clienttasks.isPackageVersion("subscription-manager",">=","1.10.3-1"))*/
    if (pool.suggested != null) {
        if (pool.suggested < 1 && instance_multiplier != null) {
            quantity = instance_multiplier;
        }
    }
    boolean isPoolRestrictedToUnmappedVirtualSystems = CandlepinTasks.isPoolRestrictedToUnmappedVirtualSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId);
    // subscribe to the pool
    File entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, quantity, /*sm_serverAdminUsername*/
    sm_clientUsername, /*sm_serverAdminPassword*/
    sm_clientPassword, sm_serverUrl);
    EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
    currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
    List<ProductSubscription> currentlyConsumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    // after subscribing to a pool, assert that its corresponding productSubscription is found among the currently consumed productSubscriptions
    ProductSubscription consumedProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productId", pool.productId, currentlyConsumedProductSubscriptions);
    Assert.assertNotNull(consumedProductSubscription, "The consumed ProductSubscription corresponding to the subscribed SubscriptionPool productId '" + pool.productId + "' was found among the list of consumed ProductSubscriptions.");
    // assert that the quantityUsed matches the quantitySuggested after implementation of Bug 1008647 - [RFE] bind requests that do not specify a quantity should automatically use the quantity needed to achieve compliance
    if (quantity != null) {
        Assert.assertEquals(consumedProductSubscription.quantityUsed, Integer.valueOf(quantity), "When the attachment quantity '" + quantity + "' is specified, the quantity used from the consumed product subscription should match.");
    } else {
        /*if (clienttasks.isPackageVersion("subscription-manager",">=","1.10.3-1"))*/
        if (pool.suggested != null) {
            if (pool.suggested > 1) {
                Assert.assertEquals(consumedProductSubscription.quantityUsed, pool.suggested, "When the suggested consumption quantity '" + pool.suggested + "' from the available pool is greater than one, the quantity used from the consumed product subscription should match.");
            } else {
                Assert.assertEquals(consumedProductSubscription.quantityUsed, Integer.valueOf(1), "When the suggested consumption quantity '" + pool.suggested + "' from the available pool is NOT greater than one, the quantity used from the consumed product subscription should be one.");
            }
        }
    }
    /*if (clienttasks.isPackageVersion("subscription-manager",">=","1.10.3-1"))*/
    if (consumedProductSubscription.machineType != null) {
        Assert.assertEquals(consumedProductSubscription.machineType, pool.machineType, "After subscribing from a pool with a machine type '" + pool.machineType + "', the consumed product subscription's machine type should match.");
    }
    // TEMPORARY WORKAROUND
    /*boolean*/
    invokeWorkaroundWhileBugIsOpen = true;
    // Bug 1204311 - Refreshing pools causes unexpected temporary pools for unmapped guests to become available
    bugId = "1204311";
    /*String*/
    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 && isPoolRestrictedToUnmappedVirtualSystems) {
        log.warning("While bug '" + bugId + "' is open and we have subscrbed to a Temporary pool, skip assertion that the consumed productSubscription provides all of the expected bundled product names " + bundledProductNames + " after subscribing to pool: " + pool);
    } else // END OF WORKAROUND
    {
        // TEMPORARY WORKAROUND
        invokeWorkaroundWhileBugIsOpen = true;
        // Bug 1394401 - The list of provided products for Temporary Subscriptions is empty
        bugId = "1394401";
        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 && isPoolRestrictedToUnmappedVirtualSystems) {
            log.warning("While bug '" + bugId + "' is open and we have subscrbed to a Temporary pool, skip assertion that the consumed productSubscription provides all of the expected bundled product names " + bundledProductNames + " after subscribing to pool: " + pool);
        } else
            // END OF WORKAROUND
            // assert that the consumed product subscription provides all the expected bundled products.
            Assert.assertTrue(consumedProductSubscription.provides.containsAll(bundledProductNames) && bundledProductNames.containsAll(consumedProductSubscription.provides), "The consumed productSubscription provides all of the expected bundled product names " + bundledProductNames + " after subscribing to pool: " + pool);
    }
    // assert the dates of the consumed product subscription...
    if (isPoolRestrictedToUnmappedVirtualSystems) {
        // ... assert endDate is 24 hours after the date of registration
        ConsumerCert cert = clienttasks.getCurrentConsumerCert();
        Calendar consumerCertStartDate = cert.validityNotBefore;
        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 expires_after by one hour to account for pre-dating the consumer identity's validityNotBefore date by one hour.");
        }
        consumerCertStartDate.add(Calendar.HOUR, hours);
        Assert.assertEquals(ProductSubscription.formatDateString(consumedProductSubscription.endDate), ProductSubscription.formatDateString(consumerCertStartDate), "Consumed productSubscription (from a unmapped_guests_only pool '" + pool.poolId + "') expires '" + hours + "' hours after the time of consumer registration (" + ConsumerCert.formatDateString(clienttasks.getCurrentConsumerCert().validityNotBefore) + ").");
    // TODO Assert the start date after bug 1199670 is resolved
    } else {
        // ... assert endDate matches the originating subscription pool
        Assert.assertEquals(ProductSubscription.formatDateString(consumedProductSubscription.endDate), ProductSubscription.formatDateString(pool.endDate), "Consumed productSubscription expires on the same DAY as the originating subscription pool.");
    // FIXME	Assert.assertTrue(productSubscription.startDate.before(entitlementCert.validityNotBefore), "Consumed ProductSubscription Began before the validityNotBefore date of the new entitlement: "+entitlementCert);
    }
    // assert the expected products are consumed
    for (int j = 0; j < bundledProductDataAsJSONArray.length(); j++) {
        JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductDataAsJSONArray.get(j);
        String bundledProductId = bundledProductAsJSONObject.getString("productId");
        String bundledProductName = bundledProductAsJSONObject.getString("productName");
        bundledProductNames.add(bundledProductName);
        // find the corresponding productNamespace from the entitlementCert
        ProductNamespace productNamespace = null;
        for (ProductNamespace pn : entitlementCert.productNamespaces) {
            if (pn.id.equals(bundledProductId))
                productNamespace = pn;
        }
        // TEMPORARY WORKAROUND
        invokeWorkaroundWhileBugIsOpen = true;
        // Bug 1394401 - The list of provided products for Temporary Subscriptions is empty
        bugId = "1394401";
        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 && !bundledProductNames.isEmpty() && pool.provides.isEmpty() && pool.subscriptionType.contains("Temporary")) {
            log.warning("While bug '" + bugId + "' is open, skip assertion of the consumed entitlement provided products amongst the list of install products.");
        } else // assert the installed status of the corresponding product
        if (entitlementCert.productNamespaces.isEmpty()) {
            log.warning("This product '" + productId + "' (" + bundledProductName + ") does not appear to grant entitlement to any client side content.  This must be a server side management add-on product. Asserting as such...");
            Assert.assertEquals(entitlementCert.contentNamespaces.size(), 0, "When there are no productNamespaces in the entitlementCert, there should not be any contentNamespaces.");
            // when there is no corresponding product, then there better not be an installed product status by the same product name
            Assert.assertNull(InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productName", bundledProductName, currentlyInstalledProducts), "Should not find any installed product status matching a server side management add-on productName: " + bundledProductName);
            // when there is no corresponding product, then there better not be an installed product cert by the same product name
            Assert.assertNull(ProductCert.findFirstInstanceWithMatchingFieldFromList("productName", bundledProductName, currentlyInstalledProductCerts), "Should not find any installed product certs matching a server side management add-on productName: " + bundledProductName);
        } else {
            Assert.assertNotNull(productNamespace, "The new entitlement cert's product namespace corresponding to this expected ProductSubscription with ProductName '" + bundledProductName + "' was found.");
            // assert the status of the installed products listed
            // should be a list of one or empty
            List<ProductCert> productCerts = ProductCert.findAllInstancesWithMatchingFieldFromList("productId", productNamespace.id, currentlyInstalledProductCerts);
            for (ProductCert productCert : productCerts) {
                List<InstalledProduct> installedProducts = InstalledProduct.findAllInstancesWithMatchingFieldFromList("productName", productCert.productName, currentlyInstalledProducts);
                Assert.assertEquals(installedProducts.size(), 1, "The status of installed product '" + productCert.productName + "' should only be reported once in the list of installed products.");
                InstalledProduct installedProduct = installedProducts.get(0);
                // TEMPORARY WORKAROUND FOR BUG
                if (installedProduct.arch.contains(",")) {
                    /*boolean*/
                    invokeWorkaroundWhileBugIsOpen = true;
                    // Bug 951633 - installed product with comma separated arch attribute fails to go green
                    bugId = "951633";
                    /*String*/
                    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("Verification for status of Installed Product name='" + installedProduct.productName + "' with arch='" + installedProduct.arch + "' is blocked by open bugzilla '" + bugId + "'.");
                    }
                }
                // END OF WORKAROUND
                // decide what the status should be...  "Subscribed" or "Partially Subscribed" (SPECIAL CASE WHEN poolProductSocketsAttribute=0  or "null" SHOULD YIELD Subscribed)
                String poolProductSocketsAttribute = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "sockets");
                // introduced by 885785 [RFE] Subscription Manager should alert a user if subscription vcpu limits are lower than system vcpu allocation
                String poolProductVcpuAttribute = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "vcpu");
                String poolProductArchAttribute = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "arch");
                List<String> poolProductArches = new ArrayList<String>();
                if (poolProductArchAttribute != null) {
                    // Note: the arch attribute can be a comma separated list of values
                    poolProductArches.addAll(Arrays.asList(poolProductArchAttribute.trim().split(" *, *")));
                    // Note: x86 is a general arch to cover all 32-bit intel microprocessors
                    if (poolProductArches.contains("x86")) {
                        poolProductArches.addAll(Arrays.asList("i386", "i486", "i586", "i686"));
                    }
                    if (poolProductArches.contains("ALL"))
                        poolProductArches.add(clienttasks.arch);
                }
                // if the sockets attribute is not numeric (e.g. "null"),  then this subscription should be available to this client
                try {
                    Integer.valueOf(poolProductSocketsAttribute);
                } catch (NumberFormatException e) {
                    // do not mark productAttributesPassRulesCheck = false;
                    log.warning("Ecountered a non-numeric value for product sockets attribute sockets on productId='" + productId + "' poolId '" + pool.poolId + "'. SIMPLY IGNORING THIS ATTRIBUTE.");
                    poolProductSocketsAttribute = null;
                }
                // consider the socket/vcpu coverage and assert the installed product's status
                if (isPoolRestrictedToUnmappedVirtualSystems && false) /*since 1200882 was CLOSED NOTABUG, never run the assertion in this if condition*/
                {
                    // TEMPORARY WORKAROUND
                    /*boolean*/
                    invokeWorkaroundWhileBugIsOpen = true;
                    // Bug 1200882 - Wrong installed product status is displayed when a unmapped_guests_only pool is attached
                    bugId = "1200882";
                    /*String*/
                    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 the assertion of the installed product status after subscribing to an unmapped_guests_only pool for ProductId '" + productId + "' while bug '" + bugId + "' is open.");
                    } else
                        // END OF WORKAROUND
                        // for more info, see bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=1197897	// CLOSED NOTABUG
                        Assert.assertEquals(installedProduct.status, "Partially Subscribed", "After subscribing to an unmapped_guests_only pool for ProductId '" + productId + "', the status of Installed Product '" + bundledProductName + "' should be Partially Subscribed regardless of any hardware socket/vcpu coverage or other subscriptions attached.");
                } else if (pool.subscriptionType != null && pool.subscriptionType.equals("Other")) {
                    Assert.fail("Encountered a subscription pool of type '" + pool.subscriptionType + "'.  Do not know how to assert the installedProduct.status after subscribing to pool: " + pool);
                } else if (pool.multiEntitlement == null && pool.subscriptionType != null && pool.subscriptionType.isEmpty()) {
                    log.warning("Encountered a pool with an empty value for subscriptionType (indicative of an older candlepin server): " + pool);
                    log.warning("After subscribing to a pool for ProductId '" + productId + ", skipping assertion of the installed product status for products provided by this pool: " + pool);
                } else if (pool.multiEntitlement != null && !pool.multiEntitlement && /*ADDED AFTER IMPLEMENTATION OF BUG 1008647*/
                !systemIsGuest && /*ADDED AFTER IMPLEMENTATION OF BUG 885785*/
                poolProductSocketsAttribute != null && Integer.valueOf(poolProductSocketsAttribute) < Integer.valueOf(clienttasks.sockets) && Integer.valueOf(poolProductSocketsAttribute) > 0) {
                    Assert.assertEquals(installedProduct.status, "Partially Subscribed", "After subscribing this physical system to a pool for ProductId '" + productId + "' (covers '" + poolProductSocketsAttribute + "' sockets), the status of Installed Product '" + bundledProductName + "' should be Partially Subscribed since a corresponding product cert was found in " + clienttasks.productCertDir + " and the machine's sockets value (" + clienttasks.sockets + ") is greater than what a single subscription from a non-multi-entitlement pool covers.");
                } else if (pool.subscriptionType != null && (pool.subscriptionType.equals("Standard") || pool.subscriptionType.equals("Stackable only with other subscriptions")) && /*ADDED AFTER IMPLEMENTATION OF BUG 1008647 AND 1029968*/
                !systemIsGuest && /*ADDED AFTER IMPLEMENTATION OF BUG 885785*/
                poolProductSocketsAttribute != null && Integer.valueOf(poolProductSocketsAttribute) < Integer.valueOf(clienttasks.sockets) && Integer.valueOf(poolProductSocketsAttribute) > 0) {
                    Assert.assertEquals(installedProduct.status, "Partially Subscribed", "After subscribing this physical system to a pool for ProductId '" + productId + "' (covers '" + poolProductSocketsAttribute + "' sockets), the status of Installed Product '" + bundledProductName + "' should be Partially Subscribed since a corresponding product cert was found in " + clienttasks.productCertDir + " and the machine's sockets value (" + clienttasks.sockets + ") is greater than what a single subscription from a non-multi-entitlement pool covers.");
                } else if (pool.multiEntitlement != null && !pool.multiEntitlement && /*ADDED AFTER IMPLEMENTATION OF BUG 1008647*/
                systemIsGuest && /*ADDED AFTER IMPLEMENTATION OF BUG 885785*/
                poolProductVcpuAttribute != null && Integer.valueOf(poolProductVcpuAttribute) < Integer.valueOf(clienttasks.vcpu) && Integer.valueOf(poolProductVcpuAttribute) > 0) {
                    Assert.assertEquals(installedProduct.status, "Partially Subscribed", "After subscribing this virtual system to a pool for ProductId '" + productId + "' (covers '" + poolProductVcpuAttribute + "' vcpu), the status of Installed Product '" + bundledProductName + "' should be Partially Subscribed since a corresponding product cert was found in " + clienttasks.productCertDir + " and the machine's vcpu value (" + clienttasks.vcpu + ") is greater than what a single subscription from a non-multi-entitlement pool covers.");
                } else if (pool.subscriptionType != null && (pool.subscriptionType.equals("Standard") || pool.subscriptionType.equals("Stackable only with other subscriptions")) && /*ADDED AFTER IMPLEMENTATION OF BUG 1008647 AND 1029968*/
                systemIsGuest && /*ADDED AFTER IMPLEMENTATION OF BUG 885785*/
                poolProductVcpuAttribute != null && Integer.valueOf(poolProductVcpuAttribute) < Integer.valueOf(clienttasks.vcpu) && Integer.valueOf(poolProductVcpuAttribute) > 0) {
                    Assert.assertEquals(installedProduct.status, "Partially Subscribed", "After subscribing this virtual system to a pool for ProductId '" + productId + "' (covers '" + poolProductVcpuAttribute + "' vcpu), the status of Installed Product '" + bundledProductName + "' should be Partially Subscribed since a corresponding product cert was found in " + clienttasks.productCertDir + " and the machine's vcpu value (" + clienttasks.vcpu + ") is greater than what a single subscription from a non-multi-entitlement pool covers.");
                } else if (!poolProductArches.contains(clienttasks.arch)) {
                    log.warning("This case is indicative that a pool refresh may be needed for this owner.");
                    Assert.assertEquals(installedProduct.status, "Partially Subscribed", "After subscribing this system with arch '" + clienttasks.arch + "' to a pool for ProductId '" + productId + "' (that supports '" + poolProductArchAttribute + "' arch), the status of Installed Product '" + bundledProductName + "' should be Partially Subscribed with a reason stating that the system's arch is not supported by this subscription.");
                    // Example Status Details:    Supports architecture x86_64,ppc64,ia64,ppc,x86,s390,s390x but the system is ppc64le.
                    String reason = String.format("Supports architecture %s but the system is %s.", poolProductArchAttribute, clienttasks.arch);
                    Assert.assertTrue(installedProduct.statusDetails.contains(reason), "Installed Product '" + installedProduct.productName + "' Status Details includes '" + reason + "'.");
                } else {
                    Assert.assertEquals(installedProduct.status, "Subscribed", "After subscribing to a pool for ProductId '" + productId + "', the status of Installed Product '" + bundledProductName + "' is Subscribed since a corresponding product cert was found in " + clienttasks.productCertDir + " and the system's sockets/vcpu needs were met.");
                }
                // TEMPORARY WORKAROUND
                /*boolean*/
                invokeWorkaroundWhileBugIsOpen = true;
                // Bug 1199443 - Wrong "End date" in installed list after attaching 24-hour subscription on a unmapped-guest
                bugId = "1199443";
                /*String*/
                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 && isPoolRestrictedToUnmappedVirtualSystems) {
                    log.warning("Skipping the assertion of installed product start-end date range after subscribing to an unmapped_guests_only pool for ProductId '" + productId + "' while bug '" + bugId + "' is open.");
                } else // Assert.assertEquals(InstalledProduct.formatDateString(installedProduct.startDate), ProductSubscription.formatDateString(productSubscription.startDate), "Installed Product '"+bundledProductName+"' starts on the same DAY as the consumed ProductSubscription: "+productSubscription);
                if (installedProduct.status.equals("Subscribed")) {
                    // assert the valid date range on the installed product match the validity period of the product subscription
                    Assert.assertEquals(InstalledProduct.formatDateString(installedProduct.endDate), ProductSubscription.formatDateString(consumedProductSubscription.endDate), "Installed Product '" + bundledProductName + "' expires on the same DAY as the consumed ProductSubscription: " + consumedProductSubscription);
                    Assert.assertEquals(InstalledProduct.formatDateString(installedProduct.startDate), ProductSubscription.formatDateString(consumedProductSubscription.startDate), "Installed Product '" + bundledProductName + "' starts on the same DAY as the consumed ProductSubscription: " + consumedProductSubscription);
                } else {
                    /* valid assertion before Bug 990639 - Update information displayed on My Installed Products tab when product is partially subscribed
						// assert the date range on the installed product is None
						Assert.assertNull(installedProduct.startDate, "Installed Product '"+bundledProductName+"' start date range should be None/null when today's status '"+installedProduct.status+"' is NOT fully Subscribed.");
						Assert.assertNull(installedProduct.endDate, "Installed Product '"+bundledProductName+"' end date range should be None/null when today's status '"+installedProduct.status+"' is NOT fully Subscribed.");
						*/
                    // assert the date range on the installed product is NOT None
                    Assert.assertNotNull(installedProduct.startDate, "Installed Product '" + bundledProductName + "' start date range should NOT be None/null even when today's status '" + installedProduct.status + "' is NOT fully Subscribed.");
                    Assert.assertNotNull(installedProduct.endDate, "Installed Product '" + bundledProductName + "' end date range should NOT be None/null even when today's status '" + installedProduct.status + "' is NOT fully Subscribed.");
                }
            }
            if (productCerts.isEmpty()) {
                Assert.assertNull(InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productName", bundledProductName, currentlyInstalledProducts), "There should NOT be an installed status report for '" + bundledProductName + "' since a corresponding product cert was not found in " + clienttasks.productCertDir);
            }
        }
    }
// TODO I BELIEVE THIS FINAL BLOCK OF TESTING IS INACCURATE - jsefler 5/27/2012
// I THINK IT SHOULD BE CHECKING HARDWARE SOCKETS AND NOT INSTALLED SOFTWARE
/*
		// check if this subscription matches the installed software and then test for availability
		boolean subscriptionProductIdMatchesInstalledSoftware = false;
		for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
			if (clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentlyInstalledProductCerts)) {
				subscriptionProductIdMatchesInstalledSoftware=true; break;
			}
		}
		clienttasks.unsubscribeFromSerialNumber(entitlementCert.serialNumber);
		pool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", productId, clienttasks.getCurrentlyAvailableSubscriptionPools());
		if (currentlyInstalledProductCerts.isEmpty()) {
			log.info("A final assertion to verify that SubscriptionPool with ProductId '"+productId+"' is available based on matching installed software is not applicable when the list of installed software is empty.");
		} else {
			if (subscriptionProductIdMatchesInstalledSoftware) {
				Assert.assertNotNull(pool, "Expected SubscriptionPool with ProductId '"+productId+"' matches the installed software and is available for subscribing when listing --available.");
			} else {
				Assert.assertNull(pool, "Expected SubscriptionPool with ProductId '"+productId+"' does NOT match the installed software and is only available for subscribing when listing --all --available.");
			}
		}
		*/
}
Also used : ArrayList(java.util.ArrayList) InstalledProduct(rhsm.data.InstalledProduct) ArrayList(java.util.ArrayList) List(java.util.List) SkipException(org.testng.SkipException) EntitlementCert(rhsm.data.EntitlementCert) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ProductSubscription(rhsm.data.ProductSubscription) ProductCert(rhsm.data.ProductCert) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) ProductNamespace(rhsm.data.ProductNamespace) BigInteger(java.math.BigInteger) JSONObject(org.json.JSONObject) SubscriptionPool(rhsm.data.SubscriptionPool) File(java.io.File) ConsumerCert(rhsm.data.ConsumerCert) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 14 with ProductNamespace

use of rhsm.data.ProductNamespace 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

ProductNamespace (rhsm.data.ProductNamespace)14 EntitlementCert (rhsm.data.EntitlementCert)11 Test (org.testng.annotations.Test)9 SkipException (org.testng.SkipException)8 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)7 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)7 ArrayList (java.util.ArrayList)7 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)6 ProductSubscription (rhsm.data.ProductSubscription)5 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)4 Calendar (java.util.Calendar)4 ProductCert (rhsm.data.ProductCert)4 File (java.io.File)3 GregorianCalendar (java.util.GregorianCalendar)3 HashSet (java.util.HashSet)3 JSONObject (org.json.JSONObject)3 ContentNamespace (rhsm.data.ContentNamespace)3 InstalledProduct (rhsm.data.InstalledProduct)3 BigInteger (java.math.BigInteger)2 HashMap (java.util.HashMap)2