Search in sources :

Example 21 with SSHCommandResult

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

the class UnsubscribeTests method testUnsubscribeFromAll.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36597", "RHEL7-51402" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL6-28489", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL7-84911", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.VERIFIES) }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "Verify the feedback after unsubscribing from all consumed subscriptions using unsubscribe --all", groups = { "Tier2Tests", "blockedByBug-812388", "blockedByBug-844455" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testUnsubscribeFromAll() {
    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);
    clienttasks.subscribeToTheCurrentlyAllAvailableSubscriptionPoolsCollectively();
    int numberSubscriptionsConsumed = clienttasks.getCurrentEntitlementCertFiles().size();
    // unsubscribe from all and assert # subscriptions are unsubscribed
    SSHCommandResult result = clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    // String expectedStdoutRegex = String.format("This machine has been unsubscribed from %s subscriptions",pools.size());	// 10/18/2013 NOT SURE WHAT COMMIT/BUG CAUSED THIS CHANGE TO THE FOLLOWING...
    String expectedStdoutRegex = String.format("%s subscriptions removed at the server." + "\n" + "%s local certificates have been deleted.", numberSubscriptionsConsumed, numberSubscriptionsConsumed);
    // commit d88d09c7060a17fba34a138313e7efd21cc79d02  D-Bus service for removing entitlements (all/ID/serial num.)
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.2-1"))
        expectedStdoutRegex = String.format("%s local certificates have been deleted." + "\n" + "%s subscriptions removed at the server.", numberSubscriptionsConsumed, numberSubscriptionsConsumed);
    Assert.assertEquals(result.getStdout().trim(), expectedStdoutRegex, "Expected feedback when unsubscribing from all the currently consumed subscriptions.");
    // now attempt to unsubscribe from all again and assert 0 subscriptions are unsubscribed
    result = clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    // Assert.assertEquals(result.getStdout().trim(), String.format("This machine has been unsubscribed from %s subscriptions",0),"Expected feedback when unsubscribing from all when no subscriptions are currently consumed.");	// 10/18/2013 NOT SURE WHAT COMMIT/BUG CAUSED THIS CHANGE TO THE FOLLOWING...
    Assert.assertEquals(result.getStdout().trim(), String.format("%s subscriptions removed at the server.", 0), "Expected feedback when unsubscribing from all when no subscriptions are currently consumed.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) BigInteger(java.math.BigInteger) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 22 with SSHCommandResult

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

the class UnsubscribeTests method testUnsubscribeFromAllSerials.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36596", "RHEL7-51401" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL6-28489", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL7-84911", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.VERIFIES) }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "Verify the feedback after unsubscribing from all consumed subscriptions using unsubscribe --serial SERIAL1 --serial SERIAL2 --serial SERIAL3 etc.", groups = { "Tier2Tests", "blockedByBug-867766" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testUnsubscribeFromAllSerials() throws Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, false, null, null, null, null);
    List<SubscriptionPool> pools = clienttasks.subscribeToTheCurrentlyAllAvailableSubscriptionPoolsCollectively();
    if (pools.isEmpty())
        throw new SkipException("This test requires multiple available pools.");
    // unsubscribe from all serials in one call and assert the feedback
    List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    String expectedStdoutMsgLabel;
    expectedStdoutMsgLabel = "Successfully unsubscribed serial numbers:";
    // changed by bug 874749
    expectedStdoutMsgLabel = "Successfully removed serial numbers:";
    // changed by bug 895447 subscription-manager commit 8e10e76fb5951e0b5d6c867c6c7209d8ec80dead
    expectedStdoutMsgLabel = "Serial numbers successfully removed at the server:";
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.17.8-1")) {
        // commit f64d5a6b012f49bb4d6d6653441d4de9bf373660  1319678: Alter the return message for removing entitlements at server
        expectedStdoutMsgLabel = "The entitlement server successfully removed these serial numbers:";
    }
    String expectedStdoutMsg = expectedStdoutMsgLabel;
    for (ProductSubscription productSubscription : productSubscriptions) expectedStdoutMsg += "\n   " + productSubscription.serialNumber;
    SSHCommandResult result = clienttasks.unsubscribeFromTheCurrentlyConsumedProductSubscriptionSerialsCollectively();
    // 201512041150:31.105 - FINE: ssh root@jsefler-6.usersys.redhat.com subscription-manager unsubscribe --serial=4651043328648416651 --serial=2129955862705896392 --serial=6036987963107037829 --serial=6517055606227995394 --serial=2413511261042915625 --serial=926011418395876185 --serial=8453228344236558779 --serial=5066796542261309304 --serial=3293732479098570905 --serial=5415112579595928189 --serial=9157726701938581232 --serial=6182970514936389843 --serial=2260599158127862401 --serial=4271127926386632804 --serial=5634936969630756863 --serial=7207476634289399667 --serial=2228491462979865207 --serial=2386453852224823924 --serial=7223061298534444815 --serial=5297175478219818300 --serial=3982095574288257352 --serial=5040485111524274578 --serial=3366381999267298553 --serial=2205964533240272738 --serial=2009203577428614683 --serial=2151906114081820015 --serial=3936210531886609574 --serial=4672997312714367813 --serial=7537851805340427070 --serial=4060809784799304042 --serial=3484999197148046565 --serial=803523513343380611 --serial=7191534188916803249 --serial=1978078461069342056 --serial=3112667572957043871 --serial=8477444878208748895 --serial=4389608640436010689 --serial=2216833362015010963 --serial=1813156641027923146 --serial=6235363562528759967 --serial=8254500161982005905 --serial=8635854683836611062 --serial=2837535867304046524 --serial=6672137066369518129 --serial=6702191060241838270 --serial=695479724906271580 (com.redhat.qe.tools.SSHCommandRunner.run)
    // 201512041151:20.262 - FINE: Stdout:
    // Serial numbers successfully removed at the server:
    // 4651043328648416651
    // 2129955862705896392
    // 6036987963107037829
    // 6517055606227995394
    // 2413511261042915625
    // 926011418395876185
    // 8453228344236558779
    // 5066796542261309304
    // 3293732479098570905
    // 5415112579595928189
    // 9157726701938581232
    // 6182970514936389843
    // 2260599158127862401
    // 4271127926386632804
    // 5634936969630756863
    // 7207476634289399667
    // 2228491462979865207
    // 2386453852224823924
    // 7223061298534444815
    // 5297175478219818300
    // 3982095574288257352
    // 5040485111524274578
    // 3366381999267298553
    // 2205964533240272738
    // 2009203577428614683
    // 2151906114081820015
    // 3936210531886609574
    // 4672997312714367813
    // 7537851805340427070
    // 4060809784799304042
    // 3484999197148046565
    // 803523513343380611
    // 7191534188916803249
    // 1978078461069342056
    // 3112667572957043871
    // 8477444878208748895
    // 4389608640436010689
    // 2216833362015010963
    // 1813156641027923146
    // 6235363562528759967
    // 8254500161982005905
    // 8635854683836611062
    // 2837535867304046524
    // 6672137066369518129
    // 6702191060241838270
    // 695479724906271580
    // 46 local certificates have been deleted.
    // 201512041151:20.283 - FINE: Stderr:
    String actualStdoutMsg = result.getStdout().trim();
    actualStdoutMsg = clienttasks.workaroundForBug906550(actualStdoutMsg);
    // NOTE: This expectedStdoutMsg makes a huge assumption about the order of the unsubscribed serial numbers printed to stdout
    // NOTE: TIME TO FIX THIS ASSERTION... Assert.assertEquals(result.getStdout().trim(), expectedStdoutMsg, "Stdout feedback when unsubscribing from all the currently consumed subscriptions.");
    List<String> expectedStdoutMsgAsList = new ArrayList<String>(Arrays.asList(expectedStdoutMsg.split("\n")));
    expectedStdoutMsgAsList.remove(expectedStdoutMsgLabel);
    List<String> actualStdoutMsgAsList = new ArrayList<String>(Arrays.asList(actualStdoutMsg.split("\n")));
    actualStdoutMsgAsList.remove(expectedStdoutMsgLabel);
    Assert.assertTrue(expectedStdoutMsgAsList.containsAll(actualStdoutMsgAsList) && actualStdoutMsgAsList.containsAll(expectedStdoutMsgAsList), "Stdout feedback when unsubscribing from all the currently consumed subscriptions contains all the expected serial numbers:" + expectedStdoutMsg.replace(expectedStdoutMsgLabel, ""));
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ProductSubscription(rhsm.data.ProductSubscription) ArrayList(java.util.ArrayList) SkipException(org.testng.SkipException) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 23 with SSHCommandResult

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

