Search in sources :

Example 1 with ProductCert

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

the class SearchDisabledReposTests method testRhelSubscriptionBaseAndOptionalReposAreAvailable.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20089", "RHEL7-55192" }, 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 we can register with auto-subscribe to cover the base RHEL product cert; assert enablement of base rhel and optional repo", groups = { "Tier1Tests" }, priority = 20, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRhelSubscriptionBaseAndOptionalReposAreAvailable() throws JSONException, Exception {
    // get the currently installed RHEL product cert
    ProductCert rhelProductCert = clienttasks.getCurrentRhelProductCert();
    Assert.assertNotNull(rhelProductCert, "Expecting a RHEL Product Cert to be installed.");
    log.info("RHEL product cert installed: " + rhelProductCert);
    // register with auto-subscribe
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    // is rhelProductCert subscribed?
    InstalledProduct rhelInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductCert.productId, clienttasks.getCurrentlyInstalledProducts());
    if (!rhelInstalledProduct.status.equals("Subscribed") && sm_serverType.equals(CandlepinType.standalone))
        throw new SkipException("Skipping this test against a standalone Candlepin server that has no RHEL subscriptions available.");
    Assert.assertEquals(rhelInstalledProduct.status, "Subscribed", "Autosubscribed status of installed RHEL productId '" + rhelProductCert.productId + "'");
    // get the yum repos
    List<Repo> subscribedRepos = clienttasks.getCurrentlySubscribedRepos();
    // Enabled: 1
    if (clienttasks.redhatReleaseX.equals("7") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("aarch64") && rhelProductCert.productId.equals("294")) /*Red Hat Enterprise Linux Server for ARM*/
    {
        rhelBaseRepoId = "rhel-7-for-arm-rpms";
    }
    // Enabled: 0
    if (clienttasks.redhatReleaseX.equals("7") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("ppc64le") && rhelProductCert.productId.equals("279")) /*Red Hat Enterprise Linux for Power, little endian*/
    {
        rhelBaseRepoId = "rhel-7-for-power-le-rpms";
    }
    // Enabled: 1
    if (clienttasks.redhatReleaseX.equals("7") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("ppc64")) {
        rhelBaseRepoId = "rhel-7-for-power-rpms";
    }
    // Enabled: 1
    if (clienttasks.redhatReleaseX.equals("7") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("s390x")) {
        rhelBaseRepoId = "rhel-7-for-system-z-rpms";
    }
    // Enabled: 1
    if (clienttasks.redhatReleaseX.equals("7") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("x86_64")) {
        rhelBaseRepoId = "rhel-7-server-rpms";
    }
    // Enabled: 1
    if (clienttasks.redhatReleaseX.equals("7") && clienttasks.variant.equals("Client") && clienttasks.arch.equals("x86_64")) {
        rhelBaseRepoId = "rhel-7-desktop-rpms";
    }
    // Enabled: 1
    if (clienttasks.redhatReleaseX.equals("7") && clienttasks.variant.equals("ComputeNode") && clienttasks.arch.equals("x86_64")) {
        rhelBaseRepoId = "rhel-7-hpc-node-rpms";
    }
    // Enabled: 1
    if (clienttasks.redhatReleaseX.equals("7") && clienttasks.variant.equals("Workstation") && clienttasks.arch.equals("x86_64")) {
        rhelBaseRepoId = "rhel-7-workstation-rpms";
    }
    // NOTE: BETA PRODUCT 362 AND GA PRODUCT 420 BOTH PROVIDE THE SAME TAGS "rhel-alt-7,rhel-alt-7-power9" WHICH MEANS THEY CAN ACCESS THE SAME CONTENT AND ARE EFFECTIVELY THE SAME PRODUCT (ASSUMING ALL POWER9 SKUS PROVIDE BOTH 362 AND 420)
    if (clienttasks.redhatReleaseX.equals("7") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("ppc64le") && (rhelProductCert.productId.equals("362") || /*Red Hat Enterprise Linux for Power 9 Beta*/
    rhelProductCert.productId.equals("420"))) {
        rhelBaseRepoId = "rhel-7-for-power-9-rpms";
    }
    // NOTE: BETA PRODUCT 433 AND GA PRODUCT 434 BOTH PROVIDE THE SAME TAGS "rhel-alt-7,rhel-alt-7-system-z-a" WHICH MEANS THEY CAN ACCESS THE SAME CONTENT AND ARE EFFECTIVELY THE SAME PRODUCT (ASSUMING ALL SYSTEMZ SKUS PROVIDE BOTH 433 AND 434)
    if (clienttasks.redhatReleaseX.equals("7") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("s390x") && (rhelProductCert.productId.equals("433") || /*Red Hat Enterprise Linux for IBM System z (Structure A) Beta*/
    rhelProductCert.productId.equals("434"))) {
        rhelBaseRepoId = "rhel-7-for-system-z-a-rpms";
    }
    // NOTE: BETA PRODUCT 363 AND GA PRODUCT 419 BOTH PROVIDE THE SAME TAGS "rhel-alt-7,rhel-alt-7-armv8-a" WHICH MEANS THEY CAN ACCESS THE SAME CONTENT AND ARE EFFECTIVELY THE SAME PRODUCT (ASSUMING ALL SYSTEMZ SKUS PROVIDE BOTH 363 AND 419)
    if (clienttasks.redhatReleaseX.equals("7") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("aarch64") && (rhelProductCert.productId.equals("363") || /*Red Hat Enterprise Linux for ARM 64 Beta*/
    rhelProductCert.productId.equals("419"))) {
        rhelBaseRepoId = "rhel-7-for-arm-64-rpms";
    }
    // Repo ID:   rhel-6-server-optional-rpms
    if (clienttasks.redhatReleaseX.equals("6") && clienttasks.variant.equals("Server") && (clienttasks.arch.matches("i\\d86|x86_64"))) {
        rhelBaseRepoId = "rhel-6-server-rpms";
    }
    // Repo ID:   rhel-6-for-power-beta-rpms
    if (clienttasks.redhatReleaseX.equals("6") && clienttasks.variant.equals("Server") && (clienttasks.arch.equals("ppc64"))) {
        rhelBaseRepoId = "rhel-6-for-power-rpms";
    }
    // Repo ID:   rhel-6-for-system-z-beta-rpms
    if (clienttasks.redhatReleaseX.equals("6") && clienttasks.variant.equals("Server") && (clienttasks.arch.equals("s390x"))) {
        rhelBaseRepoId = "rhel-6-for-system-z-rpms";
    }
    // Repo ID:   rhel-6-desktop-optional-rpms
    if (clienttasks.redhatReleaseX.equals("6") && clienttasks.variant.equals("Client") && (clienttasks.arch.matches("i\\d86|x86_64"))) {
        rhelBaseRepoId = "rhel-6-desktop-rpms";
    }
    // Repo ID:   rhel-6-hpc-node-optional-rpms
    if (clienttasks.redhatReleaseX.equals("6") && clienttasks.variant.equals("ComputeNode") && (clienttasks.arch.equals("x86_64"))) {
        rhelBaseRepoId = "rhel-6-hpc-node-rpms";
    }
    // PLATFORM=RedHatEnterpriseLinux6-Workstation-x86_64
    if (clienttasks.redhatReleaseX.equals("6") && clienttasks.variant.equals("Workstation") && (clienttasks.arch.matches("i\\d86|x86_64"))) {
        rhelBaseRepoId = "rhel-6-workstation-rpms";
    }
    // predict the disabled optional repo and potential presence of other enabled repos
    if (rhelBaseRepoId != null) {
        rhelOptionalRepoId = rhelBaseRepoId.replaceFirst("-rpms$", "-optional-rpms");
        rhelEusRepoId = rhelBaseRepoId.replaceFirst("-rpms$", "-eus-rpms");
        rhelBetaRepoId = rhelBaseRepoId.replaceFirst("-rpms$", "-beta-rpms");
        rhelHtbRepoId = rhelBaseRepoId.replaceFirst("-rpms$", "-htb-rpms");
        rhelOptionalHtbRepoId = rhelBaseRepoId.replaceFirst("-rpms$", "-optional-htb-rpms");
    } else {
        Assert.fail("Additional automation development is needed in this test to predict the name of the enabled base RHEL repo for RHEL" + clienttasks.redhatReleaseX + " " + clienttasks.variant + " " + clienttasks.arch + "; Installed Product Cert: " + rhelProductCert);
    }
    // expected rhelBaseRepoId and rhelOptionalRepoId to the corresponding HTB repos
    if (rhelProductCert.productId.equals("230") || /*Red Hat Enterprise Linux 7 Server High Touch Beta*/
    rhelProductCert.productId.equals("231")) /*Red Hat Enterprise Linux 7 Workstation High Touch Beta)*/
    {
        log.info("Adjusting the expected base and optional repos because the default installed RHEL product appears to be High Touch Beta (this is expected for Snapshot composes).");
        rhelBaseRepoId = rhelHtbRepoId;
        rhelOptionalRepoId = rhelOptionalHtbRepoId;
    }
    // assert the base rhel repo is enabled by default
    Repo rhelBaseRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelBaseRepoId, subscribedRepos);
    Assert.assertNotNull(rhelBaseRepo, "RHEL base repo id '" + rhelBaseRepoId + "' was found in subscribed repos.");
    Assert.assertTrue(rhelBaseRepo.enabled, "RHEL base repo id '" + rhelBaseRepoId + "' is enabled by default.");
    // assert the optional rhel repo is disabled by default
    Repo rhelOptionalRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelOptionalRepoId, subscribedRepos);
    Assert.assertNotNull(rhelOptionalRepo, "RHEL optional repo id '" + rhelOptionalRepoId + "' was found in subscribed repos.");
    Assert.assertTrue(!rhelOptionalRepo.enabled, "RHEL optional repo id '" + rhelOptionalRepoId + "' is disabled by default.");
    // determine if beta rhel repo is entitled; if not then set it to null
    // assert the beta rhel repo is disabled by default
    Repo rhelBetaRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelBetaRepoId, subscribedRepos);
    if (rhelBetaRepo == null)
        rhelBetaRepoId = null;
    if (rhelBetaRepo != null)
        Assert.assertTrue(!rhelBetaRepo.enabled, "RHEL beta repo id '" + rhelBetaRepoId + "' is disabled by default.");
    // determine if htb rhel repo is entitled; if not then set it to null
    Repo rhelHtbRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelHtbRepoId, subscribedRepos);
    if (rhelHtbRepo == null)
        rhelHtbRepoId = null;
    // determine if optional htb rhel repo is entitled; if not then set it to null
    Repo rhelOptionalHtbRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelOptionalHtbRepoId, subscribedRepos);
    if (rhelOptionalHtbRepo == null)
        rhelOptionalHtbRepoId = null;
    // determine if eus rhel repo is entitled; if not then set it to null
    Repo rhelEusRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelEusRepoId, subscribedRepos);
    if (rhelEusRepo == null)
        rhelEusRepoId = null;
}
Also used : Repo(rhsm.data.Repo) InstalledProduct(rhsm.data.InstalledProduct) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 2 with ProductCert

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

