Search in sources :

Example 81 with ProductCert

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

the class MigrationDataTests method testMigrationProductCertsSupportThisSystemsRhelVersion_DEPRECATED.

@Deprecated
@Test(description = "Verify that the migration product certs support this system's RHEL release version", groups = { "Tier1Tests", "blockedByBug-782208" }, dependsOnMethods = { "testChannelCertMapping" }, // 9/12/2013 RHEL65: disabled in favor of new VerifyMigrationProductCertsSupportThisSystemsRhelVersion_Test; this old test was based on the generation of subscription-manager-migration-data from product-baseline.json
enabled = false)
@ImplementsNitrateTest(caseId = 130940)
public void testMigrationProductCertsSupportThisSystemsRhelVersion_DEPRECATED() {
    // process all the migration product cert files into ProductCerts and assert their version
    boolean verifiedVersionOfAllMigrationProductCertFiles = true;
    for (ProductCert productCert : clienttasks.getProductCerts(baseProductsDir)) {
        if (!productCert.productNamespace.providedTags.toLowerCase().contains("rhel")) {
            log.warning("Migration productCert '" + productCert + "' does not provide RHEL tags.  Skipping assertion that its version matches this system's RHEL version.");
            continue;
        }
        if (productCert.productNamespace.version.equals(clienttasks.redhatReleaseXY)) {
            Assert.assertTrue(true, "Migration productCert '" + productCert + "' supports this version of RHEL '" + clienttasks.redhatReleaseXY + "'.");
        } else {
            log.warning("Migration productCert '" + productCert + "' does NOT support this version of RHEL '" + clienttasks.redhatReleaseXY + "'.");
            verifiedVersionOfAllMigrationProductCertFiles = false;
        }
    }
    Assert.assertTrue(verifiedVersionOfAllMigrationProductCertFiles, "All of the migration productCerts in directory '" + baseProductsDir + "' support this version of RHEL '" + clienttasks.redhatReleaseXY + "'.");
}
Also used : ProductCert(rhsm.data.ProductCert) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 82 with ProductCert

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

the class MigrationTests method getExpectedMappedProductCertFilenamesCorrespondingToChannels.

