Search in sources :

Example 56 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class CertificateTests method testRctCatCertReportsOrdersWithQuantityUnlimited.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20032", "RHEL7-33086" }, 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 = "assert that the rct cat-cert tool reports orders as Unlimited instead of -1", groups = { "Tier1Tests", "blockedByBug-1011961" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRctCatCertReportsOrdersWithQuantityUnlimited() throws JSONException, Exception {
    int numberOfUnlimitedPools = 0;
    boolean isSystemVirtual = Boolean.valueOf(clienttasks.getFactValue("virt.is_guest"));
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    clienttasks.autoheal(null, null, true, null, null, null, null);
    for (SubscriptionPool pool : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
        if (pool.quantity.equalsIgnoreCase("Unlimited")) {
            // skip physical_only subscriptions when run on a virtual system (not necessary if getCurrentlyAllAvailableSubscriptionPools() was changed to getCurrentlyAvailableSubscriptionPools())
            if (CandlepinTasks.isPoolRestrictedToPhysicalSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId) && isSystemVirtual)
                continue;
            // skip virt_only subscriptions when run on a physical system (not necessary if getCurrentlyAllAvailableSubscriptionPools() was changed to getCurrentlyAvailableSubscriptionPools())
            if (CandlepinTasks.isPoolRestrictedToVirtualSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId) && !isSystemVirtual)
                continue;
            numberOfUnlimitedPools++;
            File entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, /*sm_serverAdminUsername*/
            sm_clientUsername, /*sm_serverAdminPassword*/
            sm_clientPassword, sm_serverUrl);
            EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
            Assert.assertEquals(entitlementCert.orderNamespace.quantity, pool.quantity, "The Order:Quantity from the granted entitlement should match the Quantity from the available Subscription Pool: " + pool);
        } else if (pool.quantity.equals("-1")) {
            Assert.fail("Available SubscriptionPools should NOT report a quantity of '" + pool.quantity + "': " + pool);
        }
    }
    if (numberOfUnlimitedPools == 0)
        throw new SkipException("Could not find any available pools with an unlimited quantity for this test.");
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) SkipException(org.testng.SkipException) SubscriptionPool(rhsm.data.SubscriptionPool) File(java.io.File) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 57 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class CertificateTests method testBaseRHELProductCertVersionUpdates.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36366", "RHEL7-33085" }, 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 base RHEL product cert will upgrade to match the releaseVer set when a package is installed/upgraded/downgraded", groups = { "Tier1Tests", "VerifyBaseRHELProductCertVersionUpdates_Test" }, dataProvider = "getVerifyBaseRHELProductCertVersionUpdates_TestData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testBaseRHELProductCertVersionUpdates(Object blockedByBug, String testPackage, String oldProductCertVersion, String oldRelease, String newerRelease) {
    clienttasks.unregister(null, null, null, null);
    restoreOriginalRhsmProductCertDirAndProductIdJsonFile();
    // need to disable the beaker repos (actually all repos that contain a productid in the metadata would be best) to prevent the yum product-id plugin from considering it for an update to the installed RHEL product cert
    if (clienttasks.isPackageInstalled(testPackage))
        clienttasks.yumRemovePackage(testPackage, "--disablerepo=beaker-*");
    // Step 1: determine the currently installed RHEL product cert
    ProductCert originalRhelProductCert = clienttasks.getCurrentRhelProductCert();
    Assert.assertNotNull(originalRhelProductCert, "Expected a base RHEL product cert to be installed.");
    // Step 2: configure a temporary productCertDir and backup the productid json database file
    log.info("Configuring a temporary product cert directory...");
    // remember the original so it can be restored later
    if (rhsmProductCertDir == null) {
        rhsmProductCertDir = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "rhsm", "productCertDir");
        Assert.assertNotNull(rhsmProductCertDir);
    }
    RemoteFileTasks.runCommandAndAssert(client, "mkdir -p " + tmpProductCertDir, Integer.valueOf(0));
    RemoteFileTasks.runCommandAndAssert(client, "rm -f " + tmpProductCertDir + "/*.pem", Integer.valueOf(0));
    clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", tmpProductCertDir);
    // remember the original so it can be restored later
    if (productIdJsonFile == null) {
        productIdJsonFile = client.runCommandAndWait("cat " + clienttasks.productIdJsonFile).getStdout().replaceAll("\\s*\n\\s*", "");
        Assert.assertTrue(productIdJsonFile != null && !productIdJsonFile.isEmpty());
    }
    // Step 3: install an old RHEL product cert
    ProductCert oldProductCert = null;
    // for (ProductCert productCert : migrationProductCerts) {	//find the old rhel product cert from the migration product certs supplied by the subscription-manager-migration-data
    for (ProductCert productCert : rhelProductCertsFromRhnDefinition) {
        // find the old rhel product cert from a clone of the rhn definition repo data
        if (productCert.productId.equals(originalRhelProductCert.productId)) {
            if (productCert.productNamespace.arch.equals(originalRhelProductCert.productNamespace.arch)) {
                if (productCert.productNamespace.version.equals(oldProductCertVersion)) {
                    oldProductCert = productCert;
                    break;
                }
            }
        }
    }
    Assert.assertNotNull(oldProductCert, "Initiating test with this old RHEL product cert: " + oldProductCert);
    RemoteFileTasks.runCommandAndAssert(client, "cp " + oldProductCert.file + " " + tmpProductCertDir + "/" + oldProductCert.productId + ".pem", Integer.valueOf(0));
    Assert.assertNotNull(clienttasks.getInstalledProductCorrespondingToProductCert(oldProductCert), "The old product cert is installed and recognized by subscription-manager.");
    // Step 4: register with autosubscribe for RHEL content
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, null, null, null, null, null, null);
    if (!clienttasks.isRhelProductCertSubscribed())
        throw new SkipException("Failed to autosubscribe to an available RHEL subscription.");
    // determine the newest available release
    // Example: [6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6Server] 6.6 is the newest
    List<String> availableReleases = clienttasks.getCurrentlyAvailableReleases(null, null, null, null);
    String newestRelease = getNewestReleaseFromReleases(availableReleases);
    // Step 5: set the GA release corresponding to the old product cert version
    clienttasks.release(null, null, oldRelease, null, null, null, null, null);
    // Note: yum @productid.py:290 - Checking for product id certs to install or update.  THIS ONLY TRIGGERS WHEN THE RPM LIST IS CHANGED BY A REMOVAL, INSTALL, OR UPDATE.
    // Step 6: install the test package and assert the product id has been upgraded.
    // to avoid... Not using downloaded repomd.xml because it is older than what we have:
    clienttasks.yumClean("metadata");
    String installOptions = "";
    // need to disable the beaker repos (actually all repos that contain a productid in the metadata would be best) to prevent the yum product-id plugin from considering it for an update to the installed RHEL product cert
    installOptions += "--disablerepo=beaker-* ";
    // need to disable the eus repos to avoid releases that do not have content for extended update support
    installOptions += "--disablerepo=rhel-*-eus-rpms ";
    // failure: repodata/repomd.xml from rhel-7-server-eus-rpms: [Errno 256] No more mirrors to try.
    // https://cdn.redhat.com/content/eus/rhel/server/7/7.0/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
    clienttasks.yumInstallPackage(testPackage, installOptions);
    // tail -f /var/log/rhsm/rhsm.log
    // 2014-05-16 12:04:27,444 [DEBUG] yum @productid.py:290 - Checking for product id certs to install or update.
    // 2014-05-16 12:04:27,449 [DEBUG] yum @productid.py:304 - product cert: 69 repo: rhel-6-server-cf-tools-1-rpms
    // 2014-05-16 12:04:27,450 [DEBUG] yum @productid.py:363 - Latest version of product cert for Red Hat Enterprise Linux Server 6.3 is already install, not updating
    // 2014-05-16 12:04:27,451 [DEBUG] yum @productid.py:304 - product cert: 69 repo: rhel-6-server-rpms
    // 2014-05-16 12:04:27,452 [DEBUG] yum @productid.py:363 - Latest version of product cert for Red Hat Enterprise Linux Server 6.3 is already install, not updating
    // 2014-05-16 12:04:27,453 [DEBUG] yum @productid.py:407 - about to run post_product_id_install
    // 2014-05-16 12:04:27,453 [DEBUG] yum @productid.py:418 - about to run post_product_id_update
    ProductCert rhelProductCert = clienttasks.getCurrentRhelProductCert();
    Assert.assertNotNull(rhelProductCert, "Expected a base RHEL product cert to be installed.");
    Assert.assertEquals(rhelProductCert.productNamespace.version, oldRelease, "After installing package '" + testPackage + "' from release '" + oldRelease + "', the installed product cert version is updated from '" + oldProductCertVersion + "'.");
    // remove the test package
    // need to disable the beaker repos (actually all repos that contain a productid in the metadata would be best) to prevent the yum product-id plugin from considering it for an update to the installed RHEL product cert
    clienttasks.yumRemovePackage(testPackage, "--disablerepo=beaker-*");
    // Step 7: set a newer release than the installed product id
    clienttasks.release(null, null, newerRelease, null, null, null, null, null);
    // Step 8: install the test package and assert the product id has been upgraded.
    // need to disable the beaker repos (actually all repos that contain a productid in the metadata would be best) to prevent the yum product-id plugin from considering it for an update to the installed RHEL product cert
    clienttasks.yumInstallPackage(testPackage, "--disablerepo=beaker-*");
    // tail -f /var/log/rhsm/rhsm.log
    // 2014-05-16 12:07:02,447 [DEBUG] yum @productid.py:290 - Checking for product id certs to install or update.
    // 2014-05-16 12:07:02,448 [DEBUG] yum @productid.py:304 - product cert: 69 repo: rhel-6-server-cf-tools-1-rpms
    // 2014-05-16 12:07:02,448 [DEBUG] yum @productid.py:363 - Latest version of product cert for Red Hat Enterprise Linux Server 6.3 is already install, not updating
    // 2014-05-16 12:07:02,448 [DEBUG] yum @productid.py:304 - product cert: 69 repo: rhel-6-server-rpms
    // 2014-05-16 12:07:02,448 [DEBUG] yum @productid.py:359 - Updating installed product cert for Red Hat Enterprise Linux Server 6.3 to Red Hat Enterprise Linux Server 6.4
    // 2014-05-16 12:07:02,449 [DEBUG] yum @productid.py:407 - about to run post_product_id_install
    // 2014-05-16 12:07:02,449 [INFO] yum @productid.py:430 - Installed product cert 69: Red Hat Enterprise Linux Server /tmp/sm-tmpProductCertDir/69.pem
    // 2014-05-16 12:07:02,450 [DEBUG] yum @productid.py:418 - about to run post_product_id_update
    rhelProductCert = clienttasks.getCurrentRhelProductCert();
    Assert.assertNotNull(rhelProductCert, "Expected a base RHEL product cert to be installed.");
    Assert.assertEquals(rhelProductCert.productNamespace.version, newerRelease, "After installing package '" + testPackage + "' from release '" + newerRelease + "', the installed product cert version is updated from '" + oldProductCertVersion + "'.");
    // Step 9: unset the release thereby giving access to the latest content
    clienttasks.release(null, null, null, true, null, null, null, null);
    // Step 10: yum update the test package to the latest version and assert the product id has been upgraded to the original product cert.
    if (// do not assert yum transaction when newerRelease is equal to the prior minor release of the current test cycle because there is not enough content yet to update - we'll see:  No packages marked for update
    Float.compare(Float.valueOf(newerRelease) + 0.1f, Float.valueOf(clienttasks.redhatReleaseXY)) == 0)
        // do not assert yum transaction when newerRelease is equal to the prior minor release of the current test cycle because there is not enough content yet to update - we'll see:  No packages marked for update
        clienttasks.yumDoPackageFromRepo_("update", testPackage, null, "--disablerepo=beaker-*");
    else
        // need to disable the beaker repos (actually all repos that contain a productid in the metadata would be best) to prevent the yum product-id plugin from considering it for an update to the installed RHEL product cert
        clienttasks.yumUpdatePackageFromRepo(testPackage, null, "--disablerepo=beaker-*");
    // tail -f /var/log/rhsm/rhsm.log
    // 2014-05-16 12:09:23,974 [DEBUG] yum @productid.py:290 - Checking for product id certs to install or update.
    // 2014-05-16 12:09:23,975 [DEBUG] yum @productid.py:304 - product cert: 69 repo: rhel-6-server-cf-tools-1-rpms
    // 2014-05-16 12:09:23,975 [DEBUG] yum @productid.py:363 - Latest version of product cert for Red Hat Enterprise Linux Server 6.3 is already install, not updating
    // 2014-05-16 12:09:23,975 [DEBUG] yum @productid.py:304 - product cert: 69 repo: rhel-6-server-rpms
    // 2014-05-16 12:09:23,975 [DEBUG] yum @productid.py:359 - Updating installed product cert for Red Hat Enterprise Linux Server 6.4 to Red Hat Enterprise Linux Server 6.5
    // 2014-05-16 12:09:23,976 [DEBUG] yum @productid.py:407 - about to run post_product_id_install
    // 2014-05-16 12:09:23,976 [INFO] yum @productid.py:430 - Installed product cert 69: Red Hat Enterprise Linux Server /tmp/sm-tmpProductCertDir/69.pem
    // 2014-05-16 12:09:23,976 [DEBUG] yum @productid.py:418 - about to run post_product_id_update
    rhelProductCert = clienttasks.getCurrentRhelProductCert();
    Assert.assertNotNull(rhelProductCert, "Expected a base RHEL product cert to be installed.");
    // if (!originalRhelProductCert.productNamespace.version.toLowerCase().contains("beta")) {	// skip assertion when originalRhelProductCert is a beta cert since a beta productId will not be available for the latest release on the CDN
    // Assert.assertEquals(rhelProductCert.productNamespace.version, originalRhelProductCert.productNamespace.version, "After updating package '"+testPackage+"' to the latest release, the installed product cert version is updated from '"+newerRelease+"' to the original version '"+originalRhelProductCert.productNamespace.version+"'.");
    // }
    Assert.assertEquals(rhelProductCert.productNamespace.version, newestRelease, "After updating package '" + testPackage + "' to the latest release, the installed product cert version is updated from '" + newerRelease + "' to the latest released version '" + newestRelease + "'.");
    // Step 11: set the rhel release backward to perform downgrade testing
    clienttasks.release(null, null, newerRelease, null, null, null, null, null);
    // Step 12: downgrade the test package and assert the original product id remains installed.
    // to avoid... Not using downloaded repomd.xml because it is older than what we have:
    clienttasks.yumClean("metadata");
    // need to disable the beaker repos (actually all repos that contain a productid in the metadata would be best) to prevent the yum product-id plugin from considering it for an update to the installed RHEL product cert
    clienttasks.yumDowngradePackageFromRepo(testPackage, null, "--disablerepo=beaker-*");
    // tail -f /var/log/rhsm/rhsm.log
    // 2014-05-16 12:11:48,233 [DEBUG] yum @productid.py:290 - Checking for product id certs to install or update.
    // 2014-05-16 12:11:48,233 [DEBUG] yum @productid.py:304 - product cert: 69 repo: rhel-6-server-cf-tools-1-rpms
    // 2014-05-16 12:11:48,233 [DEBUG] yum @productid.py:363 - Latest version of product cert for Red Hat Enterprise Linux Server 6.3 is already install, not updating
    // 2014-05-16 12:11:48,234 [DEBUG] yum @productid.py:304 - product cert: 69 repo: rhel-6-server-rpms
    // 2014-05-16 12:11:48,234 [DEBUG] yum @productid.py:363 - Latest version of product cert for Red Hat Enterprise Linux Server 6.4 is already install, not updating
    // 2014-05-16 12:11:48,234 [DEBUG] yum @productid.py:407 - about to run post_product_id_install
    // 2014-05-16 12:11:48,234 [DEBUG] yum @productid.py:418 - about to run post_product_id_update
    ProductCert finalRhelProductCert = clienttasks.getCurrentRhelProductCert();
    Assert.assertNotNull(finalRhelProductCert, "Expected a base RHEL product cert to be installed.");
    // if (!originalRhelProductCert.productNamespace.version.toLowerCase().contains("beta")) {	// skip assertion when originalRhelProductCert is a beta cert since a beta productId will not be available for the latest release on the CDN
    // Assert.assertEquals(finalRhelProductCert.productNamespace.version, originalRhelProductCert.productNamespace.version, "After downgrading package '"+testPackage+"' from the latest release, the installed product cert version remains the same as the original version '"+originalRhelProductCert.productNamespace.version+"'.");
    // }
    Assert.assertEquals(finalRhelProductCert.productNamespace.version, newestRelease, "After downgrading package '" + testPackage + "' from the latest release '" + newestRelease + "' to '" + newerRelease + "', the installed product cert version remains unchanged at release version '" + newestRelease + "'.");
}
Also used : 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)

