Search in sources :

Example 96 with SubscriptionPool

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

the class RAMTests method testSubscribeToRamBasedSubscription.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36686", "RHEL7-51531" }, 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 subscription of Ram based subscription", groups = { "Tier2Tests", "SubscribeToRamBasedSubscription", "blockedByBug-907315" }, enabled = true)
public void testSubscribeToRamBasedSubscription() throws JSONException, Exception {
    factsMap.clear();
    factsMap.put("uname.machine", "x86_64");
    factsMap.put("cpu.core(s)_per_socket", "1");
    factsMap.put("memory.memtotal", String.valueOf(KBToGBConverter(1)));
    factsMap.put("cpu.cpu_socket(s)", "1");
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    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);
    int ramvalue = KBToGBConverter(Integer.parseInt(clienttasks.getFactValue("memory.memtotal")));
    for (SubscriptionPool pool : getRamBasedSubscriptions()) {
        if (pool.subscriptionName.contains("8GB")) {
            clienttasks.subscribe(null, null, pool.poolId, null, null, "1", null, null, null, null, null, null, null);
            for (String productName : pool.provides) {
                for (InstalledProduct installed : InstalledProduct.findAllInstancesWithMatchingFieldFromList("productName", productName, clienttasks.getCurrentlyInstalledProducts())) {
                    if (ramvalue <= 4) {
                        Assert.assertEquals(installed.status.trim(), "Subscribed", "Status of installed product '" + installed.productName + "'.");
                        factsMap.put("memory.memtotal", String.valueOf(GBToKBConverter(5)));
                        clienttasks.createFactsFileWithOverridingValues(factsMap);
                        clienttasks.facts(null, true, null, null, null, null);
                        ramvalue = KBToGBConverter(Integer.parseInt(clienttasks.getFactValue("memory.memtotal")));
                    } else if (ramvalue > 4 && ramvalue <= 8) {
                        Assert.assertEquals(installed.status.trim(), "Subscribed", "Status of installed product '" + installed.productName + "'.");
                        factsMap.put("memory.memtotal", String.valueOf(GBToKBConverter(9)));
                        clienttasks.createFactsFileWithOverridingValues(factsMap);
                        clienttasks.facts(null, true, null, null, null, null);
                        ramvalue = KBToGBConverter(Integer.parseInt(clienttasks.getFactValue("memory.memtotal")));
                    } else {
                        Assert.assertEquals(installed.status.trim(), "Partially Subscribed", "Status of installed product '" + installed.productName + "'.");
                    }
                }
            }
        }
    }
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 97 with SubscriptionPool

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

the class RHELPersonalTests method testEntitlementCertForSubPoolIsNotRevokedOnceAnotherSystemUnsubscribesFromSubPool.

