Search in sources :

Example 31 with ImplementsNitrateTest

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

the class SubscribeTests method testAttemptToSubscribeToAnAlreadySubscribedPool.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-27123", "RHEL7-51392" }, 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 = "Tier2")
@Test(description = "Subscribed for Already subscribed Entitlement.", groups = { "Tier2Tests", "blockedByBug-584137", "blockedByBug-979492" }, // dataProvider="getAvailableSubscriptionPoolsData", TAKES TOO LONG AND RARELY REVEALS A BUG - changing to getRandomSubsetOfAvailableSubscriptionPoolsData
dataProvider = "getRandomSubsetOfAvailableSubscriptionPoolsData", enabled = true)
@ImplementsNitrateTest(caseId = 41897)
public void testAttemptToSubscribeToAnAlreadySubscribedPool(SubscriptionPool pool) throws JSONException, Exception {
    String consumerId = clienttasks.getCurrentConsumerId();
    Assert.assertNull(CandlepinTasks.getConsumersNewestEntitlementSerialCorrespondingToSubscribedPoolId(sm_clientUsername, sm_clientPassword, sm_serverUrl, consumerId, pool.poolId), "The current consumer has not been granted any entitlements from pool '" + pool.poolId + "'.");
    Assert.assertNotNull(clienttasks.subscribeToSubscriptionPool_(pool), "Authenticator '" + sm_clientUsername + "' has been granted an entitlement from pool '" + pool.poolId + "' under organization '" + sm_clientOrg + "'.");
    BigInteger serial1 = CandlepinTasks.getConsumersNewestEntitlementSerialCorrespondingToSubscribedPoolId(sm_clientUsername, sm_clientPassword, sm_serverUrl, consumerId, pool.poolId);
    SSHCommandResult subscribeResult = clienttasks.subscribe_(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
    String subscribeStdout = subscribeResult.getStdout().trim();
    subscribeStdout = clienttasks.workaroundForBug906550(subscribeStdout);
    if (CandlepinTasks.isPoolProductMultiEntitlement(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId)) {
        // Assert.assertEquals(subscribeStdout, String.format("Successfully consumed a subscription from the pool with id %s.",pool.poolId),	// Bug 812410 - Subscription-manager subscribe CLI feedback
        // Assert.assertEquals(subscribeStdout, String.format("Successfully consumed a subscription for: %s",pool.subscriptionName),	// changed by Bug 874804 Subscribe -> Attach
        Assert.assertEquals(subscribeStdout, String.format("Successfully attached a subscription for: %s", pool.subscriptionName), "subscribe command allows multi-entitlement pools to be subscribed to by the same consumer more than once.");
        BigInteger serial2 = CandlepinTasks.getConsumersNewestEntitlementSerialCorrespondingToSubscribedPoolId(sm_clientUsername, sm_clientPassword, sm_serverUrl, consumerId, pool.poolId);
        Assert.assertNotSame(serial1, serial2, "Upon subscribing to a multi-entitlement pool '" + pool.poolId + "' for the second time, the newly granted entilement's serial '" + serial2 + "' number differs from the first '" + serial1 + "'.");
        Assert.assertTrue(RemoteFileTasks.testExists(client, clienttasks.entitlementCertDir + File.separator + serial1 + ".pem"), "After subscribing to multi-entitlement pool '" + pool.poolId + "' for the second time, the first granted entilement cert file still exists.");
        Assert.assertTrue(RemoteFileTasks.testExists(client, clienttasks.entitlementCertDir + File.separator + serial2 + ".pem"), "After subscribing to multi-entitlement pool '" + pool.poolId + "' for the second time, the second granted entilement cert file exists.");
    } else {
        String expectedStdout = String.format("This consumer is already subscribed to the product matching pool with id '%s'.", pool.poolId);
        if (!clienttasks.workaroundForBug876764(sm_serverType))
            expectedStdout = String.format("This unit has already had the subscription matching pool ID '%s' attached.", pool.poolId);
        if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.3.1-1")) {
            // commit 0d5fefcfa8c1c2485921d2dee6633879b1e06931 Correct incorrect punctuation in user messages
            expectedStdout = String.format("This unit has already had the subscription matching pool ID \"%s\" attached.", pool.poolId);
        }
        Assert.assertEquals(subscribeStdout, expectedStdout, "subscribe command returns proper message when the same consumer attempts to subscribe to a non-multi-entitlement pool more than once.");
        Assert.assertTrue(RemoteFileTasks.testExists(client, clienttasks.entitlementCertDir + File.separator + serial1 + ".pem"), "After attempting to subscribe to pool '" + pool.poolId + "' for the second time, the first granted entilement cert file still exists.");
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) BigInteger(java.math.BigInteger) 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 32 with ImplementsNitrateTest

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

the class TranslationTests method testPofilter_DEPRECATED.

@Test(description = "run pofilter translate tests on the translation file", groups = { "Tier2Tests" }, dataProvider = "getTranslationFilePofilterTestData", // 07/12/2012 this was the initial test created for the benefit of fsharath who further developed the test in PofilterTranslationTests.java; disabling this test in favor of his
enabled = false)
@Deprecated
public // @ImplementsNitrateTest(caseId=)
void testPofilter_DEPRECATED(Object bugzilla, String pofilterTest, File translationFile) {
    log.info("For an explanation of pofilter test '" + pofilterTest + "', see: http://translate.sourceforge.net/wiki/toolkit/pofilter_tests");
    File translationPoFile = new File(translationFile.getPath().replaceFirst(".mo$", ".po"));
    // execute the pofilter test
    String pofilterCommand = "pofilter --gnome -t " + pofilterTest;
    SSHCommandResult pofilterResult = client.runCommandAndWait(pofilterCommand + " " + translationPoFile);
    Assert.assertEquals(pofilterResult.getExitCode(), new Integer(0), "Successfully executed the pofilter tests.");
    // convert the pofilter test results into a list of failed Translation objects for simplified handling of special cases
    List<Translation> pofilterFailedTranslations = Translation.parse(pofilterResult.getStdout());
    // remove the first translation which contains only meta data
    if (!pofilterFailedTranslations.isEmpty() && pofilterFailedTranslations.get(0).msgid.equals(""))
        pofilterFailedTranslations.remove(0);
    // ignore the following special cases of acceptable results..........
    List<String> ignorableMsgIds = Arrays.asList();
    if (pofilterTest.equals("accelerators")) {
        if (translationFile.getPath().contains("/hi/"))
            ignorableMsgIds = Arrays.asList("proxy url in the form of proxy_hostname:proxy_port");
        if (translationFile.getPath().contains("/ru/"))
            ignorableMsgIds = Arrays.asList("proxy url in the form of proxy_hostname:proxy_port");
    }
    if (pofilterTest.equals("newlines")) {
        ignorableMsgIds = Arrays.asList("Optional language to use for email notification when subscription redemption is complete. Examples: en-us, de-de", "\n" + "Unable to register.\n" + "For further assistance, please contact Red Hat Global Support Services.", "Tip: Forgot your login or password? Look it up at http://red.ht/lost_password", "Unable to perform refresh due to the following exception: %s", "" + "This migration script requires the system to be registered to RHN Classic.\n" + "However this system appears to be registered to '%s'.\n" + "Exiting.", "The tool you are using is attempting to re-register using RHN Certificate-Based technology. Red Hat recommends (except in a few cases) that customers only register with RHN once.", // bug 825388	""+"We have detected that you have multiple service level\n"+"agreements on various products. Please select how you\n"+"want them assigned.", // bug 825388 or 825397 should fix this
        "\n" + "This machine appears to be already registered to Certificate-based RHN.  Exiting.", "\n" + "This machine appears to be already registered to Red Hat Subscription Management.  Exiting.");
    }
    if (pofilterTest.equals("unchanged")) {
        ignorableMsgIds = Arrays.asList("close_button", "facts_view", "register_button", "register_dialog_main_vbox", "registration_dialog_action_area\n", "prod 1, prod2, prod 3, prod 4, prod 5, prod 6, prod 7, prod 8");
    }
    // pluck out the ignorable pofilter test results
    for (String msgid : ignorableMsgIds) {
        Translation ignoreTranslation = Translation.findFirstInstanceWithMatchingFieldFromList("msgid", msgid, pofilterFailedTranslations);
        if (ignoreTranslation != null) {
            log.info("Ignoring result of pofiliter test '" + pofilterTest + "' for msgid: " + ignoreTranslation.msgid);
            pofilterFailedTranslations.remove(ignoreTranslation);
        }
    }
    // assert that there are no failed pofilter translation test results
    Assert.assertEquals(pofilterFailedTranslations.size(), 0, "Discounting the ignored test results, the number of failed pofilter '" + pofilterTest + "' tests for translation file '" + translationFile + "'.");
}
Also used : Translation(rhsm.data.Translation) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) File(java.io.File) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 33 with ImplementsNitrateTest

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

