use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class SearchDisabledReposTests method testWithNotifyOnlyOffVerifyYumSearchDisabledReposAssumingNoResponses.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-22228", "RHEL7-55195" }, 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 user is prompted to search disabled repos to complete an applicable yum install transaction when notify_only=0 is configured in /etc/yum/pluginconf.d/search-disabled-repos.conf and proceed with --assumeno responses", groups = { "Tier1Tests", "blockedByBug-1232232", "blockedByBug-1268376", "blockedByBug-1512948" }, dependsOnMethods = { "testRhelSubscriptionBaseAndOptionalReposAreAvailable" }, priority = 40, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testWithNotifyOnlyOffVerifyYumSearchDisabledReposAssumingNoResponses() {
// make sure rhelBasePackage and rhelOptionalPackage are not installed
if (clienttasks.isPackageInstalled(rhelOptionalPackage))
clienttasks.yumRemovePackage(rhelOptionalPackage);
if (clienttasks.isPackageInstalled(rhelBasePackage))
clienttasks.yumRemovePackage(rhelBasePackage);
// manually turn off notify_only 0
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSearchDisabledRepos, "notify_only", "0");
// enable rhelOptionalRepoId and disable rhelBaseRepoId
clienttasks.repos(null, null, null, rhelOptionalRepoId, rhelBaseRepoId, null, null, null, null);
// attempt to install a package that requires another package from a disabled repo
String disablerepos = "--disablerepo=beaker-*";
if (!rhelBaseRepoId.endsWith("-beta-rpms") && !rhelOptionalRepoId.endsWith("-beta-rpms"))
disablerepos += " --disablerepo=*-beta-rpms";
if (!rhelBaseRepoId.endsWith("-htb-rpms") && !rhelOptionalRepoId.endsWith("-htb-rpms"))
disablerepos += " --disablerepo=*-htb-rpms";
if (!rhelBaseRepoId.endsWith("-eus-rpms") && !rhelOptionalRepoId.endsWith("-eus-rpms"))
disablerepos += " --disablerepo=*-eus-rpms";
// disable any other repos that might be enabled to prevent // rhel-7-server-eus-rpms
SSHCommandResult result = clienttasks.yumDoPackageFromRepo_("install", rhelOptionalPackage, null, "--assumeno " + disablerepos);
// 2015-10-26 15:54:03.983 FINE: ssh root@jsefler-7.usersys.redhat.com yum -y install ghostscript-devel --disableplugin=rhnplugin --assumeno --disablerepo=*eus-rpms
// 2015-10-26 15:54:10.443 FINE: Stdout:
// Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
// : manager
// Resolving Dependencies
// --> Running transaction check
// ---> Package ghostscript-devel.x86_64 0:9.07-18.el7 will be installed
// --> Processing Dependency: ghostscript = 9.07-18.el7 for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Processing Dependency: libgs.so.9()(64bit) for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Finished Dependency Resolution
// Error: Package: ghostscript-devel-9.07-18.el7.x86_64 (rhel-7-server-optional-rpms)
// Requires: libgs.so.9()(64bit)
// Error: Package: ghostscript-devel-9.07-18.el7.x86_64 (rhel-7-server-optional-rpms)
// Requires: ghostscript = 9.07-18.el7
// **********************************************************************
// Dependency resolving failed due to missing dependencies.
// Some repositories on your system are disabled, but yum can enable them
// and search for missing dependencies. This will require downloading
// metadata for disabled repositories and may take some time and traffic.
// **********************************************************************
//
// You could try using --skip-broken to work around the problem
// ** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
// redhat-access-insights-1.0.6-0.el7.noarch has missing requires of libcgroup-tools
//
// 2015-10-26 15:54:10.469 FINE: Stderr:
// Error: Package: ghostscript-devel-9.07-18.el7.x86_64 (rhel-7-server-optional-rpms)
// Requires: libgs.so.9()(64bit)
// Error: Package: ghostscript-devel-9.07-18.el7.x86_64 (rhel-7-server-optional-rpms)
// Requires: ghostscript = 9.07-18.el7
//
// 2015-10-26 15:54:10.475 FINE: ExitCode: 1
// assert results
Assert.assertEquals(result.getExitCode(), Integer.valueOf(1), "Exit code from attempt to install '" + rhelOptionalPackage + "'.");
String requiresMessage = "Requires: " + rhelBasePackage;
Assert.assertTrue(result.getStderr().contains(requiresMessage), "Stderr from attempt to install '" + rhelOptionalPackage + "' contains the require message:\n" + requiresMessage);
String searchDisabledReposMessage = StringUtils.join(new String[] { "**********************************************************************", "Dependency resolving failed due to missing dependencies.", "Some repositories on your system are disabled, but yum can enable them", "and search for missing dependencies. This will require downloading", "metadata for disabled repositories and may take some time and traffic.", "**********************************************************************" }, "\n");
Assert.assertTrue(result.getStdout().contains(searchDisabledReposMessage), "Stdout from attempt to install '" + rhelOptionalPackage + "' contains the prompt message:\n" + searchDisabledReposMessage);
// confirm that the packages are not installed
Assert.assertTrue(!clienttasks.isPackageInstalled(rhelOptionalPackage), "Package '" + rhelOptionalPackage + "' is NOT installed.");
Assert.assertTrue(!clienttasks.isPackageInstalled(rhelBasePackage), "Package '" + rhelBasePackage + "' is NOT installed.");
// confirm the repo enablement has not changed
List<Repo> subscribedRepos = clienttasks.getCurrentlySubscribedRepos();
// assert the base rhel repo is disabled
Repo rhelBaseRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelBaseRepoId, subscribedRepos);
Assert.assertNotNull(rhelBaseRepo, "RHEL base repo id '" + rhelBaseRepoId + "' was found in subscribed repos.");
Assert.assertTrue(!rhelBaseRepo.enabled, "RHEL base repo id '" + rhelBaseRepoId + "' is disabled.");
// assert the optional rhel repo is enabled
Repo rhelOptionalRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelOptionalRepoId, subscribedRepos);
Assert.assertNotNull(rhelOptionalRepo, "RHEL optional repo id '" + rhelOptionalRepoId + "' was found in subscribed repos.");
Assert.assertTrue(rhelOptionalRepo.enabled, "RHEL optional repo id '" + rhelOptionalRepoId + "' is enabled.");
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class SearchDisabledReposTests method testWithNotifyOnlyOffVerifyYumSearchDisabledReposWithYesNoResponses.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-22231", "RHEL7-55198" }, 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 user is prompted to search disabled repos to complete an applicable yum install transaction when notify_only=0 is configured in /etc/yum/pluginconf.d/search-disabled-repos.conf and proceed with yes response to search disabled repos and no to the install prompt", groups = { "Tier1Tests", "blockedByBug-1232232", "blockedByBug-1268376", "blockedByBug-1512948" }, dependsOnMethods = { "testRhelSubscriptionBaseAndOptionalReposAreAvailable" }, priority = 70, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testWithNotifyOnlyOffVerifyYumSearchDisabledReposWithYesNoResponses() {
// make sure rhelBasePackage and rhelOptionalPackage are not installed
if (clienttasks.isPackageInstalled(rhelOptionalPackage))
clienttasks.yumRemovePackage(rhelOptionalPackage);
if (clienttasks.isPackageInstalled(rhelBasePackage))
clienttasks.yumRemovePackage(rhelBasePackage);
// manually turn off notify_only 0
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSearchDisabledRepos, "notify_only", "0");
// enable rhelOptionalRepoId and disable rhelBaseRepoId,rhelEusRepoId
List<String> enableRepos = new ArrayList<String>();
enableRepos.add(rhelOptionalRepoId);
List<String> disableRepos = new ArrayList<String>();
disableRepos.add(rhelBaseRepoId);
clienttasks.repos(null, null, null, enableRepos, disableRepos, null, null, null, null);
disableRepos.clear();
if (!rhelBaseRepoId.endsWith("-beta-rpms") && !rhelOptionalRepoId.endsWith("-beta-rpms"))
disableRepos.add("*-beta-rpms");
if (!rhelBaseRepoId.endsWith("-htb-rpms") && !rhelOptionalRepoId.endsWith("-htb-rpms"))
disableRepos.add("*-htb-rpms");
if (!rhelBaseRepoId.endsWith("-eus-rpms") && !rhelOptionalRepoId.endsWith("-eus-rpms"))
disableRepos.add("*-eus-rpms");
clienttasks.repos_(null, null, null, null, disableRepos, null, null, null, null);
// attempt to install a package that requires another package from a disabled repo
// responding yes and then no
// interactive yum responses are: y y N
SSHCommandResult result = client.runCommandAndWait("yum install " + rhelOptionalPackage + " --disableplugin=rhnplugin --disablerepo=beaker-* " + " << EOF\ny\nN\nEOF");
// 2015-10-27 18:34:34.097 FINE: ssh root@jsefler-7.usersys.redhat.com yum install ghostscript-devel --disableplugin=rhnplugin << EOF
// y
// N
// EOF
// 2015-10-27 18:34:53.829 FINE: Stdout:
// Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
// : manager
// Resolving Dependencies
// --> Running transaction check
// ---> Package ghostscript-devel.x86_64 0:9.07-18.el7 will be installed
// --> Processing Dependency: ghostscript = 9.07-18.el7 for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Processing Dependency: libgs.so.9()(64bit) for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Finished Dependency Resolution
// Error: Package: ghostscript-devel-9.07-18.el7.x86_64 (rhel-7-server-optional-rpms)
// Requires: libgs.so.9()(64bit)
// Error: Package: ghostscript-devel-9.07-18.el7.x86_64 (rhel-7-server-optional-rpms)
// Requires: ghostscript = 9.07-18.el7
// **********************************************************************
// Dependency resolving failed due to missing dependencies.
// Some repositories on your system are disabled, but yum can enable them
// and search for missing dependencies. This will require downloading
// metadata for disabled repositories and may take some time and traffic.
// **********************************************************************
//
// Enable all repositories and try again? [y/N]:
// --> Running transaction check
// ---> Package ghostscript-devel.x86_64 0:9.07-18.el7 will be installed
// --> Processing Dependency: ghostscript = 9.07-18.el7 for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Processing Dependency: libgs.so.9()(64bit) for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Running transaction check
// ---> Package ghostscript.x86_64 0:9.07-18.el7 will be installed
// --> Finished Dependency Resolution
//
// Dependencies Resolved
//
// ================================================================================
// Package Arch Version Repository Size
// ================================================================================
// Installing:
// ghostscript-devel x86_64 9.07-18.el7 rhel-7-server-optional-rpms 49 k
// Installing for dependencies:
// ghostscript x86_64 9.07-18.el7 rhel-7-server-eus-rpms 4.3 M
//
// Transaction Summary
// ================================================================================
// Install 1 Package (+1 Dependent package)
//
// Total download size: 4.4 M
// Installed size: 17 M
// Is this ok [y/d/N]:
// Exiting on user command
// Your transaction was saved, rerun it with:
// yum load-transaction /tmp/yum_save_tx.2015-10-27.18-34.Lbc8K5.yumtx
//
// 2015-10-27 18:34:53.873 FINE: Stderr:
// 2015-10-27 18:34:53.875 FINE: ExitCode: 1
// assert exitCode results
Assert.assertEquals(result.getExitCode(), Integer.valueOf(1), "Exit code from attempt to successfully install '" + rhelOptionalPackage + "' that requires '" + rhelBasePackage + "'.");
// assert stderr results
String stderrFiltered = result.getStderr();
// NOTE: The following stderr is possible when new products have not yet been released?
// Let's workaround this by filtering it from stderr before asserting an empty stderr
// 201607291254:11.409 - FINE: Stderr:
// https://cdn.redhat.com/content/dist/rhel/workstation/7/7Workstation/x86_64/insights-client/1/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
// Trying other mirror.
// To address this issue please refer to the below knowledge base article
//
// https://access.redhat.com/articles/1320623
//
// If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.
//
// https://cdn.redhat.com/content/dist/rhel/workstation/7/7Workstation/x86_64/openstack-tools/9/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
// Trying other mirror.
// https://cdn.redhat.com/content/dist/rhel/workstation/7/7Workstation/x86_64/ceph-tools/2/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
// Trying other mirror.
// https://cdn.redhat.com/content/dist/rhel/workstation/7/7Workstation/x86_64/openstack-tools/10/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
// Trying other mirror.
// 201607121645:50.724 - FINE: Stderr:
// https://cdn.redhat.com/content/dist/rhel/arm/7/7Server/aarch64/sat-tools/6.2/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
// Trying other mirror.
// To address this issue please refer to the below knowledge base article
//
// https://access.redhat.com/articles/1320623
//
// If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.
// 201611081658:33.447 - FINE: Stderr:
// https://cdn.redhat.com/content/dist/rhel/server/6/6Server/x86_64/sat-tools/6.3/os/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
// Trying other mirror.
// To address this issue please refer to the below knowledge base article
//
// https://access.redhat.com/articles/1320623
//
// If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.
//
// https://cdn.redhat.com/content/dist/rhel/server/6/6Server/x86_64/insights-client/1/os/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
// Trying other mirror.
// String stderrNotFoundRegex = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "rhsm", "baseurl")+".* HTTPS Error 404 - Not Found\nTrying other mirror.";
String stderrNotFoundRegex = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "rhsm", "baseurl") + ".* (HTTPS Error 404 - Not Found|\"The requested URL returned error: 404 Not Found\")\nTrying other mirror.";
String stderrNotFoundInfo = "To address this issue please refer to the below knowledge base article \n\nhttps://access.redhat.com/articles/1320623\n\nIf above article doesn't help to resolve this issue please open a ticket with Red Hat Support.";
if (stderrFiltered.contains(stderrNotFoundInfo))
log.warning("Ignoring stderr for all \"404 - Not Found\" errors since their discovery is not the purpose of this test.");
stderrFiltered = stderrFiltered.replace(stderrNotFoundInfo, "");
stderrFiltered = stderrFiltered.replaceAll(stderrNotFoundRegex, "");
stderrFiltered = stderrFiltered.trim();
Assert.assertEquals(stderrFiltered, "", "Ignoring all \"404 - Not Found\" errors, stderr from attempt to successfully install '" + rhelOptionalPackage + "' that requires '" + rhelBasePackage + "'.");
// assert stdout results
String prompt;
String requiresMessage = "Requires: " + rhelBasePackage;
Assert.assertTrue(result.getStdout().contains(requiresMessage), "Stdout from attempt to install '" + rhelOptionalPackage + "' contains the require message:\n" + requiresMessage);
String searchDisabledReposMessage = StringUtils.join(new String[] { "**********************************************************************", "Dependency resolving failed due to missing dependencies.", "Some repositories on your system are disabled, but yum can enable them", "and search for missing dependencies. This will require downloading", "metadata for disabled repositories and may take some time and traffic.", "**********************************************************************" }, "\n");
Assert.assertTrue(result.getStdout().contains(searchDisabledReposMessage), "Stdout from attempt to install '" + rhelOptionalPackage + "' which requires '" + rhelBasePackage + "' contains the search disabled repos message:\n" + searchDisabledReposMessage);
prompt = "Enable all repositories and try again? [y/N]: ";
Assert.assertTrue(result.getStdout().contains(prompt), "Stdout from attempt to install '" + rhelOptionalPackage + "' contains the prompt: " + prompt);
// RHEL7
prompt = "Is this ok [y/d/N]: ";
// RHEL6
if (clienttasks.redhatReleaseX.equals("6"))
prompt = "Is this ok [y/N]: ";
Assert.assertTrue(result.getStdout().contains(prompt), "Stdout from attempt to install '" + rhelOptionalPackage + "' contains the prompt: " + prompt);
// confirm that the packages are NOT installed
Assert.assertTrue(!clienttasks.isPackageInstalled(rhelOptionalPackage), "Package '" + rhelOptionalPackage + "' is NOT installed.");
Assert.assertTrue(!clienttasks.isPackageInstalled(rhelBasePackage), "Package '" + rhelBasePackage + "' is NOT installed.");
// confirm the repo enablement has not changed
List<Repo> subscribedRepos = clienttasks.getCurrentlySubscribedRepos();
// assert the optional rhel repo remains enabled
Repo rhelOptionalRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelOptionalRepoId, subscribedRepos);
Assert.assertNotNull(rhelOptionalRepo, "RHEL optional repo id '" + rhelOptionalRepoId + "' was found in subscribed repos.");
Assert.assertTrue(rhelOptionalRepo.enabled, "RHEL optional repo id '" + rhelOptionalRepoId + "' remains enabled.");
// assert the base rhel repo enablement remains disabled
Repo rhelBaseRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelBaseRepoId, subscribedRepos);
Assert.assertNotNull(rhelBaseRepo, "RHEL repo id '" + rhelBaseRepoId + "' was found in subscribed repos.");
Assert.assertTrue(!rhelBaseRepo.enabled, "RHEL repo id '" + rhelBaseRepoId + "' remains disabled.");
// assert that disabled base repo remains disabled in the repo-override list
SSHCommandResult listResult = clienttasks.repo_override(true, null, (String) null, (String) null, null, null, null, null, null);
String name = "enabled", value, regex;
value = "0";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelBaseRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelBaseRepoId + "' name='" + name + "' value='" + value + "'.");
if (rhelBetaRepoId != null) {
value = "0";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelBetaRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelBetaRepoId + "' name='" + name + "' value='" + value + "'.");
}
if (rhelHtbRepoId != null) {
value = "0";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelHtbRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelHtbRepoId + "' name='" + name + "' value='" + value + "'.");
}
if (rhelEusRepoId != null) {
value = "0";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelEusRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelEusRepoId + "' name='" + name + "' value='" + value + "'.");
}
// assert that the enabled optional repo remains enabled in the repo-override list
value = "1";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelOptionalRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelOptionalRepoId + "' name='" + name + "' value='" + value + "'.");
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class SearchDisabledReposTests method testWithNotifyOnlyOffVerifyYumSearchDisabledReposAssumingYesResponses.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-22229", "RHEL7-55196" }, 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 user is prompted to search disabled repos to complete an applicable yum install transaction when notify_only=0 is configured in /etc/yum/pluginconf.d/search-disabled-repos.conf and proceed with --assumeyes responses", groups = { "Tier1Tests", "blockedByBug-1232232", "blockedByBug-1268376", "blockedByBug-1512948", "testWithNotifyOnlyOffVerifyYumSearchDisabledReposAssumingYesResponses" }, dependsOnMethods = { "testRhelSubscriptionBaseAndOptionalReposAreAvailable" }, priority = 50, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testWithNotifyOnlyOffVerifyYumSearchDisabledReposAssumingYesResponses() {
// make sure rhelBasePackage and rhelOptionalPackage are not installed
if (clienttasks.isPackageInstalled(rhelOptionalPackage))
clienttasks.yumRemovePackage(rhelOptionalPackage);
if (clienttasks.isPackageInstalled(rhelBasePackage))
clienttasks.yumRemovePackage(rhelBasePackage);
// manually turn off notify_only 0
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSearchDisabledRepos, "notify_only", "0");
// enable rhelOptionalRepoId and disable rhelBaseRepoId,rhelEusRepoId
List<String> enableRepos = new ArrayList<String>();
enableRepos.add(rhelOptionalRepoId);
List<String> disableRepos = new ArrayList<String>();
disableRepos.add(rhelBaseRepoId);
clienttasks.repos(null, null, null, enableRepos, disableRepos, null, null, null, null);
disableRepos.clear();
if (!rhelBaseRepoId.endsWith("-beta-rpms") && !rhelOptionalRepoId.endsWith("-beta-rpms"))
disableRepos.add("*-beta-rpms");
if (!rhelBaseRepoId.endsWith("-htb-rpms") && !rhelOptionalRepoId.endsWith("-htb-rpms"))
disableRepos.add("*-htb-rpms");
if (!rhelBaseRepoId.endsWith("-eus-rpms") && !rhelOptionalRepoId.endsWith("-eus-rpms"))
disableRepos.add("*-eus-rpms");
clienttasks.repos_(null, null, null, null, disableRepos, null, null, null, null);
// 2015-10-29 17:51:58.988 FINE: ssh root@ibm-z10-30.rhts.eng.bos.redhat.com subscription-manager repos --disable=*-beta-rpms --disable=*-htb-rpms --disable=*-eus-rpms
// 2015-10-29 17:52:08.882 FINE: Stdout:
// Error: *-htb-rpms is not a valid repository ID. Use --list option to see valid repositories.
// Error: *-eus-rpms is not a valid repository ID. Use --list option to see valid repositories.
// Repository 'rhel-7-for-system-z-satellite-tools-6-beta-rpms' is disabled for this system.
// Repository 'rhel-7-for-system-z-rhn-tools-beta-rpms' is disabled for this system.
// Repository 'rhel-7-for-system-z-optional-beta-rpms' is disabled for this system.
// Repository 'rhel-7-for-system-z-rh-common-beta-rpms' is disabled for this system.
// Repository 'rhel-7-for-system-z-supplementary-beta-rpms' is disabled for this system.
// Repository 'rhel-7-for-system-z-beta-rpms' is disabled for this system.
//
// 2015-10-29 17:52:08.895 FINE: Stderr:
// 2015-10-29 17:52:08.896 FINE: ExitCode: 1
// attempt to install a package that requires another package from a disabled repo
SSHCommandResult result = clienttasks.yumDoPackageFromRepo_("install", rhelOptionalPackage, null, "--assumeyes --disablerepo=beaker-*");
// 2015-10-26 16:53:19.222 FINE: ssh root@jsefler-7.usersys.redhat.com yum -y install ghostscript-devel --disableplugin=rhnplugin --assumeyes
// 2015-10-26 16:53:55.547 FINE: Stdout:
// Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
// : manager
// Resolving Dependencies
// --> Running transaction check
// ---> Package ghostscript-devel.x86_64 0:9.07-18.el7 will be installed
// --> Processing Dependency: ghostscript = 9.07-18.el7 for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Processing Dependency: libgs.so.9()(64bit) for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Finished Dependency Resolution
// Error: Package: ghostscript-devel-9.07-18.el7.x86_64 (rhel-7-server-optional-rpms)
// Requires: libgs.so.9()(64bit)
// Error: Package: ghostscript-devel-9.07-18.el7.x86_64 (rhel-7-server-optional-rpms)
// Requires: ghostscript = 9.07-18.el7
// **********************************************************************
// Dependency resolving failed due to missing dependencies.
// Some repositories on your system are disabled, but yum can enable them
// and search for missing dependencies. This will require downloading
// metadata for disabled repositories and may take some time and traffic.
// **********************************************************************
//
// --> Running transaction check
// ---> Package ghostscript-devel.x86_64 0:9.07-18.el7 will be installed
// --> Processing Dependency: ghostscript = 9.07-18.el7 for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Processing Dependency: libgs.so.9()(64bit) for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Running transaction check
// ---> Package ghostscript.x86_64 0:9.07-18.el7 will be installed
// --> Finished Dependency Resolution
//
// Dependencies Resolved
//
// ================================================================================
// Package Arch Version Repository Size
// ================================================================================
// Installing:
// ghostscript-devel x86_64 9.07-18.el7 rhel-7-server-optional-rpms 49 k
// Installing for dependencies:
// ghostscript x86_64 9.07-18.el7 rhel-7-server-eus-rpms 4.3 M
//
// Transaction Summary
// ================================================================================
// Install 1 Package (+1 Dependent package)
//
// Total download size: 4.4 M
// Installed size: 17 M
// Downloading packages:
// --------------------------------------------------------------------------------
// Total 3.2 MB/s | 4.4 MB 00:01
// Running transaction check
// Running transaction test
// Transaction test succeeded
// Running transaction
// Installing : ghostscript-9.07-18.el7.x86_64 1/2
// Installing : ghostscript-devel-9.07-18.el7.x86_64 2/2
// Verifying : ghostscript-9.07-18.el7.x86_64 1/2
// Verifying : ghostscript-devel-9.07-18.el7.x86_64 2/2
// *******************************************************************
// Dependency resolving was successful thanks to enabling these repositories:
// rhel-7-server-eus-rpms
// *******************************************************************
//
//
// Installed:
// ghostscript-devel.x86_64 0:9.07-18.el7
//
// Dependency Installed:
// ghostscript.x86_64 0:9.07-18.el7
//
// Complete!
//
// 2015-10-26 16:53:55.548 FINE: Stderr:
// 2015-10-26 16:53:55.548 FINE: ExitCode: 0
// assert results
Assert.assertEquals(result.getExitCode(), Integer.valueOf(0), "Exit code from attempt to install '" + rhelOptionalPackage + "' that requires '" + rhelBasePackage + "'.");
// confirm that the packages are now installed
Assert.assertTrue(clienttasks.isPackageInstalled(rhelOptionalPackage), "Package '" + rhelOptionalPackage + "' is installed.");
Assert.assertTrue(clienttasks.isPackageInstalled(rhelBasePackage), "Package '" + rhelBasePackage + "' is installed.");
// assert more results
String requiresMessage = "Requires: " + rhelBasePackage;
Assert.assertTrue(result.getStdout().contains(requiresMessage), "Stdout from attempt to install '" + rhelOptionalPackage + "' contains the require message:\n" + requiresMessage);
String searchDisabledReposMessage = StringUtils.join(new String[] { "**********************************************************************", "Dependency resolving failed due to missing dependencies.", "Some repositories on your system are disabled, but yum can enable them", "and search for missing dependencies. This will require downloading", "metadata for disabled repositories and may take some time and traffic.", "**********************************************************************" }, "\n");
Assert.assertTrue(result.getStdout().contains(searchDisabledReposMessage), "Stdout from attempt to install '" + rhelOptionalPackage + "' contains the prompt message:\n" + searchDisabledReposMessage);
String rhelActualRepoId = clienttasks.getYumPackageInfo(rhelBasePackage, "From repo");
String resolutionMessage = StringUtils.join(new String[] { "*******************************************************************", "Dependency resolving was successful thanks to enabling these repositories:", rhelActualRepoId, "*******************************************************************" }, "\n");
Assert.assertTrue(result.getStdout().contains(resolutionMessage), "Stdout from attempt to install '" + rhelOptionalPackage + "' which requires '" + rhelBasePackage + "' contains the resolution message:\n" + resolutionMessage);
// confirm the repo enablement has not changed
List<Repo> subscribedRepos = clienttasks.getCurrentlySubscribedRepos();
// assert the optional rhel repo remains enabled
Repo rhelOptionalRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelOptionalRepoId, subscribedRepos);
Assert.assertNotNull(rhelOptionalRepo, "RHEL optional repo id '" + rhelOptionalRepoId + "' was found in subscribed repos.");
Assert.assertTrue(rhelOptionalRepo.enabled, "RHEL optional repo id '" + rhelOptionalRepoId + "' remains enabled.");
// assert the actual rhel repo enablement is persisted.
Repo rhelActualRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelActualRepoId, subscribedRepos);
Assert.assertNotNull(rhelActualRepo, "RHEL repo id '" + rhelActualRepoId + "' was found in subscribed repos.");
Assert.assertTrue(rhelActualRepo.enabled, "RHEL repo id '" + rhelActualRepoId + "' was enabled permanently by the search-disabled-repos plugin.");
// assert that the persisted enabled repos appear in the repo-override list
SSHCommandResult listResult = clienttasks.repo_override(true, null, (String) null, (String) null, null, null, null, null, null);
String name = "enabled", value, regex;
value = "1";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelActualRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelActualRepoId + "' name='" + name + "' value='" + value + "'.");
value = "1";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelOptionalRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelOptionalRepoId + "' name='" + name + "' value='" + value + "'.");
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class SearchDisabledReposTests method testWithNotifyOnlyOffVerifyYumSearchDisabledReposWithYesYesNoResponses.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-22230", "RHEL7-55197" }, 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 user is prompted to search disabled repos to complete an applicable yum install transaction when notify_only=0 is configured in /etc/yum/pluginconf.d/search-disabled-repos.conf and proceed with yes response to search disabled repos and install followed by no response to keep repos enabled.", groups = { "Tier1Tests", "blockedByBug-1232232", "blockedByBug-1268376", "blockedByBug-1512948", "testWithNotifyOnlyOffVerifyYumSearchDisabledReposWithYesYesNoResponses" }, dependsOnMethods = { "testRhelSubscriptionBaseAndOptionalReposAreAvailable" }, priority = 60, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testWithNotifyOnlyOffVerifyYumSearchDisabledReposWithYesYesNoResponses() {
// make sure rhelBasePackage and rhelOptionalPackage are not installed
if (clienttasks.isPackageInstalled(rhelOptionalPackage))
clienttasks.yumRemovePackage(rhelOptionalPackage);
if (clienttasks.isPackageInstalled(rhelBasePackage))
clienttasks.yumRemovePackage(rhelBasePackage);
// manually turn off notify_only 0
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSearchDisabledRepos, "notify_only", "0");
// enable rhelOptionalRepoId and disable rhelBaseRepoId,rhelEusRepoId
List<String> enableRepos = new ArrayList<String>();
enableRepos.add(rhelOptionalRepoId);
List<String> disableRepos = new ArrayList<String>();
disableRepos.add(rhelBaseRepoId);
clienttasks.repos(null, null, null, enableRepos, disableRepos, null, null, null, null);
disableRepos.clear();
if (!rhelBaseRepoId.endsWith("-beta-rpms") && !rhelOptionalRepoId.endsWith("-beta-rpms"))
disableRepos.add("*-beta-rpms");
if (!rhelBaseRepoId.endsWith("-htb-rpms") && !rhelOptionalRepoId.endsWith("-htb-rpms"))
disableRepos.add("*-htb-rpms");
if (!rhelBaseRepoId.endsWith("-eus-rpms") && !rhelOptionalRepoId.endsWith("-eus-rpms"))
disableRepos.add("*-eus-rpms");
clienttasks.repos_(null, null, null, null, disableRepos, null, null, null, null);
// attempt to install a package that requires another package from a disabled repo
// responding yes, yes, and then no
// interactive yum responses are: y y N
SSHCommandResult result = client.runCommandAndWait("yum install " + rhelOptionalPackage + " --disableplugin=rhnplugin --disablerepo=beaker-* " + " << EOF\ny\ny\nN\nEOF");
// 2015-10-27 14:08:13.820 FINE: ssh root@jsefler-7.usersys.redhat.com yum install ghostscript-devel --disableplugin=rhnplugin << EOF
// y
// y
// N
// EOF
// 2015-10-27 14:08:48.730 FINE: Stdout:
// Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
// : manager
// Resolving Dependencies
// --> Running transaction check
// ---> Package ghostscript-devel.x86_64 0:9.07-18.el7 will be installed
// --> Processing Dependency: ghostscript = 9.07-18.el7 for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Processing Dependency: libgs.so.9()(64bit) for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Finished Dependency Resolution
// Error: Package: ghostscript-devel-9.07-18.el7.x86_64 (rhel-7-server-optional-rpms)
// Requires: libgs.so.9()(64bit)
// Error: Package: ghostscript-devel-9.07-18.el7.x86_64 (rhel-7-server-optional-rpms)
// Requires: ghostscript = 9.07-18.el7
// **********************************************************************
// Dependency resolving failed due to missing dependencies.
// Some repositories on your system are disabled, but yum can enable them
// and search for missing dependencies. This will require downloading
// metadata for disabled repositories and may take some time and traffic.
// **********************************************************************
//
// Enable all repositories and try again? [y/N]:
// --> Running transaction check
// ---> Package ghostscript-devel.x86_64 0:9.07-18.el7 will be installed
// --> Processing Dependency: ghostscript = 9.07-18.el7 for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Processing Dependency: libgs.so.9()(64bit) for package: ghostscript-devel-9.07-18.el7.x86_64
// --> Running transaction check
// ---> Package ghostscript.x86_64 0:9.07-18.el7 will be installed
// --> Processing Dependency: ghostscript-fonts for package: ghostscript-9.07-18.el7.x86_64
// --> Running transaction check
// ---> Package ghostscript-fonts.noarch 0:5.50-32.el7 will be installed
// --> Finished Dependency Resolution
//
// Dependencies Resolved
//
// ================================================================================
// Package Arch Version Repository Size
// ================================================================================
// Installing:
// ghostscript-devel x86_64 9.07-18.el7 rhel-7-server-optional-rpms 49 k
// Installing for dependencies:
// ghostscript x86_64 9.07-18.el7 rhel-7-server-eus-rpms 4.3 M
// ghostscript-fonts noarch 5.50-32.el7 rhel-7-server-eus-rpms 324 k
//
// Transaction Summary
// ================================================================================
// Install 1 Package (+2 Dependent packages)
//
// Total download size: 4.7 M
// Installed size: 17 M
// Is this ok [y/d/N]:
// Downloading packages:
// --------------------------------------------------------------------------------
// Total 2.7 MB/s | 4.7 MB 00:01
// Running transaction check
// Running transaction test
// Transaction test succeeded
// Running transaction
// Installing : ghostscript-fonts-5.50-32.el7.noarch 1/3
// Installing : ghostscript-9.07-18.el7.x86_64 2/3
// Installing : ghostscript-devel-9.07-18.el7.x86_64 3/3
// Verifying : ghostscript-fonts-5.50-32.el7.noarch 1/3
// Verifying : ghostscript-9.07-18.el7.x86_64 2/3
// Verifying : ghostscript-devel-9.07-18.el7.x86_64 3/3
// *******************************************************************
// Dependency resolving was successful thanks to enabling these repositories:
// rhel-7-server-eus-rpms
// *******************************************************************
//
// Would you like to permanently enable these repositories? [y/N]:
// Installed:
// ghostscript-devel.x86_64 0:9.07-18.el7
//
// Dependency Installed:
// ghostscript.x86_64 0:9.07-18.el7 ghostscript-fonts.noarch 0:5.50-32.el7
//
// Complete!
//
// 2015-10-27 14:08:48.797 FINE: Stderr:
// 2015-10-27 14:08:48.799 FINE: ExitCode: 0
// assert exitCode results
Assert.assertEquals(result.getExitCode(), Integer.valueOf(0), "Exit code from attempt to successfully install '" + rhelOptionalPackage + "' that requires '" + rhelBasePackage + "'.");
// assert stderr results
String stderrFiltered = result.getStderr();
// NOTE: The following stderr is possible when new products have not yet been released?
// Let's workaround this by filtering it from stderr before asserting an empty stderr
// 201607291254:11.409 - FINE: Stderr:
// https://cdn.redhat.com/content/dist/rhel/workstation/7/7Workstation/x86_64/insights-client/1/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
// Trying other mirror.
// To address this issue please refer to the below knowledge base article
//
// https://access.redhat.com/articles/1320623
//
// If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.
//
// https://cdn.redhat.com/content/dist/rhel/workstation/7/7Workstation/x86_64/openstack-tools/9/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
// Trying other mirror.
// https://cdn.redhat.com/content/dist/rhel/workstation/7/7Workstation/x86_64/ceph-tools/2/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
// Trying other mirror.
// https://cdn.redhat.com/content/dist/rhel/workstation/7/7Workstation/x86_64/openstack-tools/10/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
// Trying other mirror.
// 201607121645:50.724 - FINE: Stderr:
// https://cdn.redhat.com/content/dist/rhel/arm/7/7Server/aarch64/sat-tools/6.2/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
// Trying other mirror.
// To address this issue please refer to the below knowledge base article
//
// https://access.redhat.com/articles/1320623
//
// If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.
// 201611081711:35.777 - FINE: Stderr:
// https://cdn.redhat.com/content/dist/rhel/server/6/6Server/x86_64/sat-tools/6.3/os/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
// Trying other mirror.
// To address this issue please refer to the below knowledge base article
//
// https://access.redhat.com/articles/1320623
//
// If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.
//
// https://cdn.redhat.com/content/dist/rhel/server/6/6Server/x86_64/insights-client/1/os/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
// Trying other mirror.
// String stderrNotFoundRegex = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "rhsm", "baseurl")+".* HTTPS Error 404 - Not Found\nTrying other mirror.";
String stderrNotFoundRegex = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "rhsm", "baseurl") + ".* (HTTPS Error 404 - Not Found|\"The requested URL returned error: 404 Not Found\")\nTrying other mirror.";
String stderrNotFoundInfo = "To address this issue please refer to the below knowledge base article \n\nhttps://access.redhat.com/articles/1320623\n\nIf above article doesn't help to resolve this issue please open a ticket with Red Hat Support.";
if (stderrFiltered.contains(stderrNotFoundInfo))
log.warning("Ignoring stderr for all \"404 - Not Found\" errors since their discovery is not the purpose of this test.");
stderrFiltered = stderrFiltered.replace(stderrNotFoundInfo, "");
stderrFiltered = stderrFiltered.replaceAll(stderrNotFoundRegex, "");
stderrFiltered = stderrFiltered.trim();
// TEMPORARY WORKAROUND
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1276747 - rhel-7-for-system-z-rpms/7Server/s390x/productid [Errno -1] Metadata file does not match checksum
String bugId = "1276747";
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 && rhelBaseRepoId.equals("rhel-7-for-system-z-rpms")) {
log.warning("Skipping stderr assertion while bugId '" + bugId + "' is open.");
} else
// END OF WORKAROUND
Assert.assertEquals(stderrFiltered, "", "Ignoring all \"404 - Not Found\" errors, stderr from attempt to successfully install '" + rhelOptionalPackage + "' that requires '" + rhelBasePackage + "'.");
// assert stdout results
String prompt;
String requiresMessage = "Requires: " + rhelBasePackage;
Assert.assertTrue(result.getStdout().contains(requiresMessage), "Stdout from attempt to install '" + rhelOptionalPackage + "' contains the require message:\n" + requiresMessage);
String searchDisabledReposMessage = StringUtils.join(new String[] { "**********************************************************************", "Dependency resolving failed due to missing dependencies.", "Some repositories on your system are disabled, but yum can enable them", "and search for missing dependencies. This will require downloading", "metadata for disabled repositories and may take some time and traffic.", "**********************************************************************" }, "\n");
Assert.assertTrue(result.getStdout().contains(searchDisabledReposMessage), "Stdout from attempt to install '" + rhelOptionalPackage + "' which requires '" + rhelBasePackage + "' contains the search disabled repos message:\n" + searchDisabledReposMessage);
prompt = "Enable all repositories and try again? [y/N]: ";
Assert.assertTrue(result.getStdout().contains(prompt), "Stdout from attempt to install '" + rhelOptionalPackage + "' contains the prompt: " + prompt);
// RHEL7
prompt = "Is this ok [y/d/N]: ";
// RHEL6
if (clienttasks.redhatReleaseX.equals("6"))
prompt = "Is this ok [y/N]: ";
Assert.assertTrue(result.getStdout().contains(prompt), "Stdout from attempt to install '" + rhelOptionalPackage + "' contains the prompt: " + prompt);
String rhelActualRepoId = clienttasks.getYumPackageInfo(rhelBasePackage, "From repo");
String resolutionMessage = StringUtils.join(new String[] { "*******************************************************************", "Dependency resolving was successful thanks to enabling these repositories:", rhelActualRepoId, "*******************************************************************" }, "\n");
Assert.assertTrue(result.getStdout().contains(resolutionMessage), "Stdout from attempt to install '" + rhelOptionalPackage + "' which requires '" + rhelBasePackage + "' contains the resolution message:\n" + resolutionMessage);
prompt = "Would you like to permanently enable these repositories? [y/N]: ";
Assert.assertTrue(result.getStdout().contains(prompt), "Stdout from attempt to install '" + rhelOptionalPackage + "' contains the prompt: " + prompt);
// confirm that the packages are now installed
Assert.assertTrue(clienttasks.isPackageInstalled(rhelOptionalPackage), "Package '" + rhelOptionalPackage + "' is installed.");
Assert.assertTrue(clienttasks.isPackageInstalled(rhelBasePackage), "Package '" + rhelBasePackage + "' is installed.");
// confirm the repo enablement has not changed
List<Repo> subscribedRepos = clienttasks.getCurrentlySubscribedRepos();
// assert the optional rhel repo remains enabled
Repo rhelOptionalRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelOptionalRepoId, subscribedRepos);
Assert.assertNotNull(rhelOptionalRepo, "RHEL optional repo id '" + rhelOptionalRepoId + "' was found in subscribed repos.");
Assert.assertTrue(rhelOptionalRepo.enabled, "RHEL optional repo id '" + rhelOptionalRepoId + "' remains enabled.");
// assert the actual rhel repo enablement is NOT persisted (since we said N to the prompt).
Repo rhelActualRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", rhelActualRepoId, subscribedRepos);
Assert.assertNotNull(rhelActualRepo, "RHEL repo id '" + rhelActualRepoId + "' was found in subscribed repos.");
Assert.assertTrue(!rhelActualRepo.enabled, "RHEL repo id '" + rhelActualRepoId + "' was NOT enabled permanently by the search-disabled-repos plugin.");
// assert that disabled base repo remains disabled in the repo-override list
SSHCommandResult listResult = clienttasks.repo_override(true, null, (String) null, (String) null, null, null, null, null, null);
String name = "enabled", value, regex;
value = "0";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelBaseRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelBaseRepoId + "' name='" + name + "' value='" + value + "'.");
if (rhelBetaRepoId != null) {
value = "0";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelBetaRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelBetaRepoId + "' name='" + name + "' value='" + value + "'.");
}
if (rhelHtbRepoId != null) {
value = "0";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelHtbRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelHtbRepoId + "' name='" + name + "' value='" + value + "'.");
}
if (rhelEusRepoId != null) {
value = "0";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelEusRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelEusRepoId + "' name='" + name + "' value='" + value + "'.");
}
// assert that the enabled optional repo remains enabled in the repo-override list
value = "1";
// notice that we have to escape glob characters from the value so they don't get interpreted as regex chars
regex = String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, rhelOptionalRepoId, name, value.replace("*", "\\*").replace("?", "\\?"));
Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(listResult.getStdout(), regex), "After the search-disabled-repos yum plugin was exercised, the subscription-manager repo-override list reports override repo='" + rhelOptionalRepoId + "' name='" + name + "' value='" + value + "'.");
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testServiceLevelListWithInsecure.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21864", "RHEL7-51723" }, 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: service-level list with --insecure", groups = { "Tier3Tests", "ServiceLevelListWithInsecure_Test", "blockedByBug-844411", "blockedByBug-993202", "blockedByBug-1256960", /*is a duplicate of*/
"blockedByBug-1254349" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testServiceLevelListWithInsecure() {
SSHCommandResult sshCommandResult;
// calling service level list without insecure should pass
sshCommandResult = clienttasks.service_level(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg, null, false, null, null, null, null);
// change the rhsm.ca_cert_dir configuration to simulate a missing candlepin ca cert
client.runCommandAndWait("mkdir -p /tmp/emptyDir");
sshCommandResult = clienttasks.config(null, null, true, new String[] { "rhsm", "ca_cert_dir", "/tmp/emptyDir/" });
// calling service level list without insecure should now fail (throwing stderr "certificate verify failed")
sshCommandResult = clienttasks.service_level_(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg, null, false, null, null, null, null);
Integer expectedExitCode = new Integer(255);
// EX_SOFTWARE // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
expectedExitCode = new Integer(70);
Assert.assertEquals(sshCommandResult.getExitCode(), expectedExitCode, "Exitcode from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.18.5-1") && Integer.valueOf(clienttasks.redhatReleaseX) >= 7) {
// post python-rhsm commit 214103dcffce29e31858ffee414d79c1b8063970 Reduce usage of m2crypto (#184) (RHEL7+)
Assert.assertEquals(sshCommandResult.getStderr().trim(), "Unable to verify server's identity: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)", "Stderr from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
Assert.assertEquals(sshCommandResult.getStdout().trim(), "", "Stdout from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
} else if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.9-1")) {
// post commit a695ef2d1da882c5f851fde90a24f957b70a63ad
Assert.assertEquals(sshCommandResult.getStderr().trim(), "Unable to verify server's identity: certificate verify failed", "Stderr from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
Assert.assertEquals(sshCommandResult.getStdout().trim(), "", "Stdout from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
} else if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.10.9-1")) {
// post commit 3366b1c734fd27faf48313adf60cf051836af115
Assert.assertEquals(sshCommandResult.getStderr().trim(), "", "Stderr from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
Assert.assertEquals(sshCommandResult.getStdout().trim(), "Unable to verify server's identity: certificate verify failed", "Stdout from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
} else {
Assert.assertEquals(sshCommandResult.getStderr().trim(), "certificate verify failed", "Stderr from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
Assert.assertEquals(sshCommandResult.getStdout().trim(), "", "Stdout from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
}
// calling service level list with insecure should now pass
sshCommandResult = clienttasks.service_level(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg, null, true, null, null, null, null);
// assert that option --insecure did NOT persist to rhsm.conf
Assert.assertEquals(clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "server", "insecure"), "0", "Expected value of " + clienttasks.rhsmConfFile + " server.insecure configuration. Use of the --insecure option when calling the service-level module should NOT be persisted to rhsm.conf as true.");
}
Aggregations