use of rhsm.data.SubscriptionPool 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.SubscriptionPool in project rhsm-qe by RedHatQE.
the class RepoOverrideTests method attachRandomSubscriptionThatProvidesYumRepos.
// Candidates for an automated Test:
// Configuration methods ***********************************************************************
// Protected methods ***********************************************************************
/**
* @return a list of YumRepos that result after randomly attaching a subscription
*/
protected List<YumRepo> attachRandomSubscriptionThatProvidesYumRepos() {
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.");
// = new ArrayList<YumRepo>();
List<YumRepo> yumRepos;
do {
// not important clienttasks.unsubscribe_(true, (BigInteger)null, null, null, null);
// randomly pick a pool
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
// /*debugTesting*/ pool = SubscriptionPool.findFirstInstanceWithCaseInsensitiveMatchingFieldFromList("productId", "awesomeos-per-arch-cont", pools);
pools.remove(pool);
clienttasks.subscribeToSubscriptionPool(pool);
yumRepos = clienttasks.getCurrentlySubscribedYumRepos();
} while (yumRepos.isEmpty() && !pools.isEmpty());
if (yumRepos.isEmpty())
throw new SkipException("Could not find a pool that provided YumRepos after subscribing.");
return yumRepos;
}
use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.
the class ReposTests method testReposListReportsGrantedContentNamespacesAfterSubscribingToPool.
// 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-19972", "RHEL7-51011" }, 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: subscribe to a pool and verify that the newly entitled content namespaces are represented in the repos list", groups = { "Tier1Tests", "blockedByBug-807407", "blockedByBug-962520", "blockedByBug-1034649" }, // dataProvider="getAvailableSubscriptionPoolsData", // very thorough, but takes too long to execute and rarely finds more bugs
dataProvider = "getRandomSubsetOfAvailableSubscriptionPoolsData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposListReportsGrantedContentNamespacesAfterSubscribingToPool(SubscriptionPool pool) throws JSONException, Exception {
log.info("Following is a list of previously subscribed repos...");
List<Repo> priorRepos = clienttasks.getCurrentlySubscribedRepos();
// choose a quantity before subscribing to avoid Stdout: Quantity '1' is not a multiple of instance multiplier '2'
String quantity = null;
/*if (clienttasks.isPackageVersion("subscription-manager",">=","1.10.3-1"))*/
if (pool.suggested != null) {
// when the Suggested quantity is 0, let's specify a quantity to avoid Stdout: Quantity '1' is not a multiple of instance multiplier '2'
if (pool.suggested < 1)
quantity = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "instance_multiplier");
if (pool.suggested > 1 && quantity == null)
quantity = pool.suggested.toString();
}
// subscribe and get the granted entitlement
// File entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool); // for this test, we can skip the exhaustive asserts done by this call to clienttasks.subscribeToSubscriptionPool(pool)
File entitlementCertFile = clienttasks.subscribeToSubscriptionPool_(pool, quantity);
Assert.assertTrue(RemoteFileTasks.testExists(client, entitlementCertFile.getPath()), "Found the EntitlementCert file (" + entitlementCertFile + ") that was granted after subscribing to pool id '" + pool.poolId + "'.");
EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
// check the modifierSubscriptionData for SubscriptionPools that may already have been subscribed too and will modify this pool thereby enabling more repos than expected
for (List<Object> row : modifierSubscriptionData) {
// ll.add(Arrays.asList(new Object[]{modifierPool, label, modifiedProductIds, requiredTags, providingPools}));
SubscriptionPool modifierPool = (SubscriptionPool) row.get(0);
String label = (String) row.get(1);
List<String> modifiedProductIds = (List<String>) row.get(2);
String requiredTags = (String) row.get(3);
List<SubscriptionPool> poolsModified = (List<SubscriptionPool>) row.get(4);
if (poolsModified.contains(pool)) {
if (priorSubscribedPoolIds.contains(modifierPool.poolId)) {
// the modifier's content should now be available in the repos too
EntitlementCert modifierEntitlementCert = clienttasks.getEntitlementCertCorrespondingToSubscribedPool(modifierPool);
// simply add the contentNamespaces (if not already there) from the modifier to the entitlement cert's contentNamespaces so they will be accounted for in the repos list test below
for (ContentNamespace contentNamespace : modifierEntitlementCert.contentNamespaces) {
if (!contentNamespace.type.equalsIgnoreCase("yum"))
continue;
if (!entitlementCert.contentNamespaces.contains(contentNamespace)) {
log.warning("Due to a previously subscribed modifier subscription pool (" + modifierPool.subscriptionName + "), the new repos listed should also include ContentNamespace: " + contentNamespace);
entitlementCert.contentNamespaces.add(contentNamespace);
}
}
}
}
}
priorSubscribedPoolIds.add(pool.poolId);
log.info("Following is the new list of subscribed repos after subscribing to pool: " + pool);
List<Repo> actualRepos = clienttasks.getCurrentlySubscribedRepos();
// assert that the new contentNamespaces from the entitlementCert are listed in repos
int numNewRepos = 0;
for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
if (!contentNamespace.type.equalsIgnoreCase("yum"))
continue;
// instantiate the expected Repo that represents this contentNamespace
// the expected RepoUrl is set by joining the rhsm.conf baseurl with the downloadUrl in the contentNamespace which is usually a relative path. When it is already a full path, leave it!
String expectedRepoUrl;
if (contentNamespace.downloadUrl.contains("://")) {
expectedRepoUrl = contentNamespace.downloadUrl;
} else {
// join baseurl to downloadUrl with "/"
expectedRepoUrl = clienttasks.baseurl.replaceFirst("//+$", "//") + contentNamespace.downloadUrl.replaceFirst("^//+", "");
}
Repo expectedRepo = new Repo(contentNamespace.name, contentNamespace.label, expectedRepoUrl, contentNamespace.enabled);
// assert the subscription-manager repos --list reports the expectedRepo (unless it requires tags that are not found in the installed product certs)
if (clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
// TEMPORARY WORKAROUND FOR Bug 1246636 - an expected entitled content set is not reflected in subscription-manager repos --list
if (expectedRepo.repoName.equals("content") && !actualRepos.contains(expectedRepo)) {
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "1246636";
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) {
log.warning("The newly entitled contentNamespace '" + contentNamespace + "' is NOT represented in the subscription-manager repos --list by: " + expectedRepo);
continue;
}
}
// END OF WORKAROUND
Assert.assertTrue(actualRepos.contains(expectedRepo), "The newly entitled contentNamespace '" + contentNamespace + "' is represented in the subscription-manager repos --list by: " + expectedRepo);
// also count the number of NEW contentNamespaces
if (!priorRepos.contains(expectedRepo))
numNewRepos++;
} else {
Assert.assertFalse(actualRepos.contains(expectedRepo), "The newly entitled contentNamespace '" + contentNamespace + "' is NOT represented in the subscription-manager repos --list because it requires tags (" + contentNamespace.requiredTags + ") that are not provided by the currently installed product certs.");
}
}
// assert that the number of repos reported has increased by the number of contentNamespaces in the new entitlementCert (unless the
Assert.assertEquals(actualRepos.size(), priorRepos.size() + numNewRepos, "The number of entitled repos has increased by the number of NEW contentNamespaces (" + numNewRepos + ") from the newly granted entitlementCert (including applicable contentNamespaces from a previously subscribed modifier pool).");
// randomly decide to unsubscribe from the pool only for the purpose of saving on accumulated logging and avoid a java heap memory error
// if (randomGenerator.nextInt(2)==1) clienttasks.unsubscribe(null, entitlementCert.serialNumber, null, null, null); AND ALSO REMOVE pool FROM priorSubscribedPools
}
use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.
the class ReposTests method testYumTransactionsAreNoLongerRequiredToTriggerUpdatesToRedhatRepo.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19973", "RHEL7-51012" }, 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 = "Verify that the redhat.repo file is refreshed with changes to the entitlements (yum transactions are no longer required to update the redhat.repo)", // TODO: review all tests and tasks that issue yum transactions simply to re-populate the redhat.repo
groups = { "Tier1Tests", "blockedByBug-1008016", "blockedByBug-1090206", "blockedByBug-1034429" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumTransactionsAreNoLongerRequiredToTriggerUpdatesToRedhatRepo() {
// register
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
// shut off auto-healing
clienttasks.autoheal(null, null, true, null, null, null, null);
List<ProductCert> productCerts = clienttasks.getCurrentProductCerts();
// Subscribe to a randomly available pool...
log.info("Subscribe to a randomly available pool...");
List<SubscriptionPool> pools = clienttasks.getCurrentlyAllAvailableSubscriptionPools();
if (pools.size() <= 0)
throw new SkipException("No susbcriptions were available which blocks this test from executing.");
// randomly pick a pool
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
// testing the subscribe case...
clienttasks.subscribe_(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
log.info("Immediately after attaching a subscription, we will now assert that all of the content repos from the currently attached entitlements are currently present in the redhat.repo without having triggered a yum transaction...");
verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos(productCerts);
// testing the unsubscribe case...
clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
log.info("Immediately after removing a subscription, we will now assert that the redhat.repo is empty without having triggered a yum transaction...");
verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos(productCerts);
// testing the autosubscribe case...
clienttasks.subscribe_(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
log.info("Immediately after autoattaching subscription(s), we will now assert that all of the content repos from the currently attached entitlements are currently present in the redhat.repo without having triggered a yum transaction...");
verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos(productCerts);
// testing the unregister case...
clienttasks.unregister_(null, null, null, null);
log.info("Immediately after unregistering, we will now assert that the redhat.repo is empty without having triggered a yum transaction...");
verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos(productCerts);
}
use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.
the class RAMTests method testRamBasedSubscriptionInfoInEntitlementCert.
/**
* @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-36685", "RHEL7-51530" }, 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 Ram info in product and entitlement certificate", groups = { "Tier2Tests", "RamBasedSubscriptionInfoInEntitlementCert" }, enabled = true)
public void testRamBasedSubscriptionInfoInEntitlementCert() throws JSONException, Exception {
factsMap.clear();
factsMap.put("uname.machine", "x86_64");
factsMap.put("cpu.core(s)_per_socket", "1");
clienttasks.createFactsFileWithOverridingValues(factsMap);
clienttasks.register_(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, false, null, null, (String) null, null, null, null, true, null, null, null, null, null);
for (SubscriptionPool pool : getRamBasedSubscriptions()) {
clienttasks.subscribe_(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
}
List<EntitlementCert> ramEntitlements = clienttasks.getCurrentEntitlementCerts();
for (EntitlementCert ramEntitlement : ramEntitlements) {
Assert.assertTrue(!ramEntitlement.orderNamespace.ramLimit.isEmpty(), "A ram-based entitlement cert contains a non-empty Ram Limit (actual='" + ramEntitlement.orderNamespace.ramLimit + "').");
}
}
Aggregations