Search in sources :

Example 81 with ProductSubscription

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

the class UnsubscribeTests method testUnsubscribeFromAValidPoolIdAndSerial.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36593", "RHEL7-51398" }, 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 = "Attempt to unsubscribe from an valid pool id and serial", groups = { "Tier2Tests", "blockedByBug-1198178", "blockedByBug-1498664" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testUnsubscribeFromAValidPoolIdAndSerial() {
    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");
    // 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);
    // get any available pool and subscribe
    List<SubscriptionPool> subscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    SubscriptionPool subscriptionPool = getRandomListItem(subscriptionPools);
    clienttasks.subscribe(null, null, subscriptionPool.poolId, null, null, null, null, null, null, null, null, null, null);
    // unsubscribe from the pool and its serial (actually the same entitlement)
    ProductSubscription productSubscription = getRandomListItem(clienttasks.getCurrentlyConsumedProductSubscriptions());
    SSHCommandResult result = clienttasks.unsubscribe_(null, productSubscription.serialNumber, productSubscription.poolId, null, null, null, null);
    // [root@jsefler-6 ~]# subscription-manager unsubscribe --serial=1636129384995885268 --pool=8a90879052610a8b0152610bd4e40587
    // Pools successfully removed at the server:
    // 8a90879052610a8b0152610bd4e40587
    // Serial numbers successfully removed at the server:
    // 1636129384995885268
    // 1 local certificate has been deleted.
    // NOTE: why exitCode 1?  probably because we are attempting two removes on one entitlement cert causing the second remove to fail after the first succeeds.
    Integer expectedExitCode = new Integer(1);
    String expectedStdout = "";
    expectedStdout = String.format("Pools successfully removed at the server:\n   %s", productSubscription.poolId);
    expectedStdout += "\n";
    expectedStdout += String.format("Serial numbers successfully removed at the server:\n   %s", productSubscription.serialNumber);
    expectedStdout += "\n";
    expectedStdout += String.format("%d local certificate has been deleted.", 1);
    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 successfully removed these pools:\n   %s", productSubscription.poolId);
        expectedStdout += "\n";
        expectedStdout += String.format("The entitlement server successfully removed these serial numbers:\n   %s", productSubscription.serialNumber);
        expectedStdout += "\n";
        expectedStdout += String.format("%d local certificate has been deleted.", 1);
    }
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.2-1")) {
        // commit d88d09c7060a17fba34a138313e7efd21cc79d02  D-Bus service for removing entitlements (all/ID/serial num.)
        expectedStdout = String.format("%d local certificate has been deleted.", 1);
        expectedStdout += "\n";
        expectedStdout += String.format("The entitlement server successfully removed these pools:\n   %s", productSubscription.poolId);
        expectedStdout += "\n";
        expectedStdout += String.format("The entitlement server successfully removed these serial numbers:\n   %s", productSubscription.serialNumber);
    }
    Assert.assertEquals(result.getExitCode(), expectedExitCode, "Asserting exit code when attempting to unsubscribe from a valid pool id and serial (corresponding to the same entitlement).");
    Assert.assertEquals(result.getStdout().trim(), expectedStdout.trim(), "Stdout");
    Assert.assertEquals(result.getStderr().trim(), "", "Stderr");
    // get two available pools and subscribe
    List<SubscriptionPool> subscriptionPoolsSubset = getRandomSubsetOfList(subscriptionPools, 2);
    clienttasks.subscribe(null, null, Arrays.asList(subscriptionPoolsSubset.get(0).poolId, subscriptionPoolsSubset.get(1).poolId), null, null, null, null, null, null, null, null, null, null);
    // unsubscribe from one pool and one serial
    List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    ProductSubscription productSubscription1 = productSubscriptions.get(0);
    ProductSubscription productSubscription2 = productSubscriptions.get(1);
    result = clienttasks.unsubscribe_(null, productSubscription1.serialNumber, productSubscription2.poolId, null, null, null, null);
    // [root@jsefler-6 ~]# subscription-manager unsubscribe --serial=1826457911783374718 --pool=8a90879052610a8b0152610be38f074b (com.redhat.qe.tools.SSHCommandRunner.run)
    // Pools successfully removed at the server:
    // 8a90879052610a8b0152610be38f074b
    // Serial numbers successfully removed at the server:
    // 6656837828924322952
    // 1826457911783374718
    // 2 local certificates have been deleted.
    expectedExitCode = new Integer(0);
    expectedStdout = String.format("Pools successfully removed at the server:\n   %s", productSubscription2.poolId);
    expectedStdout += "\n";
    expectedStdout += String.format("Serial numbers successfully removed at the server:\n   %s\n   %s", productSubscription2.serialNumber, productSubscription1.serialNumber);
    expectedStdout += "\n";
    expectedStdout += String.format("%d local certificates have been deleted.", 2);
    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 successfully removed these pools:\n   %s", productSubscription2.poolId);
        expectedStdout += "\n";
        expectedStdout += String.format("The entitlement server successfully removed these serial numbers:\n   %s\n   %s", productSubscription2.serialNumber, productSubscription1.serialNumber);
        expectedStdout += "\n";
        expectedStdout += String.format("%d local certificates have been deleted.", 2);
    }
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.2-1")) {
        // commit d88d09c7060a17fba34a138313e7efd21cc79d02  D-Bus service for removing entitlements (all/ID/serial num.)
        expectedStdout = String.format("%d local certificates have been deleted.", 2);
        expectedStdout += "\n";
        expectedStdout += String.format("The entitlement server successfully removed these pools:\n   %s", productSubscription2.poolId);
        expectedStdout += "\n";
        expectedStdout += String.format("The entitlement server successfully removed these serial numbers:\n   %s\n   %s", productSubscription2.serialNumber, productSubscription1.serialNumber);
        expectedStdout += "\n";
    }
    Assert.assertEquals(result.getExitCode(), expectedExitCode, "Asserting exit code when attempting to unsubscribe from from a valid pool id and serial (corresponding to two different entitlements).");
    Assert.assertEquals(result.getStdout().trim(), expectedStdout.trim(), "Stdout");
    Assert.assertEquals(result.getStderr().trim(), "", "Stderr");
}
Also used : BigInteger(java.math.BigInteger) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ProductSubscription(rhsm.data.ProductSubscription) 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 82 with ProductSubscription

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