protected Set<String> getExpectedMappedProductCertFilenamesCorrespondingToChannels(List<String> channels) {
    Set<String> mappedProductCertFilenamesCorrespondingToChannels = new HashSet<String>();
    for (String channel : channels) {
        String mappedProductCertFilename = channelsToProductCertFilenamesMap.get(channel);
        if (mappedProductCertFilename == null) {
        // log.warning("RHN Classic channel '"+channel+"' is NOT mapped in the file '"+channelCertMappingFilename+"'.");
        } else {
            log.info("The mapped product cert filename for RHN Classic channel '" + channel + "' is: " + mappedProductCertFilename);
            if (!mappedProductCertFilename.equalsIgnoreCase("none")) {
                mappedProductCertFilenamesCorrespondingToChannels.add(mappedProductCertFilename);
            }
        }
    }
    // SPECIAL CASE:  Red Hat Enterprise Workstation vs. Red Hat Enterprise Desktop
    // See https://bugzilla.redhat.com/show_bug.cgi?id=786257#c1
    // >	if customer subscribed to rhel-x86_64-client-supplementary-5:
    // >	   if customer subscribes to rhel-x86_64-client-workstation-5:
    // >	      install 71.pem
    // >	   else:
    // >	      install 68.pem
    // is product id 68 for "Red Hat Enterprise Linux Desktop" among the mappedProductCertFilenames
    String mappedProductCertFilenameCorrespondingToBaseChannel = null;
    // Red Hat Enterprise Desktop
    String productIdForBase = "68";
    for (String mappedProductCertFilename : mappedProductCertFilenamesCorrespondingToChannels) {
        if (MigrationDataTests.getProductIdFromProductCertFilename(mappedProductCertFilename).equals(productIdForBase)) {
            mappedProductCertFilenameCorrespondingToBaseChannel = mappedProductCertFilename;
            break;
        }
    }
    if (mappedProductCertFilenameCorrespondingToBaseChannel != null) {
        File mappedProductCertFileCorrespondingToBaseChannel = new File(baseProductsDir + "/" + mappedProductCertFilenameCorrespondingToBaseChannel);
        for (String productId : Arrays.asList("71")) {
            for (String mappedProductCertFilename : new HashSet<String>(mappedProductCertFilenamesCorrespondingToChannels)) {
                if (MigrationDataTests.getProductIdFromProductCertFilename(mappedProductCertFilename).equals(productId)) {
                    File mappedProductCertFileCorrespondingToAddonChannel = new File(baseProductsDir + "/" + mappedProductCertFilename);
                    ProductCert productCertBase = clienttasks.getProductCertFromProductCertFile(mappedProductCertFileCorrespondingToBaseChannel);
                    ProductCert productCertAddon = clienttasks.getProductCertFromProductCertFile(mappedProductCertFileCorrespondingToAddonChannel);
                    log.warning("SPECIAL CASE ENCOUNTERED: " + rhnMigrateTool + " should NOT install product cert " + productIdForBase + " [" + productCertBase.productName + "] when product cert " + productId + " [" + productCertAddon.productName + "] is also installed.");
                    mappedProductCertFilenamesCorrespondingToChannels.remove(mappedProductCertFilenameCorrespondingToBaseChannel);
                }
            }
        }
    }
    // SPECIAL CASE:  Red Hat Beta vs. Red Hat Developer Toolset (for RHEL [Server|HPC Node|Client|Workstation])
    // Check for special case!  email thread by dgregor entitled "Product certificates for a few channels"
    // 180.pem is "special".  It's for the "Red Hat Beta" product, which is this generic placeholder
    // that we created and it isn't tied to any specific Red Hat product release.
    // > After the migration tool does it's normal migration logic, there is a hard-coded cleanup to...
    // >   if both 180.pem (rhel-ARCH-server-dts-5-beta) and 176.pem (rhel-ARCH-server-dts-5) were migrated
    // >       remove 180.pem from /etc/pki/product
    // >   if both 180.pem (rhel-ARCH-client-dts-5-beta) and 178.pem (rhel-ARCH-client-dts-5) were migrated
    // >       remove 180.pem from /etc/pki/product
    // is product id 180 for "Red Hat Beta" among the mappedProductCertFilenames
    mappedProductCertFilenameCorrespondingToBaseChannel = null;
    // Red Hat Beta
    productIdForBase = "180";
    for (String mappedProductCertFilename : mappedProductCertFilenamesCorrespondingToChannels) {
        if (MigrationDataTests.getProductIdFromProductCertFilename(mappedProductCertFilename).equals(productIdForBase)) {
            mappedProductCertFilenameCorrespondingToBaseChannel = mappedProductCertFilename;
            break;
        }
    }
    if (mappedProductCertFilenameCorrespondingToBaseChannel != null) {
        File mappedProductCertFileCorrespondingToBaseChannel = new File(baseProductsDir + "/" + mappedProductCertFilenameCorrespondingToBaseChannel);
        for (String productId : Arrays.asList("176", /*Red Hat Developer Toolset (for RHEL Server)*/
        "177", /*Red Hat Developer Toolset (for RHEL HPC Node)*/
        "178", /*Red Hat Developer Toolset (for RHEL Client)*/
        "179")) {
            for (String mappedProductCertFilename : new HashSet<String>(mappedProductCertFilenamesCorrespondingToChannels)) {
                if (MigrationDataTests.getProductIdFromProductCertFilename(mappedProductCertFilename).equals(productId)) {
                    File mappedProductCertFileCorrespondingToAddonChannel = new File(baseProductsDir + "/" + mappedProductCertFilename);
                    ProductCert productCertBase = clienttasks.getProductCertFromProductCertFile(mappedProductCertFileCorrespondingToBaseChannel);
                    ProductCert productCertAddon = clienttasks.getProductCertFromProductCertFile(mappedProductCertFileCorrespondingToAddonChannel);
                    log.warning("SPECIAL CASE ENCOUNTERED: " + rhnMigrateTool + " should NOT install product cert " + productIdForBase + " [" + productCertBase.productName + "] when product cert " + productId + " [" + productCertAddon.productName + "] is also installed.");
                    mappedProductCertFilenamesCorrespondingToChannels.remove(mappedProductCertFilenameCorrespondingToBaseChannel);
                }
            }
        }
    }
    return mappedProductCertFilenamesCorrespondingToChannels;
}
Also used : ProductCert(rhsm.data.ProductCert) File(java.io.File) HashSet(java.util.HashSet)

Example 83 with ProductCert

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

the class MigrationTests method testInstallNumMigrateToRhsm.