// DUE TO BEHAVIOR CHNAGE, THIS TEST WAS REPLACED BY EnsurePersonCannotUnsubscribeWhileSubpoolsAreConsumed_Test
// @Test(	description="subscription-manager-cli: Ensure that the entitlement certs for subscribed subpool is revoked once the person unsubscribes from RHEL Personal",
// groups={"Tier2Tests","EnsureEntitlementCertForSubPoolIsRevokedOncePersonUnsubscribesFromRHELPersonal_Test","RHELPersonal","blockedByBug-639434"},
// dependsOnGroups={"SubscribeMultipleSystemsToSubPool_Test","EnsurePersonCannotUnsubscribeWhileSubpoolsAreConsumed_Test","EnsurePersonCannotUnregisterWhileSubpoolsAreConsumed_Test"},
// //			dataProvider="getRHELPersonalData",
// enabled=true)
// @ImplementsNitrateTest(caseId=58898)
// // 1) unsubscribe person from personal pool while systems are subscribed to subpool (scenario from calfanso@redhat.com)
// public void EnsureEntitlementCertForSubPoolIsRevokedOncePersonUnsubscribesFromRHELPersonal_Test(/*String consumerUsername,	String consumerPassword,	String personSubscriptionName,		String systemSubscriptionName,	String systemConsumedProductName*/) {
// log.info("Assuming that multiple systems have subscribed to subpool '"+systemSubscriptionName+"' in prior testcase...");
// 
// log.info("Now, unsubscribe the person on client 1 from the '"+personSubscriptionName+"' and assert that the '"+systemConsumedProductName+"' and '"+systemSubscriptionName+"' gets revoked from the system consumers.");
// client1tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
// 
// log.info("Now the the certs for '"+systemConsumedProductName+"' and '"+systemSubscriptionName+"' should be revoked from the system consumers...");
// for (String consumerId : consumerIds) {
// //client2tasks.reregister(consumerUsername,consumerPassword,consumerId);
// client2tasks.reregisterToExistingConsumer(consumerUsername,consumerPassword,consumerId);
// // 10/11/2010 NOT NEEDED SINCE register --consumerid NOW REFRESHES CERTS			client2tasks.restart_rhsmcertd(1, true);	// give rhsmcertd a chance to download the consumer's certs
// ProductSubscription productSubscription = client2tasks.findProductSubscriptionWithMatchingFieldFromList("productName",systemConsumedProductName,client2tasks.getCurrentlyConsumedProductSubscriptions());
// Assert.assertTrue(productSubscription==null,systemConsumedProductName+" is no longer consumed by '"+consumerId+"' (registered as a system under username '"+consumerUsername+"')");
// SubscriptionPool systemSubscriptionPool = client2tasks.findSubscriptionPoolWithMatchingFieldFromList("subscriptionName",systemSubscriptionName,client2tasks.getCurrentlyAvailableSubscriptionPools());
// Assert.assertTrue(systemSubscriptionPool==null,systemSubscriptionName+" is no longer available to consumer '"+consumerId+"' (registered as a system under username '"+consumerUsername+"')");
// }
// }
@Test(description = "subscription-manager-cli: Ensure that unsubscribing system from subpool while other systems are subscribed to subpool does not cause subpool to go away", groups = { "Tier2Tests", "EnsureEntitlementCertForSubPoolIsNotRevokedOnceAnotherSystemUnsubscribesFromSubPool_Test", "RHELPersonal", "blockedByBug-643405" }, // dependsOnGroups={"SubscribeMultipleSystemsToSubPool_Test","EnsurePersonCannotUnsubscribeWhileSubpoolsAreConsumed_Test","EnsurePersonCannotUnregisterWhileSubpoolsAreConsumed_Test"},
priority = 160, dependsOnMethods = { "testSubscribeMultipleSystemsToSubPool" }, // 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 = 58899)
public // 2) unsubscribe system from subpool while other systems are subscribed to subpool, make sure the subpool doesn't go away (scenario from calfanso@redhat.com)
void testEntitlementCertForSubPoolIsNotRevokedOnceAnotherSystemUnsubscribesFromSubPool() throws JSONException {
    log.info("Now start unsubscribing each system from the consumed product(s) and assert the personal sub pool is still available...");
    for (String consumerId : systemConsumerIds) {
        // client2tasks.reregister(consumerUsername,consumerPassword,consumerId);
        client2tasks.reregisterToExistingConsumer(username, password, consumerId);
        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");
            String systemConsumedProductName = null;
            for (int k = 0; k < bundledProductData.length(); k++) {
                JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductData.get(k);
                systemConsumedProductName = bundledProductAsJSONObject.getString("productName");
            }
            ProductSubscription productSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productName", systemConsumedProductName, client2tasks.getCurrentlyConsumedProductSubscriptions());
            Assert.assertNotNull(productSubscription, "Found the consumed Product Subscription with productName='" + systemConsumedProductName + "'.");
            client2tasks.unsubscribeFromProductSubscription(productSubscription);
            SubscriptionPool systemSubscriptionPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", systemProductId, client2tasks.getCurrentlyAvailableSubscriptionPools());
            Assert.assertNotNull(systemSubscriptionPool, "Subscription to ProductId '" + systemProductId + "' is once again available to consumer '" + consumerId + "' (registered as a system under username '" + username + "')");
        }
    }
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) 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)

Example 98 with SubscriptionPool

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

the class RHELPersonalTests method testAvailabilityOfSubPoolIsRevokedOncePersonUnsubscribesFromRHELPersonal.

