use of rhsm.data.Repo in project rhsm-qe by RedHatQE.
the class ReposTests method testReposListEnabledReportsNoMatchesFoundWhenNoThereAreNoEnabledRepos.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20389", "RHEL7-51685" }, 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 = "Tier3")
@Test(description = "subscription-manager: repos --list-enabled should give feedback when there are no enabled repos", groups = { "Tier3Tests", "blockedByBug-1151925" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposListEnabledReportsNoMatchesFoundWhenNoThereAreNoEnabledRepos() throws JSONException, Exception {
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.13.4-1"))
throw new SkipException("The repos --list-enabled function was not implemented until version subscription-manager-1.13.4-1");
// register
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);
clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
List<YumRepo> subscribedYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
if (subscribedYumRepos.isEmpty())
throw new SkipException("There are no entitled yum repos available for this test.");
// use a wildcard to disable all the repos
clienttasks.repos(null, null, null, null, "*", null, null, null, null);
// get the list of currently disabled repos (list should be empty)
SSHCommandResult sshCommandResult = clienttasks.repos(null, true, false, (String) null, (String) null, null, null, null, null);
List<Repo> listDisabledRepos = Repo.parse(sshCommandResult.getStdout());
Assert.assertTrue(listDisabledRepos.isEmpty(), "After using a wildcard to disable all repos, the repos --list-enabled should be empty.");
// assert the feedback when no repos are disabled
String expectedStdout = "There were no available repositories matching the specified criteria.";
Assert.assertEquals(sshCommandResult.getStdout().trim(), expectedStdout, "After using a wildcard to disable all repos, the repos --list-enabled should report feedback indicating no matches.");
}
use of rhsm.data.Repo 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.Repo in project rhsm-qe by RedHatQE.
the class ReposTests method testReposEnable.
/**
* @author skallesh
* @throws JSONException
* @throws Exception
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20369", "RHEL7-51682" }, 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 = "Tier3")
@Test(description = "subscription-manager: enable a repo.", enabled = true, groups = { "Tier3Tests" })
public // @ImplementsNitrateTest(caseId=)
void testReposEnable() throws JSONException, Exception {
// register
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);
clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
List<Repo> subscribedRepos = clienttasks.getCurrentlySubscribedRepos();
// reduce the runtime of this test by randomly reducing the subscribedRepos tested
subscribedRepos = getRandomSubsetOfList(subscribedRepos, 5);
if (subscribedRepos.isEmpty())
throw new SkipException("There are no entitled repos available for this test.");
for (Repo repo : subscribedRepos) {
SSHCommandResult result = clienttasks.repos_(false, null, null, repo.repoId, null, null, null, null, null);
String expectedStdout = String.format("Repo %s is enabled for this system.", repo.repoId);
// subscription-manager commit b9e7f7abb949bc007f2db02662e2abba76528082
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.10.7-1"))
expectedStdout = String.format("Repo '%s' is enabled for this system.", repo.repoId);
// bug 1122530 commit add5a9b746f9f2af147a7e4622b897a46b5ef132
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.6-1"))
expectedStdout = String.format("Repository '%s' is enabled for this system.", repo.repoId);
Assert.assertEquals(result.getStdout().trim(), expectedStdout);
}
}
use of rhsm.data.Repo in project rhsm-qe by RedHatQE.
the class ReposTests method testReposEnableDisableReposInOrder.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20387", "RHEL7-51679" }, 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 = "Tier3")
@Test(description = "subscription-manager: attempt enable/disable/enable/disable repos in an order", groups = { "Tier3Tests", "blockedByBug-1115499" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposEnableDisableReposInOrder() throws JSONException, Exception {
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.12.8-1"))
throw new SkipException("Bugzilla 1115499 was not implemented in this version of subscription-manager.");
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);
clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
// List<Repo> subscribedRepos = clienttasks.getCurrentlySubscribedRepos();
List<Repo> subscribedRepos = getRandomSubsetOfList(clienttasks.getCurrentlySubscribedRepos(), 5);
String expectedStdoutMsgFormat = "Repo %s is %s for this system.";
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.10.7-1"))
expectedStdoutMsgFormat = "Repo '%s' is %sd for this system.";
// bug 1122530 commit add5a9b746f9f2af147a7e4622b897a46b5ef132
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.6-1"))
expectedStdoutMsgFormat = "Repository '%s' is %sd for this system.";
String command = clienttasks.reposCommand(null, null, null, null, null, null, null, null, null);
Map<String, String> repoEnablements = new HashMap<String, String>();
List<String> enablements = Arrays.asList("enable", "disable");
for (Repo subscribedRepo : subscribedRepos) {
for (int i = 0; i < 4; i++) {
// enable or disable
String enablement = (getRandomListItem(enablements));
command += String.format(" --%s=%s", enablement, subscribedRepo.repoId);
repoEnablements.put(subscribedRepo.repoId, enablement);
}
}
SSHCommandResult sshCommandResult = client.runCommandAndWait(command);
Assert.assertEquals(sshCommandResult.getExitCode(), new Integer(0), "ExitCode from an attempt to enable/disable multiple valid repos.");
for (Repo subscribedRepo : subscribedRepos) {
String expectedEnableStdoutMsg = String.format(expectedStdoutMsgFormat, subscribedRepo.repoId, repoEnablements.get(subscribedRepo.repoId));
Assert.assertTrue(sshCommandResult.getStdout().contains(expectedEnableStdoutMsg), "Stdout from an attempt to enable/disable repos in order contains expected message: " + expectedEnableStdoutMsg);
}
List<YumRepo> currentlySubscribedYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
for (Repo subscribedRepo : subscribedRepos) {
YumRepo yumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", subscribedRepo.repoId, currentlySubscribedYumRepos);
if (repoEnablements.get(subscribedRepo.repoId).equals("enable")) {
Assert.assertTrue(yumRepo.enabled, "Enablement of yum repo " + yumRepo.id);
} else {
Assert.assertFalse(yumRepo.enabled, "Enablement of yum repo " + yumRepo.id);
}
}
}
use of rhsm.data.Repo in project rhsm-qe by RedHatQE.
the class ReposTests method testReposListEnabledReportsOnlyEnabledContentNamespaces.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20385", "RHEL7-51686" }, 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 = "Tier3")
@Test(description = "subscription-manager: subscribe to a pool and verify that repos list --list-enabled reports only the enabled repos from the newly entitled content namespaces", groups = { "Tier3Tests", "blockedByBug-1119648" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposListEnabledReportsOnlyEnabledContentNamespaces() throws JSONException, Exception {
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.13.4-1"))
throw new SkipException("The repos --list-enabled function was not implemented until version subscription-manager-1.13.4-1");
// register
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);
clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
List<YumRepo> subscribedYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
if (subscribedYumRepos.isEmpty())
throw new SkipException("There are no entitled yum repos available for this test.");
List<YumRepo> enabledYumRepos = YumRepo.findAllInstancesWithMatchingFieldFromList("enabled", Boolean.TRUE, subscribedYumRepos);
// get the list of currently enabled repos
SSHCommandResult sshCommandResult = clienttasks.repos(null, true, null, (String) null, (String) null, null, null, null, null);
List<Repo> listEnabledRepos = Repo.parse(sshCommandResult.getStdout());
// verify that the enabledYumRepos are all present in the listEnabledRepos
for (YumRepo yumRepo : enabledYumRepos) {
Repo enabledRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", yumRepo.id, listEnabledRepos);
Assert.assertNotNull(enabledRepo, "Enabled yum repo [" + yumRepo.id + "] is included in the report of repos --list-enabled.");
}
Assert.assertEquals(listEnabledRepos.size(), enabledYumRepos.size(), "The number of --list-enabled repos matches the number of enabled yum repos in '" + clienttasks.redhatRepoFile + "'.");
}
Aggregations