use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method subscribeToTheCurrentlyAvailableSubscriptionPoolsIndividually.
/**
* Individually subscribe to each of the currently available subscription pools one at a time
* @return SubscriptionPools that were available for subscribing
*/
public List<SubscriptionPool> subscribeToTheCurrentlyAvailableSubscriptionPoolsIndividually() {
// individually subscribe to each available subscription pool
List<SubscriptionPool> pools = getCurrentlyAvailableSubscriptionPools();
for (SubscriptionPool pool : pools) {
subscribeToSubscriptionPool(pool);
}
// assert
assertNoAvailableSubscriptionPoolsToList(true, "Asserting that no available subscription pools remain after individually subscribing to them all.");
return pools;
}
use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.
the class SubscriptionManagerCLITestScript method getAvailableSubscriptionPoolsDataAsListOfLists.
/**
* @return List of [SubscriptionPool pool]
*/
protected List<List<Object>> getAvailableSubscriptionPoolsDataAsListOfLists(boolean all) {
List<List<Object>> ll = new ArrayList<List<Object>>();
if (!isSetupBeforeSuiteComplete)
return ll;
if (clienttasks == null)
return ll;
if (sm_clientUsername == null)
return ll;
if (sm_clientPassword == null)
return ll;
// assure we are registered
clienttasks.unregister(null, null, null, null);
// register
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
if (client2tasks != null) {
client2tasks.unregister(null, null, null, null);
if (!sm_client2Username.equals("") && !sm_client2Password.equals(""))
client2tasks.register(sm_client2Username, sm_client2Password, sm_client2Org, null, null, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
}
// unsubscribe from all consumed product subscriptions and then assemble a list of all SubscriptionPools
clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
if (client2tasks != null) {
client2tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
}
// populate a list of all available SubscriptionPools
List<SubscriptionPool> pools = all ? clienttasks.getCurrentlyAllAvailableSubscriptionPools() : clienttasks.getCurrentlyAvailableSubscriptionPools();
for (SubscriptionPool pool : pools) {
// /*debugTesting bugzilla 1246636*/ if (pool.productId.equals("adminos-onesocketib"))
ll.add(Arrays.asList(new Object[] { pool }));
// minimize the number of dataProvided rows (useful during automated testcase development)
if (Boolean.valueOf(getProperty("sm.debug.dataProviders.minimize", "false")))
break;
}
// manually reorder the pools so that the base "Red Hat Enterprise Linux*" pool is first in the list
// This is a workaround for testInstallAndRemovePackageAfterSubscribingToPool so as to avoid installing
// a package from a repo that has a package dependency from a repo that is not yet entitled.
int i = 0;
for (List<Object> list : ll) {
if (((SubscriptionPool) (list.get(0))).subscriptionName.startsWith("Red Hat Enterprise Linux")) {
ll.remove(i);
ll.add(0, list);
break;
}
i++;
}
return ll;
}
use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.
the class ExpirationTests method testEntitlementsAfterSubscriptionExpires.
// Test methods ***********************************************************************
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36638", "RHEL7-51448" }, 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 = "subscribe to a pool that will expire soon and assert the entitlements are removed after it expires", groups = { "Tier2Tests", "blockedByBug-655835", "blockedByBug-660713", "blockedByBug-854312", "blockedByBug-907638", "blockedByBug-994266", "blockedByBug-1555582" }, dependsOnGroups = {}, enabled = true)
public void testEntitlementsAfterSubscriptionExpires() throws Exception {
clienttasks.restart_rhsmcertd(certFrequency, null, true);
// create a subscription pool that will expire 2 minutes from now
int endingMinutesFromNow = 2;
String expiringPoolId = createTestPool(-60 * 24, endingMinutesFromNow);
// assert the expiring pool is currently available
SubscriptionPool expiringPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", expiringPoolId, clienttasks.getCurrentlyAllAvailableSubscriptionPools());
Assert.assertNotNull(expiringPool, "The expiring SubscriptionPool is currently available for subscribing: " + expiringPool);
// subscribe
File expiringCertFile = clienttasks.subscribeToSubscriptionPool_(expiringPool);
/*EntitlementCert*/
expiringCert = clienttasks.getEntitlementCertFromEntitlementCertFile(expiringCertFile);
List<ProductSubscription> expiringProductSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("serialNumber", expiringCert.serialNumber, clienttasks.getCurrentlyConsumedProductSubscriptions());
Assert.assertMore(expiringProductSubscriptions.size(), 0, "Found ProductSubscriptions corresponding to the just subscribed SubscriptionPool: " + expiringPool);
for (ProductSubscription expiringProductSubscription : expiringProductSubscriptions) {
Assert.assertTrue(expiringProductSubscription.isActive, "Immediately before the consumed subscription '" + expiringProductSubscription.productName + "' is about the expire, the list --consumed should show it as Active.");
}
// wait for pool to expire
// plus a 10 sec buffer; changed to 0 sec - the buffer creates too large of an opportunity for rhsmcertd to run and wipe out the expired cert
sleep(endingMinutesFromNow * 60 * 1000 + 0 * 1000);
String rhsmcertdLogMarker = System.currentTimeMillis() + " Testing VerifyEntitlementsAfterSubscriptionExpires_Test...";
RemoteFileTasks.markFile(client, clienttasks.rhsmcertdLogFile, rhsmcertdLogMarker);
// /*debugTesting*/sleep(certFrequency*60*1000); // to delay the assert long enough for rhsmcertd to trigger and delete the expired cert; used to force the code path through the "if (expiredProductSubscription==null)" code block that follows
// verify that the subscription pool has expired and is therefore not listed in all available; coverage for Bug 655835 - Pools are no longer removed after their expiration date https://github.com/RedHatQE/rhsm-qe/issues/132
SubscriptionPool expiredPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", expiringPoolId, clienttasks.getCurrentlyAllAvailableSubscriptionPools());
Assert.assertNull(expiredPool, "Expired Test Pool ID '" + expiringPoolId + "' is no longer available for subscribing.");
/* The following behavior block of assertions was changed for a few reasons...
* 1. Bug 994266 - expired entitlement shows in GUI but not in CLI
* 2. We felt that expired entitlements should remain on the system for the system user to acknowledge
* 3. The system user can simply acknowledge the expiration by clicking Remove in the GUI tab of "My Subscriptions"
// verify that the expired product subscriptions are not listed among the consumed
List <ProductSubscription> currentProductSubscriptions = ProductSubscription.parse(clienttasks.list(null,null,true, null, null, null, null, null, null).getStdout());
for (ProductSubscription p : expiringProductSubscriptions) {
Assert.assertTrue(!currentProductSubscriptions.contains(p),"The expired ProductSubscription '"+p+"' no longer appears as consumed.");
}
* current behavior is asserted here... */
// verify that the expired product subscriptions is still listed among the consumed, but inactive
List<ProductSubscription> currentlyConsumedProductSubscriptions = ProductSubscription.parse(clienttasks.list(null, null, true, null, null, null, null, null, null, null, null, null, null, null).getStdout());
for (ProductSubscription expiringProductSubscription : expiringProductSubscriptions) {
ProductSubscription expiredProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("serialNumber", expiringProductSubscription.serialNumber, currentlyConsumedProductSubscriptions);
// catch a corner case...
if (expiredProductSubscription == null) {
// then we were probably too slow and a trigger of rhsmcertd likely deleted the expired cert.
// Using this if block of code to confirm that assumption and skip the rest of this test
// desperate attempt to give rhsmcertdLogFile a chance to be updated so rhsmcertdLogTail will not be empty
sleep(1 * 1000);
String rhsmcertdLogTail = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmcertdLogFile, rhsmcertdLogMarker, null);
// rhsmcertd:
// Fri Aug 26 15:42:19 2016 [INFO] (Cert Check) Certificates updated.
// ---------------------------------------------------------------------------------------------------------
// rhsm.log:
// 2016-08-26 15:42:17,819 [DEBUG] rhsmcertd-worker:5398:MainThread @connection.py:573 - Making request: GET /candlepin/consumers/c56bfdb6-ff4c-41b6-84c2-4e0179df3a37/certificates/serials
// 2016-08-26 15:42:18,016 [DEBUG] rhsmcertd-worker:5398:MainThread @connection.py:602 - Response: status=200, requestUuid=bfd74f37-ef19-4516-8a5f-89d44dc9dc56
// 2016-08-26 15:42:18,018 [INFO] rhsmcertd-worker:5398:MainThread @entcertlib.py:131 - certs updated:
// Total updates: 1
// Found (local) serial# [1826226756700020146L]
// Expected (UEP) serial# []
// Added (new)
// <NONE>
// Deleted (rogue):
// [sn:1826226756700020146 (Awesome OS Server Bundled) @ /etc/pki/entitlement/1826226756700020146.pem]
Assert.assertTrue(rhsmcertdLogTail.trim().endsWith("Certificates updated."), "It appears that the rhsmcertd coincidently triggered too quickly on its frequency of '" + certFrequency + "'min after the entitlement expired causing it to be deleted by the rhsmcertd.");
throw new SkipException("Skipping the rest of this test since rhsmcertd triggered too closely after the expiration of the entitlement cert for us to do all of our test assertions before rhsmcertd ran. Hopefully the next test run will complete.");
}
Assert.assertNotNull(expiredProductSubscription, "Immediately after the consumed subscription '" + expiringProductSubscription.productName + "' serial '" + expiringProductSubscription.serialNumber + "' expires, it should still be found the list of consumed product subscriptions (assuming that rhsmcertd on certFrequency='" + certFrequency + "'min has not yet triggered before this assert).");
Assert.assertTrue(!expiredProductSubscription.isActive, "Immediately after the consumed subscription '" + expiringProductSubscription.productName + "' serial '" + expiringProductSubscription.serialNumber + "' expires, the list of consumed product subscriptions should show it as inActive.");
}
// verify that the expired entitlement cert file is gone after a trigger of rhsmcertd.certFrequency
SubscriptionManagerCLITestScript.sleep(certFrequency * 60 * 1000);
Assert.assertTrue(!RemoteFileTasks.testExists(client, expiringCertFile.getPath()), "The expired entitlement cert file has been cleaned off the system by rhsmcertd");
// final test in honor of bug 854312 - rhsmcertd removes, then puts, then removes, then puts, then removes, etc... an expired entitlement cert
// verify that the expired entitlement cert file is still gone after another trigger a rhsmcertd.certFrequency
SubscriptionManagerCLITestScript.sleep(certFrequency * 60 * 1000);
Assert.assertTrue(!RemoteFileTasks.testExists(client, expiringCertFile.getPath()), "After another trigger of the cert frequency, the expired entitlement cert file remains cleaned from the system.");
}
use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.
the class ExpirationTests method testPoolIsNotYetAvailableUntilTheStartDate.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-37709", "RHEL7-51449" }, 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 a soon to be available pool is not yet available", groups = { "Tier2Tests", "blockedByBug-1555582" }, dependsOnGroups = {}, enabled = true)
public void testPoolIsNotYetAvailableUntilTheStartDate() throws Exception {
// create a subscription pool that will start 2 minutes from now
int startingMinutesFromNow = 3;
String aboutToStartPoolId = createTestPool(startingMinutesFromNow, /*60*24*/
startingMinutesFromNow + 2);
// assert the starting pool is NOT currently available
SubscriptionPool startingPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", aboutToStartPoolId, clienttasks.getCurrentlyAllAvailableSubscriptionPools());
Assert.assertNull(startingPool, "The about to start SubscriptionPool with id '" + aboutToStartPoolId + "' is currently NOT YET available for subscribing.");
// wait for pool to start
// plus a 30 sec buffer;
sleep((startingMinutesFromNow - 1) * 60 * 1000 + 0 * 1000);
// assert the starting pool is still NOT currently available (1 minute before its startDate)
startingPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", aboutToStartPoolId, clienttasks.getCurrentlyAllAvailableSubscriptionPools());
Assert.assertNull(startingPool, "The about to start SubscriptionPool with id '" + aboutToStartPoolId + "' is still NOT YET available for subscribing (1 minute before its startDate).");
// wait one more minute for pool to start
// plus a 30 sec buffer;
sleep(1 * 60 * 1000 + 30 * 1000);
// assert the starting pool is NOW currently available
startingPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", aboutToStartPoolId, clienttasks.getCurrentlyAllAvailableSubscriptionPools());
Assert.assertNotNull(startingPool, "The about to start SubscriptionPool with id '" + aboutToStartPoolId + "' is now available for subscribing: " + startingPool);
}
use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.
the class ExpirationTests method findRandomAvailableProductIdBeforeClass.
@BeforeClass(groups = "setup", dependsOnMethods = "registerBeforeClass")
public void findRandomAvailableProductIdBeforeClass() throws Exception {
// find a randomly available product id
List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
// randomly pick a pool
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
// debugging bugzilla 760162
// pool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", "awesomeos-virt-4", pools);
randomAvailableProductId = pool.productId;
}
Aggregations