@Test(description = "subscription-manager-cli: Ensure that availability of RHEL Personal Bits is revoked once the person unsubscribes from RHEL Personal", groups = { "Tier2Tests", "EnsureAvailabilityOfSubPoolIsRevokedOncePersonUnsubscribesFromRHELPersonal_Test", "RHELPersonal" }, // dependsOnGroups={"EnsureSubPoolIsConsumableAfterRegisteredPersonSubscribesToRHELPersonal_Test"},
priority = 120, 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 testAvailabilityOfSubPoolIsRevokedOncePersonUnsubscribesFromRHELPersonal() throws JSONException {
    log.info("Unsubscribe client2 (already registered as a system under username '" + username + "') from all currently consumed product subscriptions...");
    client2tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    log.info("Unsubscribe client1 (already registered as a person under username '" + username + "') from all currently consumed person subscriptions...");
    client1tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    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");
        log.info("Now verify that client2 (already registered as a system under username '" + username + "') can no longer subscribe to the '" + systemProductId + "' pool...");
        SubscriptionPool systemSubscriptionPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", systemProductId, client2tasks.getCurrentlyAvailableSubscriptionPools());
        Assert.assertNull(systemSubscriptionPool, "ProductId '" + systemProductId + "' is no longer available on client2 system '" + client2.getConnection().getRemoteHostname() + "' registered under user '" + username + "'.");
    }
}
Also used : JSONObject(org.json.JSONObject) SubscriptionPool(rhsm.data.SubscriptionPool) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 99 with SubscriptionPool

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

the class RHELPersonalTests method testSubPoolIsAvailableAfterRegisteredPersonSubscribesToRHELPersonal.

// Test Methods ***********************************************************************
@Test(description = "subscription-manager-cli: Ensure RHEL Personal Bits are available and unlimited after a person has subscribed to RHEL Personal", groups = { "Tier2Tests", "EnsureSubPoolIsAvailableAfterRegisteredPersonSubscribesToRHELPersonal_Test", "RHELPersonal", "blockedByBug-624816", "blockedByBug-641155", "blockedByBug-643405", "blockedByBug-967160" }, priority = 100, // 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 testSubPoolIsAvailableAfterRegisteredPersonSubscribesToRHELPersonal() throws JSONException {
    if (client2tasks == null)
        throw new SkipException("These tests are designed to use a second client.");
    if (username.equals(sm_serverAdminUsername))
        throw new SkipException("This test requires that the client user (" + username + ") is NOT " + sm_serverAdminUsername);
    // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=624423 - jsefler 8/16/2010
    Boolean invokeWorkaroundWhileBugIsOpen = false;
    try {
        String bugId = "624423";
        if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
            log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
            SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
        } else {
            invokeWorkaroundWhileBugIsOpen = false;
        }
    } catch (BugzillaAPIException be) {
    /* ignore exception */
    } catch (RuntimeException re) {
    /* ignore exception */
    }
    if (invokeWorkaroundWhileBugIsOpen) {
        servertasks.restartTomcat();
    }
    // END OF WORKAROUND
    client2tasks.unregister(null, null, null, null);
    // just in case client1 is still registered as the person consumer
    client1tasks.unregister(null, null, null, null);
    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");
        SubscriptionPool pool = null;
        log.info("Register client2 under username '" + username + "' as a system and assert that ProductId '" + systemProductId + "' is NOT yet available...");
        client2tasks.register(username, password, owner, null, ConsumerType.system, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
        List<SubscriptionPool> client2BeforeSubscriptionPools = client2tasks.getCurrentlyAvailableSubscriptionPools();
        pool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", systemProductId, client2BeforeSubscriptionPools);
        Assert.assertNull(pool, "ProductId '" + systemProductId + "' is NOT yet available to client2 system '" + client2.getConnection().getRemoteHostname() + "' registered under user '" + username + "'.");
        // log.info("Now register client1 under username '"+consumerUsername+"' as a person and subscribe to the '"+personSubscriptionName+"' subscription pool...");
        log.info("Now register client1 under username '" + username + "' as a person and subscribe to the personal subscription pool with ProductId '" + personProductId + "'...");
        // client1tasks.unregister(null, null, null);
        client1tasks.register(username, password, owner, null, ConsumerType.person, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
        personConsumerId = client1tasks.getCurrentConsumerId();
        // pool = client1tasks.findSubscriptionPoolWithMatchingFieldFromList("subscriptionName",personSubscriptionName,client1tasks.getCurrentlyAllAvailableSubscriptionPools());
        pool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", personProductId, client1tasks.getCurrentlyAvailableSubscriptionPools());
        personSubscriptionName = pool.subscriptionName;
        Assert.assertNotNull(pool, "Personal Subscription with ProductId '" + personProductId + "' is available to user '" + username + "' registered as a person.");
        client1tasks.subscribeToSubscriptionPool(pool);
        log.info("Now client2 (already registered as a system under username '" + username + "') should now have ProductId '" + systemProductId + "' available with a quantity if '" + systemSubscriptionQuantity + "'...");
        List<SubscriptionPool> client2AfterSubscriptionPools = client2tasks.getCurrentlyAvailableSubscriptionPools();
        SubscriptionPool systemSubscriptionPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", systemProductId, client2AfterSubscriptionPools);
        Assert.assertNotNull(systemSubscriptionPool, "ProductId '" + systemProductId + "' is now available to client2 '" + client2.getConnection().getRemoteHostname() + "' (registered as a system under username '" + username + "')");
        Assert.assertEquals(systemSubscriptionPool.quantity.toLowerCase(), systemSubscriptionQuantity, "A quantity of '" + systemSubscriptionQuantity + "' entitlements is available to the subscription for " + systemProductId + ".");
        log.info("Verifying that the available subscription pools available to client2 has increased by only the '" + systemProductId + "' pool...");
        Assert.assertTrue(client2AfterSubscriptionPools.containsAll(client2BeforeSubscriptionPools) && client2AfterSubscriptionPools.contains(systemSubscriptionPool) && client2AfterSubscriptionPools.size() == client2BeforeSubscriptionPools.size() + 1, "The list of available subscription pools seen by client2 increases only by '" + systemProductId + "' pool: " + systemSubscriptionPool);
    }
}
Also used : JSONObject(org.json.JSONObject) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) SubscriptionPool(rhsm.data.SubscriptionPool) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 100 with SubscriptionPool

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