Example 58 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class CertificateTests method testYumUpdateWithDisabledRepoWillNotDeleteJBossProductId.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20034", "RHEL7-55176" }, 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 = "When updating a RHEL package on a system with JBoss, verify that the JBoss productId is not deleted when calling yum update with --disablerepo=jb-eap-6-for-rhel-6-server-rpms", groups = { "Tier1Tests", "VerifyYumUpdateWithDisabledRepoWillNotDeleteJBossProductId_Test", "blockedByBug-1159163", "blockedByBug-1512948" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumUpdateWithDisabledRepoWillNotDeleteJBossProductId() throws JSONException, Exception {
    // fixed in https://bugzilla.redhat.com/show_bug.cgi?id=1159163#c12  subscription-manager commit 68d210bb9145e7ea65aea979fde694436e3e0373 subscription-manager-1.14.6-1
    clienttasks.unregister(null, null, null, null);
    restoreOriginalRhsmProductCertDirAndProductIdJsonFile();
    // hard data for this test...
    String rhelPackage = "zsh";
    // Required Tags: rhel-6-server Arches: x86_64, x86
    String rhelRepo = "rhel-6-server-rpms";
    rhelRepo = String.format("rhel-%s-server-rpms", clienttasks.redhatReleaseX);
    // Red Hat Enterprise Linux Server	// Tags: rhel-6,rhel-6-server Arch: x86_64
    String rhelProductId = "69";
    // rpm -q jline-eap6.noarch --requires  => rpmlib
    String jbossPackage = "jline-eap6";
    // Required Tags: rhel-6-server Arches: x86_64, x86
    String jbossRepo = "jb-eap-6-for-rhel-6-server-rpms";
    jbossRepo = String.format("jb-eap-6-for-rhel-%s-server-rpms", clienttasks.redhatReleaseX);
    // JBoss Enterprise Application Platform
    String jbossProductId = "183";
    if (clienttasks.arch.equals("ppc64")) {
        // Required Tags: rhel-6-ibm-power Arches: ppc64
        rhelRepo = "rhel-6-for-power-rpms";
        rhelRepo = String.format("rhel-%s-for-power-rpms", clienttasks.redhatReleaseX);
        // Red Hat Enterprise Linux for Power, big endian	// Tags: rhel-6,rhel-6-ibm-power Arch: ppc64
        rhelProductId = "74";
        // Required Tags: rhel-6-ibm-power Arches: ppc64
        jbossRepo = "jb-eap-6-for-rhel-6-for-power-rpms";
        jbossRepo = String.format("jb-eap-6-for-rhel-%s-for-power-rpms", clienttasks.redhatReleaseX);
        // JBoss Enterprise Application Platform
        jbossProductId = "183";
    }
    // need to disable the beaker repos (actually all repos that contain a productid in the metadata would be best) to prevent the yum product-id plugin from considering it for an update to the installed RHEL product cert
    if (clienttasks.isPackageInstalled(rhelPackage))
        clienttasks.yumRemovePackage(rhelPackage, "--disablerepo=beaker-*");
    // need to disable the beaker repos (actually all repos that contain a productid in the metadata would be best) to prevent the yum product-id plugin from considering it for an update to the installed RHEL product cert
    if (clienttasks.isPackageInstalled(jbossPackage))
        clienttasks.yumRemovePackage(jbossPackage, "--disablerepo=beaker-*");
    // determine the currently installed product certs
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    ProductCert rhelProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductId, currentProductCerts);
    if (rhelProductCert == null)
        throw new SkipException("JBoss Enterprise Application Platform is not offered on this variant '" + clienttasks.variant + "' of RHEL.");
    ProductCert jbossProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", jbossProductId, currentProductCerts);
    Assert.assertNull(jbossProductCert, "Do not expect the JBoss product to be installed at the beginning of this test.");
    // configure a temporary productCertDir and backup the productid json database file
    log.info("Configuring a temporary product cert directory...");
    // remember the original so it can be restored later
    if (rhsmProductCertDir == null) {
        rhsmProductCertDir = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "rhsm", "productCertDir");
        Assert.assertNotNull(rhsmProductCertDir);
    }
    RemoteFileTasks.runCommandAndAssert(client, "mkdir -p " + tmpProductCertDir, Integer.valueOf(0));
    RemoteFileTasks.runCommandAndAssert(client, "rm -f " + tmpProductCertDir + "/*.pem", Integer.valueOf(0));
    // due to /etc/pki/product-default/ certs, this assert will fail when /etc/pki/product/ is empty  RemoteFileTasks.runCommandAndAssert(client,"cp "+rhsmProductCertDir+"/*.pem "+tmpProductCertDir, Integer.valueOf(0));
    RemoteFileTasks.runCommandAndWait(client, "cp " + rhsmProductCertDir + "/*.pem " + tmpProductCertDir, TestRecords.action());
    clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", tmpProductCertDir);
    // remember the original so it can be restored later
    if (productIdJsonFile == null) {
        productIdJsonFile = client.runCommandAndWait("cat " + clienttasks.productIdJsonFile).getStdout().replaceAll("\\s*\n\\s*", "");
        Assert.assertTrue(productIdJsonFile != null && !productIdJsonFile.isEmpty());
    }
    // register with autosubscribe for rhel content
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, null, null, null, null, null, null);
    List<InstalledProduct> currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
    InstalledProduct rhelInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductId, currentlyInstalledProducts);
    Assert.assertNotNull(rhelInstalledProduct, "Expecting the installed RHEL Server product '" + rhelProductId + "' to be installed.");
    if (!rhelInstalledProduct.status.equals("Subscribed") && CandlepinType.standalone.equals(sm_serverType))
        throw new SkipException("This test is designed for execution against a non-standalone candlepin server where available RHEL subscriptions are expected.");
    Assert.assertEquals(rhelInstalledProduct.status, "Subscribed", "Expecting the RHEL Server product to have been auto-subscribed during registration.");
    // subscribe to JBoss Enterprise Application Platform - Example SKU MW0167254 Red Hat JBoss Enterprise Application Platform with Management, 16 Core Standard, L3 Support Partner)
    String jbossPoolId = null;
    List<SubscriptionPool> jbossSubscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools(jbossProductId, sm_serverUrl);
    if (jbossSubscriptionPools.isEmpty() && !CandlepinType.standalone.equals(sm_serverType))
        Assert.fail("Expected to find an available subscription pool for Red Hat JBoss Enterprise Application Platform.");
    if (jbossSubscriptionPools.isEmpty())
        throw new SkipException("Cannot run this test when there is no available subscription for Red Hat JBoss Enterprise Application Platform.");
    // too many asserts... clienttasks.subscribeToSubscriptionPool(jbossSubscriptionPools.get(0));
    clienttasks.subscribe_(null, null, jbossSubscriptionPools.get(0).poolId, null, null, null, null, null, null, null, null, null, null);
    // enable the jb-eap-6-for-rhel-6-server-rpms repo
    // Note: This is necessary. If only enabled during yum install --enablerepo=jb-eap-6-for-rhel-6-server-rpms then the jboss product id will install, but it will also be deleted during the yum install of a rhel package.
    clienttasks.repos(null, null, null, jbossRepo, null, null, null, null, null);
    // yum install jline-eap6 from repo jb-eap-6-for-rhel-6-server-rpms
    // clienttasks.yumInstallPackageFromRepo(jbossPackage, jbossRepo, null);
    clienttasks.yumInstallPackage(jbossPackage);
    // assert that the jboss product id 183 has been newly installed
    currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
    InstalledProduct jbossInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", jbossProductId, currentlyInstalledProducts);
    Assert.assertNotNull(jbossInstalledProduct, "After installing jboss package '" + jbossPackage + "' from enabled jboss repo '" + jbossRepo + "', the jboss product id '" + jbossProductId + "' is installed.");
    // now for the real test...  install a rhel package with yum --disablerepo and then verify that the jboss product cert remains installed...
    // clienttasks.repos(null, null, null, rhelRepo, null, null, null, null); // is already enabled by default
    clienttasks.yumInstallPackage(rhelPackage, "--disablerepo=" + jbossRepo);
    // verify that the jboss product cert remains installed - Bug 1159163 - RHSM product certificate gets deleted by product-id plugin on running 'yum update --disablerepo
    currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
    jbossInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", jbossProductId, currentlyInstalledProducts);
    Assert.assertNotNull(jbossInstalledProduct, "After installing rhel package '" + rhelPackage + "' while disabling the jboss repo '" + jbossRepo + "' in-line, the jboss product id '" + jbossProductId + "' remains installed.");
    // remove the only installed jboss package while disabling the rhel repo and verify the jboss product id has been removed, but the rhel product id remains
    // TEMPORARY WORKAROUND
    boolean invokeWorkaroundWhileBugIsOpen = true;
    // Bug 1222627 - deletion of JBOSS product certificate is neglected by product-id plugin on running 'yum remove JBOSS-PKG --disablerepo=RHEL-REPO'
    String bugId = "1222627";
    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, we will exclude the --disablerepo=" + rhelRepo + " option from the yum removal of the jboss package.");
        // THIS PASSES THE FOLLOWING Assert.assertNull(jbossInstalledProduct,...
        clienttasks.yumRemovePackage(jbossPackage);
    } else
        // END OF WORKAROUND
        // THIS FAILS THE FOLLOWING Assert.assertNull(jbossInstalledProduct,...  due to Bug 1222627
        clienttasks.yumRemovePackage(jbossPackage, "--disablerepo=" + rhelRepo);
    // verify that the jboss product cert is removed
    currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
    jbossInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", jbossProductId, currentlyInstalledProducts);
    Assert.assertNull(jbossInstalledProduct, "After removing jboss package '" + jbossPackage + "' while disabling rhel repo '" + rhelRepo + "', the jboss product id '" + jbossProductId + "' is removed (because it is the final remaining package installed from jboss repo '" + jbossRepo + "').");
    // verify that the rhel product cert remains installed
    rhelInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductId, currentlyInstalledProducts);
    Assert.assertNotNull(rhelInstalledProduct, "After removing jboss package '" + jbossPackage + "' while disabling rhel repo '" + rhelRepo + "', the rhel product id '" + rhelProductId + "' remains installed (because there are many other rhel packages from rhel repo '" + rhelRepo + "' still installed).");
    // remove the rhel package
    clienttasks.yumRemovePackage(rhelPackage);
    // verify that the jboss product cert remains uninstalled
    currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
    jbossInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", jbossProductId, currentlyInstalledProducts);
    Assert.assertNull(jbossInstalledProduct, "After removing rhel package '" + rhelPackage + "', the jboss product id '" + jbossProductId + "' from enabled repo '" + jbossRepo + "' remains uninstalled.");
    // verify that the rhel product cert remains installed
    rhelInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductId, currentlyInstalledProducts);
    Assert.assertNotNull(rhelInstalledProduct, "After removing rhel package '" + rhelPackage + "' the rhel product id '" + rhelProductId + "' remains installed (because there are many other rhel packages from rhel repo '" + rhelRepo + "' still installed).");
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 59 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class CertificateTests method testBaseRHELProductCertArchAndTags.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20037", "RHEL7-51046" }, // TODO should be a list of ["redhat-release-server","redhat-release-client","redhat-release-workstation","redhat-release-computenode"]
level = DefTypes.Level.COMPONENT, // TODO should be a list of ["redhat-release-server","redhat-release-client","redhat-release-workstation","redhat-release-computenode"]
component = "redhat-release-server", 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 installed base RHEL product cert provides the expected tags", groups = { "Tier1Tests", "blockedByBug-1259820", "blockedByBug-1259839" }, dependsOnMethods = { "testBaseRHELProductCertIsInstalled" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testBaseRHELProductCertArchAndTags() {
    ProductCert productCert = clienttasks.getCurrentRhelProductCert();
    List<String> providedTags = Arrays.asList(productCert.productNamespace.providedTags.split("\\s*,\\s*"));
    List<String> expectedTags = Arrays.asList("FIXME");
    // assert the product cert arch matches the system
    String system_arch = clienttasks.arch;
    if (Arrays.asList("i386", "i486", "i586", "i686").contains(clienttasks.arch)) {
        // Note: x86 is a general arch to cover all 32-bit intel microprocessors
        system_arch = "i386";
    }
    Assert.assertEquals(productCert.productNamespace.arch, system_arch, "Current RHEL product cert arch.");
    // http://git.app.eng.bos.redhat.com/git/rcm/rcm-metadata.git/tree/product_ids
    switch(Integer.valueOf(productCert.productId)) {
        case // Red Hat Enterprise Linux Desktop
        68:
            expectedTags = Arrays.asList("rhel-#,rhel-#-client".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux Server
        69:
            expectedTags = Arrays.asList("rhel-#,rhel-#-server".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux Workstation
        71:
            expectedTags = Arrays.asList("rhel-#,rhel-#-workstation".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux for IBM z Systems
        72:
            expectedTags = Arrays.asList("rhel-#,rhel-#-ibm-system-z".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux for IBM POWER
        74:
            expectedTags = Arrays.asList("rhel-#,rhel-#-ibm-power".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux for Scientific Computing
        76:
            expectedTags = Arrays.asList("rhel-#,rhel-#-computenode".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux for IBM POWER LE
        279:
            expectedTags = Arrays.asList("rhel-#,rhel-#-ibm-power-le".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux Server for ARM
        294:
            expectedTags = Arrays.asList("rhel-#,rhel-#-arm".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux for ARM 64
        419:
            expectedTags = Arrays.asList("rhel-#,rhel-alt-#,rhel-alt-#-armv8-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            // ADD WORKAROUND FOR Bug 1518886 - RHEL-ALT-7.5 product certs should also provide tag "rhel-7"
            // UPDATE: BUG 1518886 was CLOSED WONTFIX in favor of the fix from Bug 1510024 which now recognizes rhel-alt-# as a RHEL product
            expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-armv8-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux for Power 9
        420:
            expectedTags = Arrays.asList("rhel-#,rhel-alt-#,rhel-alt-#-power9".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            // ADD WORKAROUND FOR Bug 1518886 - RHEL-ALT-7.5 product certs should also provide tag "rhel-7"
            // UPDATE: BUG 1518886 was CLOSED WONTFIX in favor of the fix from Bug 1510024 which now recognizes rhel-alt-# as a RHEL product
            expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-power9".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux for IBM System z (Structure A)
        434:
            expectedTags = Arrays.asList("rhel-#,rhel-alt-#,rhel-alt-#-system-z-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            // ADD WORKAROUND FOR Bug 1518886 - RHEL-ALT-7.5 product certs should also provide tag "rhel-7"
            // UPDATE: BUG 1518886 was CLOSED WONTFIX in favor of the fix from Bug 1510024 which now recognizes rhel-alt-# as a RHEL product
            expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-system-z-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux for ARM 64 Beta
        363:
            expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-armv8-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux for Power 9 Beta
        362:
            expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-power9".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux for IBM System z (Structure A) Beta
        433:
            expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-system-z-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux 6 Server HTB
        135:
            expectedTags = Arrays.asList("rhel-6-server-htb,rhel-6-server".split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux 6 Workstation HTB
        155:
            expectedTags = Arrays.asList("rhel-6-workstation-htb,rhel-6-workstation".split("\\s*,\\s*"));
            break;
        case // Red Hat Enterprise Linux 7 Server High Touch Beta
        230:
            expectedTags = Arrays.asList("rhel-7-htb,rhel-7-server".split("\\s*,\\s*"));
            // TEMPORARY WORKAROUND
            if (!providedTags.containsAll(expectedTags)) {
                boolean invokeWorkaroundWhileBugIsOpen = true;
                // Bug 1538957 - product-default .pem files do not contain expected data
                String bugId = "1538957";
                try {
                    if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
                        log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                        SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                    } else {
                        invokeWorkaroundWhileBugIsOpen = false;
                    }
                } catch (BugzillaAPIException be) {
                /* ignore exception */
                } catch (RuntimeException re) {
                /* ignore exception */
                }
                if (invokeWorkaroundWhileBugIsOpen) {
                    throw new SkipException("Skipping this test when product '" + productCert.productName + "' is installed while blocking bug '" + bugId + "' is open.");
                }
            }
            // END OF WORKAROUND
            break;
        case // Red Hat Enterprise Linux 7 Workstation High Touch Beta
        231:
            expectedTags = Arrays.asList("rhel-7-htb,rhel-7-workstation".split("\\s*,\\s*"));
            // TEMPORARY WORKAROUND
            if (!providedTags.containsAll(expectedTags)) {
                boolean invokeWorkaroundWhileBugIsOpen = true;
                // Bug 1538957 - product-default .pem files do not contain expected data
                String bugId = "1538957";
                try {
                    if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
                        log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                        SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                    } else {
                        invokeWorkaroundWhileBugIsOpen = false;
                    }
                } catch (BugzillaAPIException be) {
                /* ignore exception */
                } catch (RuntimeException re) {
                /* ignore exception */
                }
                if (invokeWorkaroundWhileBugIsOpen) {
                    throw new SkipException("Skipping this test when product '" + productCert.productName + "' is installed while blocking bug '" + bugId + "' is open.");
                }
            }
            // END OF WORKAROUND
            break;
        default:
            Assert.fail("Unknown productCert id '" + productCert.productId + "'");
            break;
    }
    // assert the product cert provides all the expected tags
    for (String expectedTag : expectedTags) {
        Assert.assertTrue(providedTags.contains(expectedTag), "Actuals RHEL Product Cert tags " + providedTags + " contain expected tag '" + expectedTag + "' for RHEL '" + clienttasks.redhatReleaseX + "' product id '" + productCert.productNamespace.id + "'");
    }
}
Also used : ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 60 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class CertificateTests method testOnlyOneBaseRHELProductCertIsInstalled.

// 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-20031", "RHEL7-51044" }, 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 no more than one RHEL product cert is ever installed.", groups = { "Tier1Tests", "blockedByBug-854879", "blockedByBug-904193", "blockedByBug-1506271" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testOnlyOneBaseRHELProductCertIsInstalled() {
    // base RHEL product ids
    // Reference: http://git.app.eng.bos.redhat.com/git/rcm/rcm-metadata.git/tree/product_ids
    List<String> baseProductIds = Arrays.asList(// Red Hat Enterprise Linux Desktop
    "68", // Red Hat Enterprise Linux Server
    "69", // Red Hat Enterprise Linux Workstation
    "71", // Red Hat Enterprise Linux for IBM System z
    "72", // Red Hat Enterprise Linux for IBM POWER
    "74", // Red Hat Enterprise Linux for Scientific Computing
    "76", // Red Hat Enterprise Linux for IBM POWER LE
    "279", // Red Hat Enterprise Linux Server for ARM
    "294", // Red Hat Enterprise Linux for Power 9
    "420", // Red Hat Enterprise Linux for ARM 64
    "419", // Red Hat Enterprise Linux for IBM System z (Structure A)
    "434", // Red Hat Enterprise Linux for Power 9 Beta
    "362", // Red Hat Enterprise Linux for ARM 64 Beta
    "363", // Red Hat Enterprise Linux for IBM System z (Structure A) Beta
    "433", // Red Hat Enterprise Linux 6 Server HTB
    "135", // Red Hat Enterprise Linux 6 Workstation HTB
    "155", // Red Hat Enterprise Linux 7 Server High Touch Beta
    "230", // Red Hat Enterprise Linux 7 Workstation High Touch Beta
    "231", // Red Hat Beta
    "180");
    // find all installed RHEL product Certs
    List<ProductCert> currentRhelProductCerts = new ArrayList<ProductCert>();
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    for (ProductCert productCert : currentProductCerts) {
        if (baseProductIds.contains(productCert.productId)) {
            currentRhelProductCerts.add(productCert);
        }
    }
    if (currentRhelProductCerts.size() > 1) {
        log.warning("Found multiple installed RHEL product certs:");
        for (ProductCert productCert : currentRhelProductCerts) {
            log.warning(productCert.toString());
        }
    }
    if (currentRhelProductCerts.isEmpty()) {
        log.warning("Did not detect any RHEL product certs among the following installed products:");
        for (ProductCert productCert : currentProductCerts) {
            log.info(productCert.toString());
        }
    }
    /* 7/13/2015 no longer true now that /etc/pki/product-default may also provide a duplicate rhel product
		Assert.assertTrue(rhelProductCertsInstalled.size()==1,"At most only one base RHEL product cert should ever be installed.");
		instead, let's make sure they all cover the same product id... */
    Set<String> rhelProductIds = new HashSet<String>();
    for (ProductCert rhelProductCert : currentRhelProductCerts) rhelProductIds.add(rhelProductCert.productId);
    Assert.assertEquals(rhelProductIds.size(), 1, "Only one base RHEL product cert ID (actual " + rhelProductIds + ") is currently installed.");
    String baseRhelProductId = (String) (rhelProductIds.toArray())[0];
    Assert.assertEquals(InstalledProduct.findAllInstancesWithMatchingFieldFromList("productId", baseRhelProductId, clienttasks.getCurrentlyInstalledProducts()).size(), 1, "Only one base RHEL product cert ID (" + baseRhelProductId + ") appears in list of installed products.");
    Assert.assertNotNull(clienttasks.getCurrentRhelProductCert(), "Discovered the currently installed base RHEL product cert based on an expected tag.");
}
Also used : ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) HashSet(java.util.HashSet) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)267 Test (org.testng.annotations.Test)267 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)244 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)146 SkipException (org.testng.SkipException)125 SubscriptionPool (rhsm.data.SubscriptionPool)71 ArrayList (java.util.ArrayList)62 BigInteger (java.math.BigInteger)53 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)42 ProductSubscription (rhsm.data.ProductSubscription)42 File (java.io.File)36 JSONObject (org.json.JSONObject)33 EntitlementCert (rhsm.data.EntitlementCert)32 ProductCert (rhsm.data.ProductCert)32 InstalledProduct (rhsm.data.InstalledProduct)15 ConsumerCert (rhsm.data.ConsumerCert)14 HashMap (java.util.HashMap)11 Calendar (java.util.Calendar)10 List (java.util.List)10 JSONArray (org.json.JSONArray)8