use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.
the class RepoOverrideTests method testOverrideBaseurl.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19979", "RHEL7-51705" }, 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 = "attempt to override a baseurl using subscription-manager repos-override", groups = { "Tier1Tests", "blockedByBug-1030604" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testOverrideBaseurl() {
// 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 a random pool (so as to consume an entitlement) and remember the original list of YumRepos read from the redhat.repo file
List<YumRepo> yumRepos = attachRandomSubscriptionThatProvidesYumRepos();
// attempt to override the baseurl
// randomly pick a YumRepo
YumRepo yumRepo = yumRepos.get(randomGenerator.nextInt(yumRepos.size()));
Map<String, String> repoOverrideNameValueMap = new HashMap<String, String>();
repoOverrideNameValueMap.put("baseurl", "https://cdn.redhat.com/repo-override-testing/$releasever/$basearch");
repoOverrideNameValueMap.put("test", "value");
SSHCommandResult result = clienttasks.repo_override_(null, null, Arrays.asList(yumRepo.id, "foo-bar"), null, repoOverrideNameValueMap, null, null, null, null);
// new standalone candlepin behavior allows baseurl overrides
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.10-1") && servertasks.statusStandalone) {
// candlepin commit bbba2dfc1ba44a16fef3d483caf4e7d4eaf63c10
log.info("Starting in candlepin version 2.0.10-1, the restriction on overriding the baseurl has been lifted against a standalone candlepin server for the benefit of mirror lists in Satellite. See https://trello.com/c/6IKbKppZ/7-work-with-satellite-team-to-design-out-mirror-lists-for-subscription-manager");
Assert.assertEquals(result.getExitCode(), Integer.valueOf(0), "ExitCode (against a standalone candlepin version >= 2.0.10-1) from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
Assert.assertEquals(result.getStdout().trim(), "Repository 'foo-bar' does not currently exist, but the override has been added.", "Stdout (against a standalone candlepin version >= 2.0.10-1) from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
Assert.assertEquals(result.getStderr().trim(), "", "Stderr (against a standalone candlepin version >= 2.0.10-1) from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
} else {
// original candlepin behavior denies baseurl overrides
Assert.assertEquals(result.getExitCode(), Integer.valueOf(1), "ExitCode from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
Assert.assertEquals(result.getStdout().trim(), "", "Stdout from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
Assert.assertEquals(result.getStderr().trim(), "Not allowed to override values for: baseurl", "Stderr from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
} else {
Assert.assertEquals(result.getStderr().trim(), "", "Stderr from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
Assert.assertEquals(result.getStdout().trim(), "Not allowed to override values for: baseurl", "Stdout from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
}
}
}
use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.
the class RepoOverrideTests method testOverrideBaseurlInMixedCases.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19978", "RHEL7-51704" }, 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 = "attempt to override a bASeUrL (note the case) using subscription-manager repos-override", groups = { "Tier1Tests", "blockedByBug-1030604", "blockedByBug-1034375" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testOverrideBaseurlInMixedCases() {
// 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 a random pool (so as to consume an entitlement) and remember the original list of YumRepos read from the redhat.repo file
List<YumRepo> yumRepos = attachRandomSubscriptionThatProvidesYumRepos();
// attempt to override the baseUrl (note the uppercase character)
// randomly pick a YumRepo
YumRepo yumRepo = yumRepos.get(randomGenerator.nextInt(yumRepos.size()));
Map<String, String> repoOverrideNameValueMap = new HashMap<String, String>();
// attempt to override bASeUrL
// contains mixed case characters
String baseUrl = "bASeUrL";
// repoOverrideNameValueMap.put(baseUrl, "https://cdn.redhat.com/repo-override-testing/$releasever/$basearch");
// $releasever/$basearch will get interpreted as bash env vars which are empty strings.
repoOverrideNameValueMap.put(baseUrl, "https://cdn.redhat.com/repo-override-testing/");
SSHCommandResult result = clienttasks.repo_override_(null, null, Arrays.asList(yumRepo.id, "foo-bar"), null, repoOverrideNameValueMap, null, null, null, null);
// new standalone candlepin behavior allows baseurl overrides
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.10-1") && servertasks.statusStandalone) {
// candlepin commit bbba2dfc1ba44a16fef3d483caf4e7d4eaf63c10
log.info("Starting in candlepin version 2.0.10-1, the restriction on overriding the baseurl has been lifted against a standalone candlepin server for the benefit of mirror lists in Satellite. See https://trello.com/c/6IKbKppZ/7-work-with-satellite-team-to-design-out-mirror-lists-for-subscription-manager");
Assert.assertEquals(result.getExitCode(), Integer.valueOf(0), "ExitCode (against a standalone candlepin version >= 2.0.10-1) from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
Assert.assertEquals(result.getStdout().trim(), "Repository 'foo-bar' does not currently exist, but the override has been added.", "Stdout (against a standalone candlepin version >= 2.0.10-1) from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
Assert.assertEquals(result.getStderr().trim(), "", "Stderr (against a standalone candlepin version >= 2.0.10-1) from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
} else {
// original candlepin behavior denies baseurl overrides
Assert.assertEquals(result.getExitCode(), Integer.valueOf(1), "ExitCode from an attempt to repo-override the " + baseUrl + " (note the case) of yumRepo '" + yumRepo.id + "'.");
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
Assert.assertEquals(result.getStdout().trim(), "", "Stdout from an attempt to repo-override the '" + baseUrl + "' (note the case) of yumRepo '" + yumRepo.id + "'.");
Assert.assertEquals(result.getStderr().trim(), "Not allowed to override values for: " + baseUrl, "Stderr from an attempt to repo-override the '" + baseUrl + "' (note the case) of yumRepo '" + yumRepo.id + "'.");
} else {
Assert.assertEquals(result.getStderr().trim(), "", "Stderr from an attempt to repo-override the '" + baseUrl + "' (note the case) of yumRepo '" + yumRepo.id + "'.");
Assert.assertEquals(result.getStdout().trim(), "Not allowed to override values for: " + baseUrl, "Stdout from an attempt to repo-override the '" + baseUrl + "' (note the case) of yumRepo '" + yumRepo.id + "'.");
}
}
// attempt to override two bASeUrL and baseurl
// repoOverrideNameValueMap.put("baseurl", "https://cdn.redhat.com/repo-override-testing/$releasever/$basearch");
// $releasever/$basearch will get interpreted as bash env vars which are empty strings.
repoOverrideNameValueMap.put("baseurl", "https://cdn.redhat.com/repo-override-testing/");
// include another valid parameter for the fun of it
repoOverrideNameValueMap.put("mirrorlist_expire", "10");
result = clienttasks.repo_override_(null, null, Arrays.asList(yumRepo.id, "foo-bar"), null, repoOverrideNameValueMap, null, null, null, null);
// new standalone candlepin behavior allows baseurl overrides
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.10-1") && servertasks.statusStandalone) {
// candlepin commit bbba2dfc1ba44a16fef3d483caf4e7d4eaf63c10
log.info("Starting in candlepin version 2.0.10-1, the restriction on overriding the baseurl has been lifted against a standalone candlepin server for the benefit of mirror lists in Satellite. See https://trello.com/c/6IKbKppZ/7-work-with-satellite-team-to-design-out-mirror-lists-for-subscription-manager");
Assert.assertEquals(result.getExitCode(), Integer.valueOf(0), "ExitCode (against a standalone candlepin version >= 2.0.10-1) from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
Assert.assertEquals(result.getStdout().trim(), "Repository 'foo-bar' does not currently exist, but the override has been added.", "Stdout (against a standalone candlepin version >= 2.0.10-1) from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
Assert.assertEquals(result.getStderr().trim(), "", "Stderr (against a standalone candlepin version >= 2.0.10-1) from an attempt to repo-override the baseurl of yumRepo: " + yumRepo);
} else {
// original candlepin behavior denies baseurl overrides
Assert.assertEquals(result.getExitCode(), Integer.valueOf(1), "ExitCode from an attempt to repo-override " + baseUrl + " (note the case) and 'baseurl' of yumRepo '" + yumRepo.id + "'.");
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
Assert.assertEquals(result.getStdout().trim(), "", "Stdout from an attempt to repo-override the '" + baseUrl + "' (note the case) and 'baseurl' of yumRepo '" + yumRepo.id + "'.");
Assert.assertEquals(result.getStderr().trim(), "Not allowed to override values for: " + baseUrl + ", baseurl", "Stderr from an attempt to repo-override the '" + baseUrl + "' (note the case) and 'baseurl' of yumRepo '" + yumRepo.id + "'.");
} else {
Assert.assertEquals(result.getStderr().trim(), "", "Stderr from an attempt to repo-override the '" + baseUrl + "' (note the case) and 'baseurl' of yumRepo '" + yumRepo.id + "'.");
Assert.assertEquals(result.getStdout().trim(), "Not allowed to override values for: " + baseUrl + ", baseurl", "Stdout from an attempt to repo-override the '" + baseUrl + "' (note the case) and 'baseurl' of yumRepo '" + yumRepo.id + "'.");
}
}
// verify that no repo overrides have been added (including the valid parameter for the fun of it)
result = clienttasks.repo_override(true, null, (String) null, (String) null, null, null, null, null, null);
// new standalone candlepin behavior allows baseurl overrides
String expectedStdout = "This system does not have any content overrides applied to it.";
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.10-1") && servertasks.statusStandalone) {
// candlepin commit bbba2dfc1ba44a16fef3d483caf4e7d4eaf63c10
// [root@jsefler-6 ~] subscription-manager repo-override --list
// Repository: content-label-empty-gpg
// baseurl: https://cdn.redhat.com/repo-override-testing//
// mirrorlist_expire: 10
//
// Repository: foo-bar
// baseurl: https://cdn.redhat.com/repo-override-testing//
// mirrorlist_expire: 10
Assert.assertTrue(!result.getStdout().trim().equals(expectedStdout), "Stdout from repo-override --list after attempts to add baseurl overrides (against a standalone candlepin version >= 2.0.10-1).");
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(result.getStdout(), String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, yumRepo.id, "baseurl", repoOverrideNameValueMap.get("baseurl"))), "Stdout from repo-override --list after attempts to add baseurl overrides (against a standalone candlepin version >= 2.0.10-1).");
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(result.getStdout(), String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, yumRepo.id, "mirrorlist_expire", repoOverrideNameValueMap.get("mirrorlist_expire"))), "Stdout from repo-override --list after attempts to add baseurl overrides (against a standalone candlepin version >= 2.0.10-1).");
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(result.getStdout(), String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, "foo-bar", "baseurl", repoOverrideNameValueMap.get("baseurl"))), "Stdout from repo-override --list after attempts to add baseurl overrides (against a standalone candlepin version >= 2.0.10-1).");
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(result.getStdout(), String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, "foo-bar", "mirrorlist_expire", repoOverrideNameValueMap.get("mirrorlist_expire"))), "Stdout from repo-override --list after attempts to add baseurl overrides (against a standalone candlepin version >= 2.0.10-1).");
} else {
// original candlepin behavior denies baseurl overrides
Assert.assertEquals(result.getStdout().trim(), expectedStdout, "Stdout from repo-override --list after attempts to add baseurl overrides.");
}
Assert.assertEquals(result.getStderr().trim(), "", "Stderr from repo-override --list after attempts to add baseurl overrides.");
Assert.assertEquals(result.getExitCode(), Integer.valueOf(/*1*/
0), "ExitCode from repo-override --list after attempts to add baseurl overrides.");
}
use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.
the class ReposTests method testYumRepoListPreservesAdditionalOptionsToRedhatReposUsingManualEdits.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19974", "RHEL7-51013" }, 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: manually add more yum repository options to redhat.repo and assert persistence.", groups = { "Tier1Tests", "blockedByBug-845349", "blockedByBug-834806", "blockedByBug-1098891", "blockedByBug-1101571", "blockedByBug-1101584", "blockedByBug-1366301" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumRepoListPreservesAdditionalOptionsToRedhatReposUsingManualEdits() 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<YumRepo> subscribedYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
if (subscribedYumRepos.isEmpty())
throw new SkipException("There are no entitled yum repos available for this test.");
// randomly choose one of the YumRepos, set new option values, and manually update the yum repo
YumRepo yumRepo = subscribedYumRepos.get(randomGenerator.nextInt(subscribedYumRepos.size()));
// yumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", "awesomeos-modifier",subscribedYumRepos); // debugTesting case when yum repo comes from a modifier entitlement
// yumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", "content-label-no-gpg",subscribedYumRepos); // debugTesting case when sslclientcert appears to change.
yumRepo.exclude = "my-test-pkg my-test-pkg-* my-test-pkgversion-?";
yumRepo.priority = new Integer(10);
clienttasks.updateYumRepo(clienttasks.redhatRepoFile, yumRepo);
// assert that the manually added repository options do not get clobbered by a new yum transaction
// issue a new yum transaction
client.runCommandAndWait("yum -q repolist --disableplugin=rhnplugin");
// getCurrentlySubscribedYumRepos() includes a yum transaction: "yum -q repolist --disableplugin=rhnplugin" (NOT ANYMORE after bug 1008016)
YumRepo yumRepoAfterUpdate = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", yumRepo.id, clienttasks.getCurrentlySubscribedYumRepos());
Assert.assertNotNull(yumRepoAfterUpdate, "Found yum repo [" + yumRepo.id + "] after we manually altered it and issued a yum transaction.");
Assert.assertEquals(yumRepoAfterUpdate.exclude, yumRepo.exclude, "Yum repo [" + yumRepo.id + "] has persisted the manually added \"exclude\" option and its value.");
Assert.assertEquals(yumRepoAfterUpdate.priority, yumRepo.priority, "Yum repo [" + yumRepo.id + "] has persisted the manually added \"priority\" option and its value.");
Assert.assertEquals(yumRepoAfterUpdate, yumRepo, "Yum repo [" + yumRepo.id + "] has persisted all of its repository option values after running a yum transaction.");
// also assert that the repository values persist even after refresh
clienttasks.removeAllCerts(false, true, false);
clienttasks.refresh(null, null, null, null);
yumRepoAfterUpdate = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", yumRepo.id, clienttasks.getCurrentlySubscribedYumRepos());
/* temporary idea to figure how why an sslclientcert would change; did not prove to be true; keeping for future
BigInteger bi = clienttasks.getSerialNumberFromEntitlementCertFile(new File(yumRepoAfterUpdate.sslclientcert));
SubscriptionPool sp = clienttasks.getSubscriptionPoolFromProductSubscription(ProductSubscription.findFirstInstanceWithMatchingFieldFromList("serialNumber", bi, clienttasks.getCurrentlyConsumedProductSubscriptions()), sm_clientUsername, sm_clientPassword);
if (CandlepinTasks.isPoolAModifier(sm_clientUsername, sm_clientPassword, sp.poolId, sm_serverUrl)) {
yumRepoAfterUpdate.sslclientcert = null;
yumRepoAfterUpdate.sslclientkey = null;
yumRepo.sslclientcert = null;
yumRepo.sslclientkey = null;
Assert.assertEquals(yumRepoAfterUpdate, yumRepo, "Discounting the sslclientcert and sslclientkey, yum repo ["+yumRepo.id+"] still persists all of its repository option values after running refresh and a yum transaction.");
} else {
Assert.assertEquals(yumRepoAfterUpdate, yumRepo, "Yum repo ["+yumRepo.id+"] still persists all of its repository option values after running refresh and a yum transaction.");
}
*/
// Assert.assertEquals(yumRepoAfterUpdate, yumRepo, "Yum repo ["+yumRepo.id+"] still persists all of its repository option values after running refresh and a yum transaction.");
yumRepoAfterUpdate.sslclientcert = null;
yumRepo.sslclientcert = null;
yumRepoAfterUpdate.sslclientkey = null;
yumRepo.sslclientkey = null;
Assert.assertEquals(yumRepoAfterUpdate, yumRepo, "Discounting changes to the sslclientcert and sslclientkey, yum repo [" + yumRepo.id + "] still persists all of its repository option values after running refresh and a yum transaction.");
// also assert (when possible) that the repository values persist even after setting a release preference
List<String> releases = clienttasks.getCurrentlyAvailableReleases(null, null, null, null);
if (!releases.isEmpty()) {
clienttasks.release(null, null, releases.get(randomGenerator.nextInt(releases.size())), null, null, null, null, null);
yumRepoAfterUpdate = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", yumRepo.id, clienttasks.getCurrentlySubscribedYumRepos());
Assert.assertNotNull(yumRepoAfterUpdate, "Found yum repo [" + yumRepo.id + "] after we manually altered it, set a release, and issued a yum transaction.");
Assert.assertEquals(yumRepoAfterUpdate.exclude, yumRepo.exclude, "Yum repo [" + yumRepo.id + "] has persisted the manually added \"exclude\" option and its value even after setting a release and issuing a yum transaction.");
Assert.assertEquals(yumRepoAfterUpdate.priority, yumRepo.priority, "Yum repo [" + yumRepo.id + "] has persisted the manually added \"priority\" option and its value even after setting a release and issuing a yum transaction.");
// THIS WILL LIKELY NOT BE EQUAL WHEN THE yumRepoAfterUpdate.baseurl POINTS TO RHEL CONTENT SINCE IT WILL CONTAIN THE RELEASE PREFERENCE SUBSTITUTED FOR $releasever //Assert.assertEquals(yumRepoAfterUpdate, yumRepo, "Yum repo ["+yumRepo.id+"] has persisted all of its repository option values even after setting a release and issuing a yum transaction.");
}
}
use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.
the class ReposTests method testYumRepoListPreservesManuallyEnabledRedhatReposAfterDeletingVarLibRhsmRepoServerValRedHatRepo.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47937", "RHEL7-99476" }, 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: manually enable (using sed) all yum repositories in redhat.repo and assert persistence in 'yum repolist enabled' (but make sure /var/lib/rhsm/repo_server_val/redhat.repo is truncated first).", groups = { "Tier1Tests", "blockedByBug-1480659", "blockedByBug-1486338" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumRepoListPreservesManuallyEnabledRedhatReposAfterDeletingVarLibRhsmRepoServerValRedHatRepo() throws JSONException, Exception {
// STEP 1: ENSURE SYSTEM IS UNREGISTERED
clienttasks.unregister(null, null, null, null);
// STEP 2: DELETE/TRUNCATE THE /var/lib/rhsm/repo_server_val/redhat.repo FILE
client.runCommandAndWait("truncate --size=0 " + clienttasks.redhatRepoServerValueFile);
// STEP 3: REGISTER A RHEL SYSTEM WITH AUTO-ATTACH TO GET AN ENTITLEMENT TO ACCESS REPOS ON THE CDN
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);
// get all the entitled yum repos that are disabled by default
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", 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);
// STEP 4: MANUALLY EDIT (USING sed OR vi) /etc/yum.repos.d/redhat.repo FILE TO ENABLE ONE OR MORE REPOS (NORMALLY DISABLED BY DEFAULT)
client.runCommandAndWait("sed -i 's/enabled\\s*=\\s*0/enabled = 1/' " + clienttasks.redhatRepoFile);
Assert.assertEquals(client.runCommandAndWait("egrep 'enabled\\s*=\\s*0' " + clienttasks.redhatRepoFile + " | wc -l").getStdout().trim(), "0", "The number of disabled repos in '" + clienttasks.redhatRepoFile + "' after using sed to enable all entitled repos.");
// STEP 5: RUN yum repolist all AND VERIFY THAT ALL THE ENTITLED REPOS ARE ENABLED
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 sed to manually enable it in '" + clienttasks.redhatRepoFile + "'.");
}
}
use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.
the class ReposTests method testReposListDisabledReportsNoMatchesFoundWhenNoThereAreNoDisabledRepos.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20300", "RHEL7-51683" }, 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-disabled should give feedback when there are no disabled repos", groups = { "Tier3Tests", "blockedByBug-1151925" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposListDisabledReportsNoMatchesFoundWhenNoThereAreNoDisabledRepos() 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.");
// use a wildcard to enable 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, false, true, (String) null, (String) null, null, null, null, null);
List<Repo> listDisabledRepos = Repo.parse(sshCommandResult.getStdout());
Assert.assertTrue(listDisabledRepos.isEmpty(), "After using a wildcard to enable all repos, the repos --list-disabled should be empty.");
// assert the feedback when no repos are enabled
String expectedStdout = "There were no available repositories matching the specified criteria.";
Assert.assertEquals(sshCommandResult.getStdout().trim(), expectedStdout, "After using a wildcard to enable all repos, the repos --list-disabled should report feedback indicating no matches.");
}
Aggregations