the class UnsubscribeTests method testUnsubscribeFromAnUnknownPoolId.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36363", "RHEL7-51405" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL6-28489", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL7-84911", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.VERIFIES) }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "Attempt to unsubscribe from an unknown pool id", groups = { "Tier1Tests", "blockedByBug-1198178", "blockedByBug-1298586" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testUnsubscribeFromAnUnknownPoolId() {
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.16.5-1"))
        throw new SkipException("The unsubscribe --pool function was not implemented in this version of subscription-manager.  See RFE Bug 1198178");
    // register
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, false, null, null, null, null);
    String poolId = "1234567890abcdef1234567890abcdef";
    SSHCommandResult result = clienttasks.unsubscribe_(null, null, poolId, null, null, null, null);
    if (servertasks.statusCapabilities.contains("remove_by_pool_id")) {
        Integer expectedExitCode = new Integer(1);
        String expectedStdout = "";
        // commit e418b77ce2a7389e310ac341a6beb46cb7eb3d0f	// Bug 1298586: Message needed for remove only invalid pool
        expectedStdout = String.format("Pools unsuccessfully removed at the server:\n   %s", poolId);
        if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.17.8-1")) {
            // commit f64d5a6b012f49bb4d6d6653441d4de9bf373660  1319678: Alter the return message for removing entitlements at server
            expectedStdout = String.format("The entitlement server failed to remove these pools:\n   %s", poolId);
        }
        Assert.assertEquals(result.getExitCode(), expectedExitCode, "Asserting exit code when attempting to unsubscribe from an unknown pool id.");
        Assert.assertEquals(result.getStdout().trim(), expectedStdout, "Stdout");
        Assert.assertEquals(result.getStderr().trim(), "", "Stderr");
    } else {
        // coverage for Bug 1285004 - subscription-manager remove --pool throws: Runtime Error Could not find resource for relative of full path
        Integer expectedExitCode = new Integer(69);
        Assert.assertEquals(result.getExitCode(), expectedExitCode, "Asserting exit code when attempting to unsubscribe from an invalid pool id (from an incapable server).");
        if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.16.7-1")) {
            // d9a82d3135a1770f794c2c8181f44e7e4628e0b6 Output of errors now goes to stderr
            Assert.assertEquals(result.getStderr().trim(), "Error: The registered entitlement server does not support remove --pool.\nInstead, use the remove --serial option.", "Stderr");
            Assert.assertEquals(result.getStdout().trim(), "", "Stdout");
        } else {
            Assert.assertEquals(result.getStdout().trim(), "Error: The registered entitlement server does not support remove --pool.\nInstead, use the remove --serial option.", "Stdout");
            Assert.assertEquals(result.getStderr().trim(), "", "Stderr");
        }
        throw new SkipException("The registered entitlement server does not support remove --pool");
    }
}
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)

