Search in sources :

Example 91 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class BugzillaTests method testAttemptRegisterWithWhiteSpacesInUsername.

/**
 * @author skallesh
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21900", "RHEL7-51761" }, 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 = "subscription-manager: attempt register to with white space in the user name should fail", groups = { "Tier3Tests", "registeredTests", "blockedByBug-719378" }, enabled = true)
public void testAttemptRegisterWithWhiteSpacesInUsername() {
    SSHCommandResult result = clienttasks.register_("user name", "password", sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    Assert.assertEquals(result.getStderr().trim(), servertasks.invalidCredentialsMsg(), "The expected stdout result when attempting to register with a username containing whitespace.");
}
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)

Example 92 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class BugzillaTests method testDeletionOfSubscribedProduct_Test.

/**
 * @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-21943", "RHEL7-51805" }, 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 Product with UUID '%s' cannot be deleted while subscriptions exist.", groups = { "Tier3Tests", "DeleteProductTest", "blockedByBug-684941" }, enabled = true)
public void testDeletionOfSubscribedProduct_Test() throws JSONException, Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, null, null, null, null, null);
    clienttasks.subscribe_(true, null, null, (String) null, null, null, null, null, null, null, null, null, null);
    if (clienttasks.getCurrentlyConsumedProductSubscriptions().isEmpty()) {
        throw new SkipException("no installed products are installed");
    } else {
        for (InstalledProduct installed : clienttasks.getCurrentlyInstalledProducts()) {
            if (installed.status.equals("Subscribed")) {
                for (SubscriptionPool AvailSub : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
                    if (installed.productName.contains(AvailSub.subscriptionName)) {
                        String resourcePath = "/products/" + AvailSub.productId;
                        if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
                            resourcePath = "/owners/" + sm_clientOrg + resourcePath;
                        JSONObject jsonConsumer = new JSONObject(CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath));
                        String expectedDisplayMessage = "Product with UUID '" + AvailSub.productId + "' cannot be deleted while subscriptions exist.";
                        if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
                            expectedDisplayMessage = "Product with ID '" + AvailSub.productId + "' cannot be deleted while subscriptions exist.";
                        if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.3.1-1")) {
                            // commit 0d5fefcfa8c1c2485921d2dee6633879b1e06931 Correct incorrect punctuation in user messages
                            expectedDisplayMessage = String.format("Product with ID \"%s\" cannot be deleted while subscriptions exist.", AvailSub.productId);
                        }
                        Assert.assertEquals(jsonConsumer.getString("displayMessage"), expectedDisplayMessage);
                    }
                }
            }
        }
    }
}
Also used : JSONObject(org.json.JSONObject) InstalledProduct(rhsm.data.InstalledProduct) SkipException(org.testng.SkipException) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 93 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class BugzillaTests method testUnsubscribeAllForExpiredSubscription.

/**
 * @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-21974", "RHEL7-51836" }, 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 = "subscription-manager unsubscribe --all on expired subscriptions removes certs from entitlement folder", groups = { "Tier3Tests", "VerifyUnsubscribeAllForExpiredSubscription", "blockedByBug-852630", "blockedByBug-906550", "blockedByBug-1555582" }, enabled = true)
public void testUnsubscribeAllForExpiredSubscription() throws JSONException, Exception {
    clienttasks.clean();
    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);
    String consumerId = clienttasks.getCurrentConsumerId();
    ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
    String expiringPoolId = createTestPool(-60 * 24, 1, false);
    Calendar c1 = new GregorianCalendar();
    clienttasks.subscribe(null, null, expiringPoolId, null, null, null, null, null, null, null, null, null, null);
    Calendar c2 = new GregorianCalendar();
    // wait for the pool to expire
    // sleep(endingMinutesFromNow*60*1000);
    // trying to reduce the wait time for the expiration by subtracting off
    // some expensive test time
    sleep(1 * 60 * 1000 - (c2.getTimeInMillis() - c1.getTimeInMillis()));
    List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    List<ProductSubscription> activeProductSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("isActive", Boolean.TRUE, consumedProductSubscriptions);
    Set<BigInteger> activeProductSubscriptionSerials = new HashSet<BigInteger>();
    for (ProductSubscription activeProductSubscription : activeProductSubscriptions) activeProductSubscriptionSerials.add(activeProductSubscription.serialNumber);
    List<ProductSubscription> expiredProductSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("isActive", Boolean.FALSE, consumedProductSubscriptions);
    Assert.assertEquals(expiredProductSubscriptions.size(), 1, "Found one expired entitlement (indicated by Active:False) among the list of consumed subscriptions.");
    SSHCommandResult result = clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    String expected = String.format("%d subscriptions removed at the server.\n%d local certificates have been deleted.", activeProductSubscriptionSerials.size(), activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size());
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.2-1")) {
        // commit d88d09c7060a17fba34a138313e7efd21cc79d02  D-Bus service for removing entitlements (all/ID/serial num.)
        expected = String.format("%d local certificates have been deleted." + "\n" + "%d subscriptions removed at the server.", activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size(), activeProductSubscriptionSerials.size());
    }
    if (activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size() == 1)
        expected = expected.replace("local certificates have been", "local certificate has been");
    Assert.assertEquals(result.getStdout().trim(), expected);
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ProductSubscription(rhsm.data.ProductSubscription) BigInteger(java.math.BigInteger) HashSet(java.util.HashSet) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 94 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition 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 95 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class BugzillaTests method testSubscribingWithIncorrectFormatForPoolId.

/**
 * @author skallesh
 * @throws IOException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21958", "RHEL7-51820" }, 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 = "subscription-manager: subscribe multiple pools in incorrect format", groups = { "Tier3Tests", "MysubscribeTest", "blockedByBug-772218" }, enabled = true)
public void testSubscribingWithIncorrectFormatForPoolId() throws IOException {
    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> poolid = new ArrayList<String>();
    for (SubscriptionPool pool : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
        poolid.add(pool.poolId);
    }
    if (poolid.isEmpty())
        throw new SkipException("Cannot randomly pick a pool for subscribing when there are no available pools for testing.");
    int i = randomGenerator.nextInt(poolid.size());
    int j = randomGenerator.nextInt(poolid.size());
    if (i == j) {
        j = randomGenerator.nextInt(poolid.size());
    }
    SSHCommandResult subscribeResult = subscribeInvalidFormat_(null, null, poolid.get(i), poolid.get(j), null, null, null, null, null, null, null, null);
    Assert.assertEquals(subscribeResult.getStdout().trim(), "cannot parse argument: " + poolid.get(j));
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) SkipException(org.testng.SkipException) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)687 Test (org.testng.annotations.Test)687 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)401 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)366 SkipException (org.testng.SkipException)328 ArrayList (java.util.ArrayList)144 SubscriptionPool (rhsm.data.SubscriptionPool)137 JSONObject (org.json.JSONObject)95 BigInteger (java.math.BigInteger)90 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)88 HashMap (java.util.HashMap)78 File (java.io.File)74 ProductSubscription (rhsm.data.ProductSubscription)72 InstalledProduct (rhsm.data.InstalledProduct)66 EntitlementCert (rhsm.data.EntitlementCert)58 ProductCert (rhsm.data.ProductCert)54 YumRepo (rhsm.data.YumRepo)34 Repo (rhsm.data.Repo)26 Calendar (java.util.Calendar)25 List (java.util.List)24