the class SubscribeTests method getInstalledProductCertsDataAsListOfLists.

protected List<List<Object>> getInstalledProductCertsDataAsListOfLists() {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    for (ProductCert productCert : clienttasks.getCurrentProductCerts()) {
        BlockedByBzBug blockedByBzBug = null;
        // Bug 951633 - installed product with comma separated arch attribute fails to go green
        if (productCert.productNamespace.arch.contains(","))
            blockedByBzBug = new BlockedByBzBug("951633");
        ll.add(Arrays.asList(new Object[] { blockedByBzBug, productCert }));
    }
    return ll;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JSONObject(org.json.JSONObject) ProductCert(rhsm.data.ProductCert) BlockedByBzBug(com.redhat.qe.auto.bugzilla.BlockedByBzBug)

Example 3 with ProductCert

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

the class BugzillaTests method configureTmpProductCertDirWithInstalledProductCerts.

protected void configureTmpProductCertDirWithInstalledProductCerts(List<ProductCert> installedProductCerts) {
    if (rhsmProductCertDir == null) {
        rhsmProductCertDir = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "rhsm", "productCertDir");
        Assert.assertNotNull(rhsmProductCertDir);
    }
    log.info("Initializing a new product cert directory with the currently installed product certs for this test...");
    RemoteFileTasks.runCommandAndAssert(client, "mkdir -p " + tmpProductCertDir, Integer.valueOf(0));
    RemoteFileTasks.runCommandAndAssert(client, "rm -f " + tmpProductCertDir + "/*.pem", Integer.valueOf(0));
    for (ProductCert productCert : installedProductCerts) {
        RemoteFileTasks.runCommandAndAssert(client, "cp " + productCert.file + " " + tmpProductCertDir, Integer.valueOf(0));
    }
    clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", tmpProductCertDir);
}
Also used : ProductCert(rhsm.data.ProductCert)