the class BugzillaTests method testSubscribeWithInvalidFileFromStdin.

/**
 * @author redakkan
 * @throws Exception
 * JSON Exception
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47892", "RHEL7-96016" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL6-28489", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL7-84911", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.VERIFIES) }, 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.LOW, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "subscription-manager: verify subscribe with --file=invalid file from stdin is handled properly", groups = { "Tier3Tests", "blockedByBug-1350402", "testSubscribeWithInvalidFileFromStdin" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSubscribeWithInvalidFileFromStdin() throws JSONException, Exception {
    // commit 3167333fc3a261de939f4aa0799b4283f2b9f4d2 bug 1159974
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.13.8-1"))
        throw new SkipException("The attach --file function was not implemented in this version of subscription-manager.");
    // commit cda076cce4ac66d09eba31b64454d2780a6d1312 bug 1350402
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.20.1-1"))
        throw new SkipException("The currently installed version (" + clienttasks.installedPackageVersionMap.get("subscription-manager") + ") is blocked by bug 1350402 which is fixed in subscription-manager-1.20.1-1 and newer.");
    if (clienttasks.getCurrentlyRegisteredOwnerKey() == null) {
        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);
    } else
        clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
    String InvalidFile = "/tmp/invalid.txt";
    /*About the bug : When stdout/stderr output of subscription-manager is redirected using pipe to some other process ... e.g. subscription-manager list --all --available --pool-only | subscription-manager subscribe --file=/tmp/invalid
        and the second process does not read anything from stdout like in this case, then subscription-manager cannot write the buffer anywhere hence the command was terminated with some errors
        The bug is reproducible only with stdin , hence passing the poolOnlyListCommand to pipe the out put

        [root@ibm-x3250m3-01 ~]# subscription-manager list --all --available --pool-only | subscription-manager subscribe --file=/tmp/invalid
		Error: The file "/tmp/invalid" does not exist or cannot be read.
		close failed in file object destructor:
		sys.excepthook is missing
		lost sys.stderr
        */
    String poolOnlyListCommand = clienttasks.listCommand(true, true, null, null, null, null, null, null, null, true, null, null, null, null);
    String stdinFileSubscribeCommand = clienttasks.subscribeCommand(null, null, (List<String>) null, (List<String>) null, null, null, null, null, InvalidFile, null, null, null, null);
    SSHCommandResult stdinFileSubscribeCommandResult = client.runCommandAndWait(poolOnlyListCommand + "|" + stdinFileSubscribeCommand, (long) (3 * /*min*/
    60 * 1000));
    // Assert the additional error messages no longer appear
    Assert.assertEquals(stdinFileSubscribeCommandResult.getStderr().trim(), "Error: The file \"/tmp/invalid.txt\" does not exist or cannot be read.");
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.1-1")) {
        // commit 79f86e4c043ee751677131ed4e3cf00affd13087
        Assert.assertEquals(stdinFileSubscribeCommandResult.getExitCode(), Integer.valueOf(65), "Exit Code comparison between the expected result of subscribing using a list of poolids from stdin along with a invalid file.");
    } else {
        Assert.assertEquals(stdinFileSubscribeCommandResult.getExitCode(), Integer.valueOf(64), "Exit Code comparison between the expected result of subscribing using a list of poolids from stdin along with a invalid file.");
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) BigInteger(java.math.BigInteger) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 34 with ImplementsNitrateTest

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

