Search in sources :

Example 16 with TestDefinition

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

the class ServiceLevelTests method testServiceLevelSetWithUnavailableServiceLevel.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21873", "RHEL7-51728" }, 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: service-level --set (with unavailable serviceLevel)", groups = { "Tier3Tests", "blockedByBug-864508" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testServiceLevelSetWithUnavailableServiceLevel() throws JSONException, Exception {
    // test while registered
    if (clienttasks.getCurrentConsumerId() == null)
        clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg);
    // current org (in case sm_clientOrg is null)
    String org = clienttasks.getCurrentlyRegisteredOwnerKey();
    String unavailableSericeLevel = "FOO";
    SSHCommandResult result = clienttasks.service_level_(null, null, unavailableSericeLevel, null, null, null, null, null, null, null, null, null, null);
    // valid before bug fix 864508
    String expectedStderr = String.format("Service level %s is not available to consumers of organization %s.", unavailableSericeLevel, org);
    expectedStderr = String.format("Service level '%s' is not available to consumers of organization %s.", unavailableSericeLevel, org);
    if (!clienttasks.workaroundForBug876764(sm_serverType))
        expectedStderr = String.format("Service level '%s' is not available to units of organization %s.", unavailableSericeLevel, org);
    Integer expectedExitCode = new Integer(255);
    // EX_SOFTWARE	// post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
        expectedExitCode = new Integer(70);
    Assert.assertEquals(result.getExitCode(), expectedExitCode, "ExitCode from service-level --set with unavailable serviceLevel");
    Assert.assertEquals(result.getStderr().trim(), expectedStderr, "Stderr from service-level --set with unavailable serviceLevel");
    Assert.assertEquals(result.getStdout().trim(), "", "Stdout from service-level --set with unavailable serviceLevel");
}
Also used : BigInteger(java.math.BigInteger) 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 17 with TestDefinition

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

the class ServiceLevelTests method testServiceLevelShowWhenNotRegistered.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21878", "RHEL7-51717" }, 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: service-level --show (when not registered)", groups = { "Tier3Tests", "blockedByBug-826856" /*"blockedByBug-837036"*/
}, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testServiceLevelShowWhenNotRegistered() {
    // make sure we are not registered
    clienttasks.unregister(null, null, null, null);
    SSHCommandResult result;
    // with credentials
    result = clienttasks.service_level_(true, null, null, null, sm_clientUsername, sm_clientPassword, /*sm_clientOrg*/
    null, null, null, null, null, null, null);
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
        // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
        Assert.assertEquals(result.getExitCode(), Integer.valueOf(1), "ExitCode from service-level --show without being registered");
        Assert.assertEquals(result.getStderr().trim(), "This system is not yet registered. Try 'subscription-manager register --help' for more information.", "Stderr from service-level --show without being registered");
    } else {
        Assert.assertEquals(result.getExitCode(), Integer.valueOf(255), "ExitCode from service-level --show without being registered");
        // Assert.assertEquals(result.getStdout().trim(),"Error: This system is currently not registered.", "Stdout from service-level --show without being registered");
        Assert.assertEquals(result.getStdout().trim(), "This system is not yet registered. Try 'subscription-manager register --help' for more information.", "Stdout from service-level --show without being registered");
    }
    if (sm_clientOrg != null) {
        result = clienttasks.service_level_(null, null, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null);
        if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
            // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
            Assert.assertEquals(result.getExitCode(), Integer.valueOf(64), /*EX_USAGE*/
            "ExitCode from service-level --show without being registered");
            Assert.assertEquals(result.getStderr().trim(), "Error: --org is only supported with the --list option", "Stderr from service-level --show without being registered");
        } else {
            Assert.assertEquals(result.getExitCode(), Integer.valueOf(255), "ExitCode from service-level --show without being registered");
            Assert.assertEquals(result.getStdout().trim(), "Error: --org is only supported with the --list option", "Stdout from service-level --show without being registered");
        }
    }
    // without credentials
    result = clienttasks.service_level_(true, null, null, null, null, null, null, null, null, null, null, null, null);
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
        // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
        Assert.assertEquals(result.getExitCode(), Integer.valueOf(1), "ExitCode from service-level --show without being registered");
        Assert.assertEquals(result.getStderr().trim(), "This system is not yet registered. Try 'subscription-manager register --help' for more information.", "Stderr from service-level --show without being registered");
    } else {
        Assert.assertEquals(result.getExitCode(), Integer.valueOf(255), "ExitCode from service-level --show without being registered");
        // Assert.assertEquals(result.getStdout().trim(),"Error: This system is currently not registered.", "Stdout from service-level --show without being registered");
        Assert.assertEquals(result.getStdout().trim(), "This system is not yet registered. Try 'subscription-manager register --help' for more information.", "Stdout from service-level --show without being registered");
    }
}
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 18 with TestDefinition

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

