Search in sources :

Example 36 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition 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 37 with TestDefinition

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

the class UnsubscribeTests method testUnsubscribeFromAnInvalidSerial.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36598", "RHEL7-51403" }, 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 when from an invalid serial number", groups = { "Tier2Tests", "blockedByBug-706889", "blockedByBug-867766" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testUnsubscribeFromAnInvalidSerial() {
    SSHCommandResult result;
    BigInteger serial = BigInteger.valueOf(-123);
    result = clienttasks.unsubscribe_(null, serial, null, null, null, null, null);
    Integer expectedExitCode = new Integer(255);
    // EX_USAGE // post commit 5697e3af094be921ade01e19e1dfe7b548fb7d5b bug 1119688
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
        expectedExitCode = new Integer(64);
    Assert.assertEquals(result.getExitCode(), expectedExitCode, "Asserting exit code when attempting to unsubscribe from an invalid serial number.");
    // Assert.assertEquals(result.getStderr().trim(), "Error: '-123' is not a valid serial number");
    // Assert.assertEquals(result.getStdout().trim(), "");
    // stderr moved to stdout by Bug 867766 - [RFE] unsubscribe from multiple entitlement certificates using serial numbers
    Assert.assertEquals(result.getStdout().trim(), String.format("Error: '%s' is not a valid serial number", serial), "Stdout");
    Assert.assertEquals(result.getStderr().trim(), "", "Stderr");
    List<BigInteger> serials = Arrays.asList(new BigInteger[] { BigInteger.valueOf(123), BigInteger.valueOf(-456), BigInteger.valueOf(789) });
    result = clienttasks.unsubscribe_(null, serials, null, null, null, null, null);
    Assert.assertEquals(result.getExitCode(), expectedExitCode, "Asserting exit code when attempting to unsubscribe from an invalid serial number.");
    Assert.assertEquals(result.getStdout().trim(), String.format("Error: '%s' is not a valid serial number", serials.get(1)), "Stdout");
    Assert.assertEquals(result.getStderr().trim(), "", "Stderr");
}
Also used : BigInteger(java.math.BigInteger) 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 38 with TestDefinition

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

the class VersionTests method testNoErrorWhileCheckingServerVersion.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-25814", "RHEL7-51275" }, 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 = "assert that no errors are reported while executing version module while registered and unregistered", groups = { "Tier2Tests", "blockedByBug-848409", "blockedByBug-1284120" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testNoErrorWhileCheckingServerVersion() {
    // from Bug 848409 - Error while checking server version: No such file or directory
    // [root@jsefler-59server ~]# subscription-manager version
    // Error while checking server version: No such file or directory
    // remote entitlement server: Unknown
    // remote entitlement server type: Unknown
    // subscription-manager: 1.0.13-1.git.27.2a76fe7.el5
    // assert results from version do not contain an error (while unregistered)
    String error = "Error";
    clienttasks.unregister(null, null, null, null);
    SSHCommandResult versionResult = clienttasks.version(null, null, null, null);
    Assert.assertTrue(!versionResult.getStdout().contains(error), "Stdout from the version report does NOT contain an '" + error + "' message (while unregistered).");
    Assert.assertTrue(!versionResult.getStderr().contains(error), "Stderr from the version report does NOT contain an '" + error + "' message (while unregistered).");
    // assert results from version do not contain an error (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);
    versionResult = clienttasks.version(null, null, null, null);
    Assert.assertTrue(!versionResult.getStdout().contains(error), "Stdout from the version report does NOT contain an '" + error + "' message (while registered).");
    Assert.assertTrue(!versionResult.getStderr().contains(error), "Stderr from the version report does NOT contain an '" + error + "' message (while registered).");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 39 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition 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 40 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition 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

TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)687 Test (org.testng.annotations.Test)687 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)401 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)366 SkipException (org.testng.SkipException)328 ArrayList (java.util.ArrayList)144 SubscriptionPool (rhsm.data.SubscriptionPool)137 JSONObject (org.json.JSONObject)95 BigInteger (java.math.BigInteger)90 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)88 HashMap (java.util.HashMap)78 File (java.io.File)74 ProductSubscription (rhsm.data.ProductSubscription)72 InstalledProduct (rhsm.data.InstalledProduct)66 EntitlementCert (rhsm.data.EntitlementCert)58 ProductCert (rhsm.data.ProductCert)54 YumRepo (rhsm.data.YumRepo)34 Repo (rhsm.data.Repo)26 Calendar (java.util.Calendar)25 List (java.util.List)24