the class BugzillaTests method testFunctionalityAccessAfterUnregister.

/**
 * @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-21952", "RHEL7-51814" }, 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 Functionality Access After Unregister", groups = { "Tier3Tests", "VerifyFunctionalityAccessAfterUnregister" }, enabled = true)
@ImplementsNitrateTest(caseId = 50215)
public void testFunctionalityAccessAfterUnregister() throws JSONException, Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg);
    String availList = clienttasks.listAllAvailableSubscriptionPools().getStdout();
    Assert.assertNotNull(availList);
    clienttasks.unregister(null, null, null, null);
    SSHCommandResult listResult = clienttasks.list_(true, true, null, null, null, null, null, null, null, null, null, null, null, null);
    String expected = "This system is not yet registered. Try 'subscription-manager register --help' for more information.";
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
        // post
        // commit
        // df95529a5edd0be456b3528b74344be283c4d258
        Assert.assertEquals(listResult.getStderr().trim(), expected, "stderr");
    } else {
        Assert.assertEquals(listResult.getStdout().trim(), expected, "stdout");
    }
    ConsumerCert consumercert = clienttasks.getCurrentConsumerCert();
    Assert.assertNull(consumercert);
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ConsumerCert(rhsm.data.ConsumerCert) 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 35 with ImplementsNitrateTest

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

the class BugzillaTests method testStatusForPartialSubscription.

/**
 * @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-21972", "RHEL7-51834" }, 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 Subscription manager displays incorrect status for partially subscribed subscription", groups = { "Tier3Tests", "VerifyStatusForPartialSubscription", "blockedByBug-743710" }, enabled = true)
@ImplementsNitrateTest(caseId = 119327)
public void testStatusForPartialSubscription() throws JSONException, Exception {
    String Flag = "false";
    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);
    Map<String, String> factsMap = new HashMap<String, String>();
    factsMap.put("virt.is_guest", String.valueOf(Boolean.FALSE));
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.facts(null, true, null, null, null, null);
    for (SubscriptionPool SubscriptionPool : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
        if (!CandlepinTasks.isPoolProductMultiEntitlement(sm_clientUsername, sm_clientPassword, sm_serverUrl, SubscriptionPool.poolId)) {
            String poolProductSocketsAttribute = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, SubscriptionPool.poolId, "sockets");
            if ((!(poolProductSocketsAttribute == null)) && (poolProductSocketsAttribute.equals("2"))) {
                clienttasks.subscribeToSubscriptionPool_(SubscriptionPool);
                Flag = "true";
            }
        }
    }
    Assert.assertTrue(Boolean.valueOf(Flag), "Found and subscribed to non-multi-entitlement 2 socket subscription pool(s) for this test.");
    Integer moreSockets = 4;
    factsMap.put("cpu.cpu_socket(s)", String.valueOf(moreSockets + Integer.valueOf(clienttasks.sockets)));
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.facts(null, true, null, null, null, null);
    Flag = "false";
    for (InstalledProduct product : clienttasks.getCurrentlyInstalledProducts()) {
        if (!product.status.equals("Not Subscribed") && !product.status.equals("Subscribed") && !product.status.equals("Unknown")) {
            Assert.assertEquals(product.status, "Partially Subscribed", "Installed product '" + product.productName + "' status is Partially Subscribed.");
            Flag = "true";
        }
    }
    Assert.assertEquals(Flag, "true", "Verified Partially Subscribed installed product(s).");
}
Also used : BigInteger(java.math.BigInteger) HashMap(java.util.HashMap) InstalledProduct(rhsm.data.InstalledProduct) 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)

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