use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.
the class ReposTests method testYumConfigManagerTransactionsWillNowGenerateRedhatRepo.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47936", "RHEL7-99418" }, 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 subscription-manager yum plugin will be invoked by yum-config-manager thereby populating the redhat.repo file (eliminating the need to run a seemingly no-op yum repolist just to populate an empty/missing redhat.repo file.) Reference RFE Bugzilla 1329349", groups = { "Tier1Tests", "blockedByBug-1329349", "blockedByBug-1486326", "blockedByBug-1480659", "blockedByBug-1486338" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumConfigManagerTransactionsWillNowGenerateRedhatRepo() throws JSONException, Exception {
// register with auto-subscribe to get an entitlement to at least one yum repo
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, false, null, null, null, null);
List<YumRepo> subscribedYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
if (subscribedYumRepos.isEmpty())
throw new SkipException("There are no entitled yum repos available for this test.");
// get all the disabled yum repos for this test
List<YumRepo> disabledYumRepos = YumRepo.findAllInstancesWithMatchingFieldFromList("enabled", false, subscribedYumRepos);
if (disabledYumRepos.isEmpty())
throw new SkipException("Could not find any entitled yum repos that were disabled for this test.");
List<String> disabledRepos = new ArrayList<String>();
for (YumRepo disabledYumRepo : disabledYumRepos) disabledRepos.add(disabledYumRepo.id);
// manually delete or truncate the redhat.repo files
client.runCommandAndWait("rm -f " + clienttasks.redhatRepoFile);
client.runCommandAndWait("rm -f " + clienttasks.redhatRepoServerValueFile);
Assert.assertTrue(!RemoteFileTasks.testExists(client, clienttasks.redhatRepoFile));
// use yum-config-manager to enable the repos that were disabled by default
clienttasks.yumConfigManagerEnableRepos(disabledRepos, null);
// assert that the redhat.repo was regenerated by the new subscription-manager plugin to yum-config-manager (blocked by RFE Bug 1329349)
Assert.assertTrue(RemoteFileTasks.testExists(client, clienttasks.redhatRepoFile), "File '" + clienttasks.redhatRepoFile + "' has been automatically generated by a subscription-manager plugin to yum-config-manager.");
// assert that the yum repos within redhat.repo are now enabled
subscribedYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
for (String disabledRepo : disabledRepos) {
YumRepo yumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", disabledRepo, subscribedYumRepos);
Assert.assertTrue(yumRepo.enabled, "Entitled yum repo '" + disabledRepo + "' (which was disabled by default) appears in '" + clienttasks.redhatRepoFile + "' as enabled after using yum-config-manager to enable it.");
}
// run yum repolist enabled and assert that all the repos are enabled (blocked by Bug 1480659)
ArrayList<String> yumRepoListEnabledRepos = clienttasks.getYumRepolist("enabled");
for (String disabledRepo : disabledRepos) {
Assert.assertTrue(yumRepoListEnabledRepos.contains(disabledRepo), "Entitled yum repo '" + disabledRepo + "' which was disabled by default, appears in 'yum repolist enabled' as enabled after using yum-config-manager to enable it.");
}
}
use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.
the class ReposTests method testReposListPreservesSimultaneousEnablementOfRedhatRepos.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19971", "RHEL7-51010" }, 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: after subscribing to all pools, verify that edits (using subscription-manager --enable --disable options specified multiple times in a single call) to repos in redhat.repo are preserved.", groups = { "Tier1Tests", "blockedByBug-843915", "blockedByBug-962520", "blockedByBug-1034649", "blockedByBug-1121272", "blockedByBug-1366301" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposListPreservesSimultaneousEnablementOfRedhatRepos() {
// 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);
// subscribe to all available subscription so as to populate the redhat.repo file
clienttasks.subscribeToTheCurrentlyAllAvailableSubscriptionPoolsCollectively();
// get the current listing of repos
// determined by calling subscription-manager repos --list
List<Repo> originalRepos = clienttasks.getCurrentlySubscribedRepos();
// List<YumRepo> yumRepos = clienttasks.getCurrentlySubscribedYumRepos(); // determined by parsing /etc/yum.repos.d/redhat.repo
// verify the repos listed and yumRepos are in sync
// for (Repo repo : originalRepos) {
// Assert.assertNotNull(YumRepo.findFirstInstanceWithMatchingFieldFromList("id", repo.repoId, yumRepos),"Found yum repo id ["+repo.repoId+"] matching current repos --list item: "+repo);
// }
// assemble lists of the current repoIds to be collectively toggled
List<String> enableRepoIds = new ArrayList<String>();
List<String> disableRepoIds = new ArrayList<String>();
for (Repo repo : originalRepos) {
if (repo.enabled) {
disableRepoIds.add(repo.repoId);
} else {
enableRepoIds.add(repo.repoId);
}
}
// collectively toggle the enablement of the current repos
clienttasks.repos(null, null, null, enableRepoIds, disableRepoIds, null, null, null, null);
// verify that the change is preserved by subscription-manager repos --list
// determined by calling subscription-manager repos --list
List<Repo> toggledRepos = clienttasks.getCurrentlySubscribedRepos();
// List<YumRepo> toggledYumRepos = clienttasks.getCurrentlySubscribedYumRepos(); // determined by parsing /etc/yum.repos.d/redhat.repo
// assert enablement of all the original repos have been toggled
Assert.assertEquals(toggledRepos.size(), originalRepos.size(), "The count of repos listed should remain the same after collectively toggling their enablement.");
for (Repo originalRepo : originalRepos) {
Repo toggledRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", originalRepo.repoId, toggledRepos);
Assert.assertTrue(toggledRepo.enabled.equals(!originalRepo.enabled), "Repo [" + originalRepo.repoId + "] enablement has been toggled from '" + originalRepo.enabled + "' to '" + !originalRepo.enabled + "'.");
}
// now remove and refresh entitlement certificates and again assert the toggled enablement is preserved
log.info("Remove and refresh entitlement certs...");
clienttasks.removeAllCerts(false, true, false);
clienttasks.refresh(null, null, null, null);
// verify that the change is preserved by subscription-manager repos --list
// determined by calling subscription-manager repos --list
toggledRepos = clienttasks.getCurrentlySubscribedRepos();
// List<YumRepo> toggledYumRepos = clienttasks.getCurrentlySubscribedYumRepos(); // determined by parsing /etc/yum.repos.d/redhat.repo
// assert enablement of all the original repos have been toggled
Assert.assertEquals(toggledRepos.size(), originalRepos.size(), "Even after refreshing certificates, the count of repos listed should remain the same after collectively toggling their enablement.");
for (Repo originalRepo : originalRepos) {
Repo toggledRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", originalRepo.repoId, toggledRepos);
Assert.assertTrue(toggledRepo.enabled.equals(!originalRepo.enabled), "Even after refreshing certificates, repo [" + originalRepo.repoId + "] enablement has been toggled from '" + originalRepo.enabled + "' to '" + !originalRepo.enabled + "'.");
}
}
use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.
the class ReposTests method testReposListDisabledReportsOnlyDisabledContentNamespaces.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20368", "RHEL7-51684" }, 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-disabled reports only the disabled repos from the newly entitled content namespaces", groups = { "Tier3Tests", "blockedByBug-1119648" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposListDisabledReportsOnlyDisabledContentNamespaces() throws JSONException, Exception {
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.13.4-1"))
throw new SkipException("The repos --list-disabled 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> disabledYumRepos = YumRepo.findAllInstancesWithMatchingFieldFromList("enabled", Boolean.FALSE, subscribedYumRepos);
// get the list of currently disabled repos
SSHCommandResult sshCommandResult = clienttasks.repos(null, null, true, (String) null, (String) null, null, null, null, null);
List<Repo> listDisabledRepos = Repo.parse(sshCommandResult.getStdout());
// verify that the disabledYumRepos are all present in the listDisabledRepos
for (YumRepo yumRepo : disabledYumRepos) {
Repo disabledRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", yumRepo.id, listDisabledRepos);
Assert.assertNotNull(disabledRepo, "Disabled yum repo [" + yumRepo.id + "] is included in the report of repos --list-disabled.");
}
Assert.assertEquals(listDisabledRepos.size(), disabledYumRepos.size(), "The number of --list-disabled repos matches the number of disabled yum repos in '" + clienttasks.redhatRepoFile + "'.");
}
use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.
the class ReposTests method verifyTogglingTheEnablementOfRedhatRepo.
/**
* @param yumRepo
* @param manually - if true, then toggling the enabled flag in yumRepo is performed manually using sed, otherwise subscription-manager repos --enable or --disable option is used
*/
protected void verifyTogglingTheEnablementOfRedhatRepo(YumRepo yumRepo, boolean manually) {
Repo repo = new Repo(yumRepo.name, yumRepo.id, yumRepo.baseurl, yumRepo.enabled);
// assert that the yumRepo is reported in the subscription-manager repos
List<Repo> currentlySubscribedRepos = clienttasks.getCurrentlySubscribedRepos();
Assert.assertTrue(currentlySubscribedRepos.contains(repo), "The yumRepo '" + yumRepo + "' is represented in the subscription-manager repos --list by: " + repo);
// also verify that yumRepo is reported in the yum repolist
Assert.assertTrue(clienttasks.getYumRepolist(yumRepo.enabled ? "enabled" : "disabled").contains(yumRepo.id), "yum repolist properly reports the enablement of yumRepo id '" + yumRepo.id + "' before manually changing its enabled value.");
// edit the redhat.repo and change the enabled parameter for this yumRepo
// toggle the value
Boolean newEnabledValue = yumRepo.enabled ? false : true;
if (manually) {
// toggle the enabled flag manually
clienttasks.updateYumRepoParameter(clienttasks.redhatRepoFile, yumRepo.id, "enabled", newEnabledValue.toString());
} else if (newEnabledValue) {
// toggle the enabled flag using subscription-manager repos --enable
clienttasks.repos(null, null, null, yumRepo.id, null, null, null, null, null);
} else {
// toggle the enabled flag using subscription-manager repos --disable
clienttasks.repos(null, null, null, null, yumRepo.id, null, null, null, null);
}
Repo newRepo = new Repo(yumRepo.name, yumRepo.id, yumRepo.baseurl, newEnabledValue);
// verify that the change is preserved by subscription-manager repos --list
currentlySubscribedRepos = clienttasks.getCurrentlySubscribedRepos();
Assert.assertTrue(currentlySubscribedRepos.contains(newRepo), "yumRepo id '" + yumRepo.id + "' was manually changed to enabled=" + newEnabledValue + " and the subscription-manager repos --list reflects the change as: " + newRepo);
Assert.assertFalse(currentlySubscribedRepos.contains(repo), "The original repo (" + repo + ") is no longer found in subscription-manager repos --list.");
// also verify the change is reflected in yum repolist
Assert.assertTrue(clienttasks.getYumRepolist(newEnabledValue ? "enabled" : "disabled").contains(yumRepo.id), "yum repolist properly reports the enablement of yumRepo id '" + yumRepo.id + "' which was manually changed to '" + newEnabledValue + "'.");
Assert.assertFalse(clienttasks.getYumRepolist(!newEnabledValue ? "enabled" : "disabled").contains(yumRepo.id), "yum repolist properly reports the enablement of yumRepo id '" + yumRepo.id + "' which was manually changed to '" + newEnabledValue + "'.");
// now remove and refresh entitlement certificates and again assert the manual edits are preserved
log.info("Remove and refresh entitlement certs...");
clienttasks.removeAllCerts(false, true, false);
clienttasks.refresh(null, null, null, null);
// verify that the change is preserved by subscription-manager repos --list (even after deleting and refreshing entitlement certs)
currentlySubscribedRepos = clienttasks.getCurrentlySubscribedRepos();
Assert.assertTrue(currentlySubscribedRepos.contains(newRepo), "yumRepo id '" + yumRepo.id + "' was manually changed to enabled=" + newEnabledValue + " and even after deleting and refreshing certs, the subscription-manager repos --list reflects the change as: " + newRepo);
Assert.assertFalse(currentlySubscribedRepos.contains(repo), "The original repo (" + repo + ") is no longer found in subscription-manager repos --list.");
// also verify the change is reflected in yum repolist (even after deleting and refreshing entitlement certs)
Assert.assertTrue(clienttasks.getYumRepolist(newEnabledValue ? "enabled" : "disabled").contains(yumRepo.id), "even after deleting and refreshing certs, yum repolist properly reports the enablement of yumRepo id '" + yumRepo.id + "' which was manually changed to '" + newEnabledValue + "'.");
Assert.assertFalse(clienttasks.getYumRepolist(!newEnabledValue ? "enabled" : "disabled").contains(yumRepo.id), "even after deleting and refreshing certs, yum repolist properly reports the enablement of yumRepo id '" + yumRepo.id + "' which was manually changed to '" + newEnabledValue + "'.");
}
Aggregations