Example 24 with SSHCommandResult

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

the class UnsubscribeTests method testUnsubscribeFromSerialWhenNotRegistered.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36600", "RHEL7-51408" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL6-28489", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL7-84911", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.VERIFIES) }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "Attempt to unsubscribe from a serial when not registered", groups = { "Tier2Tests", "blockedByBug-735338", "blockedByBug-838146", "blockedByBug-865590", "blockedByBug-873791" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testUnsubscribeFromSerialWhenNotRegistered() {
    // first make sure we are subscribed to a pool
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, false, null, null, null, null);
    List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    // random available pool
    SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
    EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(clienttasks.subscribeToSubscriptionPool(pool, /*sm_serverAdminUsername*/
    sm_clientUsername, /*sm_serverAdminPassword*/
    sm_clientPassword, sm_serverUrl));
    // now remove the consumer cert to simulate an unregister
    clienttasks.removeAllCerts(true, false, false);
    SSHCommandResult identityResult = clienttasks.identity_(null, null, null, null, null, null, null, null);
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
        // post commit 5697e3af094be921ade01e19e1dfe7b548fb7d5b bug 1119688
        Assert.assertEquals(identityResult.getStderr().trim(), clienttasks.msg_ConsumerNotRegistered, "stderr");
    } else {
        Assert.assertEquals(identityResult.getStdout().trim(), clienttasks.msg_ConsumerNotRegistered, "stdout");
    }
    // now unsubscribe from the serial number (while not registered)
    Assert.assertTrue(clienttasks.getCurrentlyConsumedProductSubscriptions().size() > 0, "We should be consuming an entitlement (even while not registered)");
    // clienttasks.unsubscribeFromSerialNumber(entitlementCert.serialNumber);	// this will assert a different stdout message, instead call unsubscribe manually and assert results
    SSHCommandResult result = clienttasks.unsubscribe(null, entitlementCert.serialNumber, null, null, null, null, null);
    Assert.assertEquals(result.getStdout().trim(), "Subscription with serial number " + entitlementCert.serialNumber + " removed from this system", "We should always be able to remove a subscription (even while not registered).");
    Assert.assertEquals(clienttasks.getCurrentlyConsumedProductSubscriptions().size(), 0, "We should not be consuming any entitlements after unsubscribing (while not registered).");
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 25 with SSHCommandResult

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

