Search in sources :

Example 36 with ImplementsNitrateTest

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

the class BugzillaTests method testBindAndUnbindInSyslog.

/**
 * @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-21940", "RHEL7-51802" }, 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 that bind and unbind event is recorded in syslog", groups = { "Tier3Tests", "VerifyBindAndUnbindInSyslog", "blockedByBug-919700" }, enabled = true)
@ImplementsNitrateTest(caseId = 68740)
public void testBindAndUnbindInSyslog() throws JSONException, Exception {
    clienttasks.clean();
    // clienttasks.unregister(null, null, null, null);
    String logMarker, expectedSyslogMessage, tailFromSyslogFile;
    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);
    logMarker = System.currentTimeMillis() + " Testing Subscribe **********************";
    RemoteFileTasks.markFile(client, clienttasks.messagesLogFile, logMarker);
    List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    List<String> poolIds = new ArrayList<String>();
    for (SubscriptionPool pool : pools) poolIds.add(pool.poolId);
    clienttasks.subscribe(null, null, poolIds, null, null, null, null, null, null, null, null, null, null);
    tailFromSyslogFile = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.messagesLogFile, logMarker, null);
    for (SubscriptionPool pool : pools) {
        expectedSyslogMessage = String.format("%s: Added subscription for '%s' contract '%s'", clienttasks.command, pool.subscriptionName, pool.contract.isEmpty() ? "None" : pool.contract);
        Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After subscribing to '" + pool.subscriptionName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        for (String providedProduct : pool.provides) {
            // https://bugzilla.redhat.com/show_bug.cgi?id=1016300
            if (providedProduct.equals("Awesome OS Server Bundled")) {
                boolean invokeWorkaroundWhileBugIsOpen = true;
                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("Ignoring the provided MKT product '" + providedProduct + "'.  No syslog assertion for this product will be made.");
                    continue;
                }
            }
            // END OF WORKAROUND
            expectedSyslogMessage = String.format("%s: Added subscription for product '%s'", clienttasks.command, providedProduct);
            Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After subscribing to '" + pool.subscriptionName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        }
    }
    logMarker = System.currentTimeMillis() + " Testing Unsubscribe **********************";
    RemoteFileTasks.markFile(client, clienttasks.messagesLogFile, logMarker);
    List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    tailFromSyslogFile = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.messagesLogFile, logMarker, null);
    for (ProductSubscription productSubscription : productSubscriptions) {
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for 'Awesome OS Server Bundled (2 Sockets, Standard
        // Support)' contract '3'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Clustering Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Awesome OS Server Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Load Balancing Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Large File Support Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Shared Storage Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Management Bits'
        expectedSyslogMessage = String.format("%s: Removed subscription for '%s' contract '%s'", clienttasks.command, productSubscription.productName, // Note
        productSubscription.contractNumber == null ? "None" : productSubscription.contractNumber);
        // that
        // a
        // null/missing
        // contract
        // will
        // be
        // reported
        // as
        // None.
        // Seems
        // reasonable.
        Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After unsubscribing from '" + productSubscription.productName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        for (String providedProduct : productSubscription.provides) {
            expectedSyslogMessage = String.format("%s: Removed subscription for product '%s'", clienttasks.command, providedProduct);
            Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After unsubscribing from '" + productSubscription.productName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) 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) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 37 with ImplementsNitrateTest

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

the class BugzillaTests method testConsumerUnsubscribedWhenSubscriptionRevoked.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@SuppressWarnings("deprecation")
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21905", "RHEL7-51766" }, 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 = "Consumer unsubscribed when Subscription revoked", groups = { "Tier3Tests", "ConsumerUnsubscribedWhenSubscriptionRevoked", "blockedByBug-947429", "blockedByBug-1555582" }, enabled = true)
@ImplementsNitrateTest(caseId = 56025)
public void testConsumerUnsubscribedWhenSubscriptionRevoked() throws Exception {
    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);
    String consumerId = clienttasks.getCurrentConsumerId();
    ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
    String name, productId;
    List<String> providedProductIds = new ArrayList<String>();
    name = "Test product to check subscription-removal";
    productId = "test-product";
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.clear();
    attributes.put("version", "1.0");
    attributes.put("variant", "server");
    attributes.put("arch", "ALL");
    attributes.put("warning_period", "30");
    attributes.put("type", "MKT");
    attributes.put("type", "SVC");
    File entitlementCertFile = null;
    CandlepinTasks.deleteSubscriptionsAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, productId);
    String resourcePath = "/products/" + productId;
    if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
        resourcePath = "/owners/" + sm_clientOrg + resourcePath;
    CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath);
    clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    CandlepinTasks.createProductUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, name + " BITS", productId, 1, attributes, null);
    CandlepinTasks.createSubscriptionAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, 20, -1 * 24 * 60, /* 1 day ago */
    15 * 24 * 60, /* 15 days from now */
    getRandInt(), getRandInt(), productId, providedProductIds, null);
    server.runCommandAndWait("rm -rf " + CandlepinTasks.candlepinCRLFile);
    for (SubscriptionPool pool : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
        if (pool.productId.equals(productId)) {
            entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
        }
    }
    Assert.assertNotNull(entitlementCertFile, "Successfully created and subscribed to product subscription '" + productId + "' created by and needed for this test.");
    EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
    List<ProductSubscription> consumedSusbscription = clienttasks.getCurrentlyConsumedProductSubscriptions();
    Assert.assertFalse(consumedSusbscription.isEmpty());
    CandlepinTasks.deleteSubscriptionsAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, productId);
    resourcePath = "/products/" + productId;
    if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
        resourcePath = "/owners/" + sm_clientOrg + resourcePath;
    CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath);
    sleep(2 * /* min */
    60 * 1000);
    // verify the entitlement serial has been added to the CRL on the server
    List<RevokedCert> revokedCerts = servertasks.getCurrentlyRevokedCerts();
    RevokedCert revokedCert = RevokedCert.findFirstInstanceWithMatchingFieldFromList("serialNumber", entitlementCert.serialNumber, revokedCerts);
    Assert.assertNotNull(revokedCert, "The Certificate Revocation List file on the candlepin server contains an entitlement serial '" + entitlementCert.serialNumber + "' to the product subscription '" + productId + "' that was just deleted on the candlepin server.");
    // trigger the rhsmcertd on the system and verify the entitlement has
    // been removed
    clienttasks.run_rhsmcertd_worker(false);
    Assert.assertTrue(clienttasks.getCurrentlyConsumedProductSubscriptions().isEmpty(), "The revoked entitlement has been removed from the system by rhsmcertd.");
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) File(java.io.File) SubscriptionPool(rhsm.data.SubscriptionPool) RevokedCert(rhsm.data.RevokedCert) 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 38 with ImplementsNitrateTest

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