@TestDefinition(projectID = {/*Project.RHEL5*/
}, testCaseID = {})
@Test(description = "Execute migration tool install-num-migrate-to-rhsm with install-num used to provision this machine", groups = { "Tier1Tests", "InstallNumMigrateToRhsm_Test", "blockedByBug-854879" }, dependsOnMethods = {}, enabled = true)
@ImplementsNitrateTest(caseId = 130760)
public void testInstallNumMigrateToRhsm() throws JSONException {
    if (!clienttasks.redhatReleaseX.equals("5"))
        throw new SkipException("This test is applicable to RHEL5 only.");
    if (clienttasks.isPackageVersion("subscription-manager-migration", ">", "1.11.3-4") && clienttasks.redhatReleaseX.equals("5")) {
        throw new SkipException("Due to bug 1092754, the migration tool '" + installNumTool + "' has been removed from RHEL5.");
    }
    if (!RemoteFileTasks.testExists(client, machineInstNumberFile) && RemoteFileTasks.testExists(client, backupMachineInstNumberFile)) {
        log.info("Restoring backup of the rhn install-num file...");
        client.runCommandAndWait("mv -f " + backupMachineInstNumberFile + " " + machineInstNumberFile);
    }
    if (!RemoteFileTasks.testExists(client, machineInstNumberFile))
        throw new SkipException("This system was NOT provisioned with an install number.");
    // get the install number used to provision this machine
    SSHCommandResult result = client.runCommandAndWait("cat " + machineInstNumberFile);
    String installNumber = result.getStdout().trim();
    // test this install number explicitly (specifying --instnumber option)
    SSHCommandResult explicitResult = InstallNumMigrateToRhsmWithInstNumber(installNumber);
    // now test this install number implicitly (without specifying any options)
    clienttasks.removeAllCerts(false, false, true);
    clienttasks.removeAllFacts();
    SSHCommandResult implicitResult = client.runCommandAndWait(installNumTool);
    // compare implicit to explicit results for verification
    Assert.assertEquals(implicitResult.getStdout().trim(), explicitResult.getStdout().trim(), "Stdout from running :" + installNumTool);
    Assert.assertEquals(implicitResult.getStderr().trim(), explicitResult.getStderr().trim(), "Stderr from running :" + installNumTool);
    Assert.assertEquals(implicitResult.getExitCode(), explicitResult.getExitCode(), "ExitCode from running :" + installNumTool);
    Assert.assertEquals(clienttasks.getFactValue(migrationFromFact), "install_number", "The migration fact '" + migrationFromFact + "' should be set after running command: " + installNumTool);
    Assert.assertNull(clienttasks.getFactValue(migrationSystemIdFact), "The migration fact '" + migrationSystemIdFact + "' should NOT be set after running command: " + installNumTool);
    // assert that the migrated product certs provide (at least) the same product tags as originally installed with the install number
    List<ProductCert> migratedProductCerts = clienttasks.getCurrentProductCerts();
    log.info("The following productCerts were originally installed on this machine prior to this migration test:");
    for (ProductCert originalProductCert : originallyInstalledRedHatProductCerts) log.info(originalProductCert.toString());
    log.info("The following productCerts were migrated to the product install directory after running the migration test:");
    for (ProductCert migratedProductCert : migratedProductCerts) log.info(migratedProductCert.toString());
    log.info("Will now verify that all of the productTags from the originally installed productCerts are found among the providedTags of the migrated productCerts...");
    for (ProductCert originalProductCert : originallyInstalledRedHatProductCerts) {
        if (originalProductCert.productNamespace.providedTags == null)
            continue;
        List<String> originalProvidedTags = Arrays.asList(originalProductCert.productNamespace.providedTags.trim().split(" *, *"));
        for (ProductCert migratedProductCert : migratedProductCerts) {
            List<String> migratedProvidedTags = Arrays.asList(migratedProductCert.productNamespace.providedTags.trim().split(" *, *"));
            if (migratedProvidedTags.containsAll(originalProvidedTags)) {
                Assert.assertTrue(true, "This migrated productCert provides all the same tags as one of the originally installed product certs.\nMigrated productCert: " + migratedProductCert);
                // originalProvidedTags.clear();
                originalProvidedTags = new ArrayList<String>();
                break;
            }
        }
        if (!originalProvidedTags.isEmpty()) {
            Assert.fail("Failed to find the providedTags from the originally installed productCert among the migrated productCerts.\nOriginal productCert: " + originalProductCert);
        }
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) 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)

Example 84 with ProductCert

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

the class OstreeTests method testOstreeConfigurationsAreSetAfterSubscribingAndUnsubscribing.

