use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class ListTests method testInstalledProductsListed.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-37700", "RHEL7-51326" }, 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: list installed products", groups = { "Tier2Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testInstalledProductsListed() {
clienttasks.unregister(null, null, null, null);
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);
List<ProductCert> productCerts = clienttasks.getCurrentProductCerts();
Set<String> productCertIds = clienttasks.getCurrentProductIds();
String installedProductsAsString = clienttasks.listInstalledProducts().getStdout();
// List <InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
List<InstalledProduct> installedProducts = InstalledProduct.parse(installedProductsAsString);
// assert some stdout
if (installedProducts.size() > 0) {
String bannerTitle = "Installed Product Status";
Assert.assertTrue(installedProductsAsString.contains(bannerTitle), "The list of installed products is entitled '" + bannerTitle + "'.");
}
// assert the number of installed product matches the unique product certs Ids installed
Assert.assertEquals(installedProducts.size(), productCertIds.size(), "A single product is reported as installed for each unique product cert ID found in " + clienttasks.productCertDir + " and " + clienttasks.productCertDefaultDir);
// assert that each of the installed ProductCerts are listed as InstalledProducts with status "Not Subscribed"
for (ProductCert productCert : productCerts) {
InstalledProduct installedProduct = clienttasks.getInstalledProductCorrespondingToProductCert(productCert, installedProducts);
Assert.assertNotNull(installedProduct, "The following installed product cert is included by subscription-manager in the list --installed: " + (installedProduct == null ? "null" : installedProduct));
Assert.assertEquals(installedProduct.status, "Not Subscribed", "The status of installed product when newly registered: " + installedProduct);
}
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class ListTests method testListAvailableWithNoOverlap.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36565", "RHEL7-51349" }, 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: subcription manager list all with --match-installed option", groups = { "Tier2Tests", "blockedByBug-654501", "blockedByBug-1022622", /*rhel7*/
"blockedByBug-1114717", /*rhel6*/
"blockedByBug-1493711" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListAvailableWithNoOverlap() throws JSONException, Exception {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, false, null, null, null, null, null);
clienttasks.autoheal(null, null, true, null, null, null, null);
// assemble a list of currently installed product ids
List<ProductCert> installedProductCerts = clienttasks.getCurrentProductCerts();
List<String> installedProductIds = new ArrayList<String>();
for (ProductCert productCert : installedProductCerts) installedProductIds.add(productCert.productId);
// get the available subscription pools
List<SubscriptionPool> availableSubscriptionPools = SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, null, false, null, null, null, null, null, null).getStdout());
// randomly attach a positive subset of available subscriptions
List<SubscriptionPool> randomAvailableSubscriptionPools = getRandomSubsetOfList(availableSubscriptionPools, randomGenerator.nextInt(availableSubscriptionPools.size() - 1) + 1);
List<String> poolIds = new ArrayList<String>();
for (SubscriptionPool subscriptionPool : randomAvailableSubscriptionPools) poolIds.add(subscriptionPool.poolId);
if (false) {
// debugTesting will cause test to fail due to bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=1022622#c0
poolIds.clear();
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Server Basic", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS for All Arch (excpt for x86_64 content)", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS with unlimited virtual guests", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Multi-Attribute Stackable (2 GB, 2 Cores)", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Server Basic (data center)", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Multi-Attribute Stackable (2 sockets)", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS for systems with no sockets", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Server Basic (multi-entitlement)", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Modifier", availableSubscriptionPools).poolId);
}
clienttasks.subscribe(null, null, poolIds, null, null, "1", null, null, null, null, null, null, null);
List<InstalledProduct> installedProducts = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, null, null, null, null, null, null).getStdout());
List<SubscriptionPool> availableSubscriptionPoolsWithoutOverlap = SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, null, true, null, null, null, null, null, null).getStdout());
// loop through the list of available subscription pools without overlap and assert that at least one of pool's provided products is not fully subscribed.
for (SubscriptionPool subscriptionPool : availableSubscriptionPoolsWithoutOverlap) {
boolean noOverlapFound = false;
List<String> providedProductIds = CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, subscriptionPool.poolId);
if (providedProductIds.isEmpty()) {
Assert.assertTrue(providedProductIds.isEmpty(), "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides no products and therefore does not overlap an already covered product.");
noOverlapFound = true;
}
for (String providedProductId : providedProductIds) {
InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProducts);
if (installedProduct != null) {
if (!installedProduct.status.equalsIgnoreCase("Subscribed")) {
Assert.assertTrue(!installedProduct.status.equalsIgnoreCase("Subscribed"), "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides product id '" + providedProductId + "' which is installed with status '" + installedProduct.status + "' and therefore does not overlap an already covered product.");
noOverlapFound = true;
} else {
log.warning("Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides product id '" + providedProductId + "' which is installed with status '" + installedProduct.status + "'.");
}
} else {
Assert.assertTrue(installedProduct == null, "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides product id '" + providedProductId + "' which is not installed and therefore does not overlap an already covered product.");
noOverlapFound = true;
}
}
Assert.assertTrue(noOverlapFound, "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " that is reported in the list available with no-overlap provides at least one product that is not fully Subscribed.");
}
// the remainder of this --no-overlap test has been fixed in subscription-manager-1.12.6-1 and newer; otherwise skip it.
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.12.6-1"))
throw new SkipException("The installed version of subscription-manager does not contain the fix for https://bugzilla.redhat.com/show_bug.cgi?id=1022622#c3");
// assert that availableSubscriptionPools that are not filtered out of the availableSubscriptionPoolsWithoutOverlap provide products that are all fully Subscribed
availableSubscriptionPools = SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, null, false, null, null, null, null, null, null).getStdout());
for (SubscriptionPool availableSubscriptionPool : availableSubscriptionPools) {
if (!availableSubscriptionPoolsWithoutOverlap.contains(availableSubscriptionPool)) {
for (String providedProductId : CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, availableSubscriptionPool.poolId)) {
InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProducts);
if (installedProduct != null) {
Assert.assertEquals(installedProduct.status, "Subscribed", "Subscription '" + availableSubscriptionPool.subscriptionName + "' provides=" + availableSubscriptionPool.provides + " is excluded from the list available with no-overlap. It provides product id '" + providedProductId + "' which is installed and covered by an active subscription.");
} else {
// skip the providedProductId when not installed
}
}
}
}
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class ListTests method testListAllAvailableWithMatchInstalled.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36553", "RHEL7-51330" }, 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: subcription manager list all with --match-installed option", groups = { "Tier2Tests", "blockedByBug-654501", "blockedByBug-1493711" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListAllAvailableWithMatchInstalled() throws JSONException, Exception {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, false, null, null, null, null, null);
clienttasks.autoheal(null, null, true, null, null, null, null);
// assemble a list of currently installed product ids
List<ProductCert> installedProductCerts = clienttasks.getCurrentProductCerts();
List<String> installedProductIds = new ArrayList<String>();
for (ProductCert productCert : installedProductCerts) installedProductIds.add(productCert.productId);
// get all the available subscription pools
List<SubscriptionPool> allAvailableSubscriptionPools = SubscriptionPool.parse(clienttasks.list(true, true, null, null, null, null, false, null, null, null, null, null, null, null).getStdout());
List<SubscriptionPool> allAvailableSubscriptionPoolsMatchingInstalled = SubscriptionPool.parse(clienttasks.list(true, true, null, null, null, null, true, null, null, null, null, null, null, null).getStdout());
// loop through the list of all available subscription pools with match-installed and assert they really do provide at least one product that is installed.
for (SubscriptionPool subscriptionPool : allAvailableSubscriptionPoolsMatchingInstalled) {
ProductCert matchedInstalledProductCert = null;
for (String providedProductId : CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, subscriptionPool.poolId)) {
matchedInstalledProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProductCerts);
if (matchedInstalledProductCert != null)
break;
}
if (matchedInstalledProductCert != null)
Assert.assertTrue(matchedInstalledProductCert != null, "Available subscription pool '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " includes product id '" + matchedInstalledProductCert.productId + "' which was found among the product ids of the currently installed product certs. " + installedProductIds);
else
Assert.fail("Subscription-manager list all available with match-installed option erroneously reported SubscriptionPool '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " which does NOT provide a product whose id was found among the currently installed product certs. " + installedProductIds);
}
// loop through the list of all available subscription without match-installed and make sure those that provide an installed product id are included in the filtered list
for (SubscriptionPool subscriptionPool : allAvailableSubscriptionPools) {
boolean providesAnInstalledProductId = false;
for (String providedProductId : CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, subscriptionPool.poolId)) {
if (installedProductIds.contains(providedProductId))
providesAnInstalledProductId = true;
}
if (providesAnInstalledProductId)
Assert.assertTrue(allAvailableSubscriptionPoolsMatchingInstalled.contains(subscriptionPool), "The list of all available subscriptions with match-installed option includes '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides);
else
Assert.assertTrue(!allAvailableSubscriptionPoolsMatchingInstalled.contains(subscriptionPool), "The list of all available subscriptions with match-installed option does NOT include '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides);
}
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class ReleaseTests method testReleaseListMatchesCDN.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20009", "RHEL7-55174" }, 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 = "register to a RHEL subscription and verify that release --list matches the expected CDN listing for this x-stream release of RHEL", groups = { "Tier1Tests", "blockedByBug-818298", "blockedByBug-820639", "blockedByBug-844368", "blockedByBug-893746", "blockedByBug-904193", "blockedByBug-1506271" }, dataProvider = "getCredentialsToVerifyReleaseListMatchesCDN_Test", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReleaseListMatchesCDN(Object bugzilla, String username, String password, String org) throws JSONException, Exception {
// make sure we are newly registered
clienttasks.register(username, password, org, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, null, null, null, null, null);
// get the current base RHEL product cert
ProductCert rhelProductCert = clienttasks.getCurrentRhelProductCert();
// find an available RHEL subscription pool that provides for this base RHEL product cert
// List<SubscriptionPool> rhelSubscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools(rhelProductCert.productId, sm_serverUrl); // no longer works; encounters "Insufficient permissions"
List<SubscriptionPool> rhelSubscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools(rhelProductCert.productId, /*sm_serverAdminUsername*/
username, /*sm_serverAdminPassword*/
password, sm_serverUrl);
if (rhelSubscriptionPools.isEmpty())
throw new SkipException("Cannot find an available SubscriptionPool that provides for this installed RHEL Product: " + rhelProductCert);
// choose one
SubscriptionPool rhelSubscriptionPool = rhelSubscriptionPools.get(0);
// subscribe to the RHEL subscription
clienttasks.subscribeToSubscriptionPool(rhelSubscriptionPool);
// get the currently expected release listing based on the currently enabled repos
List<String> expectedReleases = clienttasks.getCurrentlyExpectedReleases();
// get the actual release listing
List<String> actualReleases = clienttasks.getCurrentlyAvailableReleases(null, null, null, null);
// TEMPORARY WORKAROUND FOR BUG
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "1108257";
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) {
if (rhelProductCert.productNamespace.providedTags.contains("rhel-5-client-workstation")) {
throw new SkipException("Skipping this test while bug '" + bugId + "' is open. (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
}
}
// TEMPORARY WORKAROUND FOR BUG
if (actualReleases.isEmpty() && !expectedReleases.isEmpty()) {
invokeWorkaroundWhileBugIsOpen = true;
// Bug 1518886 - RHEL-ALT-7.5 product certs should also provide tag "rhel-7"
bugId = "1518886";
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) {
if (Arrays.asList(new String[] { // this is a RHEL-ALT system
"419", /* Red Hat Enterprise Linux for ARM 64 */
"420", /* Red Hat Enterprise Linux for Power 9 */
"434", /* Red Hat Enterprise Linux for IBM System z (Structure A) */
"363", /* Red Hat Enterprise Linux for ARM 64 Beta */
"362", /* Red Hat Enterprise Linux for Power 9 Beta */
"433" /* Red Hat Enterprise Linux for IBM System z (Structure A) Beta */
}).contains(rhelProductCert.productId)) {
throw new SkipException("subscription-manager release listings on RHEL-ALT will be empty until bug '" + bugId + "' is fixed.");
}
}
}
// END OF WORKAROUND
// assert that they are equivalent
Assert.assertTrue(expectedReleases.containsAll(actualReleases) && actualReleases.containsAll(expectedReleases), "The actual subscription-manager releases list " + actualReleases + " matches the expected consolidated CDN listing " + expectedReleases + " after being granted an entitlement from subscription product: " + rhelSubscriptionPool.productId);
Assert.assertTrue(expectedReleases.size() == actualReleases.size(), "The actual subscription-manager releases list " + actualReleases + " does not contain any duplicates. It should be a unique list.");
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class ReleaseTests method testRateLimitExceededExceptionShouldNotAlterRedhatRepo.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47938", "RHEL7-99713" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "subscription-manager: after using the release module to pin the content set repos paths, use yum repolist to bombard the IT-Candlepin server with GET requests to /subscription/consumers/{uuid}/release so as to generate a RateLimitExceededException", groups = { "Tier1Tests", "blockedByBug-1481384", "blockedByBug-1486549" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRateLimitExceededExceptionShouldNotAlterRedhatRepo() throws JSONException, Exception {
// register a new consumer and auto-subscribe to cover the installed RHEL product
clienttasks.unregister(null, null, null, null);
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, null, false, null, null, null, null);
ProductCert rhelProductCert = clienttasks.getCurrentRhelProductCert();
if (rhelProductCert == null)
throw new SkipException("This test requires an entitlement to an installed RHEL product");
InstalledProduct installedRhelProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductCert.productId, clienttasks.getCurrentlyInstalledProducts());
if (installedRhelProduct == null)
Assert.fail("Could not find the installed product corresponding to the current RHEL product cert: " + rhelProductCert);
if (!installedRhelProduct.status.equals("Subscribed"))
throw new SkipException("This test requires attachment to a RHEL subscription for the installed RHEL product.");
// assert that there are some occurrences of $releasever in redhat.repo (for non Beta)
String sshCommandGreppingRedhatRepoForNumberReleaseverOccurrences = "grep '$releasever' " + clienttasks.redhatRepoFile + " | wc --lines";
Integer numberReleaseverOccurrences = Integer.valueOf(client.runCommandAndWait(sshCommandGreppingRedhatRepoForNumberReleaseverOccurrences).getStdout().trim());
if (false) {
// NOT A VALID ASSERTION BECAUSE RCM HAS CHOSEN TO USE THE SAME TAGS ON BETA ENG IDS 362,363,433 AS THEIR GA COUNTERPARTS 420,419,434 WHICH MEANS THAT IF A SUBSCRIPTION THAT PROVIDES BOTH BETA AND GA ARE ATTACHED TO A SYSTEM WITH ONLY THE BETA PRODUCT CERT INSTALLED THEN ACCESS TO GA CONTENT WITH $releasever IS GRANTED.
if (Arrays.asList("362", "363", "433").contains(installedRhelProduct.productId)) {
Assert.assertEquals(numberReleaseverOccurrences, Integer.valueOf(0), "Because the currently installed RHEL engineering product '" + installedRhelProduct.productId + "' should only provide content access to beta|htb repositories, none of the current entitled repo urls should contain reference to $releasever.");
throw new SkipException("This test requires a RHEL entitlement to an engineering product with content sets that can be pinned to a $releasever.");
}
}
if (numberReleaseverOccurrences == 0)
throw new SkipException("This test requires a RHEL entitlement providing an engineering product with content sets that can be pinned to a $releasever.");
// NOT A VALID ASSERTION Assert.assertTrue(numberReleaseverOccurrences>0, "The number of occurrences ("+numberReleaseverOccurrences+") for '$releasever' in '"+clienttasks.redhatRepoFile+"' is greater than zero.");
// are any releases available?
List<String> availableReleases = clienttasks.getCurrentlyAvailableReleases(null, null, null, null);
if (availableReleases.isEmpty())
throw new SkipException("When no releases are available, this test must be skipped.");
// set a release
// assume the first release is good enough for this test
String release = availableReleases.get(0);
if (availableReleases.contains("7.3"))
release = "7.3";
clienttasks.release(null, null, release, null, null, null, null, null);
// assert that no occurrences of $releasever are in redhat.repo
Assert.assertEquals(client.runCommandAndWait(sshCommandGreppingRedhatRepoForNumberReleaseverOccurrences).getStdout().trim(), "0", "Number of occurances for \"$releasever\" in '" + clienttasks.redhatRepoFile + "' after setting the release to '" + release + "'.");
// remember the number of available packages
Integer numPackagesAvailableBeforeExceedingRateLimit = clienttasks.getYumListAvailable("--disablerepo=beaker*").size();
// now bombard the server with more than 60 hits to encounter a RateLimitExceededException
client.runCommandAndWait("for i in {1..60}; do yum repolist --disablerepo=beaker* --quiet; done;");
String rhsmLogMarker = System.currentTimeMillis() + " testRateLimitExceededExceptionShouldNotAlterRedhatRepo...";
RemoteFileTasks.markFile(client, clienttasks.rhsmLogFile, rhsmLogMarker);
Integer numPackagesAvailableAfterExceedingRateLimit = clienttasks.getYumListAvailable("--disablerepo=beaker*").size();
// assert that there are still no occurrences of $releasever in redhat.repo
Assert.assertEquals(client.runCommandAndWait(sshCommandGreppingRedhatRepoForNumberReleaseverOccurrences).getStdout().trim(), "0", "Number of occurances for \"$releasever\" in '" + clienttasks.redhatRepoFile + "' after setting the release to '" + release + "' and then bombarding the server via the subscription-manager yum plugin via system invocations of yum repolist.");
// assert that there is an ERROR in the rhsm.log for the RateLimitExceededException
String rhsmLogStatement = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, rhsmLogMarker, "ERROR").trim();
// 2017-09-01 16:16:47,199 [ERROR] yum:16448:MainThread @cache.py:235 - Access rate limit exceeded
if (!rhsmLogStatement.isEmpty())
log.warning(rhsmLogStatement);
// https://github.com/candlepin/subscription-manager/pull/1694 // commit abca9b07c0cbc852d015dc9316927f8e39d1ba0d 1481384: Do not update redhat.repo at RateLimitExceededException
String expectedErrorMsg = "Access rate limit exceeded";
Assert.assertTrue(rhsmLogStatement.contains(expectedErrorMsg), "After bombarding the server to purposefully invoke a RateLimitExceededException, the '" + clienttasks.rhsmLogFile + "' reports expected ERROR '" + expectedErrorMsg + "'.");
// assert that the number of available packages remains the same
Assert.assertEquals(numPackagesAvailableAfterExceedingRateLimit, numPackagesAvailableBeforeExceedingRateLimit, "The number of yum available packages after exceeding the rate limit (" + numPackagesAvailableAfterExceedingRateLimit + ") matches the number before exceeding the rate limit (" + numPackagesAvailableBeforeExceedingRateLimit + ").");
}
Aggregations