use of rhsm.data.Repo in project rhsm-qe by RedHatQE.
the class ReposTests method testReposEnableDisableAllReposUsingWildcard.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20395", "RHEL7-51677" }, 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 all repos (using wildcard *)", groups = { "Tier3Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposEnableDisableAllReposUsingWildcard() throws JSONException, Exception {
// [root@jsefler-6 ~]# subscription-manager repos --enable=* --disable=*
// Repo awesomeos is enabled for this system.
// Repo awesomeos-x86_64 is enabled for this system.
// Repo awesomeos-modifier is enabled for this system.
// Repo awesomeos-ppc is enabled for this system.
// Repo never-enabled-content is enabled for this system.
// Repo awesomeos-ppc64 is enabled for this system.
// Repo content-label is enabled for this system.
// Repo content-label-empty-gpg is enabled for this system.
// Repo awesomeos-s390x is enabled for this system.
// Repo content-label-no-gpg is enabled for this system.
// Repo awesomeos-ia64 is enabled for this system.
// Repo awesomeos-i686 is enabled for this system.
// Repo awesomeos-x86_64-i386-content is enabled for this system.
// Repo awesomeos-x86_64-only-content is enabled for this system.
// Repo awesomeos is disabled for this system.
// Repo awesomeos-x86_64 is disabled for this system.
// Repo awesomeos-modifier is disabled for this system.
// Repo awesomeos-ppc is disabled for this system.
// Repo never-enabled-content is disabled for this system.
// Repo awesomeos-ppc64 is disabled for this system.
// Repo content-label is disabled for this system.
// Repo content-label-empty-gpg is disabled for this system.
// Repo awesomeos-s390x is disabled for this system.
// Repo content-label-no-gpg is disabled for this system.
// Repo awesomeos-ia64 is disabled for this system.
// Repo awesomeos-i686 is disabled for this system.
// Repo awesomeos-x86_64-i386-content is disabled for this system.
// Repo awesomeos-x86_64-only-content is disabled for this system.
// [root@jsefler-6 ~]# echo $?
// 0
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();
String expectedStdoutMsgFormat = "Repo %s is %s for this system.";
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.10.7-1"))
expectedStdoutMsgFormat = "Repo '%s' is %s for this system.";
// bug 1122530 commit add5a9b746f9f2af147a7e4622b897a46b5ef132
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.6-1"))
expectedStdoutMsgFormat = "Repository '%s' is %s for this system.";
// test: subscription-manager repos --enablerepo=* --disablerepo=*
SSHCommandResult result = clienttasks.repos_(null, null, null, "*", "*", null, null, null, null);
Assert.assertEquals(result.getExitCode(), new Integer(0), "ExitCode from an attempt to enable/disable all repos (using wildcard *).");
// verify the feedback
for (Repo subscribedRepo : subscribedRepos) {
String expectedEnableStdoutMsg = String.format(expectedStdoutMsgFormat, subscribedRepo.repoId, "enabled");
String expectedDisableStdoutMsg = String.format(expectedStdoutMsgFormat, subscribedRepo.repoId, "disabled");
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.12.8-1")) {
Assert.assertTrue(!result.getStdout().contains(expectedEnableStdoutMsg), "Stdout from an attempt to enable/disable all repos (using wildcard *) does NOT contain message: " + expectedEnableStdoutMsg);
} else {
Assert.assertTrue(result.getStdout().contains(expectedEnableStdoutMsg), "Stdout from an attempt to enable/disable all repos (using wildcard *) contains expected message: " + expectedEnableStdoutMsg);
}
Assert.assertTrue(result.getStdout().contains(expectedDisableStdoutMsg), "Stdout from an attempt to enable/disable all repos (using wildcard *) contains expected message: " + expectedDisableStdoutMsg);
}
// verify the actual yum repolist disabled
List<String> yumRepoListDisabled = clienttasks.getYumRepolist("disabled");
for (Repo subscribedRepo : subscribedRepos) {
Assert.assertTrue(yumRepoListDisabled.contains(subscribedRepo.repoId), "After using wildcard * to disable all repos using subscription-manager, entitled repo '" + subscribedRepo.repoId + "' appears on the yum repolist disabled.");
}
// test: subscription-manager repos --enablerepo=*
result = clienttasks.repos_(null, null, null, "*", null, null, null, null, null);
Assert.assertEquals(result.getExitCode(), new Integer(0), "ExitCode from an attempt to enable all repos (using wildcard *).");
// verify the feedback
for (Repo subscribedRepo : subscribedRepos) {
String expectedEnableStdoutMsg = String.format(expectedStdoutMsgFormat, subscribedRepo.repoId, "enabled");
String expectedDisableStdoutMsg = String.format(expectedStdoutMsgFormat, subscribedRepo.repoId, "disabled");
Assert.assertTrue(result.getStdout().contains(expectedEnableStdoutMsg), "Stdout from an attempt to enable all repos (using wildcard *) contains expected message: " + expectedEnableStdoutMsg);
Assert.assertTrue(!result.getStdout().contains(expectedDisableStdoutMsg), "Stdout from an attempt to enable all repos (using wildcard *) does NOT contain message: " + expectedDisableStdoutMsg);
}
// verify the actual yum repolist enabled
List<String> yumRepoListEnabled = clienttasks.getYumRepolist("enabled");
for (Repo subscribedRepo : subscribedRepos) {
Assert.assertTrue(yumRepoListDisabled.contains(subscribedRepo.repoId), "After using wildcard * to enable all repos using subscription-manager, entitled repo '" + subscribedRepo.repoId + "' appears on the yum repolist enabled.");
}
}
use of rhsm.data.Repo 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.Repo 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.Repo in project rhsm-qe by RedHatQE.
the class ReposTests method testYumTransactionsDoNotCauseUnnessarilyRewritesOfRedHatRepoFile.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20381", "RHEL7-51697" }, 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 = "Verify that redhat.repo file is unnecessarily re-written with every yum transaction", groups = { "Tier3Tests", "blockedByBug-1035440", /*,"blockedByBug-1090206","blockedByBug-1008016"*/
"blockedByBug-1104731", "blockedByBug-1104777" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumTransactionsDoNotCauseUnnessarilyRewritesOfRedHatRepoFile() {
clienttasks.register_(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, null, null, null, null, null);
clienttasks.autoheal_(null, null, true, null, null, null, null);
List<Repo> repos = clienttasks.getCurrentlySubscribedRepos();
// if (repos.isEmpty()) clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
if (repos.isEmpty())
Assert.fail("Expected subscription-manager registration with autosubscribe to grant access to at least one repository. If failed, check installed product certs and available subscriptions.");
List<String> defaultEnabledRepos = new ArrayList<String>();
List<String> defaultDisabledRepos = new ArrayList<String>();
for (Repo repo : repos) if (repo.enabled)
defaultEnabledRepos.add(repo.repoId);
else
defaultDisabledRepos.add(repo.repoId);
// get the initial modification time for the redhat.repo file
String initialModTime = client.runCommandAndWait("stat -c %y " + clienttasks.redhatRepoFile).getStdout().trim();
// trigger the subscription-manager yum plugin and assert the modification time remains unchanged
clienttasks.yumClean("all");
Assert.assertEquals(client.runCommandAndWait("stat -c %y " + clienttasks.redhatRepoFile).getStdout().trim(), initialModTime, "The modification time of '" + clienttasks.redhatRepoFile + "' before and after a yum transaction.");
clienttasks.getYumRepolist("all -q");
Assert.assertEquals(client.runCommandAndWait("stat -c %y " + clienttasks.redhatRepoFile).getStdout().trim(), initialModTime, "The modification time of '" + clienttasks.redhatRepoFile + "' before and after a yum transaction.");
// toggle the enablement of repos which should force an immediate modification to redhat.repo
clienttasks.repos(null, null, null, defaultDisabledRepos, defaultEnabledRepos, null, null, null, null);
String finalModTime = client.runCommandAndWait("stat -c %y " + clienttasks.redhatRepoFile).getStdout().trim();
Assert.assertTrue(!finalModTime.equals(initialModTime), "The modification time of '" + clienttasks.redhatRepoFile + "' before and after repos enablement should be different.");
// finally let's trigger the subscription-manager yum plugin and assert the modification time remains unchanged
clienttasks.getYumRepolist("all -q");
Assert.assertEquals(client.runCommandAndWait("stat -c %y " + clienttasks.redhatRepoFile).getStdout().trim(), finalModTime, "The modification time of '" + clienttasks.redhatRepoFile + "' before and after a yum transaction.");
clienttasks.yumClean("all");
Assert.assertEquals(client.runCommandAndWait("stat -c %y " + clienttasks.redhatRepoFile).getStdout().trim(), finalModTime, "The modification time of '" + clienttasks.redhatRepoFile + "' before and after a yum transaction.");
}
use of rhsm.data.Repo 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