the class UnsubscribeTests method testUnsubscribeFromAllPoolIds.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36594", "RHEL7-51399" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL6-28489", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL7-84911", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.VERIFIES) }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "Verify the feedback after unsubscribing from all consumed subscriptions using unsubscribe --pool POOLID1 --pool POOLID2 --pool POOLID3 etc.", groups = { "Tier2Tests", "blockedByBug-1198178", "blockedByBug-1288626" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testUnsubscribeFromAllPoolIds() throws Exception {
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.16.5-1"))
        throw new SkipException("The unsubscribe --pool function was not implemented in this version of subscription-manager.  See RFE Bug 1198178");
    if (!servertasks.statusCapabilities.contains("remove_by_pool_id"))
        throw new SkipException("The registered entitlement server does not support remove --pool");
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, false, null, null, null, null);
    List<SubscriptionPool> pools = clienttasks.subscribeToTheCurrentlyAllAvailableSubscriptionPoolsCollectively();
    if (pools.isEmpty())
        throw new SkipException("This test requires multiple available pools.");
    List<String> poolIds = new ArrayList<String>();
    for (SubscriptionPool pool : pools) poolIds.add(pool.poolId);
    // add more serials from multi-entitlement pools (ignoring failures)
    clienttasks.subscribe_(null, null, poolIds, null, null, null, null, null, null, null, null, null, null);
    // unsubscribe from all pool in one call and assert the feedback
    List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    String successfulStdoutSerialsMsgLabel;
    successfulStdoutSerialsMsgLabel = "Successfully unsubscribed serial numbers:";
    // changed by bug 874749
    successfulStdoutSerialsMsgLabel = "Successfully removed serial numbers:";
    // changed by bug 895447 subscription-manager commit 8e10e76fb5951e0b5d6c867c6c7209d8ec80dead
    successfulStdoutSerialsMsgLabel = "Serial numbers successfully removed at the server:";
    // commit f64d5a6b012f49bb4d6d6653441d4de9bf373660  1319678: Alter the return message for removing entitlements at server
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.17.8-1"))
        successfulStdoutSerialsMsgLabel = "The entitlement server successfully removed these serial numbers:";
    String successfulStdoutPoolIdsMsgLabel;
    successfulStdoutPoolIdsMsgLabel = "Pools successfully removed at the server:";
    // commit f64d5a6b012f49bb4d6d6653441d4de9bf373660  1319678: Alter the return message for removing entitlements at server
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.17.8-1"))
        successfulStdoutPoolIdsMsgLabel = "The entitlement server successfully removed these pools:";
    String unsuccessfulStdoutSerialsMsgLabel;
    unsuccessfulStdoutSerialsMsgLabel = "Serial numbers unsuccessfully removed at the server:";
    // commit f64d5a6b012f49bb4d6d6653441d4de9bf373660  1319678: Alter the return message for removing entitlements at server
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.17.8-1"))
        unsuccessfulStdoutSerialsMsgLabel = "The entitlement server failed to remove these serial numbers:";
    String unsuccessfulStdoutPoolsMsgLabel;
    unsuccessfulStdoutPoolsMsgLabel = "Pools unsuccessfully removed at the server:";
    // commit f64d5a6b012f49bb4d6d6653441d4de9bf373660  1319678: Alter the return message for removing entitlements at server
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.17.8-1"))
        unsuccessfulStdoutPoolsMsgLabel = "The entitlement server failed to remove these pools:";
    Set<String> expectedPoolIds = new HashSet<String>();
    Set<String> expectedSerials = new HashSet<String>();
    for (ProductSubscription productSubscription : productSubscriptions) {
        expectedPoolIds.add(productSubscription.poolId);
        expectedSerials.add(productSubscription.serialNumber.toString());
    }
    SSHCommandResult result = clienttasks.unsubscribeFromTheCurrentlyConsumedProductSubscriptionPoolIdsCollectively();
    // 201511231656:37.570 - FINE: ssh root@jsefler-6.usersys.redhat.com subscription-manager unsubscribe --pool=8a9087905136504801513651940f049a --pool=8a90879051365048015136519c0d055b --pool=8a9087905136504801513651946b04a7 --pool=8a9087905136504801513651ad77079b --pool=8a9087905136504801513651aa620721 --pool=8a9087905136504801513651ac43076c --pool=8a9087905136504801513651bc6e09aa --pool=8a90879051365048015136519a7c0529 --pool=8a9087905136504801513651a1b1061d --pool=8a9087905136504801513651b9a3094c --pool=8a90879051365048015136519b730556 --pool=8a9087905136504801513651ab5f0741 --pool=8a9087905136504801513651a06705ef --pool=8a9087905136504801513651a51b0689 --pool=8a9087905136504801513651ae9907d4 --pool=8a9087905136504801513651ad370790 --pool=8a9087905136504801513651a86906ed --pool=8a9087905136504801513651b7960927 --pool=8a90879051365048015136519c4c056a --pool=8a9087905136504801513651b4cc08cd --pool=8a9087905136504801513651940f0498 --pool=8a9087905136504801513651a2b7063a --pool=8a9087905136504801513651a79306d5 --pool=8a9087905136504801513651ae6007b9 --pool=8a9087905136504801513651a03305d5 --pool=8a9087905136504801513651b7cf0936 --pool=8a9087905136504801513651a74b06c9 --pool=8a9087905136504801513651946504a4 --pool=8a9087905136504801513651ae8c07c2 --pool=8a9087905136504801513651b56908d7 --pool=8a90879051365048015136519c65056e --pool=8a9087905136504801513651ab860744 --pool=8a90879051365048015136519b510553 --pool=8a90879051365048015136519c7e0572 --pool=8a90879051365048015136519c0c055a --pool=8a9087905136504801513651b21f0872 --pool=8a9087905136504801513651a2430630 --pool=8a9087905136504801513651ae6b07bf --pool=8a9087905136504801513651a222062d --pool=8a9087905136504801513651953b04aa --pool=8a9087905136504801513651bb9f0987 --pool=8a9087905136504801513651b4d708cf --pool=8a9087905136504801513651b892093c --pool=8a9087905136504801513651b3b708bb --pool=8a9087905136504801513651bd1b09b2 --pool=8a9087905136504801513651a88b06f6 --pool=8a9087905136504801513651945604a1 --pool=8a9087905136504801513651940f0499 --pool=8a9087905136504801513651b1320855 --pool=8a9087905136504801513651ba510960 (com.redhat.qe.tools.SSHCommandRunner.run)
    // 201511231657:33.946 - FINE: Stdout:
    // Pools successfully removed at the server:
    // 8a9087905136504801513651940f049a
    // 8a90879051365048015136519c0d055b
    // 8a9087905136504801513651946b04a7
    // Serial numbers successfully removed at the server:
    // 8865613847264050544
    // 8937932663056862717
    // 3352861400531049008
    // 8107962814745856003
    // 8514271782573332949
    // 3379403338434026844
    // 2230666936775183579
    // 7 local certificates have been deleted.
    // 201511231657:33.989 - FINE: Stderr:
    // 201512041343:44.111 - FINE: ssh root@jsefler-6.usersys.redhat.com subscription-manager unsubscribe --pool=8a908790516a011001516a02508b049b --pool=8a908790516a011001516a025891054a --pool=8a908790516a011001516a025dbc05ec --pool=8a908790516a011001516a026b970797 --pool=8a908790516a011001516a0250a1049e --pool=8a908790516a011001516a0264a006d3 --pool=8a908790516a011001516a02646b06c3 --pool=8a908790516a011001516a02511e04a4 --pool=8a908790516a011001516a02762e0904 --pool=8a908790516a011001516a0261720680 --pool=8a908790516a011001516a0265b906e1 --pool=8a908790516a011001516a02714d089b --pool=8a908790516a011001516a0261720680 --pool=8a908790516a011001516a0259dd056e --pool=8a908790516a011001516a02588b0547 --pool=8a908790516a011001516a025a490575 --pool=8a908790516a011001516a02646b06c3 --pool=8a908790516a011001516a0263ac06bb --pool=8a908790516a011001516a026168067d --pool=8a908790516a011001516a025e0e05f9 --pool=8a908790516a011001516a027e6b09db --pool=8a908790516a011001516a0251b504aa --pool=8a908790516a011001516a0274dd08e0 --pool=8a908790516a011001516a026919073f --pool=8a908790516a011001516a02662606f4 --pool=8a908790516a011001516a0278a70937 --pool=8a908790516a011001516a027b7f0984 --pool=8a908790516a011001516a0250650498 --pool=8a908790516a011001516a0264a106d6 --pool=8a908790516a011001516a026b030786 --pool=8a908790516a011001516a0278aa0939 --pool=8a908790516a011001516a0265b906e1 --pool=8a908790516a011001516a02714d089b --pool=8a908790516a011001516a025d6005e8 --pool=8a908790516a011001516a0278a70937 --pool=8a908790516a011001516a0258030542 --pool=8a908790516a011001516a0278aa0939 --pool=8a908790516a011001516a02510504a1 --pool=8a908790516a011001516a0264a106d6 --pool=8a908790516a011001516a02762e0904 --pool=8a908790516a011001516a02588b0547 --pool=8a908790516a011001516a027b930986 --pool=8a908790516a011001516a0260e5066a --pool=8a908790516a011001516a0258e20560 --pool=8a908790516a011001516a025a490575 --pool=8a908790516a011001516a025e0e05f9 --pool=8a908790516a011001516a0269940747 --pool=8a908790516a011001516a026acf0781 --pool=8a908790516a011001516a0251b504aa --pool=8a908790516a011001516a026910073c --pool=8a908790516a011001516a0274c608de --pool=8a908790516a011001516a02710c0899 --pool=8a908790516a011001516a02516304a7 --pool=8a908790516a011001516a0269940747 --pool=8a908790516a011001516a0259b60569 --pool=8a908790516a011001516a0274dd08e0 --pool=8a908790516a011001516a0259dd056e --pool=8a908790516a011001516a02516304a7 --pool=8a908790516a011001516a0269bf074b --pool=8a908790516a011001516a0263ac06bb --pool=8a908790516a011001516a0269bf074b --pool=8a908790516a011001516a026b33078f --pool=8a908790516a011001516a026b030786 --pool=8a908790516a011001516a026acf0781 --pool=8a908790516a011001516a026f8d0869 --pool=8a908790516a011001516a0257ab0529 --pool=8a908790516a011001516a025dbc05ec --pool=8a908790516a011001516a0264a006d3 --pool=8a908790516a011001516a027b930986 (com.redhat.qe.tools.SSHCommandRunner.run)
    // 201512041344:51.518 - FINE: Stdout:
    // Pools successfully removed at the server:
    // 8a908790516a011001516a0269bf074b
    // 8a908790516a011001516a026b33078f
    // 8a908790516a011001516a026f8d0869
    // 8a908790516a011001516a0257ab0529
    // Pools unsuccessfully removed at the server:
    // 8a908790516a011001516a0261720680
    // 8a908790516a011001516a02646b06c3
    // Serial numbers successfully removed at the server:
    // 6147826158890249653
    // 2710596911835822689
    // 8362938208950031094
    // 130483993634735580
    // 2732609281506598523
    // Serial numbers unsuccessfully removed at the server:
    // 8a908790516a011001516a0261720680   <=== Bug 1288626
    // 8a908790516a011001516a02646b06c3   <=== Bug 1288626
    // 5 local certificates have been deleted.
    // 201512041344:51.520 - FINE: Stderr:  (com.redhat.qe.tools.SSHCommandRunner.runCommandAndWait)
    String actualStdoutMsg = result.getStdout().trim();
    actualStdoutMsg = clienttasks.workaroundForBug906550(actualStdoutMsg);
    Assert.assertTrue(actualStdoutMsg.contains(successfulStdoutPoolIdsMsgLabel), "Stdout from unsubscribing many pool ids contains expected label '" + successfulStdoutPoolIdsMsgLabel + "'.");
    Assert.assertTrue(actualStdoutMsg.contains(successfulStdoutSerialsMsgLabel), "Stdout from unsubscribing many pool ids contains expected label '" + successfulStdoutSerialsMsgLabel + "'.");
    String actualStdoutPoolIdsMsg = actualStdoutMsg.split(successfulStdoutSerialsMsgLabel)[0];
    actualStdoutPoolIdsMsg = actualStdoutPoolIdsMsg.replace(successfulStdoutPoolIdsMsgLabel + "\n", "").replace(unsuccessfulStdoutPoolsMsgLabel + "\n", "");
    String actualStdoutSerialsMsg = actualStdoutMsg.split(successfulStdoutSerialsMsgLabel)[1];
    actualStdoutSerialsMsg = actualStdoutSerialsMsg.replace(successfulStdoutSerialsMsgLabel + "\n", "").replace(unsuccessfulStdoutSerialsMsgLabel + "\n", "");
    Set<String> actualStdoutPoolIds = new HashSet<String>();
    actualStdoutPoolIds.addAll(Arrays.asList(actualStdoutPoolIdsMsg.trim().split("\\s*\n\\s*")));
    Set<String> actualStdoutSerials = new HashSet<String>();
    actualStdoutSerials.addAll(Arrays.asList(actualStdoutSerialsMsg.trim().split("\\s*\n\\s*")));
    // Note: these assertions will pass regardless if the pools/serial removed were successful or unsuccessful
    Assert.assertTrue(actualStdoutPoolIds.containsAll(expectedPoolIds) && expectedPoolIds.containsAll(actualStdoutPoolIds), "Stdout feedback when unsubscribing from all the currently consumed subscriptions pool ids contains all the expected pool ids from the list of consumed Product Subscriptions.");
    Assert.assertTrue(actualStdoutSerials.containsAll(expectedSerials) && expectedSerials.containsAll(actualStdoutSerials), "Stdout feedback when unsubscribing from all the currently consumed subscriptions pool ids contains all the expected serials from the list of consumed Product Subscriptions.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) SkipException(org.testng.SkipException) SubscriptionPool(rhsm.data.SubscriptionPool) HashSet(java.util.HashSet) 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