use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class RefreshTests method testRefreshEntitlements.
// 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-20023", "RHEL7-51040" }, 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 = "subscription-manager-cli: refresh and verify entitlements are updated", groups = { "Tier1Tests", "RefreshEntitlements_Test", "blockedByBug-907638", "blockedByBug-962520", "blockedByBug-1366301" }, enabled = true)
// http://gibson.usersys.redhat.com/agilo/ticket/4022
@ImplementsNitrateTest(caseId = 64182)
public void testRefreshEntitlements() {
// Start fresh by unregistering and registering...
log.info("Start fresh by unregistering and registering...");
clienttasks.unregister(null, null, null, null);
clienttasks.getCurrentConsumerId(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));
// make sure the certFrequency will not affect the results of this test
log.info("Change the certFrequency to a large value to assure the rhsmcertd does not interfere with this test.");
clienttasks.restart_rhsmcertd(60, null, true);
// Subscribe to a randomly available pool...
log.info("Subscribe to a randomly available pool...");
List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
if (pools.isEmpty())
throw new SkipException("There are no available pools at all to get entitlements from. Cannot attempt this test.");
// randomly pick a pool
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
clienttasks.subscribeToSubscriptionPool(pool);
// remember the currently consumed product subscriptions (and entitlement certs)
List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
List<EntitlementCert> entitlementCerts = clienttasks.getCurrentEntitlementCerts();
// remove your entitlements
log.info("Removing the entitlement certs...");
clienttasks.removeAllCerts(false, true, false);
Assert.assertEquals(clienttasks.getCurrentEntitlementCerts().size(), 0, "Entitlements have been removed.");
Assert.assertEquals(clienttasks.getCurrentlyConsumedProductSubscriptions().size(), 0, "Consumed subscription pools do NOT exist after entitlements have been removed.");
// mark the rhsm.log file
String rhsmLogMarker = System.currentTimeMillis() + " Testing RefreshEntitlements_Test...";
RemoteFileTasks.markFile(client, clienttasks.rhsmLogFile, rhsmLogMarker);
// The following was implemented by to temporarily avoid an IT blocked candlepin end point as described by https://bugzilla.redhat.com/show_bug.cgi?id=1366301#c2
// python-rhsm-1.17.7-1 commits...
// python-rhsm RHEL7.3 commit 2debbb619cba05727f44f6823ea60a2aa6b3e269 1366301: Entitlement regeneration no longer propagates server errors
// python-rhsm RHEL7.3 commit cd43496585d5990500c4b272af9c4fa5e28661aa Update fix to include BadStatusLine responses from the server
// python-rhsm RHEL7.3 commit c021772a21c34d07542b8e9a01dcfadfc223624b Ensure both cert regen methods succeed despite BadStatusLine from server
// subscription-manager RHEL7.3 commit a07c9d7b890034a2e8e7e39fe32782b69def1736 1366301: Entitlement regeneration failure no longer aborts refresh
// 2016-08-30 08:23:19,642 [DEBUG] subscription-manager:20105:MainThread @connection.py:573 - Making request: PUT /subscription/consumers/b29e0643-44b4-4d75-9912-47cf127be7ca/certificates?lazy_regen=true
// 2016-08-30 08:23:20,070 [DEBUG] subscription-manager:20105:MainThread @connection.py:602 - Response: status=404
// 2016-08-30 08:23:20,071 [DEBUG] subscription-manager:20105:MainThread @connection.py:1365 - Unable to refresh entitlement certificates: Service currently unsupported.
// 2016-08-30 08:23:20,071 [DEBUG] subscription-manager:20105:MainThread @connection.py:1366 - Server error attempting a PUT to /subscription/consumers/b29e0643-44b4-4d75-9912-47cf127be7ca/certificates?lazy_regen=true returned status 404
// 2016-08-30 08:23:20,072 [DEBUG] subscription-manager:20105:MainThread @managercli.py:652 - Warning: Unable to refresh entitlement certificates; service likely unavailable
// subscription-manager RHEL7.3 commit a07c9d7b890034a2e8e7e39fe32782b69def1736 1366301: Entitlement regeneration failure no longer aborts refresh
String warningMsg = "Warning: Unable to refresh entitlement certificates; service likely unavailable";
// "Unable to refresh entitlement certificates: Service currently unsupported." // python-rhsm RHEL7.3 commit 2debbb619cba05727f44f6823ea60a2aa6b3e269 1366301: Entitlement regeneration no longer propagates server errors
// refresh
log.info("Refresh...");
clienttasks.refresh(null, null, null, null);
// was subscription-manager "Unable to refresh" as a result of a 404 trying to PUT?
String rhsmLogTail = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, rhsmLogMarker, "Unable to refresh");
boolean unableToRefresh = rhsmLogTail.contains(warningMsg);
// if yes, then refresh behavior prior to Bug 1360909 will be tested
if (unableToRefresh)
log.warning("Due to encountered warning '" + warningMsg + "', the original refresh behavior prior to Bug 1360909 will be asserted...");
// Assert the entitlement certs are restored after the refresh
log.info("After running refresh, assert that the entitlement certs are restored...");
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.17.10-1") && !unableToRefresh) {
// 1360909: Added functionality for regenerating entitlement certificates
// after the for Bug 1360909 - Clients unable to access newly released content (Satellite 6.2 GA)
// subscription-manager refresh will grant a new entitlement serial, but the contents are usually identical (unless a content set has been updated)
// assert nearly the same entitlement was restored (should only differ by serial number)
List<EntitlementCert> entitlementCertsAfterRefresh = clienttasks.getCurrentEntitlementCerts();
List<ProductSubscription> consumedProductSubscriptionsAfterRefresh = clienttasks.getCurrentlyConsumedProductSubscriptions();
Assert.assertEquals(entitlementCertsAfterRefresh.size(), entitlementCerts.size(), "The number of entitlement certs granted after refresh should match the number before refresh.");
Assert.assertEquals(consumedProductSubscriptionsAfterRefresh.size(), consumedProductSubscriptions.size(), "The number of consumed Product Subscriptions after refresh should match the number before refresh.");
// The following asserts assume that one one entitlement was granted from a single pool
Assert.assertEquals(entitlementCertsAfterRefresh.size(), 1, "The remaining assertions in this test assume that an entitlement from only one pool was subscribed. (If this test fails, then this test requires logic updates.)");
Assert.assertTrue(!entitlementCertsAfterRefresh.get(0).serialString.equals(entitlementCerts.get(0).serialString), "Serial '" + entitlementCertsAfterRefresh.get(0).serialString + "' in the refreshed entitlement should NOT match serial '" + entitlementCerts.get(0).serialString + "' from the original entitlement.");
Assert.assertEquals(entitlementCertsAfterRefresh.get(0).version, entitlementCerts.get(0).version, "Version in the refreshed entitlement should match the version from the original entitlement.");
Assert.assertEquals(entitlementCertsAfterRefresh.get(0).validityNotBefore, entitlementCerts.get(0).validityNotBefore, "ValidityNotBefore in the refreshed entitlement should match the ValidityNotBefore from the original entitlement.");
Assert.assertEquals(entitlementCertsAfterRefresh.get(0).validityNotAfter, entitlementCerts.get(0).validityNotAfter, "ValidityNotAfter in the refreshed entitlement should match the ValidityNotAfter from the original entitlement.");
Assert.assertEquals(entitlementCertsAfterRefresh.get(0).orderNamespace, entitlementCerts.get(0).orderNamespace, "Order information in the refreshed entitlement should match the order information from the original entitlement.");
Assert.assertEquals(entitlementCertsAfterRefresh.get(0).productNamespaces, entitlementCerts.get(0).productNamespaces, "Product information in the refreshed entitlement should match the product information from the original entitlement. (IF THIS FAILS, THEN THERE WAS AN UPSTREAM PROVIDED PRODUCT MODIFICATION LIKE THE SCENARIO IN BUG 1360909. HIGHLY UNLIKELY BETWEEN NOW AND THE START OF THIS TEST.)");
Assert.assertEquals(entitlementCertsAfterRefresh.get(0).contentNamespaces, entitlementCerts.get(0).contentNamespaces, "Content information in the refreshed entitlement should match the content information from the original entitlement. (IF THIS FAILS, THEN THERE WAS AN UPSTREAM CONTENT MODIFICATION LIKE THE SCENARIO IN BUG 1360909. HIGHLY UNLIKELY BETWEEN NOW AND THE START OF THIS TEST.)");
Assert.assertEquals(consumedProductSubscriptionsAfterRefresh.size(), 1, "The remaining assertions in this test assume that an only one pool was subscribed. (If this test fails, then this test requires logic updates.)");
Assert.assertTrue(!consumedProductSubscriptionsAfterRefresh.get(0).serialNumber.equals(consumedProductSubscriptions.get(0).serialNumber), "Serial Number '" + consumedProductSubscriptionsAfterRefresh.get(0).serialNumber + "' in the refreshed product subscription should NOT match serial number '" + consumedProductSubscriptions.get(0).serialNumber + "' from the original product subscription.");
Assert.assertEquals(consumedProductSubscriptionsAfterRefresh.get(0).poolId, consumedProductSubscriptions.get(0).poolId, "PoolId in the refreshed consumed product subscription should match the pool id from the original consumed product subscription.");
// TODO continue asserting equality between fields of the consumedProductSubscriptions (all should be equal except serialNumber which was already asserted above)
} else {
// assert the exact same entitlement was restored
Assert.assertEquals(clienttasks.getCurrentEntitlementCerts(), entitlementCerts, "Original entitlements have been restored.");
Assert.assertEquals(clienttasks.getCurrentlyConsumedProductSubscriptions(), consumedProductSubscriptions, "Original consumed product subscriptions have been restored.");
}
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class RegisterTests method testRegisterWithForce.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36522", "RHEL7-51294" }, 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 = "subscription-manager-cli: register with --force", groups = { "Tier2Tests", "blockedByBug-623264" }, enabled = true)
public void testRegisterWithForce() {
// start fresh by unregistering
clienttasks.unregister(null, null, null, null);
// make sure you are first registered
SSHCommandResult sshCommandResult = 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);
String firstConsumerId = clienttasks.getCurrentConsumerId();
// subscribe to a random pool (so as to consume an entitlement)
List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
if (pools.isEmpty())
throw new SkipException("Cannot randomly pick a pool for subscribing when there are no available pools for testing.");
// randomly pick a pool
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
clienttasks.subscribeToSubscriptionPool(pool);
// attempt to register again and assert that you are warned that the system is already registered
sshCommandResult = 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 (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
Assert.assertTrue(sshCommandResult.getStderr().startsWith("This system is already registered."), "Expecting stderr indication: This system is already registered.");
} else {
Assert.assertTrue(sshCommandResult.getStdout().startsWith("This system is already registered."), "Expecting stdout indication: This system is already registered.");
}
// register with force
sshCommandResult = clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null, null);
String secondConsumerId = clienttasks.getCurrentConsumerId();
// assert the stdout reflects a new consumer
String msg = "The system with UUID " + firstConsumerId + " has been unregistered";
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.19.11-1")) {
// commit 217c3863448478d06c5008694e327e048cc54f54 Bug 1443101: Provide unregistering feedback when force registering
Assert.assertTrue(sshCommandResult.getStdout().contains(msg), "Stdout contains '" + msg + "'");
} else {
Assert.assertTrue(sshCommandResult.getStdout().startsWith(msg), "Stdout starts with '" + msg + "'");
}
Assert.assertTrue(!secondConsumerId.equals(firstConsumerId), "After registering with force, a newly registered consumerid was returned.");
// assert that the new consumer is not consuming any entitlements
List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
Assert.assertEquals(productSubscriptions.size(), 0, "After registering with force, no product subscriptions should be consumed.");
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class RegisterTests method testReregisterBasicRegistration.
/**
* https://tcms.engineering.redhat.com/case/56327/?from_plan=2476
*/
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19953", "RHEL7-51002" }, 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 = "subscription-manager-cli: reregister basic registration\n" + "\t\tActions:\n" + "\n" + "\t \t\t* register a client to candlepin (take note of the uuid returned)\n" + "\t \t\t* take note of your identity cert info using openssl x509\n" + "\t \t\t* subscribe to a pool\n" + "\t \t\t* list consumed\n" + "\t \t\t* ls /etc/pki/entitlement/products\n" + "\t \t\t* Now.. mess up your identity.. mv /etc/pki/consumer/cert.pem /bak\n" + "\t \t\t* run the \"reregister\" command w/ username and passwd AND w/consumerid=<uuid>\n" + "\n" + "\t\tExpected Results:\n" + "\n" + "\t \t\t* after running reregister you should have a new identity cert\n" + "\t \t\t* after registering you should still the same products consumed (list consumed)\n" + "\t \t\t* the entitlement serials should be the same as before the registration", groups = { "Tier1Tests", "blockedByBug-636843", "blockedByBug-962520" }, enabled = true)
@ImplementsNitrateTest(caseId = 56327)
public void testReregisterBasicRegistration() {
// start fresh by unregistering and registering
clienttasks.unregister(null, null, null, null);
String consumerIdBefore = clienttasks.getCurrentConsumerId(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));
// take note of your identity cert before reregister
ConsumerCert consumerCertBefore = clienttasks.getCurrentConsumerCert();
// subscribe to a random pool
List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
if (pools.isEmpty())
throw new SkipException("Cannot randomly pick a pool for subscribing when there are no available pools for testing.");
// randomly pick a pool
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
clienttasks.subscribeToSubscriptionPool(pool);
// get a list of the consumed products
List<ProductSubscription> consumedProductSubscriptionsBefore = clienttasks.getCurrentlyConsumedProductSubscriptions();
// reregister
// clienttasks.reregister(null,null,null);
clienttasks.reregisterToExistingConsumer(sm_clientUsername, sm_clientPassword, consumerIdBefore);
// assert that the identity cert has not changed
ConsumerCert consumerCertAfter = clienttasks.getCurrentConsumerCert();
Assert.assertEquals(consumerCertBefore, consumerCertAfter, "The consumer identity cert has not changed after reregistering with consumerid.");
// assert that the user is still consuming the same products
List<ProductSubscription> consumedProductSubscriptionsAfter = clienttasks.getCurrentlyConsumedProductSubscriptions();
Assert.assertTrue(consumedProductSubscriptionsAfter.containsAll(consumedProductSubscriptionsBefore) && consumedProductSubscriptionsBefore.size() == consumedProductSubscriptionsAfter.size(), "The list of consumed products after reregistering is identical.");
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class RegisterTests method testReregisterWithConsumerIdShouldAutomaticallyRefreshEntitlements.
/**
* https://tcms.engineering.redhat.com/case/72845/?from_plan=2476
*
* @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-36530", "RHEL7-51303" }, 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 = "register with existing consumerid should automatically refresh entitlements\n" + "Actions:\n" + "\n" + " * register with username and password and remember the consumerid\n" + " * subscribe to one or more subscriptions\n" + " * list the consumed subscriptions and remember them\n" + " * clean system\n" + " * assert that there are no entitlements on the system\n" + " * register with same username, password and existing consumerid\n" + " * assert that originally consumed subscriptions are once again being consumed\n" + "\n" + "\t\n" + "Expected Results:\n" + "\n" + " * when registering a new system to an already existing consumer, all of the existing consumers entitlement certs should be downloaded to the new system", groups = { "Tier2Tests" }, enabled = true)
@ImplementsNitrateTest(caseId = 72845)
public void testReregisterWithConsumerIdShouldAutomaticallyRefreshEntitlements() throws JSONException, Exception {
// register with username and password and remember the consumerid
clienttasks.unregister(null, null, null, null);
String consumerId = clienttasks.getCurrentConsumerId(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));
// subscribe to one or more subscriptions
// // subscribe to a random pool
// List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
// SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size())); // randomly pick a pool
// clienttasks.subscribeToSubscriptionPoolUsingPoolId(pool);
clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
// list the consumed subscriptions and remember them
List<ProductSubscription> originalConsumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
// also remember the current entitlement certs
List<EntitlementCert> originalEntitlementCerts = clienttasks.getCurrentEntitlementCerts();
// clean system
clienttasks.clean();
// assert that there are no entitlements on the system
// Assert.assertTrue(clienttasks.getCurrentlyConsumedProductSubscriptions().isEmpty(),"There are NO consumed Product Subscriptions on this system after running clean");
Assert.assertTrue(clienttasks.getCurrentEntitlementCerts().isEmpty(), "There are NO Entitlement Certs on this system after running clean");
// register with same username, password and existing consumerid
// Note: no need to register with force as running clean wipes system of all local registration data
clienttasks.register(sm_clientUsername, sm_clientPassword, null, null, null, null, consumerId, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
// assert that originally consumed subscriptions are once again being consumed
List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
Assert.assertEquals(consumedProductSubscriptions.size(), originalConsumedProductSubscriptions.size(), "The number of consumed Product Subscriptions after registering to an existing consumerid matches his original count.");
for (ProductSubscription productSubscription : consumedProductSubscriptions) {
Assert.assertContains(originalConsumedProductSubscriptions, productSubscription);
}
// assert that original entitlement certs are once on the system
List<EntitlementCert> entitlementCerts = clienttasks.getCurrentEntitlementCerts();
Assert.assertEquals(entitlementCerts.size(), originalEntitlementCerts.size(), "The number of Entitlement Certs on the system after registering to an existing consumerid matches his original count.");
for (EntitlementCert entitlementCert : entitlementCerts) {
Assert.assertContains(originalEntitlementCerts, entitlementCert);
}
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testInstalledProductsProvidedByAvailablePoolsWithExemptServiceLevelAreAutoSubscribedRegardlessOfServiceLevel.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21703", "RHEL7-51027" }, 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 = "installed products provided by available pools with an exempt service level should be auto-subscribed regardless of what service level is specified (or is not specified)", groups = { "Tier1Tests", "blockedByBug-818319", "blockedByBug-859652", "blockedByBug-919700" }, dataProvider = "getExemptInstalledProductAndServiceLevelData", enabled = true)
@ImplementsNitrateTest(caseId = 157229)
public void testInstalledProductsProvidedByAvailablePoolsWithExemptServiceLevelAreAutoSubscribedRegardlessOfServiceLevel(Object bugzilla, String installedProductId, String serviceLevel) {
// randomize the case of the service level
String seRvICElevEl = randomizeCaseOfCharactersInString(serviceLevel);
log.info("This test will be conducted with a randomized serviceLevel value: " + seRvICElevEl);
// TEMPORARY WORKAROUND FOR BUG
if (sm_serverType.equals(CandlepinType.hosted)) {
String bugId = "818319";
boolean invokeWorkaroundWhileBugIsOpen = true;
try {
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) {
seRvICElevEl = serviceLevel;
log.warning("This test will NOT be conducted with a randomized serviceLevel value. Testing with serviceLevel: " + seRvICElevEl);
}
}
// END OF WORKAROUND
// register with autosubscribe and a randomize case serviceLevel
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, seRvICElevEl, null, (List<String>) null, null, null, null, true, false, null, null, null, null);
// assert that the installed ProductId is "Subscribed"
InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", installedProductId, clienttasks.getCurrentlyInstalledProducts());
Assert.assertEquals(installedProduct.status, "Subscribed", "After registering with autosubscribe and serviceLevel '" + seRvICElevEl + "' the following installed exempt product should be subscribed: " + installedProduct);
// EXTRA CREDIT: assert that the consumed ProductSubscription that provides the installed exempt product is among the known exempt service levels.
// WARNING: THIS MAY NOT BE AN APPROPRIATE ASSERTION WHEN THE EXEMPT PRODUCT HAPPENS TO ALSO BE PROVIDED BY A SUBSCRIPTION THAT COINCIDENTY PROVIDES ANOTHER INSTALLED PRODUCT
List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
for (EntitlementCert entitlementCert : clienttasks.getCurrentEntitlementCerts()) {
for (ProductNamespace productNamespace : entitlementCert.productNamespaces) {
if (productNamespace.id.equals(installedProductId)) {
BigInteger serialNumber = clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCert.file);
ProductSubscription productSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("serialNumber", serialNumber, productSubscriptions);
Assert.assertTrue(sm_exemptServiceLevelsInUpperCase.contains(productSubscription.serviceLevel.toUpperCase()), "Installed exempt product '" + installedProduct + "' is entitled by consumed productSubscription '" + productSubscription + "' that provides one of the exempt service levels '" + sm_exemptServiceLevelsInUpperCase + "'.");
}
}
}
}
Aggregations