the class ServiceLevelTests method testServiceLevelSetWhenNotRegistered.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21872", "RHEL7-51726" }, 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: service-level --set (when not registered)", groups = { "Tier3Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testServiceLevelSetWhenNotRegistered() {
    // make sure we are not registered
    clienttasks.unregister(null, null, null, null);
    SSHCommandResult result;
    // with credentials
    result = clienttasks.service_level_(null, null, "FOO", null, sm_clientUsername, sm_clientPassword, /*sm_clientOrg*/
    null, null, null, null, null, null, null);
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
        // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
        Assert.assertEquals(result.getExitCode(), new Integer(1), "ExitCode from service-level --set without being registered");
        Assert.assertEquals(result.getStderr().trim(), "This system is not yet registered. Try 'subscription-manager register --help' for more information.", "Stderr from service-level --set without being registered");
    } else {
        Assert.assertEquals(result.getExitCode(), new Integer(255), "ExitCode from service-level --set without being registered");
        // Assert.assertEquals(result.getStdout().trim(),"Error: This system is currently not registered.", "Stdout from service-level --set without being registered");
        Assert.assertEquals(result.getStdout().trim(), "This system is not yet registered. Try 'subscription-manager register --help' for more information.", "Stdout from service-level --set without being registered");
    }
    if (sm_clientOrg != null) {
        result = clienttasks.service_level_(null, null, "FOO", null, sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null);
        if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
            // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
            Assert.assertEquals(result.getExitCode(), Integer.valueOf(64), /*EX_USAGE*/
            "ExitCode from service-level --set without being registered");
            Assert.assertEquals(result.getStderr().trim(), "Error: --org is only supported with the --list option", "Stderr from service-level --set without being registered");
        } else {
            Assert.assertEquals(result.getExitCode(), Integer.valueOf(255), "ExitCode from service-level --set without being registered");
            Assert.assertEquals(result.getStdout().trim(), "Error: --org is only supported with the --list option", "Stdout from service-level --set without being registered");
        }
    }
    // without credentials
    result = clienttasks.service_level_(null, null, "FOO", null, null, null, null, null, null, null, null, null, null);
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
        // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
        Assert.assertEquals(result.getExitCode(), new Integer(1), "ExitCode from service-level --set without being registered");
        Assert.assertEquals(result.getStderr().trim(), "This system is not yet registered. Try 'subscription-manager register --help' for more information.", "Stderr from service-level --set without being registered");
    } else {
        Assert.assertEquals(result.getExitCode(), new Integer(255), "ExitCode from service-level --set without being registered");
        // Assert.assertEquals(result.getStdout().trim(),"Error: This system is currently not registered.", "Stdout from service-level --set without being registered");
        Assert.assertEquals(result.getStdout().trim(), "This system is not yet registered. Try 'subscription-manager register --help' for more information.", "Stdout from service-level --set without being registered");
    }
}
Also used : BigInteger(java.math.BigInteger) 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 19 with TestDefinition

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

the class SpellCheckTests method testSpellingsOnManPageForSubscriptionManagerGui.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21784", "RHEL7-51601" }, 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-gui man page for misspelled words and typos", groups = { "Tier3Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSpellingsOnManPageForSubscriptionManagerGui() throws IOException {
    if (clienttasks == null)
        throw new SkipException("A client connection is needed for this test.");
    String tool = "subscription-manager-gui";
    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();
    // unhyphenate all words at the ends of a line
    modifiedManPage = modifiedManPage.replaceAll("(\\w+)(?:‐|-)\\n\\s+(\\w+)", "$1$2");
    modifiedManPage = modifiedManPage.replaceAll("System Manager's Manual", " bugzilla1192574comment2isNotFixed ");
    modifiedManPage = modifiedManPage.replaceAll("https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Subscription_Management/1.0/html/Subscription_Management_Guide/index.html", " bugzilla1192574comment3isNotFixed ");
    modifiedManPage = modifyMisspellingsInManPage(modifiedManPage);
    // TEMPORARY WORKAROUND FOR BUG
    for (String word : Arrays.asList(new String[] { "bugzilla1192574comment2isNotFixed", "bugzilla1192574comment3isNotFixed" })) {
        if (modifiedManPage.contains(word)) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1192574 - typos and poor grammar in subscription-manager-gui man page
            String bugId = "1192574";
            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("bugzilla1192574comment3isNotFixed") && clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1")) {
                // commit 589bf7debe8702d147f3a69f61f34c44ab47ef63
                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");
            }
        }
    }
    // 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 20 with TestDefinition

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

the class SpellCheckTests method testSpellingsOnManPageForRct.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21778", "RHEL7-51595" }, 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 rct man page for misspelled words and typos", groups = { "Tier3Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSpellingsOnManPageForRct() throws IOException {
    if (clienttasks == null)
        throw new SkipException("A client connection is needed for this test.");
    String tool = "rct";
    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(manPageResult.getStdout());
    modifiedManPage = modifiedManPage.replaceAll("System Manager's Manual", " bugzilla1193991comment3isNotFixed ");
    // TEMPORARY WORKAROUND FOR BUG
    for (String word : Arrays.asList(new String[] { "certficate", "filesystem", "bugzilla1193991comment3isNotFixed" })) {
        if (modifiedManPage.contains(word)) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1193991 - typos and poor grammar in rct man page
            String bugId = "1193991";
            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("certficate") && clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1")) {
                // commit a7a358714b66faf1ba2031f2e9918e1078756efa
                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");
            }
        }
    }
    // 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)

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