Search in sources :

Example 1 with SubscriptionPool

use of rhsm.data.SubscriptionPool 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 2 with SubscriptionPool

use of rhsm.data.SubscriptionPool 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 3 with SubscriptionPool

use of rhsm.data.SubscriptionPool 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)

Example 4 with SubscriptionPool

use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.

the class VirtualizationTests method testHostAndGuestPoolsAreSubscribableOnGuestSystem.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-27131", "RHEL7-64494" }, 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 host and guest pools to a virtualization-aware subscription are subscribable on a guest system (unless it is physical_only).", groups = { "Tier2Tests", "VerifyHostAndGuestPoolsAreSubscribableOnGuestSystem_Test" }, dependsOnGroups = {}, dataProvider = "getVirtSubscriptionData", enabled = true)
public void testHostAndGuestPoolsAreSubscribableOnGuestSystem(String subscriptionId, String productName, String productId, int quantity, String virtLimit, String hostPoolId, String guestPoolId, Boolean physicalOnly) throws JSONException, Exception {
    if (hostPoolId == null && guestPoolId == null)
        throw new SkipException("Failed to find expected host and guest pools derived from virtualization-aware subscription id '" + subscriptionId + "' (" + productName + ").");
    // trick this system into believing it is a virt guest
    forceVirtWhatToReturnGuest("kvm");
    // assert that the hostPoolId is available...
    List<SubscriptionPool> availablePools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    SubscriptionPool hostPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", hostPoolId, availablePools);
    if (physicalOnly == null || !physicalOnly) {
        // ...when the originating subscription is not physical_only
        Assert.assertNotNull(hostPool, "A host pool derived from the virtualization-aware subscription id '" + subscriptionId + "' is available on a guest system.  hostPool=" + hostPool);
        // attempt to subscribe to the hostPoolId (should succeed)
        // clienttasks.subscribeToSubscriptionPool(hostPool);	// too much overhead
        clienttasks.subscribe(null, null, hostPoolId, null, null, null, null, null, null, null, null, null, null);
    } else {
        // ...but not when the originating subscription is physical_only
        // introduced by Bug 1066120
        Assert.assertNull(hostPool, "A host pool derived from the virtualization-aware subscription id '" + subscriptionId + "' that is physical_only is NOT available on a guest system.");
        // however, it should still be available from --all --available
        hostPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", hostPoolId, clienttasks.getCurrentlyAllAvailableSubscriptionPools());
        // introduced by Bug 1066120
        Assert.assertNotNull(hostPool, "A host pool derived from the virtualization-aware subscription id '" + subscriptionId + "' that is physical_only is included in --all available on a guest system.");
        Assert.assertEquals(hostPool.machineType, "Physical", "The machine type for a physical_only pool.");
        // attempt to subscribe to the hostPoolId (should fail)
        // [root@jsefler-7 ~]# subscription-manager attach --pool 8a9087e3443db08f01443db1810c125e
        // Pool is restricted to physical systems: '8a9087e3443db08f01443db1810c125e'.
        SSHCommandResult result = clienttasks.subscribe_(null, null, hostPoolId, null, null, null, null, null, null, null, null, null, null);
        String expectedMsg = String.format("Pool is restricted to physical systems: '%s'.", hostPoolId);
        if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.3.1-1")) {
            // commit 0d5fefcfa8c1c2485921d2dee6633879b1e06931 Correct incorrect punctuation in user messages
            expectedMsg = String.format("Pool is restricted to physical systems: \"%s\".", hostPoolId);
        }
        Assert.assertEquals(result.getStdout().trim(), expectedMsg, "Stdout from an attempt to subscribe a virtual system to physical_only pool: " + hostPool);
        Assert.assertEquals(result.getStderr(), "", "Stderr from an attempt to subscribe a virtual system to physical_only pool: " + hostPool);
        Assert.assertEquals(result.getExitCode(), Integer.valueOf(1), "Exitcode from an attempt to subscribe a virtual system to physical_only pool: " + hostPool);
    }
    // assert that the guestPoolId is available
    SubscriptionPool guestPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", guestPoolId, availablePools);
    Assert.assertNotNull(guestPool, "A guest pool derived from the virtualization-aware subscription id '" + subscriptionId + "' is available on a guest system: " + guestPool);
    // attempt to subscribe to the guestPoolId
    clienttasks.subscribeToSubscriptionPool(guestPool);
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) 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 5 with SubscriptionPool

use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.

the class VirtualizationTests method testPhysicalMachineTypeValuesInListAvailablePools.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-37712", "RHEL7-51489" }, 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 subscription-manager list --avail appropriately displays pools with MachineType: physical", groups = { "Tier2Tests", "VerifyPhysicalMachineTypeValuesInListAvailablePools_Test" }, dependsOnGroups = {}, enabled = true)
public void testPhysicalMachineTypeValuesInListAvailablePools() throws JSONException, Exception {
    // trick this system into believing it is a host
    forceVirtWhatToReturnHost();
    boolean poolFound = false;
    for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        if (!CandlepinTasks.isPoolVirtOnly(sm_clientUsername, sm_clientPassword, pool.poolId, sm_serverUrl)) {
            // Assert.assertEquals(pool.machineType, "physical", "MachineType:physical should be displayed in the available Subscription Pool listing when the pool has a virt_only=false attribute (or absense of a virt_only attribute).  Pool: "+pool);
            // Assert.assertEquals(pool.machineType, "Physical", "MachineType: Physical should be displayed in the available Subscription Pool listing when the pool has a virt_only=false attribute (or absense of a virt_only attribute).  Pool: "+pool);	// updated after Bug 864184 - String Update: Capitalize Machine Type value from 'subscription-manager --available'
            // changed by bug 874760
            Assert.assertEquals(pool.machineType, "Physical", "System Type: Physical should be displayed in the available Subscription Pool listing when the pool has a virt_only=false attribute (or absense of a virt_only attribute).  Pool: " + pool);
            poolFound = true;
        }
    }
    if (!poolFound)
        throw new SkipException("Could not find an available pool with which to verify the MachineType:physical is reported in the Subscription Pool listing.");
}
Also used : 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)

Aggregations

SubscriptionPool (rhsm.data.SubscriptionPool)195 Test (org.testng.annotations.Test)155 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)137 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)112 SkipException (org.testng.SkipException)90 ArrayList (java.util.ArrayList)87 JSONObject (org.json.JSONObject)66 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)53 ProductSubscription (rhsm.data.ProductSubscription)38 BigInteger (java.math.BigInteger)37 File (java.io.File)34 List (java.util.List)33 EntitlementCert (rhsm.data.EntitlementCert)33 HashMap (java.util.HashMap)32 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)28 InstalledProduct (rhsm.data.InstalledProduct)25 ProductCert (rhsm.data.ProductCert)24 JSONArray (org.json.JSONArray)22 Calendar (java.util.Calendar)12 GregorianCalendar (java.util.GregorianCalendar)11