the class UnsubscribeTests method testUnsubscribeFromAllSerialsIncludingRevokedSerials.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36595", "RHEL7-51400" }, 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 (including revoked serials) using unsubscribe --serial SERIAL1 --serial SERIAL2 --serial SERIAL3 etc.", groups = { "Tier2Tests", "blockedByBug-867766" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testUnsubscribeFromAllSerialsIncludingRevokedSerials() throws JSONException, 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.getCurrentlyAllAvailableSubscriptionPools();
    if (pools.isEmpty())
        throw new SkipException("This test requires multiple available pools.");
    // which poolIds are modifiers?
    Set<String> modifierPoolIds = new HashSet<String>();
    for (SubscriptionPool subscriptionPool : pools) if (CandlepinTasks.isPoolAModifier(sm_clientUsername, sm_clientPassword, subscriptionPool.poolId, sm_serverUrl))
        modifierPoolIds.add(subscriptionPool.poolId);
    // subscribe to all of the available pools
    List<String> poolIds = new ArrayList<String>();
    for (SubscriptionPool pool : pools) poolIds.add(pool.poolId);
    clienttasks.subscribe(null, null, poolIds, null, null, null, null, null, null, null, null, null, null);
    // prepare a list of currently consumed serials that we can use to collectively unsubscribe from
    List<BigInteger> serials = new ArrayList<BigInteger>();
    for (ProductSubscription productSubscription : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
        // insert modifiers at the head of the serials list so their removal won't cause a cert regeneration
        if (!productSubscription.poolId.equals("Unknown") && /*indicative of an older candlepin*/
        modifierPoolIds.contains(productSubscription.poolId))
            serials.add(0, productSubscription.serialNumber);
        else
            serials.add(productSubscription.serialNumber);
    }
    // unsubscribe from all serials in one call and assert the feedback;
    SSHCommandResult result = clienttasks.unsubscribe(null, serials, null, null, null, null, null);
    String actualStdoutMsg = result.getStdout().trim();
    actualStdoutMsg = clienttasks.workaroundForBug906550(actualStdoutMsg);
    String expectedStdoutMsg;
    // changed by bug 874749
    expectedStdoutMsg = "Successfully unsubscribed serial numbers:";
    expectedStdoutMsg = "Successfully removed serial numbers:";
    // changed by bug 895447 subscription-manager commit 8e10e76fb5951e0b5d6c867c6c7209d8ec80dead
    expectedStdoutMsg = "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"))
        expectedStdoutMsg = "The entitlement server successfully removed these serial numbers:";
    // NOTE: This expectedStdoutMsg makes a huge assumption about the order of the unsubscribed serial numbers printed to stdout
    for (BigInteger serial : serials) expectedStdoutMsg += "\n   " + serial;
    Assert.assertEquals(actualStdoutMsg, expectedStdoutMsg, "Stdout feedback when unsubscribing from all the currently consumed subscriptions.");
    // remember the unsubscribed serials as revoked serials
    List<BigInteger> revokedSerials = new ArrayList<BigInteger>();
    for (BigInteger serial : serials) revokedSerials.add(serial);
    // re-subscribe to all the available pools again
    clienttasks.subscribe(null, null, poolIds, null, null, null, null, null, null, null, null, null, null);
    // re-prepare a list of currently consumed serials that we can use to collectively unsubscribe from
    // include the revokedSerials by interleaving them into the currently consumed serials
    serials.clear();
    List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    for (int i = 0; i < productSubscriptions.size(); i++) {
        ProductSubscription productSubscription = productSubscriptions.get(i);
        // insert modifiers at the head of the serials list so their removal won't cause a cert regeneration
        if (!productSubscription.poolId.equals("Unknown") && /*indicative of an older candlepin*/
        modifierPoolIds.contains(productSubscription.poolId))
            serials.add(0, productSubscription.serialNumber);
        else
            serials.add(productSubscription.serialNumber);
        // interleave the former revokedSerials amongst the serials
        serials.add(revokedSerials.get(i));
    }
    // now attempt to unsubscribe from both the current serials AND the previously consumed serials in one call and assert the feedback
    result = clienttasks.unsubscribe(null, serials, null, null, null, null, null);
    actualStdoutMsg = result.getStdout().trim();
    actualStdoutMsg = clienttasks.workaroundForBug906550(actualStdoutMsg);
    // added by bug 867766	// changed by bug 874749
    expectedStdoutMsg = "Successfully unsubscribed serial numbers:";
    expectedStdoutMsg = "Successfully removed serial numbers:";
    // changed by bug 895447 subscription-manager commit 8e10e76fb5951e0b5d6c867c6c7209d8ec80dead
    expectedStdoutMsg = "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"))
        expectedStdoutMsg = "The entitlement server successfully removed these serial numbers:";
    // NOTE: This expectedStdoutMsg makes a huge assumption about the order of the unsubscribed serial numbers printed to stdout
    for (BigInteger serial : serials) if (!revokedSerials.contains(serial))
        expectedStdoutMsg += "\n   " + serial;
    expectedStdoutMsg += "\n";
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.17.8-1")) {
        // commit f64d5a6b012f49bb4d6d6653441d4de9bf373660  1319678: Alter the return message for removing entitlements at server
        expectedStdoutMsg += "The entitlement server failed to remove these serial numbers:";
    } else {
        // expectedStdoutMsg += "Unsuccessfully unsubscribed serial numbers:";	// added by bug 867766	// changed by bug 874749
        // expectedStdoutMsg += "Unsuccessfully removed serial numbers:";
        // changed by bug 895447 subscription-manager commit 8e10e76fb5951e0b5d6c867c6c7209d8ec80dead
        expectedStdoutMsg += "Serial numbers unsuccessfully removed at the server:";
    }
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.16.6-1")) {
        // NOTE: This expectedStdoutMsg makes a huge assumption about the order of the unsubscribed serial numbers printed to stdout
        for (BigInteger revokedSerial : revokedSerials) expectedStdoutMsg += "\n   " + revokedSerial;
    } else {
        // NOTE: This expectedStdoutMsg makes a huge assumption about the order of the unsubscribed serial numbers printed to stdout
        for (BigInteger revokedSerial : revokedSerials) expectedStdoutMsg += "\n   " + String.format("Entitlement Certificate with serial number '%s' could not be found.", revokedSerial);
    }
    Assert.assertEquals(actualStdoutMsg, expectedStdoutMsg, "Stdout feedback when unsubscribing from all the currently consumed subscriptions (including revoked serials).");
}
Also used : ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) BigInteger(java.math.BigInteger) 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 83 with ProductSubscription

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

