Search in sources :

Example 6 with SSHCommandResult

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

the class ServiceLevelTests method testServiceLevelListWithInvalidOrg.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21865", "RHEL7-51721" }, 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 --list (with invalid org)", groups = { "Tier3Tests", "blockedByBug-796468", "blockedByBug-815479", "blockedByBug-1256960", /*is a duplicate of*/
"blockedByBug-1254349" }, enabled = true)
@ImplementsNitrateTest(caseId = 165509)
public void testServiceLevelListWithInvalidOrg() {
    String x = String.valueOf(getRandInt());
    SSHCommandResult result;
    // test while unregistered
    clienttasks.unregister(null, null, null, null);
    result = clienttasks.service_level_(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg + x, null, null, null, null, null, null);
    if (sm_serverOld) {
        Assert.assertEquals(result.getStderr().trim(), "ERROR: The service-level command is not supported by the server.");
        throw new SkipException("Skipping this test since service-level is gracefully not supported when configured against an old candlepin server.");
    }
    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 --list with invalid org");
    Assert.assertEquals(result.getStderr().trim(), String.format("Organization with id %s could not be found.", sm_clientOrg + x), "Stderr from service-level --list with invalid org");
    Assert.assertEquals(result.getStdout().trim(), "", "Stdout from service-level --list with invalid credentials");
    // test while registered
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, null, null, null, null, null, null);
    result = clienttasks.service_level_(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg + x, null, null, null, null, null, null);
    Assert.assertEquals(result.getExitCode(), expectedExitCode, "ExitCode from service-level --list with invalid org");
    Assert.assertEquals(result.getStderr().trim(), String.format("Organization with id %s could not be found.", sm_clientOrg + x), "Stderr from service-level --list with invalid org");
    Assert.assertEquals(result.getStdout().trim(), "", "Stdout from service-level --list with invalid credentials");
}
Also used : BigInteger(java.math.BigInteger) 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) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 7 with SSHCommandResult

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

the class ServiceLevelTests method testRegisterWithUnavailableServiceLevel.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21863", "RHEL7-51725" }, 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: register to a Candlepin server using autosubscribe with an unavailable servicelevel", groups = { "Tier3Tests", "blockedByBug-795798", "blockedByBug-864508", "blockedByBug-864508", "blockedByBug-1221273" }, enabled = true)
public void testRegisterWithUnavailableServiceLevel() {
    // attempt the registration
    String unavailableServiceLevel = "FOO";
    SSHCommandResult sshCommandResult = clienttasks.register_(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, unavailableServiceLevel, null, (String) null, null, null, null, true, null, null, null, null, null);
    String msg;
    // valid before bug fix 795798 - Cannot set a service level for a consumer that is not available to its organization.
    msg = "Cannot set a service level for a consumer that is not available to its organization.";
    // valid before bug fix 864508 - Service level {0} is not available to consumers....
    msg = String.format("Service level %s is not available to consumers of organization %s.", unavailableServiceLevel, sm_clientOrg);
    msg = String.format("Service level '%s' is not available to consumers of organization %s.", unavailableServiceLevel, sm_clientOrg);
    if (!clienttasks.workaroundForBug876764(sm_serverType))
        msg = String.format("Service level '%s' is not available to units of organization %s.", unavailableServiceLevel, sm_clientOrg);
    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);
    // post RHEL7.2 commit 84340a0acda9f070e3e0b733e4335059b5dc204e bug 1221273
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.15.9-5"))
        expectedExitCode = new Integer(1);
    Assert.assertEquals(sshCommandResult.getExitCode(), expectedExitCode);
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.16.3-1")) {
        // post commit 7795df84edcb4f4fef08085548f6c2a23f86ceb4 bug 1262919: Added convenience function for printing to stderr
        Assert.assertEquals(sshCommandResult.getStderr().trim(), msg, "Stderr message from an attempt to register with autosubscribe and an unavailable servicelevel.");
    } else if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.15.9-5")) {
        // post RHEL7.2 commit 84340a0acda9f070e3e0b733e4335059b5dc204e bug 1221273
        Assert.assertTrue(sshCommandResult.getStdout().trim().contains(msg), "Stdout message contains: " + msg);
        Assert.assertEquals(sshCommandResult.getStderr().trim(), "", "Stderr message from an attempt to register with autosubscribe and an unavailable servicelevel.");
    } else if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.9-1")) {
        // post commit a695ef2d1da882c5f851fde90a24f957b70a63ad
        Assert.assertEquals(sshCommandResult.getStderr().trim(), msg, "Stderr message from an attempt to register with autosubscribe and an unavailable servicelevel.");
    } else {
        Assert.assertTrue(sshCommandResult.getStdout().trim().contains(msg), "Stdout message contains: " + msg);
        Assert.assertEquals(sshCommandResult.getStderr().trim(), "", "Stderr message from an attempt to register with autosubscribe and an unavailable servicelevel.");
    }
    // despite a failed attempt to set a service level, we should still be registered
    Assert.assertNotNull(clienttasks.getCurrentConsumerId(), "Despite a failed attempt to set a service level during register with autosubscribe, we should still be registered");
    // since the autosubscribe was aborted, we should not be consuming and entitlements
    Assert.assertTrue(clienttasks.getCurrentEntitlementCerts().isEmpty(), "Due to a failed attempt to set a service level during register with autosubscribe, we should not be consuming any entitlements.");
}
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 8 with SSHCommandResult

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

the class ServiceLevelTests method testServiceLevelShowAfterRegisteringWithoutServiceLevel_DEPRECATED.

@Test(description = "subscription-manager: service-level --show (after registering without a service level)", groups = { "Tier3Tests" }, // assertions in this test are already a subset of ServiceLevelShowAvailable_Test(...)
enabled = false)
@Deprecated
@ImplementsNitrateTest(caseId = 157213)
public void testServiceLevelShowAfterRegisteringWithoutServiceLevel_DEPRECATED() throws JSONException, Exception {
    SSHCommandResult result;
    // register with no service-level
    String consumerId = clienttasks.getCurrentConsumerId(clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, null, null, null, null, null));
    // get the current consumer object and assert that the serviceLevel persisted
    JSONObject jsonConsumer = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/consumers/" + consumerId));
    Assert.assertEquals(jsonConsumer.get("serviceLevel"), JSONObject.NULL, "The call to register without a servicelevel leaves the current consumer object serviceLevel attribute value null.");
    result = clienttasks.service_level(true, false, null, null, null, null, null, null, null, null, null, null, null);
    Assert.assertEquals(result.getStdout().trim(), "Current service level:", "When the system has been registered without a service level, the current service level should be null.");
}
Also used : JSONObject(org.json.JSONObject) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 9 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult 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 10 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult 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)

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