the class BugzillaTests method testRegenerateEntitlementCert.

/**
 * @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-21963", "RHEL7-51825" }, 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 if entitlement certs are regenerated if certs are manually removed", groups = { "Tier3Tests", "VerifyRegenrateEntitlementCert" }, enabled = true)
@ImplementsNitrateTest(caseId = 64181)
public void testRegenerateEntitlementCert() throws JSONException, Exception {
    String poolId = null;
    int Certfrequeny = 1;
    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);
    List<String[]> listOfSectionNameValues = new ArrayList<String[]>();
    listOfSectionNameValues.add(new String[] { "rhsmcertd", "autoAttachInterval".toLowerCase(), "1440" });
    clienttasks.config(null, null, true, listOfSectionNameValues);
    clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    for (SubscriptionPool availList : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        poolId = availList.poolId;
    }
    clienttasks.subscribe_(null, null, poolId, null, null, null, null, null, null, null, null, null, null);
    client.runCommandAndWait("rm -rf " + clienttasks.entitlementCertDir + "/*.pem");
    clienttasks.restart_rhsmcertd(Certfrequeny, null, null);
    SubscriptionManagerCLITestScript.sleep(Certfrequeny * 60 * 1000);
    List<File> Cert = clienttasks.getCurrentEntitlementCertFiles();
    Assert.assertNotNull(Cert.size());
}
Also used : ArrayList(java.util.ArrayList) 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) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 39 with ImplementsNitrateTest

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

the class BugzillaTests method testRegisterWithConsumerIdOfDeletedOwner.

/**
 * @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-21925", "RHEL7-51786" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "verify that you blocked when trying to register using the consumerId of a deleted owner", groups = { "Tier3Tests", "RegisterWithConsumeridOfDeletedOwner" }, enabled = true)
@ImplementsNitrateTest(caseId = 148216)
public void testRegisterWithConsumerIdOfDeletedOwner() throws JSONException, Exception {
    String orgname = "testOwner1";
    servertasks.createOwnerUsingCPC(orgname);
    clienttasks.register_(sm_serverAdminUsername, sm_serverAdminPassword, orgname, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    String consumerId = clienttasks.getCurrentConsumerId();
    CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, "/owners/" + orgname);
    clienttasks.clean_();
    SSHCommandResult result = clienttasks.register_(sm_serverAdminUsername, sm_serverAdminPassword, orgname, null, null, null, consumerId, null, null, null, (String) null, null, null, null, null, null, null, null, null, null);
    String expected = "Consumer " + consumerId + " has been deleted";
    if (!clienttasks.workaroundForBug876764(sm_serverType))
        expected = "Unit " + consumerId + " has been deleted";
    Assert.assertEquals(result.getStderr().trim(), expected);
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) 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 40 with ImplementsNitrateTest

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

the class BugzillaTests method testConsumerAccountAndContractIdPresence.

/**
 * @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-21941", "RHEL7-51803" }, 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 that Consumer Account And Contract Id are Present in the consumed list", groups = { "Tier3Tests", "VerifyConsumerAccountAndContractIdPresence" }, enabled = true)
@ImplementsNitrateTest(caseId = 68738)
public void testConsumerAccountAndContractIdPresence() throws JSONException, Exception {
    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);
    for (ProductSubscription consumed : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
        Assert.assertNotNull(consumed.accountNumber);
        Assert.assertNotNull(consumed.contractNumber);
    }
}
Also used : ProductSubscription(rhsm.data.ProductSubscription) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

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