Example 4 with ProductCert

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

the class BugzillaTests method testSystemCompliantFactWhenAllProductsAreExpired.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@Test(description = "verify that system should not be compliant for an expired subscription", groups = { "Tier3Tests", "VerifySystemCompliantFact" }, enabled = false)
public void testSystemCompliantFactWhenAllProductsAreExpired() throws JSONException, Exception {
    List<ProductCert> productCerts = clienttasks.getCurrentProductCerts();
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    File expectCertFile = new File(System.getProperty("automation.dir", null) + "/certs/Expiredcert.pem");
    RemoteFileTasks.putFile(client, expectCertFile.toString(), "/root/", "0755");
    clienttasks.importCertificate_("/root/Expiredcert.pem");
    for (InstalledProduct installed : clienttasks.getCurrentlyInstalledProducts()) {
        if ((installed.status.equals("Expired"))) {
            ProductCert productCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", installed.productId, productCerts);
            configureTmpProductCertDirWithInstalledProductCerts(Arrays.asList(productCert));
        }
    }
    clienttasks.facts(null, true, null, null, null, null);
    List<InstalledProduct> currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
    Assert.assertEquals(currentlyInstalledProducts.size(), 1, "Expecting one installed product provided by the expired entitlement just imported.");
    String actual = clienttasks.getFactValue(factname).trim();
    Assert.assertEquals(actual, "invalid", "Value of system fact '" + factname + "'.");
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ProductCert(rhsm.data.ProductCert) File(java.io.File) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 5 with ProductCert

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

the class BugzillaTests method testStatusAfterProductIdIsAddedOrDeleted.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21971", "RHEL7-51833" }, 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 = "Tier3")
@Test(description = "verify status check and response from server after addition and deletion of product to/from /etc/pki/product/", groups = { "Tier3Tests", "VerifyStatusCheck", "blockedByBug-921870", "blockedByBug-1183175" }, enabled = true)
public void testStatusAfterProductIdIsAddedOrDeleted() throws Exception {
    String result, expectedStatus;
    Boolean Flag = false;
    ProductCert installedProductCert32060 = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "32060", clienttasks.getCurrentProductCerts());
    Assert.assertNotNull(installedProductCert32060, "Found installed product cert 32060 needed for this test.");
    configureTmpProductCertDirWithInstalledProductCerts(Arrays.asList(new ProductCert[] {}));
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    Assert.assertTrue(clienttasks.getCurrentProductCertFiles().isEmpty(), "No product certs are installed.");
    result = clienttasks.status(null, null, null, null, null).getStdout();
    expectedStatus = "Overall Status: Current";
    Assert.assertTrue(result.contains(expectedStatus), "System status displays '" + expectedStatus + "' because no products are installed.");
    client.runCommandAndWait("cp " + installedProductCert32060.file + " " + tmpProductCertDir);
    result = clienttasks.status(null, null, null, null, null).getStdout();
    expectedStatus = "Overall Status: Invalid";
    Assert.assertTrue(result.contains(expectedStatus), "System status displays '" + expectedStatus + "' after manully installing a product cert.");
    for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        if (CandlepinTasks.isPoolRestrictedToUnmappedVirtualSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId)) {
            clienttasks.subscribeToSubscriptionPool(pool);
            Flag = true;
            break;
        }
    }
    // enable
    clienttasks.autoheal(null, true, null, null, null, null, null);
    clienttasks.run_rhsmcertd_worker(true);
    result = clienttasks.status(null, null, null, null, null).getStdout();
    if (Flag) {
        expectedStatus = "Overall Status: Insufficient";
        Assert.assertTrue(result.contains(expectedStatus), "System status displays '" + expectedStatus + "' after finally running rhsmcertd worker with auto-healing.");
    } else {
        expectedStatus = "Overall Status: Current";
        Assert.assertTrue(result.contains(expectedStatus), "System status displays '" + expectedStatus + "' after finally running rhsmcertd worker with auto-healing.");
    }
}
Also used : ProductCert(rhsm.data.ProductCert) SubscriptionPool(rhsm.data.SubscriptionPool) 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