Search in sources :

Example 16 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class SpellCheckTests method testSpellingsOnManPageForSubscriptionManager.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21785", "RHEL7-51602" }, 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 = "check the subscription-manager man page for misspelled words and typos", groups = { "Tier3Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSpellingsOnManPageForSubscriptionManager() throws IOException {
    if (clienttasks == null)
        throw new SkipException("A client connection is needed for this test.");
    // "subscription-manager";
    String tool = clienttasks.command;
    SSHCommandResult manPageResult = client.runCommandAndWait("man " + tool);
    Assert.assertEquals(manPageResult.getExitCode(), Integer.valueOf(0), "ExitCode from man page for '" + tool + "'.");
    // modify the contents of manPageResult for acceptable word spellings
    String modifiedManPage = manPageResult.getStdout();
    modifiedManPage = modifyMisspellingsInManPage(modifiedManPage);
    // TODO: should not fail on "PLUGIN OPTIONS" since it is a valid module
    modifiedManPage = modifiedManPage.replaceAll("PLUGIN OPTIONS", "PLUG-IN OPTIONS");
    // TODO: should not fail on "PLUGIN OPTIONS" since it is a valid module
    modifiedManPage = modifiedManPage.replaceAll("The plugins command", "The plug-ins command");
    modifiedManPage = modifiedManPage.replaceAll("plugins", " bugzilla1192120comment13isNotFixed ");
    modifiedManPage = modifiedManPage.replaceAll("plugin", " bugzilla1192120comment13isNotFixed ");
    // TEMPORARY WORKAROUND FOR BUG
    if (doesStringContainMatches(modifiedManPage, "[^-]servicelevel")) {
        boolean invokeWorkaroundWhileBugIsOpen = true;
        // Bug 1192094 - man page for subscription-manager references "servicelevel" command when it should say "service-level
        String bugId = "1192094";
        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 */
        }
        String word = "servicelevel";
        if (invokeWorkaroundWhileBugIsOpen) {
            log.warning("Ignoring unrecognized word '" + word + "' while bug '" + bugId + "' is open.");
            modifiedManPage = modifiedManPage.replaceAll("([^-])" + word, "$1service-level");
        }
        if (clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1")) {
            // commit 961aa8d43ef6e18ef9cde2e740be8462101bb4c6
            log.fine("Invoking workaround for Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
            SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
            log.warning("Ignoring unrecognized word '" + word + "' which is fixed in newer release subscription-manager-1.15.1-1.");
            modifiedManPage = modifiedManPage.replace(word, "TYPO");
        }
    }
    // TEMPORARY WORKAROUND FOR BUG
    if (modifiedManPage.contains("unregister") || modifiedManPage.contains("Unregister") || modifiedManPage.contains("UNREGISTER")) {
        boolean invokeWorkaroundWhileBugIsOpen = true;
        // Bug 1149098 - Grammar issue, "unregister" not a word.
        String bugId = "1149098";
        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 unrecognized word '" + "unregister" + "' while bug '" + bugId + "' is open.");
            modifiedManPage = modifiedManPage.replaceAll("unregister", "deregister");
            modifiedManPage = modifiedManPage.replaceAll("Unregister", "Deregister");
            modifiedManPage = modifiedManPage.replaceAll("UNREGISTER", "DEREGISTER");
            // deregister is not recognized by hunspell -d en_US
            modifiedManPage = modifiedManPage.replaceAll("deregister", "register");
            // Deregister is not recognized by hunspell -d en_US
            modifiedManPage = modifiedManPage.replaceAll("Deregister", "Register");
            // DEREGISTERING is not recognized by hunspell -d en_US
            modifiedManPage = modifiedManPage.replaceAll("DEREGISTER", "REGISTER");
            // Deregistration is not recognized by hunspell -d en_US
            modifiedManPage = modifiedManPage.replaceAll("Deregistration", "Registration");
        }
    }
    // TEMPORARY WORKAROUND FOR BUG
    for (String word : Arrays.asList(new String[] { "wildcards", "wildcard", "suborganizations", "expirations", "reregistered", "reregister", "instaled", "equilivent", "bugzilla1192120comment13isNotFixed" })) {
        if (modifiedManPage.contains(word)) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1192120 - typos and poor grammar in subscription-manager man page
            String bugId = "1192120";
            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 known misspelling of '" + word + "' while bug '" + bugId + "' is open.");
                modifiedManPage = modifiedManPage.replace(word, "TYPO");
            }
            if (word.equals("suborganizations") && clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1")) {
                // commit 063747b1b1d83fe89eff91fc5fb96f57d95eb5d5
                log.fine("Invoking workaround for Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                log.warning("Ignoring known misspelling of '" + word + "' which is fixed in newer release subscription-manager-1.15.1-1.");
                modifiedManPage = modifiedManPage.replace(word, "TYPO");
            }
            if (word.equals("expirations") && clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1")) {
                // commit 063747b1b1d83fe89eff91fc5fb96f57d95eb5d5
                log.fine("Invoking workaround for Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                log.warning("Ignoring known misspelling of '" + word + "' which is fixed in newer release subscription-manager-1.15.1-1.");
                modifiedManPage = modifiedManPage.replace(word, "TYPO");
            }
            if (word.equals("reregistered")) /*&& clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1" FailedQA)*/
            {
                // commit 063747b1b1d83fe89eff91fc5fb96f57d95eb5d5
                log.fine("Invoking workaround for Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                log.warning("Ignoring known misspelling of '" + word + "' while bug '" + bugId + "' is open.");
                modifiedManPage = modifiedManPage.replace(word, "TYPO");
            }
            if (word.equals("instaled") && clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1")) {
                // commit 063747b1b1d83fe89eff91fc5fb96f57d95eb5d5
                log.fine("Invoking workaround for Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                log.warning("Ignoring known misspelling of '" + word + "' which is fixed in newer release subscription-manager-1.15.1-1.");
                modifiedManPage = modifiedManPage.replace(word, "TYPO");
            }
            if (word.equals("equilivent") && clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1")) {
                // commit 063747b1b1d83fe89eff91fc5fb96f57d95eb5d5
                log.fine("Invoking workaround for Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                log.warning("Ignoring known misspelling of '" + word + "' which is fixed in newer release subscription-manager-1.15.1-1.");
                modifiedManPage = modifiedManPage.replace(word, "TYPO");
            }
        }
    }
    // TEMPORARY WORKAROUND FOR BUG
    if (modifiedManPage.contains("Specifes")) {
        boolean invokeWorkaroundWhileBugIsOpen = true;
        // Bug 1440319 - typo in the word "Specifes" in subscription-manager man page
        String bugId = "1440319";
        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 unrecognized word '" + "Specifes" + "' while bug '" + bugId + "' is open.");
            modifiedManPage = modifiedManPage.replaceAll("Specifes", "Specifies");
        }
    }
    // END OF WORKAROUND
    // assert that there were no unexpected hunspell check failures in the modified man page
    Assert.assertEquals(getSpellCheckFailuresForModifiedManPage(tool, manPageResult.getStdout(), modifiedManPage).size(), 0, "There are zero unexpected hunspell check failures in the man page for '" + tool + "'.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 17 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class SpellCheckTests method testSpellingOfAllMsgidsForSubscriptionManager.

// 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-21777", "RHEL7-51594" }, 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 = "check the subscription-manager msgid strings for misspelled words and typos", groups = { "Tier3Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSpellingOfAllMsgidsForSubscriptionManager() throws IOException {
    File remoteFile = new File("/tmp/sm-modifiedMsgIdsForSubscriptionManager.txt");
    File localFile = new File((getProperty("automation.dir", "/tmp") + "/tmp/" + remoteFile.getName()).replace("tmp/tmp", "tmp"));
    // adjust the msgids for known acceptable words that will fail the hunspell check
    Set<String> msgIds = new HashSet<String>();
    for (String msgId : translationMsgidSetForSubscriptionManager) {
        msgId = msgId.replace("Proxy _Username:", "Proxy Username:");
        msgId = msgId.replace("Configure Pro_xy", "Configure Proxy");
        msgId = msgId.replace("Proxy P_assword:", "Proxy Password:");
        msgId = msgId.replace("Repo_sitories", "Repositories");
        msgId = msgId.replace("R_edeem", "Redeem");
        msgId = msgId.replace("Au_thentication", "Authentication");
        msgId = msgId.replace("sla_", "service_level_agreement_");
        msgId = msgId.replace("_combobox", "_combination_box");
        msgId = msgId.replace("--servicelevel", "--service_level");
        msgId = msgId.replace("--ondate", "--on_date");
        msgId = msgId.replace("serverurl", "server_url");
        msgId = msgId.replace("baseurl", "base_url");
        msgId = msgId.replace("stdin", "standard in");
        msgId = msgId.replace("%prog", "%program");
        msgId = msgId.replace("Username", "User Name");
        msgId = msgId.replace("username", "user name");
        msgId = msgId.replace("Virt-who", "Virtualization-who");
        msgId = msgId.replace("Virt Only", "Virtualization Only");
        msgId = msgId.replace("Virt Limit", "Virtualization Limit");
        msgId = msgId.replace("Virtualization", "Virtual");
        msgId = msgId.replace("cert's", "certificate's");
        msgId = msgId.replace("(Examples: en-us, de-de)", "(Examples: English, German)");
        msgId = msgId.replace("sos report", "save our ship report");
        msgId = msgId.replace("connectionStatusLabel", "connection Status Label");
        msgId = msgId.replace("autoheal_checkbox", "auto_heal_check_box");
        msgId = msgId.replace("checkbox", "check box");
        msgId = msgId.replace("Checkbox", "Check box");
        msgId = msgId.replace("Candlepin", "Candle pin");
        msgId = msgId.replace("Gpgcheck", "GNU privacy guard");
        msgId = msgId.replace("CLI", "Command Line Interface");
        msgId = msgId.replace("owner_treeview", "owner_tree_view");
        msgId = msgId.replace("progressbar", "progress_bar");
        msgId = msgId.replace("%(mappingfile)s", "mapping file");
        msgId = msgId.replace("mappingfile", "mapping file");
        msgId = msgId.replace("scrolledwindow", "scrolled_window");
        // msgid: prod 1, prod2, prod 3, prod 4, prod 5, prod 6, prod 7, prod 8
        msgId = msgId.replace("prod2", "prod 2");
        msgId = msgId.replace("environment_treeview", "environment_tree_view");
        msgId = msgId.replace("rhsmcertd", "red hat subscription management certificate daemon");
        msgId = msgId.replace("up2date_client.config", "up to date client configuration");
        msgId = msgId.replace("up2date_client.rhnChannel", "up to date client red hat network channel");
        msgId = msgId.replace("up2date", "up to date");
        msgId = msgId.replace("firstboot", "first boot");
        msgId = msgId.replace("hostname", "host name");
        msgId = msgId.replace("Hostname", "Host name");
        msgId = msgId.replace("redhat", "red hat");
        msgId = msgId.replace("\\tManifest", "Manifest");
        msgId = msgId.replace("jbappplatform", "java boss application platform");
        msgId = msgId.replace("_vbox", "_vertical_box");
        msgId = msgId.replace("env_select", "environment_select");
        msgId = msgId.replace("login", "log-in");
        msgId = msgId.replace("Login", "Log-in");
        msgId = msgId.replace("Repo ", "Repository ");
        msgId = msgId.replace("repo ", "repository ");
        msgId = msgId.replace("repo-", "repository-");
        msgId = msgId.replace("repos ", "repositories ");
        msgId = msgId.replace("orgs", "organizations");
        msgId = msgId.replaceAll("repo$", "repository");
        msgId = msgId.replace("YYYY-MM-DD", "YEAR-MONTH-DAY");
        msgId = msgId.replace("privacy_statement.html", "privacy_statement.HTML");
        msgId = msgId.replace("rhn", "red hat network");
        msgId = msgId.replace("RHN", "Red Hat Network");
        msgId = msgId.replace("RHEL", "Red Hat Enterprise Linux");
        // locator is not recognized by hunspell-1.2.8-16.el6
        msgId = msgId.replace("url", "uniform resource location");
        // Locator is not recognized by hunspell-1.2.8-16.el6
        msgId = msgId.replace("URL", "Uniform Resource Location");
        msgId = msgId.replace("DER size", "binary size");
        msgId = msgId.replace("SSL", "Secure Sockets Layer");
        msgId = msgId.replace("UUID", "universally unique identifier");
        msgId = msgId.replace("uuid", "universally unique identifier");
        msgId = msgId.replace("SKU", "Stock Keeping Unit");
        msgId = msgId.replace("SLA", "Service Level Agreement");
        msgId = msgId.replace("DMI", "Desktop Management Interface");
        msgId = msgId.replace("UEP", "Unified Entitlement and Product");
        msgId = msgId.replace("GPG", "GNU privacy guard");
        msgId = msgId.replace("GNU", "G Not Unix");
        msgId = msgId.replace("GPLv2", "General Public License, version 2");
        msgId = msgId.replace("MERCHANTABILITY", "MERCHANTABLE");
        // python variable used in msgid: Date entered is invalid. Date should be in YYYY-MM-DD format (example: {dateexample})
        msgId = msgId.replace("{dateexample}", "");
        msgId = msgId.replace("'subscription-manager plugins'", "subscription-manager plugins");
        msgId = msgId.replace("'subscription-manager register --help'", "subscription-manager register --help");
        msgId = msgId.replace("'Subscription Manager'", "Subscription Manager");
        msgId = msgId.replace("'release --list'", "release --list");
        msgId = msgId.replace("'red hat network-channel --remove --channel=<conflicting_channel>'", "red hat network-channel --remove --channel=<conflicting_channel>");
        // Knowledge Base Article: https://access.redhat.com/kb/docs/DOC-45563
        msgId = msgId.replace("/kb/", "/knowledge-base/");
        // not recognized by hunspell-1.2.8-16.el6
        msgId = msgId.replace("Doesn't", "Does not");
        msgId = msgId.replace("doesn't", "does not");
        msgId = msgId.replace("Couldn't", "Could not");
        msgId = msgId.replace("couldn't", "could not");
        msgId = msgId.replace("Shouldn't", "Should not");
        msgId = msgId.replace("shouldn't", "should not");
        // fails on hunspell-1.2.8-16.el6
        msgId = msgId.replace("isn't", "is not");
        // fails on hunspell-1.2.8-16.el6
        msgId = msgId.replace("aren't", "are not");
        msgId = msgId.replace("consumerid", "consumer_id");
        msgId = msgId.replace("consumer_uuid", "consumer_universally_unique_identifier");
        msgId = msgId.replace("subscription-manager config --rhsm", "subscription-manager configure --red-hat-subscription-manager");
        msgId = msgId.replace("&#x2022;", "bullet");
        // msgId = msgId.replace("'%s'", "%s");	// already fixed by adjustment below
        // remove surrounding single quotes from single words
        msgId = msgId.replaceAll("'([^ ]+)'", "$1");
        msgId = msgId.replaceFirst("^Ok$", "Okay");
        // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1188265
        if (msgId.contains("Susbscriptions")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1188265 - typo in subscription-manager-gui popup message
            String bugId = "1188265";
            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 known misspelling of '" + "Susbscriptions" + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("Susbscriptions", "Subscriptions");
            }
        }
        // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1189880
        if (msgId.contains("unentitle")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1189880 - Grammar issue, "unentitle" not a word.
            String bugId = "1189880";
            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 unrecognized word '" + "unentitle" + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("unentitle", "unsubscribed");
            }
            if (clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1")) {
                // commit 599f217a4cf06248720fa0a30bd08b0b4ecc0f18
                log.fine("Invoking workaround for Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                log.warning("Ignoring known misspelling of '" + "unentitle" + "' which is fixed in newer release subscription-manager-1.15.1-1.");
                msgId = msgId.replace("unentitle", "unsubscribed");
            }
        }
        // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1149098
        if (msgId.contains("unregister") || msgId.contains("Unregister") || msgId.contains("unregistration") || msgId.contains("reregister")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1149098 - Grammar issue, "unregister" not a word.
            String bugId = "1149098";
            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 unrecognized word '" + "unregister" + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("unregister", "deregister");
                msgId = msgId.replace("Unregister", "Deregister");
                msgId = msgId.replace("unregistration", "Deregistration");
                msgId = msgId.replace("reregister", "register again");
                // deregister is not recognized by hunspell -d en_US
                msgId = msgId.replace("deregister", "register");
                // Deregister is not recognized by hunspell -d en_US
                msgId = msgId.replace("Deregister", "Register");
                // Deregistration is not recognized by hunspell -d en_US
                msgId = msgId.replace("Deregistration", "Registration");
            } else {
                log.info("Bug '" + bugId + "' was CLOSED WONTFIX.  Tolerating 'unregister'.");
                msgId = msgId.replace("unregister", "deregister");
                msgId = msgId.replace("Unregister", "Deregister");
                msgId = msgId.replace("unregistration", "Deregistration");
                msgId = msgId.replace("reregister", "register again");
                // deregister is not recognized by hunspell -d en_US
                msgId = msgId.replace("deregister", "register");
                // Deregister is not recognized by hunspell -d en_US
                msgId = msgId.replace("Deregister", "Register");
                // Deregistration is not recognized by hunspell -d en_US
                msgId = msgId.replace("Deregistration", "Registration");
            }
        }
        // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1189937
        if (msgId.contains("Wildcard")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1189937 - Grammar issue, "Wildcard" is not a word
            String bugId = "1189937";
            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 unrecognized word '" + "Wildcard" + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("Wildcard", "Wild card");
            } else {
                log.info("Bug '" + bugId + "' was CLOSED WONTFIX.  Tolerating 'Wildcard'.");
                msgId = msgId.replace("Wildcard", "Wild card");
            }
        }
        // TEMPORARY WORKAROUND FOR BUG
        if (msgId.contains("_Ok") || msgId.contains("Ok ")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1189933 - Grammar issue, "Ok" not a word.
            String bugId = "1189933";
            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 unrecognized word '" + "Ok" + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("_Ok", "OK");
                msgId = msgId.replace("Ok ", "OK ");
            }
        }
        // TEMPORARY WORKAROUND FOR BUG
        if (msgId.contains("startup")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1189953 - Grammar issue, "startup" is not a word.
            String bugId = "1189953";
            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 unrecognized word '" + "startup" + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("startup", "start-up");
            } else {
                log.info("Bug '" + bugId + "' was CLOSED WONTFIX.  Tolerating 'startup'.");
                msgId = msgId.replace("startup", "start-up");
            }
        }
        // TEMPORARY WORKAROUND FOR BUG
        if (msgId.contains("pre-configure")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1189946 - Grammar issue, "pre-configure" versus "preconfigure".
            String bugId = "1189946";
            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 unrecognized word '" + "pre-configure" + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("pre-configure", "preconfigure");
            }
            if (clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1")) {
                // commit 0162a16a4dde7c54985ec27fd1515f1b664d829c
                log.fine("Invoking workaround for Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                log.warning("Ignoring unrecognized word '" + "pre-configure" + "' which is fixed in newer release subscription-manager-1.15.1-1.");
                msgId = msgId.replace("pre-configure", "preconfigure");
            }
        }
        // END OF WORKAROUND
        // hunspell -d en_US does not recognize preconfigure
        msgId = msgId.replace("preconfigure", "prior configure");
        // TEMPORARY WORKAROUND FOR BUG
        if (msgId.contains("plugin")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1200507 - Grammar issue, "plugin" should be hyphenated.
            String bugId = "1200507";
            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 unrecognized word '" + "plugin" + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("plugin", "plug-in");
            } else {
                log.info("Bug '" + bugId + "' was CLOSED WONTFIX.  Tolerating 'plugin'.");
                msgId = msgId.replace("plugin", "plug-in");
            }
        }
        // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1223852
        if (msgId.contains("Deletedfd")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1223852 - repolib report has 'deletedfd' typo in string catalog
            String bugId = "1223852";
            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 unrecognized word '" + "Deletedfd" + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("Deletedfd", "Deleted");
            }
        }
        // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1233379
        if (msgId.contains("systemid")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1233379 - Grammar issue, "systemid" is not a word
            String bugId = "1233379";
            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 */
            }
            String word = "systemid";
            if (invokeWorkaroundWhileBugIsOpen) {
                log.warning("Ignoring unrecognized word '" + word + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("systemid", "system id");
            }
        }
        // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1188265
        if (msgId.contains("Editition")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1317613 - typo in src/subscription_manager/gui/data/ui/selectsla.ui
            String bugId = "1317613";
            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 known misspelling of '" + "Awesome Developer Editition" + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("Awesome Developer Editition", "Awesome Developer Edition");
            }
        }
        // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1372779
        if (msgId.contains("Proxy connnection")) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1372779 - another typo in "Proxy connnection failed, please check your settings."
            String bugId = "1372779";
            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 known misspelling of '" + "Proxy connnection" + "' while bug '" + bugId + "' is open.");
                msgId = msgId.replace("Proxy connnection", "Proxy connection");
            }
        }
        // END OF WORKAROUND
        msgIds.add(msgId);
    }
    // write the msgIds to a temporary file on the client
    writeSetOfStringsToFile(msgIds, localFile, System.getProperty("line.separator") + "--------" + System.getProperty("line.separator"));
    RemoteFileTasks.putFile(client, localFile.getPath(), remoteFile.getPath(), "0644");
    // run a hunspell check on the msgIds
    SSHCommandResult hunspellResult = client.runCommandAndWait("hunspell -l -d en_US " + remoteFile);
    Assert.assertEquals(hunspellResult.getExitCode(), Integer.valueOf(0), "ExitCode from running hunspell check on " + remoteFile);
    Assert.assertEquals(hunspellResult.getStderr(), "", "Stderr from running hunspell check on " + remoteFile);
    // report the hunspell check failures and the msgIds that the failed words are found in
    List<String> hunspellFailures = new ArrayList<String>();
    if (!hunspellResult.getStdout().trim().isEmpty())
        hunspellFailures = Arrays.asList(hunspellResult.getStdout().trim().split("\n"));
    for (String hunspellFailure : hunspellFailures) {
        log.warning("'" + hunspellFailure + "' was identified by hunspell check as a potential misspelling.");
        for (String msgId : translationMsgidSetForSubscriptionManager) {
            if (msgId.contains(hunspellFailure)) {
                log.info("   '" + hunspellFailure + "' was found in msgid: " + msgId);
            }
        }
    }
    // assert that there were no unexpected hunspell check failures
    Assert.assertEquals(hunspellFailures.size(), 0, "There are zero unexpected hunspell check failures in the msgids.");
