Search in sources :

Example 76 with SSHCommandResult

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

the class BugzillaTests method testAttachingEmptyFile.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21932", "RHEL7-51794" }, 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 = "verify subscription-manager attach --file <file> ,with file being empty attaches subscription for installed product", groups = { "Tier3Tests", "VerifyAttachingEmptyFile", "blockedByBug-1175291" }, enabled = true)
public void testAttachingEmptyFile() throws Exception {
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.13.8-1"))
        throw new SkipException("The attach --file function was not implemented in this version of subscription-manager.");
    String file = "/tmp/empty_file";
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    // disable
    clienttasks.autoheal(null, null, true, null, null, null, null);
    client.runCommandAndWait("touch " + file);
    client.runCommandAndWait("cat " + file);
    SSHCommandResult sshCommandResult = clienttasks.subscribe_(null, (String) null, (String) null, (String) null, null, null, null, null, file, null, null, null, null);
    String expectedStderr = String.format("Error: The file \"%s\" does not contain any pool IDs.", file);
    Assert.assertEquals(sshCommandResult.getStderr().trim(), expectedStderr, "The stderr result from subscribe with an empty file of poolIds.");
}
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 77 with SSHCommandResult

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

the class BugzillaTests method listFutureSubscription_OnDate.

protected List<String> listFutureSubscription_OnDate(Boolean available, String ondate) {
    List<String> PoolId = new ArrayList<String>();
    SSHCommandResult result = clienttasks.list_(true, true, null, null, null, ondate, null, null, null, null, null, null, null, null);
    List<SubscriptionPool> Pool = SubscriptionPool.parse(result.getStdout());
    for (SubscriptionPool availablePool : Pool) {
        if (availablePool.multiEntitlement) {
            PoolId.add(availablePool.poolId);
        }
    }
    return PoolId;
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) SubscriptionPool(rhsm.data.SubscriptionPool)

Example 78 with SSHCommandResult

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

the class BugzillaTests method testRegisterWithConsumerIdOfDeletedOwner.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21925", "RHEL7-51786" }, 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 = "verify that you blocked when trying to register using the consumerId of a deleted owner", groups = { "Tier3Tests", "RegisterWithConsumeridOfDeletedOwner" }, enabled = true)
@ImplementsNitrateTest(caseId = 148216)
public void testRegisterWithConsumerIdOfDeletedOwner() throws JSONException, Exception {
    String orgname = "testOwner1";
    servertasks.createOwnerUsingCPC(orgname);
    clienttasks.register_(sm_serverAdminUsername, sm_serverAdminPassword, orgname, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    String consumerId = clienttasks.getCurrentConsumerId();
    CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, "/owners/" + orgname);
    clienttasks.clean_();
    SSHCommandResult result = clienttasks.register_(sm_serverAdminUsername, sm_serverAdminPassword, orgname, null, null, null, consumerId, null, null, null, (String) null, null, null, null, null, null, null, null, null, null);
    String expected = "Consumer " + consumerId + " has been deleted";
    if (!clienttasks.workaroundForBug876764(sm_serverType))
        expected = "Unit " + consumerId + " has been deleted";
    Assert.assertEquals(result.getStderr().trim(), expected);
}
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) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 79 with SSHCommandResult

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

the class BugzillaTests method testConfigSetServerPortValueToBlank.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21904", "RHEL7-51765" }, 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 = "verify config Server port with blank or incorrect text produces traceback", groups = { "Tier3Tests", "configBlankTest", "blockedByBug-744654" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testConfigSetServerPortValueToBlank() {
    List<String[]> listOfSectionNameValues = new ArrayList<String[]>();
    String section = "server";
    String name = "port";
    String newValue = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, section, name);
    listOfSectionNameValues.add(new String[] { section, name.toLowerCase(), "" });
    SSHCommandResult results = clienttasks.config(null, null, true, listOfSectionNameValues);
    String value = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, section, name);
    Assert.assertEquals("", results.getStdout().trim());
    listOfSectionNameValues.add(new String[] { section, name.toLowerCase(), newValue });
    clienttasks.config(null, null, true, listOfSectionNameValues);
    value = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, section, name);
    Assert.assertEquals(value, newValue);
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 80 with SSHCommandResult

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