// 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-22238", "RHEL7-51753" }, 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 the ostree config and origin files are set after attaching an atomic subscription; attempt an atomic upgrade; unsubscribe and verify ostree config files are unset", groups = { "Tier1Tests", "subscribeAndUnsubscribeTests" }, dataProvider = "getOstreeSubscriptionPools", priority = 10, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testOstreeConfigurationsAreSetAfterSubscribingAndUnsubscribing(Object bugzilla, SubscriptionPool osTreeSubscriptionPool) {
    // this test is designed to be entitled to one subscription at a time.
    clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
    String baseurl = clienttasks.getConfParameter("baseurl");
    String repo_ca_cert = clienttasks.getConfParameter("repo_ca_cert");
    // get a list of the current Product Certs installed on the system
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    // get a list of the ostree repos from the ostree repo config file before attaching an ostree subscription
    List<OstreeRepo> ostreeReposBefore = getCurrentlyConfiguredOstreeRepos(ostreeRepoConfigFile);
    // get the ostree origin refspec before attaching an ostree subscription
    // UPDATE: After subscription-manager-plugin-ostree-1.18.5-1 RFE Bug 1378495, the ostree origin refspec file is no longer touched
    String ostreeOriginRefspecBefore = ostreeOriginFile == null ? null : clienttasks.getConfFileParameter(ostreeOriginFile.getPath(), "origin", "refspec");
    // also setup an old /ostree/repo/config file to test the migration clean up scenario described in https://bugzilla.redhat.com/show_bug.cgi?id=1152734#c5
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.9-1")) {
        // post committ 11b377f78dcb06d8dbff5645750791b729e20a0e
        if (!clienttasks.isPackageInstalled("ostree")) {
            client.runCommandAndWait("mkdir -p " + oldOstreeRepoConfigFile.getParent());
            client.runCommandAndWait("echo -e '[core]\nrepo_version=1\nmode=bare\n\n[remote \"REMOTE\"]\nurl=file:///install/ostree\ngpg-verify=false' > " + oldOstreeRepoConfigFile.getPath());
        }
    }
    // attach the subscription that provides ostree content
    File file = clienttasks.subscribeToSubscriptionPool(osTreeSubscriptionPool, sm_clientUsername, sm_clientPassword, sm_serverUrl);
    EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(file);
    // get a list of the ostree repos from the ostree repo config file after attaching an ostree subscription
    List<OstreeRepo> ostreeReposAfter = getCurrentlyConfiguredOstreeRepos(ostreeRepoConfigFile);
    // get the ostree origin refspec after attaching an ostree subscription
    // UPDATE: After subscription-manager-plugin-ostree-1.18.5-1 RFE Bug 1378495, the ostree origin refspec file is no longer touched
    String ostreeOriginRefspecAfter = ostreeOriginFile == null ? null : clienttasks.getConfFileParameter(ostreeOriginFile.getPath(), "origin", "refspec");
    // also assert the clean up of remotes from the old /ostree/repo/config file
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.9-1")) {
        // post committ 11b377f78dcb06d8dbff5645750791b729e20a0e
        if (RemoteFileTasks.testExists(client, oldOstreeRepoConfigFile.getPath())) {
            Assert.assertTrue(getCurrentlyConfiguredOstreeRepos(oldOstreeRepoConfigFile).isEmpty(), "Subscription-manager should have cleaned out the old remotes from '" + oldOstreeRepoConfigFile + "'.");
        }
    }
    // assert that ostree repos have been added for each ostree content namespace
    List<ContentNamespace> osTreeContentNamespaces = ContentNamespace.findAllInstancesWithMatchingFieldFromList("type", "ostree", entitlementCert.contentNamespaces);
    List<ContentNamespace> osTreeContentNamespacesMatchingInstalledProducts = new ArrayList<ContentNamespace>();
    for (ContentNamespace osTreeContentNamespace : osTreeContentNamespaces) {
        log.info("Asserting the following ostree contentNamespace is added to ostree config file '" + ostreeRepoConfigFile + "' : " + osTreeContentNamespace);
        // THIS TAGGING DECISION WAS IMPLEMENTED AS A SOLUTION TO https://bugzilla.redhat.com/show_bug.cgi?id=1153366#c5
        if (clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(osTreeContentNamespace, currentProductCerts)) {
            OstreeRepo ostreeRepo = OstreeRepo.findFirstInstanceWithMatchingFieldFromList("remote", osTreeContentNamespace.label, ostreeReposAfter);
            Assert.assertNotNull(ostreeRepo, "Found an OSTree repo configuration in '" + ostreeRepoConfigFile + "' after attaching subscription '" + osTreeSubscriptionPool.subscriptionName + "' originating from entitlement content: " + osTreeContentNamespace);
            Assert.assertEquals(ostreeRepo.url, baseurl + osTreeContentNamespace.downloadUrl, "OSTree repo remote '" + ostreeRepo.remote + "' config for url. (maps to content downloadUrl)");
            Assert.assertEquals(ostreeRepo.gpg_verify, Boolean.valueOf(!osTreeContentNamespace.gpgKeyUrl.replaceFirst("https?://", "").trim().isEmpty()), "OSTree repo remote '" + ostreeRepo.remote + "' config for gpg-verify. (maps to TRUE when content contains gpgKeyUrl)");
            Assert.assertEquals(ostreeRepo.tls_client_cert_path, entitlementCert.file.getPath(), "OSTree repo remote '" + ostreeRepo.remote + "' config for tls-client-cert-path. (maps to path of the entitlement cert)");
            Assert.assertEquals(ostreeRepo.tls_client_key_path, clienttasks.getEntitlementCertKeyFileFromEntitlementCert(entitlementCert).getPath(), "OSTree repo remote '" + ostreeRepo.remote + "' config for tls-client-key-path. (maps to path of the entitlement cert key)");
            Assert.assertEquals(ostreeRepo.tls_ca_path, repo_ca_cert, "OSTree repo remote '" + ostreeRepo.remote + "' config for tls-ca-path. (maps to path of the candlepin CA cert)");
            if (!osTreeContentNamespacesMatchingInstalledProducts.contains(osTreeContentNamespace))
                osTreeContentNamespacesMatchingInstalledProducts.add(osTreeContentNamespace);
        } else {
            OstreeRepo ostreeRepo = OstreeRepo.findFirstInstanceWithMatchingFieldFromList("remote", osTreeContentNamespace.label, ostreeReposAfter);
            Assert.assertNull(ostreeRepo, "Should NOT find an OSTree repo configuration for remote '" + osTreeContentNamespace.label + "' in '" + ostreeRepoConfigFile + "' after attaching subscription '" + osTreeSubscriptionPool.subscriptionName + "' because the Required Tags '" + osTreeContentNamespace.requiredTags + "' from the entitlement content are not found among the current product certs installed.");
        }
    }
    // assert that other ostree repos remain configured
    // TEMPORARY WORKAROUND FOR BUG: 1152734 - Update subman ostree content plugin to use ostree cli for manipulating 'remote' configs
    boolean invokeWorkaroundWhileBugIsOpen = true;
    String bugId = "1152734";
    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 that other remotes in '" + ostreeRepoConfigFile + "' remain unchanged when attaching an atomic subscription.");
    } else
        // END OF WORKAROUND
        for (OstreeRepo ostreeRepoBefore : ostreeReposBefore) {
            if (ContentNamespace.findFirstInstanceWithMatchingFieldFromList("label", ostreeRepoBefore.remote, osTreeContentNamespaces) == null) {
                OstreeRepo ostreeRepoAfter = OstreeRepo.findFirstInstanceWithMatchingFieldFromList("remote", ostreeRepoBefore.remote, ostreeReposAfter);
                Assert.assertNotNull(ostreeRepoAfter, "OSTree repo configuration in '" + ostreeRepoConfigFile + "' remote '" + ostreeRepoBefore.remote + "' remains configured after attaching subscription '" + osTreeSubscriptionPool.subscriptionName + "' (because it was not among the ostree content sets).");
                Assert.assertEquals(ostreeRepoAfter.url, ostreeRepoBefore.url, "Remote '" + ostreeRepoBefore.remote + "' url");
                Assert.assertEquals(ostreeRepoAfter.gpg_verify, ostreeRepoBefore.gpg_verify, "Remote '" + ostreeRepoBefore.remote + "' gpg-verify");
                Assert.assertEquals(ostreeRepoAfter.tls_client_cert_path, ostreeRepoBefore.tls_client_cert_path, "Remote '" + ostreeRepoBefore.remote + "' tls-client-cert-path");
                Assert.assertEquals(ostreeRepoAfter.tls_client_key_path, ostreeRepoBefore.tls_client_key_path, "Remote '" + ostreeRepoBefore.remote + "' tls-client-key-path");
                Assert.assertEquals(ostreeRepoAfter.tls_ca_path, ostreeRepoBefore.tls_ca_path, "Remote '" + ostreeRepoBefore.remote + "' tls-ca-path");
            }
        }
    /* replacing this with assertion that there is only osTreeContentNamespaceToTest
		// throw a failure on the subscription if there is more than one ostree repo
		// if there is more than one ostree repo, then it is undefined which repo remote to set in the ostree origin file
		Assert.assertEquals(osTreeContentNamespaces.size(), 1, "The number of ostree content sets provided by atomic subscription '"+osTreeSubscriptionPool.subscriptionName+"'.  (Greater than 1 is undefined)");
*/
    // assert that there is only one entitled osTreeContentNamespaceMatchingInstalledProducts
    // TEMPORARY WORKAROUND FOR BUG: 1160771 - Missing provides/requires tags in ostree content sets (not product cert)
    invokeWorkaroundWhileBugIsOpen = true;
    // Status: 	MODIFIED
    invokeWorkaroundWhileBugIsOpen = false;
    bugId = "1160771";
    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 (osTreeContentNamespacesMatchingInstalledProducts.size() > 1)
            log.warning("Found more than one entitled ostree ContentNamespace whose RequiredTags match the installed productCerts.  Blocked by Jira request https://projects.engineering.redhat.com/browse/APPINFRAT-246");
        log.warning("Skipping the assertion for more than one entitled ostree ContentNamespace whose RequiredTags match the installed productCerts due to open bug '" + bugId + "'.");
    }
    // END OF WORKAROUND
    if (clienttasks.isPackageVersion("subscription-manager-plugin-ostree", "<", "1.13.9-1")) {
        // commit 11b377f78dcb06d8dbff5645750791b729e20a0e
        // Bug 1152734 - Update subman ostree content plugin to use ostree cli for manipulating 'remote' configs
        Assert.fail("This version of subscription-manager-plugin-ostree is blocked by bug 1152734.");
    }
    ContentNamespace osTreeContentNamespaceMatchingInstalledProducts = null;
    if (osTreeContentNamespacesMatchingInstalledProducts.isEmpty()) {
        log.warning("This is probably NOT an atomic system.");
        if (ostreeOriginRefspecBefore != null)
            Assert.assertEquals(ostreeOriginRefspecAfter, ostreeOriginRefspecBefore, "When there are no installed products whose tags match the ostree ContentNamespace tags, then the ostree origin refspec in file '" + ostreeOriginFile + "' should remain unchanged after attaching subscription '" + osTreeSubscriptionPool.subscriptionName + "'.");
    } else {
        Assert.assertEquals(osTreeContentNamespacesMatchingInstalledProducts.size(), 1, "At most there should only be one entitled ostree ContentNamespace that matches the installed product certs.");
        osTreeContentNamespaceMatchingInstalledProducts = osTreeContentNamespacesMatchingInstalledProducts.get(0);
        // UPDATE: After subscription-manager-plugin-ostree-1.18.5-1 RFE Bug 1378495, the ostree origin refspec file is no longer touched
        if (ostreeOriginRefspecAfter != null)
            Assert.assertEquals(ostreeOriginRefspecAfter.split(":")[1], ostreeOriginRefspecBefore.split(":")[1], "The remote path portion of the refspec in the ostree origin file '" + ostreeOriginFile + "' should remain unchanged after attaching atomic subscription '" + osTreeSubscriptionPool.subscriptionName + "'.");
        if (ostreeOriginRefspecAfter != null)
            Assert.assertEquals(ostreeOriginRefspecAfter.split(":")[0], osTreeContentNamespaceMatchingInstalledProducts.label, "The remote label portion of the refspec in the ostree origin file '" + ostreeOriginFile + "' should be updated to the newly entitled ostree content label after attaching atomic subscription '" + osTreeSubscriptionPool.subscriptionName + "'.");
    }
    // attempt to do an atomic upgrade
    String pkg = "rpm-ostree-client";
    if (!clienttasks.isPackageInstalled(pkg)) {
        log.warning("Skipping assertion attempt to do an atomic upgrade after attaching the atomic subscription since package '" + pkg + "' is not installed.");
    } else {
        SSHCommandResult atomicUpgradeResultAfterSubscribe = client.runCommandAndWait("atomic upgrade");
        // -bash-4.2# atomic upgrade
        // Updating from: rhel-atomic-host-beta-ostree:rhel-atomic-host/7/x86_64/standard
        // 
        // Requesting /content/beta/rhel/atomic/7/x86_64/ostree/repo/refs/heads/rhel-atomic-host/7/x86_64/standard
        // Copying /etc changes: 13 modified, 4 removed, 42 added
        // Transaction complete; bootconfig swap: no deployment count change: 0
        // Changed:
        // docker-1.2.0-1.8.el7.x86_64
        // kubernetes-0.4+-0.9.git8e1d416.el7.x86_64
        // tzdata-2014i-1.el7.noarch
        // Updates prepared for next boot; run "systemctl reboot" to start a reboot
        // -bash-4.2#
        String stdoutStartsWith = "Updating from: " + ostreeOriginRefspecBefore;
        String stdoutEndsWith = "Updates prepared for next boot; run \"systemctl reboot\" to start a reboot";
        Assert.assertEquals(atomicUpgradeResultAfterSubscribe.getExitCode(), new Integer(0), "Exitcode after attempting to do an atomic upgrade after attaching an atomic subscription.");
        Assert.assertTrue(atomicUpgradeResultAfterSubscribe.getStdout().trim().startsWith(stdoutStartsWith), "Stdout starts with '" + stdoutStartsWith + "' after attempting to do an atomic upgrade after attaching an atomic subscription.");
        Assert.assertTrue(atomicUpgradeResultAfterSubscribe.getStdout().trim().endsWith(stdoutEndsWith), "Stdout ends with '" + stdoutEndsWith + "' after attempting to do an atomic upgrade after attaching an atomic subscription.");
        Assert.assertEquals(atomicUpgradeResultAfterSubscribe.getStderr().trim(), "", "Exitcode after attempting to do an atomic upgrade after attaching an atomic subscription.");
        // -bash-4.2# atomic status
        // VERSION   ID             OSNAME               REFSPEC
        // 7.0.4     0fc676bdec     rhel-atomic-host     rhel-atomic-host-beta-ostree:rhel-atomic-host/7/x86_64/standard
        // * 7.0.2     9a0dbc159e     rhel-atomic-host     rhel-atomic-host-beta-ostree:rhel-atomic-host/7/x86_64/standard
        // -bash-4.2#
        // This sample output shows that rhel-atomic-host 0fc676bdec... will be booted into on the next restart. The version to be booted on
        // the next restart is printed first.
        // This sample also shows that rhel-atomic-host 9a0dbc159e... is the currently running version. The currently running version is
        // marked with an asterisk (*). This output was created just after the atomic upgrade command was executed, therefore a new
        // version has been staged to be applied at the next restart.
        SSHCommandResult atomicStatusResultAfterSubscribe = client.runCommandAndWait("atomic status | grep -v VERSION");
        Assert.assertTrue(!atomicStatusResultAfterSubscribe.getStdout().trim().split("\n")[0].startsWith("*"), "Stdout from atomic status after doing an atomic upgrade indicates that the upgraded version is listed first and will be booted on the next systemctl reboot.");
        Assert.assertTrue(atomicStatusResultAfterSubscribe.getStdout().trim().split("\n")[1].startsWith("*"), "Stdout from atomic status after doing an atomic upgrade indicates that the currently running version (listed second) is marked with an asterisk (*)");
    }
    // MOVED TO SUBSEQUENT TEST
    // // randomly choose to remove the ostree subscription and assert...
    // if (getRandomBoolean()) {
    // MOVED BACK
    clienttasks.unsubscribe(null, clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCert.file), null, null, null, null, null);
    // after removing the entitlement, assert its corresponding ostree repos are removed
    ostreeReposAfter = getCurrentlyConfiguredOstreeRepos(ostreeRepoConfigFile);
    for (ContentNamespace osTreeContentNamespace : osTreeContentNamespaces) {
        OstreeRepo ostreeRepo = OstreeRepo.findFirstInstanceWithMatchingFieldFromList("remote", osTreeContentNamespace.label, ostreeReposAfter);
        Assert.assertNull(ostreeRepo, "Should no longer find an OSTree repo configuration for remote '" + osTreeContentNamespace.label + "' in '" + ostreeRepoConfigFile + "' after removing subscription '" + osTreeSubscriptionPool.subscriptionName + "'.");
    }
    // TODO: This assertion may be changed by Bug 1193208 - 'atomic host upgrade' gives incorrect error after unregistering with subscription-manager
    if (ostreeOriginFile != null)
        Assert.assertEquals(clienttasks.getConfFileParameter(ostreeOriginFile.getPath(), "origin", "refspec"), ostreeOriginRefspecAfter, "The OSTree origin refspec in '" + ostreeOriginFile + "' should remain unchanged after removing subscription '" + osTreeSubscriptionPool.subscriptionName + "'.");
    // when removing the entitlement, assert that other ostree repos remain configured
    // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1152734
    invokeWorkaroundWhileBugIsOpen = true;
    bugId = "1152734";
    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 that other remotes in '" + ostreeRepoConfigFile + "' remain unchanged when removing an atomic subscription.");
    } else
        // END OF WORKAROUND
        for (OstreeRepo ostreeRepoBefore : ostreeReposBefore) {
            if (ContentNamespace.findFirstInstanceWithMatchingFieldFromList("label", ostreeRepoBefore.remote, osTreeContentNamespaces) == null) {
                OstreeRepo ostreeRepoAfter = OstreeRepo.findFirstInstanceWithMatchingFieldFromList("remote", ostreeRepoBefore.remote, ostreeReposAfter);
                Assert.assertNotNull(ostreeRepoAfter, "OSTree repo configuration in '" + ostreeRepoConfigFile + "' remote '" + ostreeRepoBefore.remote + "' remains configured after removing subscription '" + osTreeSubscriptionPool.subscriptionName + "' (because it was not among the ostree content sets).");
                Assert.assertEquals(ostreeRepoAfter.url, ostreeRepoBefore.url, "Remote '" + ostreeRepoBefore.remote + "' url");
                Assert.assertEquals(ostreeRepoAfter.gpg_verify, ostreeRepoBefore.gpg_verify, "Remote '" + ostreeRepoBefore.remote + "' gpg-verify");
                Assert.assertEquals(ostreeRepoAfter.tls_client_cert_path, ostreeRepoBefore.tls_client_cert_path, "Remote '" + ostreeRepoBefore.remote + "' tls-client-cert-path");
                Assert.assertEquals(ostreeRepoAfter.tls_client_key_path, ostreeRepoBefore.tls_client_key_path, "Remote '" + ostreeRepoBefore.remote + "' tls-client-key-path");
                Assert.assertEquals(ostreeRepoAfter.tls_ca_path, ostreeRepoBefore.tls_ca_path, "Remote '" + ostreeRepoBefore.remote + "' tls-ca-path");
            }
        }
    // }
    // MOVED BACK
    // attempt to run the atomic upgrade without an entitlement
    // /usr/bin/atomic is provided by rpm-ostree-client-2014.109-2.atomic.el7.x86_64
    pkg = "rpm-ostree-client";
    if (!clienttasks.isPackageInstalled(pkg)) {
        log.warning("Skipping assertion attempt to do an atomic upgrade after removing the atomic subscription since package '" + pkg + "' is not installed.");
    } else {
        SSHCommandResult atomicUpgradeResultAfterUnsubscribe = client.runCommandAndWait("atomic upgrade");
        // -bash-4.2# atomic upgrade
        // Updating from: rhel-atomic-host-beta-ostree:rhel-atomic-host/7/x86_64/standard
        // 
        // 
        // error: No remote 'remote "rhel-atomic-host-beta-ostree"' found in /etc/ostree/remotes.d
        // -bash-4.2#
        // TODO: need to be run on Atomic and updated to make a better assert after the changes from subscription-manager-1.18.5-1 Bug 1378495 - [RFE] Do not change OStree origin refspec
        String stdoutStartsWith = "Updating from: " + ostreeOriginRefspecAfter;
        Assert.assertEquals(atomicUpgradeResultAfterUnsubscribe.getExitCode(), new Integer(1), "Exitcode after attempting to do an atomic upgrade after removing the atomic subscription.");
        Assert.assertTrue(atomicUpgradeResultAfterUnsubscribe.getStdout().trim().startsWith(stdoutStartsWith), "Stdout starts with '" + stdoutStartsWith + "' after attempting to do an atomic upgrade after removing the atomic subscription.");
        Assert.assertEquals(atomicUpgradeResultAfterUnsubscribe.getStderr().trim(), "error: No remote 'remote \"" + osTreeContentNamespaceMatchingInstalledProducts.label + "\"' found in /etc/ostree/remotes.d", "Exitcode after attempting to do an atomic upgrade after removing the atomic subscription.");
    }
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) BigInteger(java.math.BigInteger) ContentNamespace(rhsm.data.ContentNamespace) OstreeRepo(rhsm.data.OstreeRepo) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) File(java.io.File) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 85 with ProductCert

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

Aggregations

ProductCert (rhsm.data.ProductCert)90 Test (org.testng.annotations.Test)60 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)54 SkipException (org.testng.SkipException)44 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)40 ArrayList (java.util.ArrayList)40 File (java.io.File)26 SubscriptionPool (rhsm.data.SubscriptionPool)24 EntitlementCert (rhsm.data.EntitlementCert)23 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)22 InstalledProduct (rhsm.data.InstalledProduct)21 JSONObject (org.json.JSONObject)19 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)17 List (java.util.List)16 ContentNamespace (rhsm.data.ContentNamespace)15 HashSet (java.util.HashSet)13 Calendar (java.util.Calendar)7 HashMap (java.util.HashMap)7 BigInteger (java.math.BigInteger)6 JSONArray (org.json.JSONArray)6