// How to demonstrate spellcheck failures...
// Failure: "startup"
// [root@jsefler-os7 ~]# msgunfmt --no-wrap /usr/share/locale/as/LC_MESSAGES/rhsm.mo | grep "startup"
// msgid "launches the registration dialog on startup"
// How to use hunspell check to find failures...
// [root@jsefler-os7 ~]# msgunfmt --no-wrap /usr/share/locale/ja/LC_MESSAGES/rhsm.mo | grep msgid | sed 's/msgid //' > /tmp/msgids.txt && hunspell -l -d en_US /tmp/msgids.txt
// [root@jsefler-os7 ~]# msgunfmt --no-wrap /usr/share/locale/ja/LC_MESSAGES/rhsm.mo | grep msgid | sed 's/msgid //' > /tmp/msgids.txt && hunspell -w -d en_US /tmp/msgids.txt
// [root@jsefler-os7 ~]# msgunfmt --no-wrap /usr/share/locale/ja/LC_MESSAGES/rhsm.mo | grep msgid | sed 's/msgid //' > /tmp/msgids.txt && hunspell -L -d en_US /tmp/msgids.txt
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) File(java.io.File) HashSet(java.util.HashSet) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 18 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class TranslationTests method testYumSearchDoesNotThrowAsciiCodecError.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19946", "RHEL7-55158" }, linkedWorkItems = { // RHSM-REQ : Translation
@LinkedItem(project = Project.RHEL6, workitemId = "RHEL6-28564", role = DefTypes.Role.VERIFIES), // RHSM-REQ : Translation
@LinkedItem(project = Project.RedHatEnterpriseLinux7, workitemId = "RHEL7-84942", role = DefTypes.Role.VERIFIES), // RHSM-REQ : Yum installation of entitled content and product certificates
@LinkedItem(project = Project.RHEL6, workitemId = "RHEL6-28563", role = DefTypes.Role.RELATES_TO), // RHSM-REQ : Yum installation of entitled content and product certificates
@LinkedItem(project = Project.RedHatEnterpriseLinux7, workitemId = "RHEL7-84940", role = DefTypes.Role.RELATES_TO) }, 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 \"'ascii' codec can't decode byte\" errors do not occur with yum search", groups = { "Tier1Tests", "blockedByBug-1199597", "VerifyYumSearchDoesNotThrowAsciiCodecError_Test" }, dataProvider = "getSupportedLangsData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumSearchDoesNotThrowAsciiCodecError(Object bugzilla, String lang) {
    // skip the test when we do not have access to RHEL content
    if (!isRhelProductCertSubscribedForVerifyYumSearchDoesNotThrowAsciiCodecError)
        throw new SkipException("Cannot perform this test until an available RHEL subscription has been attached.");
    // attempt to search for the zsh package using the lang
    String command = "yum search zsh";
    SSHCommandResult result = clienttasks.runCommandWithLang(lang, command);
    // 201505281651:59.086 - FINE: ssh root@jsefler-os6.usersys.redhat.com LANG=as.UTF-8 yum search zsh
    // 201505281652:05.593 - FINE: Stdout:
    // Loaded plugins: product-id, refresh-packagekit, rhnplugin, security,
    // : subscription-manager
    // =============================== N/S Matched: zsh ===============================
    // zsh.x86_64 : A powerful interactive shell
    // 
    // Name and summary matches only, use "search all" for everything.
    // 201505281652:05.599 - FINE: Stderr:
    // Failed to set locale, defaulting to C
    // This system is not registered with RHN Classic or RHN Satellite.
    // You can use rhn_register to register.
    // RHN Satellite or RHN Classic support will be disabled.
    // 201505281652:05.603 - FINE: ExitCode: 0
    String errorMsg = "Failed to set locale, defaulting to C";
    Assert.assertTrue(!result.getStdout().toLowerCase().contains(errorMsg.toLowerCase()), "Stdout from running '" + command + "' in locale '" + lang + "' does not contain error '" + errorMsg + "'.");
    Assert.assertTrue(!result.getStderr().toLowerCase().contains(errorMsg.toLowerCase()), "Stderr from running '" + command + "' in locale '" + lang + "' does not contain error '" + errorMsg + "'.");
    // 201505281705:36.206 - FINE: ssh root@jsefler-os6.usersys.redhat.com LANG=de_DE.UTF-8 yum search zsh (com.redhat.qe.tools.SSHCommandRunner.run)
    // 201505281705:42.591 - FINE: Stdout:
    // Geladene Plugins: product-id, refresh-packagekit, rhnplugin, security,
    // : subscription-manager
    // =============================== N/S Matched: zsh ===============================
    // zsh.x86_64 : A powerful interactive shell
    // 
    // Name and summary matches only, use "search all" for everything.
    // (com.redhat.qe.tools.SSHCommandRunner.runCommandAndWait)
    // 201505281705:42.592 - FINE: Stderr:
    // 'ascii' codec can't decode byte 0xc3 in position 8: ordinal not in range(128)
    // This system is not registered with RHN Classic or RHN Satellite.
    // You can use rhn_register to register.
    // RHN Satellite oder RHN Classic Unterstützung wird deaktiviert.
    // (com.redhat.qe.tools.SSHCommandRunner.runCommandAndWait)
    // 201505281705:42.592 - FINE: ExitCode: 0
    errorMsg = "'ascii' codec can't decode byte";
    Assert.assertTrue(!result.getStdout().toLowerCase().contains(errorMsg.toLowerCase()), "Stdout from running '" + command + "' in locale '" + lang + "' does not contain error '" + errorMsg + "'.");
    Assert.assertTrue(!result.getStderr().toLowerCase().contains(errorMsg.toLowerCase()), "Stderr from running '" + command + "' in locale '" + lang + "' does not contain error '" + errorMsg + "'.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 19 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class TranslationTests method testRegisterWithFallbackCLocale.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21765", "RHEL7-32170" }, linkedWorkItems = { // RHSM-REQ : Translation
@LinkedItem(project = Project.RHEL6, workitemId = "RHEL6-28564", role = DefTypes.Role.VERIFIES), // RHSM-REQ : Translation
@LinkedItem(project = Project.RedHatEnterpriseLinux7, workitemId = "RHEL7-84942", role = DefTypes.Role.VERIFIES), // RHSM-REQ : subscription-manager cli registration and deregistration
@LinkedItem(project = Project.RHEL6, workitemId = "RHEL6-28485", role = DefTypes.Role.VERIFIES), // RHSM-REQ : subscription-manager cli registration and deregistration
@LinkedItem(project = Project.RedHatEnterpriseLinux7, workitemId = "RHEL7-84906", 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.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "verify subscription-manager register will succeed with fallback locale LANG=C; also verify the system.default_locale fact", groups = { "Tier2Tests", "blockedByBug-729988" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRegisterWithFallbackCLocale() {
    // Bug 729988
    // [root@rhsm-compat-rhel61 ~]# LANG=C subscription-manager register --username stage_test_12 --password redhat 1>/tmp/stdout 2>/tmp/stderr
    // [root@rhsm-compat-rhel61 ~]# echo $?
    // 255
    // [root@rhsm-compat-rhel61 ~]# cat /tmp/stdout
    // [root@rhsm-compat-rhel61 ~]# cat /tmp/stderr
    // 'NoneType' object has no attribute 'lower'
    // [root@rhsm-compat-rhel61 ~]#
    String lang = "C";
    clienttasks.unregister(null, null, null, null);
    String command = String.format("%s register --username %s --password %s", clienttasks.command, sm_clientUsername, sm_clientPassword);
    if (sm_clientOrg != null)
        command += String.format(" --org %s", sm_clientOrg);
    // SSHCommandResult sshCommandResult = clienttasks.runCommandWithLang(lang,clienttasks.command+" register --username "+sm_clientUsername+" --password "+sm_clientPassword+" "+(sm_clientOrg!=null?"--org "+sm_clientOrg:""));
    SSHCommandResult sshCommandResult = client.runCommandAndWait("LANG=" + lang + " " + clienttasks.command + " register --username " + sm_clientUsername + " --password " + sm_clientPassword + " " + (sm_clientOrg != null ? "--org " + sm_clientOrg : ""));
    Assert.assertEquals(sshCommandResult.getExitCode(), Integer.valueOf(0), "ExitCode after register with LANG=" + lang + " fallback locale.");
    // also test the system.default_locale fact for an unknown locale
    if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.3-1")) {
        // commit 0670d70540a24a8e173d347e2240dcfb7535608a Bug 1425922: System locale in facts
        String systemDefaultLocaleFact = "system.default_locale";
        String systemDefaultLocaleFactValue = clienttasks.getFactValue(systemDefaultLocaleFact);
        String localeLANG = client.runCommandAndWait("locale | grep LANG").getStdout().trim().split("=")[1];
        // UTF-8 and UTF8 are interchangeable (UTF8 appears as the fact value on RHEL6)
        Assert.assertEquals(systemDefaultLocaleFactValue.replace("UTF8", "UTF-8"), localeLANG.replace("UTF8", "UTF-8"), "The system's value for fact '" + systemDefaultLocaleFact + "' matches the locale LANG. (Note: UTF-8 and UTF8 are interchangeable)");
    }
}
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 20 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class TranslationTests method testRegisterWithUnknownLocale.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47920", "RHEL7-97321" }, linkedWorkItems = { // RHSM-REQ : Translation
@LinkedItem(project = Project.RHEL6, workitemId = "RHEL6-28564", role = DefTypes.Role.VERIFIES), // RHSM-REQ : Translation
@LinkedItem(project = Project.RedHatEnterpriseLinux7, workitemId = "RHEL7-84942", role = DefTypes.Role.VERIFIES), // RHSM-REQ : subscription-manager cli registration and deregistration
@LinkedItem(project = Project.RHEL6, workitemId = "RHEL6-28485", role = DefTypes.Role.VERIFIES), // RHSM-REQ : subscription-manager cli registration and deregistration
@LinkedItem(project = Project.RedHatEnterpriseLinux7, workitemId = "RHEL7-84906", 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.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "verify subscription-manager register will succeed with an unknown locale LANG=foo; also verify the system.default_locale fact reports Unknown", groups = { "Tier2Tests", "blockedByBug-729988", "blockedByBug-1449824" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRegisterWithUnknownLocale() {
    String lang = "foo";
    clienttasks.unregister(null, null, null, null);
    String command = String.format("%s register --username %s --password %s", clienttasks.command, sm_clientUsername, sm_clientPassword);
    if (sm_clientOrg != null)
        command += String.format(" --org %s", sm_clientOrg);
    SSHCommandResult sshCommandResult = client.runCommandAndWait("LANG=" + lang + " " + clienttasks.registerCommand(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, null, null, null, null, null, null));
    Assert.assertEquals(sshCommandResult.getExitCode(), Integer.valueOf(0), "ExitCode after register with LANG=" + lang + " fallback locale.");
    Assert.assertEquals(clienttasks.getCurrentConsumerId(sshCommandResult), clienttasks.getCurrentConsumerId(), "The registered consumer's identity should be interpreted correctly from the stdout when registering with LANG=" + lang + " fallback locale.");
    // also test the system.default_locale fact for an unknown locale
    if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.3-1")) {
        // commit 0670d70540a24a8e173d347e2240dcfb7535608a Bug 1425922: System locale in facts
        String systemDefaultLocaleFact = "system.default_locale";
        String systemDefaultLocale = "Unknown";
        sshCommandResult = client.runCommandAndWait("LANG=" + lang + " " + clienttasks.factsCommand(true, null, null, null, null, null) + " | grep " + systemDefaultLocaleFact);
        Assert.assertEquals(sshCommandResult.getStdout().trim(), String.format("%s: %s", systemDefaultLocaleFact, systemDefaultLocale), "The system's fact for the default locale when run with locale LANG=" + lang + ".");
    }
}
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)

Aggregations

SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)553 Test (org.testng.annotations.Test)416 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)401 SkipException (org.testng.SkipException)219 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)201 ArrayList (java.util.ArrayList)101 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)79 BigInteger (java.math.BigInteger)68 File (java.io.File)58 SubscriptionPool (rhsm.data.SubscriptionPool)53 JSONObject (org.json.JSONObject)47 HashMap (java.util.HashMap)42 ProductSubscription (rhsm.data.ProductSubscription)31 EntitlementCert (rhsm.data.EntitlementCert)30 List (java.util.List)21 YumRepo (rhsm.data.YumRepo)18 ProductCert (rhsm.data.ProductCert)17 Repo (rhsm.data.Repo)16 InstalledProduct (rhsm.data.InstalledProduct)15 Calendar (java.util.Calendar)13