the class BugzillaTests method testRegisterUsingActivationKeyWithExpiredPool.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21924", "RHEL7-51785" }, 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 = "verify if Registering with an activation key which has run out of susbcriptions results in a system, but no identity certificate", groups = { "Tier3Tests", "RegisterWithActivationKeyWithExpiredPool", "blockedByBug-803814", "blockedByBug-1555582" }, enabled = true)
public void testRegisterUsingActivationKeyWithExpiredPool() throws Exception {
    int endingMinutesFromNow = 1;
    Integer addQuantity = 1;
    String name = String.format("%s_%s-ActivationKey%s", sm_clientUsername, sm_clientOrg, System.currentTimeMillis());
    Map<String, String> mapActivationKeyRequest = new HashMap<String, String>();
    mapActivationKeyRequest.put("name", name);
    mapActivationKeyRequest.put("autoAttach", "false");
    JSONObject jsonActivationKeyRequest = new JSONObject(mapActivationKeyRequest);
    JSONObject jsonActivationKey = new JSONObject(CandlepinTasks.postResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/owners/" + sm_clientOrg + "/activation_keys", jsonActivationKeyRequest.toString()));
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    String consumerId = clienttasks.getCurrentConsumerId();
    ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
    Calendar endCalendar = new GregorianCalendar();
    String expiringPoolId = createTestPool(-60 * 24, endingMinutesFromNow, false);
    Calendar c1 = new GregorianCalendar();
    endCalendar.add(Calendar.MINUTE, endingMinutesFromNow);
    DateFormat yyyy_MM_dd_DateFormat = new SimpleDateFormat("M/d/yy h:mm aaa");
    String EndingDate = yyyy_MM_dd_DateFormat.format(endCalendar.getTime());
    Calendar c2 = new GregorianCalendar();
    sleep(1 * 59 * 1000 - (c2.getTimeInMillis() - c1.getTimeInMillis()));
    new JSONObject(CandlepinTasks.postResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/activation_keys/" + jsonActivationKey.getString("id") + "/pools/" + expiringPoolId + (addQuantity == null ? "" : "?quantity=" + addQuantity), null));
    clienttasks.unregister(null, null, null, null);
    SSHCommandResult registerResult = clienttasks.register_(null, null, sm_clientOrg, null, null, null, null, null, null, null, name, null, null, null, true, null, null, null, null, null);
    List<ProductSubscription> consumedResult = clienttasks.getCurrentlyConsumedProductSubscriptions();
    SSHCommandResult consumedListResult = clienttasks.list(null, null, true, null, null, null, null, null, null, null, null, null, null, null);
    String expected_message = "Unable to attach pool with ID '" + expiringPoolId + "'.: Subscriptions for " + productId + " expired on: " + EndingDate + ".";
    if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.2.0-1")) {
        Assert.assertContainsMatch(registerResult.getStderr().trim(), "None of the subscriptions on the activation key were available for attaching.", "stderr");
        Assert.assertEquals(consumedListResult.getStdout().trim(), "No consumed subscription pools were found.", "Expired subscription cannot be attached to activationkey");
    }
    if ((SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">", "0.9.30-1")) && (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, "<", "2.2.0-1"))) {
        // Follows:
        expected_message = "No activation key was applied successfully.";
        // candlepin-0.9.30-1
        // //
        // https://github.com/candlepin/candlepin/commit/bcb4b8fd8ee009e86fc9a1a20b25f19b3dbe6b2a
        Assert.assertEquals(registerResult.getStderr().trim(), expected_message);
        Assert.assertEquals(consumedResult.get(randomGenerator.nextInt(consumedResult.size() - 1)).statusDetails.toString(), "[Subscription is expired]", "Attached subscription is in expired state");
    }
    SSHCommandResult identityResult = clienttasks.identity_(null, null, null, null, null, null, null, null);
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.9-1")) {
        // post
        // commit
        // a695ef2d1da882c5f851fde90a24f957b70a63ad
        Assert.assertEquals(identityResult.getStderr().trim(), clienttasks.msg_ConsumerNotRegistered, "stderr");
    } else {
        Assert.assertEquals(identityResult.getStdout().trim(), clienttasks.msg_ConsumerNotRegistered, "stdout");
    }
}
Also used : HashMap(java.util.HashMap) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ProductSubscription(rhsm.data.ProductSubscription) BigInteger(java.math.BigInteger) JSONObject(org.json.JSONObject) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) SimpleDateFormat(java.text.SimpleDateFormat) 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