the class RepoOverrideTests method testAddAndRemoveRepoOverridesUsingMultipleRepos.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19977", "RHEL7-33077" }, 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 = "Tier1")
@Test(description = "add yum repo overrides, verify they persist, and remove them across multiple repo ids simultaneously (use multiple --repo args)", groups = { "Tier1Tests", "blockedByBug-1069230", "blockedByBug-1034396" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testAddAndRemoveRepoOverridesUsingMultipleRepos() {
    // register
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    // subscribe to a random pool (so as to consume an entitlement) and remember the original list of YumRepos read from the redhat.repo file
    List<YumRepo> originalYumRepos = attachRandomSubscriptionThatProvidesYumRepos();
    // choose a random small subset of repos to test repo-override
    List<YumRepo> originalYumReposSubset = getRandomSubsetOfList(originalYumRepos, 5);
    // add several repo overrides (specifying all repos in multiplicity)
    Map<String, Map<String, String>> repoOverridesMapOfMaps = new HashMap<String, Map<String, String>>();
    Map<String, String> repoOverrideNameValueMap = new HashMap<String, String>();
    repoOverrideNameValueMap.put("enabled", "true");
    repoOverrideNameValueMap.put("gpgcheck", "false");
    repoOverrideNameValueMap.put("exclude", "foo-bar");
    repoOverrideNameValueMap.put("retries", "5");
    repoOverrideNameValueMap.put("ui_repoid_vars", "releasever basearch foo");
    repoOverrideNameValueMap.put("sslverify", "false");
    repoOverrideNameValueMap.put("sslcacert", "/overridden/candlepin.pem");
    repoOverrideNameValueMap.put("sslclientkey", "/overridden/serial-key.pem");
    repoOverrideNameValueMap.put("sslclientcert", "/overridden/serial.pem");
    for (YumRepo yumRepo : originalYumReposSubset) repoOverridesMapOfMaps.put(yumRepo.id, repoOverrideNameValueMap);
    List<String> repoIds = new ArrayList<String>(repoOverridesMapOfMaps.keySet());
    clienttasks.repo_override(null, null, repoIds, null, repoOverrideNameValueMap, null, null, null, null);
    // verify the current YumRepos read from the redhat.repo file actually contain the overrides
    verifyCurrentYumReposReflectRepoOverrides(originalYumRepos, repoOverridesMapOfMaps, true);
    // unsubscribe/resubscribe
    SSHCommandResult listResultBeforeUnsubscribe = clienttasks.repo_override_(true, null, (String) null, (String) null, null, null, null, null, null);
    List<String> poolIds = new ArrayList<String>();
    for (ProductSubscription productSubscription : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
        clienttasks.unsubscribe(true, productSubscription.serialNumber, null, null, null, null, null);
        poolIds.add(productSubscription.poolId);
    }
    SSHCommandResult listResultAfterUnsubscribe = clienttasks.repo_override_(true, null, (String) null, (String) null, null, null, null, null, null);
    // valid prior to bug 1034396	Assert.assertEquals(listResultAfterUnsubscribe.getStdout().trim(), "This system does not have any subscriptions.", "Stdout from repo-override --list without any subscriptions attached (but should still have overrides cached in the consumer).");
    Assert.assertEquals(listResultAfterUnsubscribe.getStdout(), listResultBeforeUnsubscribe.getStdout(), "Stdout from repo-override --list without any subscriptions attached should be identical to the list when subscriptions were attached.");
    Assert.assertTrue(clienttasks.getCurrentlySubscribedYumRepos().isEmpty(), "The YumRepos in '" + clienttasks.redhatRepoFile + "' should be empty after unsubscribing from each serial.");
    clienttasks.subscribe(null, null, poolIds, null, null, null, null, null, null, null, null, null, null);
    // ...and verify the YumRepos read from the redhat.repo file persists the overrides
    verifyCurrentYumReposReflectRepoOverrides(originalYumRepos, repoOverridesMapOfMaps, false);
    // remove names from multiple repos using repo-override and verify the list
    clienttasks.repo_override(null, null, repoIds, Arrays.asList(new String[] { "name" }), null, null, null, null, null);
    clienttasks.repo_override(null, null, repoIds, Arrays.asList(new String[] { "name", "enabled", "ui_repoid_vars" }), null, null, null, null, null);
    // clienttasks.repo_override(null,null,repoids,Arrays.asList(new String[]{"gpgcheck","exclude","retries"}),null,null,null,null);	// for test variability, let's not delete these
    clienttasks.repo_override(null, null, repoIds, Arrays.asList(new String[] { "sslverify", "sslcacert", "sslclientkey", "sslclientcert" }), null, null, null, null, null);
    for (String repoId : repoIds) {
        repoOverridesMapOfMaps.get(repoId).remove("name");
        repoOverridesMapOfMaps.get(repoId).remove("enabled");
        repoOverridesMapOfMaps.get(repoId).remove("ui_repoid_vars");
        // repoOverridesMapOfMaps.get(repoId).remove("gpgcheck");
        // repoOverridesMapOfMaps.get(repoId).remove("exclude");
        // repoOverridesMapOfMaps.get(repoId).remove("retries");
        repoOverridesMapOfMaps.get(repoId).remove("sslverify");
        repoOverridesMapOfMaps.get(repoId).remove("sslcacert");
        repoOverridesMapOfMaps.get(repoId).remove("sslclientkey");
        repoOverridesMapOfMaps.get(repoId).remove("sslclientcert");
    }
    // verify the current YumRepos read from the redhat.repo file no longer contains the removed override (the original should be restored)
    verifyCurrentYumReposReflectRepoOverrides(originalYumRepos, repoOverridesMapOfMaps, false);
    // remove all of the repo overrides
    clienttasks.repo_override(null, true, (List<String>) null, (List<String>) null, null, null, null, null, null);
    repoOverridesMapOfMaps.clear();
    // 3/23/2015 ocassional workaround needed to remove stale repos from /etc/yum.repos.d/redhat.repo	// TODO figure out how to remove this
    clienttasks.getYumRepolist(null);
    // verify the current YumRepos read from the redhat.repo file no longer contains any overrides (the original should be restored)
    verifyCurrentYumReposReflectRepoOverrides(originalYumRepos, repoOverridesMapOfMaps, false);
}
Also used : HashMap(java.util.HashMap) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) YumRepo(rhsm.data.YumRepo) HashMap(java.util.HashMap) Map(java.util.Map) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 84 with ProductSubscription

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

the class RHELPersonalTests method testSystemAutosubscribeConsumesSubPool.

@Test(description = "subscription-manager-cli: Ensure system autosubscribe consumes subpool RHEL Personal Bits", groups = { "Tier2Tests", "EnsureSystemAutosubscribeConsumesSubPool_Test", "blockedByBug-637937", "blockedByBug-737762" }, // dependsOnGroups={"EnsureSubPoolIsNotDeletedAfterAllOtherSystemsUnsubscribeFromSubPool_Test"},
priority = 200, dependsOnMethods = { "testSubPoolIsConsumableAfterRegisteredPersonSubscribesToRHELPersonal" }, // registered consumers type of "person" was originally intended for entitling people to training.  Red Hat Learning Management systems never made use if it, and candlepin has no active requirements for it.  Disabling the personal tests...  Reference CLOSED WONTFIX BUG https://bugzilla.redhat.com/show_bug.cgi?id=967160#c1
enabled = false)
public // @ImplementsTCMS(id="")
void testSystemAutosubscribeConsumesSubPool() throws JSONException {
    if (client2tasks == null)
        throw new SkipException("A second client system is required for this test.");
    for (int j = 0; j < sm_personSubscriptionPoolProductData.length(); j++) {
        JSONObject poolProductDataAsJSONObject = (JSONObject) sm_personSubscriptionPoolProductData.get(j);
        String personProductId = poolProductDataAsJSONObject.getString("personProductId");
        JSONObject subpoolProductDataAsJSONObject = poolProductDataAsJSONObject.getJSONObject("subPoolProductData");
        String systemProductId = subpoolProductDataAsJSONObject.getString("systemProductId");
        JSONArray bundledProductData = subpoolProductDataAsJSONObject.getJSONArray("bundledProductData");
        log.info("Register client1 under username '" + username + "' as a person and subscribe to the '" + personProductId + "' subscription pool...");
        personConsumerId = client1tasks.getCurrentConsumerId(client1tasks.register(username, password, owner, null, ConsumerType.person, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null, null));
        SubscriptionPool personalPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", personProductId, client1tasks.getCurrentlyAllAvailableSubscriptionPools());
        Assert.assertNotNull(personalPool, "Personal subscription with ProductId '" + personProductId + "' is available to user '" + username + "' registered as a person.");
        List<File> beforeEntitlementCertFiles = client1tasks.getCurrentEntitlementCertFiles();
        client1tasks.subscribeToSubscriptionPool(personalPool);
        log.info("Now register client2 under username '" + username + "' as a system with autosubscribe to assert that subpools bundled products gets consumed...");
        client2tasks.unregister(null, null, null, null);
        client2tasks.register(username, password, owner, null, ConsumerType.system, null, null, Boolean.TRUE, null, null, (String) null, null, null, null, null, false, null, null, null, null);
        List<ProductSubscription> client2ConsumedProductSubscriptions = client2tasks.getCurrentlyConsumedProductSubscriptions();
        /* OLD ASSERTION BEFORE IMPLEMENTATION OF Bug 801187 - collapse list of provided products for subscription-manager list --consumed
			for (int k=0; k<bundledProductData.length(); k++) {
				JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductData.get(k);
				String systemConsumedProductName = bundledProductAsJSONObject.getString("productName");
				
				ProductSubscription consumedProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productName",systemConsumedProductName,client2ConsumedProductSubscriptions);
				Assert.assertNotNull(consumedProductSubscription,systemConsumedProductName+" has been autosubscribed by client2 '"+client2.getConnection().getRemoteHostname()+"' (registered as a system under username '"+username+"')");
	
			}
			*/
        List<String> systemConsumedProductNames = new ArrayList<String>();
        for (int k = 0; k < bundledProductData.length(); k++) {
            JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductData.get(k);
            String systemConsumedProductName = bundledProductAsJSONObject.getString("productName");
            systemConsumedProductNames.add(systemConsumedProductName);
        }
        ProductSubscription systemProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productName", personSubscriptionName, client2ConsumedProductSubscriptions);
        Assert.assertNotNull(systemProductSubscription, personSubscriptionName + " has been autosubscribed by client2 '" + client2.getConnection().getRemoteHostname() + "' (registered as a system under username '" + username + "')");
        Assert.assertTrue(systemProductSubscription.provides.containsAll(systemConsumedProductNames) && systemConsumedProductNames.containsAll(systemProductSubscription.provides), "All of the expected bundled products " + systemConsumedProductNames + " are now being provided for on client2 system '" + client2.getConnection().getRemoteHostname() + "' after having autosubscribed.");
        client2tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
        client1tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    }
    // unregister the last person consumer from client1
    client1tasks.unregister(null, null, null, null);
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) ProductSubscription(rhsm.data.ProductSubscription) ArrayList(java.util.ArrayList) SkipException(org.testng.SkipException) SubscriptionPool(rhsm.data.SubscriptionPool) File(java.io.File) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 85 with ProductSubscription

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

the class RHELPersonalTests method testSubPoolIsConsumableAfterRegisteredPersonSubscribesToRHELPersonal.

@Test(description = "subscription-manager-cli: Ensure RHEL Personal Bits are consumable after a person has subscribed to RHEL Personal", groups = { "Tier2Tests", "EnsureSubPoolIsConsumableAfterRegisteredPersonSubscribesToRHELPersonal_Test", "RHELPersonal" }, // dependsOnGroups={"EnsureSubPoolIsAvailableAfterRegisteredPersonSubscribesToRHELPersonal_Test"},
priority = 110, dependsOnMethods = { "testSubPoolIsAvailableAfterRegisteredPersonSubscribesToRHELPersonal" }, // registered consumers type of "person" was originally intended for entitling people to training.  Red Hat Learning Management systems never made use if it, and candlepin has no active requirements for it.  Disabling the personal tests...  Reference CLOSED WONTFIX BUG https://bugzilla.redhat.com/show_bug.cgi?id=967160#c1
enabled = false)
@ImplementsNitrateTest(caseId = 55702)
public // @ImplementsNitrateTest(caseId={55702,55718})
void testSubPoolIsConsumableAfterRegisteredPersonSubscribesToRHELPersonal() throws JSONException {
    for (int j = 0; j < sm_personSubscriptionPoolProductData.length(); j++) {
        JSONObject poolProductDataAsJSONObject = (JSONObject) sm_personSubscriptionPoolProductData.get(j);
        String personProductId = poolProductDataAsJSONObject.getString("personProductId");
        JSONObject subpoolProductDataAsJSONObject = poolProductDataAsJSONObject.getJSONObject("subPoolProductData");
        String systemProductId = subpoolProductDataAsJSONObject.getString("systemProductId");
        JSONArray bundledProductData = subpoolProductDataAsJSONObject.getJSONArray("bundledProductData");
        log.info("Now client2 (already registered as a system under username '" + username + "') can now consume '" + systemProductId + "'...");
        SubscriptionPool systemSubscriptionPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", systemProductId, client2tasks.getCurrentlyAvailableSubscriptionPools());
        client2tasks.subscribeToSubscriptionPool(systemSubscriptionPool);
        /* OLD ASSERTION BEFORE IMPLEMENTATION OF Bug 801187 - collapse list of provided products for subscription-manager list --consumed
			for (int k=0; k<bundledProductData.length(); k++) {
				JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductData.get(k);
				String systemConsumedProductName = bundledProductAsJSONObject.getString("productName");

				log.info("Now client2 should be consuming the product '"+systemConsumedProductName+"'...");
				ProductSubscription systemProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productName",systemConsumedProductName,client2tasks.getCurrentlyConsumedProductSubscriptions());
				Assert.assertNotNull(systemProductSubscription,systemConsumedProductName+" is now consumed on client2 system '"+client2.getConnection().getRemoteHostname()+"' registered under user '"+username+"'.");
			}
			*/
        List<String> systemConsumedProductNames = new ArrayList<String>();
        for (int k = 0; k < bundledProductData.length(); k++) {
            JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductData.get(k);
            String systemConsumedProductName = bundledProductAsJSONObject.getString("productName");
            systemConsumedProductNames.add(systemConsumedProductName);
        }
        log.info("Now client2 should be consuming the subscription '" + personSubscriptionName + "' that provides '" + systemConsumedProductNames + "'...");
        ProductSubscription systemProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productName", personSubscriptionName, client2tasks.getCurrentlyConsumedProductSubscriptions());
        Assert.assertNotNull(systemProductSubscription, personSubscriptionName + " is now consumed on client2 system '" + client2.getConnection().getRemoteHostname() + "' registered under user '" + username + "'.");
        Assert.assertTrue(systemProductSubscription.provides.containsAll(systemConsumedProductNames) && systemConsumedProductNames.containsAll(systemProductSubscription.provides), "All of the expected bundled products " + systemConsumedProductNames + " are now being provided for on client2 system '" + client2.getConnection().getRemoteHostname() + "' registered under user '" + username + "'.");
    }
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) SubscriptionPool(rhsm.data.SubscriptionPool) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

ProductSubscription (rhsm.data.ProductSubscription)90 Test (org.testng.annotations.Test)82 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)72 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)56 SkipException (org.testng.SkipException)46 ArrayList (java.util.ArrayList)41 SubscriptionPool (rhsm.data.SubscriptionPool)38 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)31 JSONObject (org.json.JSONObject)31 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)23 HashMap (java.util.HashMap)22 BigInteger (java.math.BigInteger)20 EntitlementCert (rhsm.data.EntitlementCert)17 InstalledProduct (rhsm.data.InstalledProduct)16 Calendar (java.util.Calendar)15 JSONArray (org.json.JSONArray)13 File (java.io.File)10 GregorianCalendar (java.util.GregorianCalendar)10 HashSet (java.util.HashSet)6 ConsumerCert (rhsm.data.ConsumerCert)6