the class RHELPersonalTests method testSubscribeMultipleSystemsToSubPool.

@Test(description = "subscription-manager-cli: Ensure that multiple (unlimited) systems can subscribe to subpool", groups = { "Tier2Tests", "SubscribeMultipleSystemsToSubPool_Test", "RHELPersonal" /*, "blockedByBug-661130"*/
}, // dependsOnGroups={"EnsureAvailabilityOfSubPoolIsRevokedOncePersonUnsubscribesFromRHELPersonal_Test"},
priority = 130, 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)
public // @ImplementsTCMS(id="")
void testSubscribeMultipleSystemsToSubPool() throws JSONException {
    log.info("Making sure the clients are not subscribed to anything...");
    // client2tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    // client2tasks.unregister();
    // client1tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    unsubscribeAndUnregisterMultipleSystemsAfterGroups();
    client1tasks.register(username, password, owner, null, ConsumerType.person, /*"blockedByBug-661130" "ME"*/
    null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    personConsumerId = client1tasks.getCurrentConsumerId();
    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("Subscribe client1 (already registered as a person under username '" + username + "') to subscription pool with ProductId'" + personProductId + "'...");
        personSubscriptionPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", personProductId, client1tasks.getCurrentlyAllAvailableSubscriptionPools());
        Assert.assertNotNull(personSubscriptionPool, "Personal subscription with ProductId '" + personProductId + "' is available to user '" + username + "' registered as a person.");
        // client1tasks.subscribe(personSubscriptionPool.poolId, null, null, null, null);
        // personalEntitlementCert = client1tasks.getEntitlementCertFromEntitlementCertFile(client1tasks.subscribeToSubscriptionPool(personSubscriptionPool));
        personEntitlementCert = client1tasks.getEntitlementCertFromEntitlementCertFile(client1tasks.subscribeToSubscriptionPool(personSubscriptionPool, /*sm_serverAdminUsername*/
        username, /*sm_serverAdminPassword*/
        password, sm_serverUrl));
        log.info("Register " + multipleSystems + " new systems under username '" + username + "' and subscribe to sub productId '" + systemProductId + "'...");
        systemConsumerIds = new ArrayList<String>();
        for (int systemNum = 1; systemNum <= multipleSystems; systemNum++) {
            // simulate a clean system
            client2tasks.removeAllCerts(true, true, false);
            String consumerId = client2tasks.getCurrentConsumerId(client2tasks.register(username, password, owner, null, ConsumerType.system, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null, null));
            systemConsumerIds.add(consumerId);
            SubscriptionPool subPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", systemProductId, client2tasks.getCurrentlyAvailableSubscriptionPools());
            log.info("Subscribing system '" + systemNum + "' ('" + consumerId + "' under username '" + username + "') to sub pool for productId '" + systemProductId + "'...");
            client2tasks.subscribeToSubscriptionPool(subPool);
            /* 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 productSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productName",systemConsumedProductName,client2tasks.getCurrentlyConsumedProductSubscriptions());
					Assert.assertNotNull(productSubscription,systemConsumedProductName+" is now consumed by consumer '"+consumerId+"' (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);
            }
            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 by consumer '" + consumerId + "' (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() + "' consumed by consumer '" + consumerId + "'.");
        }
    }
}
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)

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