Search in sources :

Example 6 with Repo

use of rhsm.data.Repo 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 + "'.");
}
Also used : Repo(rhsm.data.Repo) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 7 with Repo

use of rhsm.data.Repo in project rhsm-qe by RedHatQE.

the class BugzillaTests method testManualChangesToRedhatRepo.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21915", "RHEL7-51776" }, 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 Manual Changes To Redhat.Repo is sticky", groups = { "Tier3Tests", "ManualChangesToRedhat_Repo", "blockedByBug-797243" }, enabled = true)
public void testManualChangesToRedhatRepo() throws Exception {
    List<String[]> listOfSectionNameValues = new ArrayList<String[]>();
    listOfSectionNameValues.add(new String[] { "rhsmcertd", "autoAttachInterval".toLowerCase(), "1440" });
    clienttasks.config(null, null, true, listOfSectionNameValues);
    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);
    List<SubscriptionPool> Availablepools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    SubscriptionPool pool = Availablepools.get(randomGenerator.nextInt(Availablepools.size()));
    clienttasks.subscribeToSubscriptionPool(pool);
    for (Repo repo : clienttasks.getCurrentlySubscribedRepos()) {
        if (repo.repoId.equals("always-enabled-content")) {
            Assert.assertTrue(repo.enabled);
        }
    }
    client.runCommandAndWait("sed -i \"/\\[always-enabled-content]/,/\\[/s/^enabled\\s*=.*/Enabled: false/\" /etc/yum.repos.d/redhat.repo");
    for (Repo repo : clienttasks.getCurrentlySubscribedRepos()) {
        if (repo.repoId.equals("always-enabled-content")) {
            Assert.assertFalse(repo.enabled);
        }
    }
    client.runCommandAndWait(" yum repolist enabled");
    clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    String expected_message = "This system has no repositories available through subscriptions.";
    String reposlist = clienttasks.repos(true, null, null, (String) null, null, null, null, null, null).getStdout();
    Assert.assertEquals(reposlist.trim(), expected_message);
    clienttasks.unregister(null, null, null, null);
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    reposlist = clienttasks.repos(true, null, null, (String) null, null, null, null, null, null).getStdout();
    Assert.assertEquals(reposlist.trim(), expected_message);
    clienttasks.subscribe(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
    for (Repo repo : clienttasks.getCurrentlySubscribedRepos()) {
        if (repo.repoId.equals("always-enabled-content")) {
            Assert.assertTrue(repo.enabled);
        }
    }
}
Also used : Repo(rhsm.data.Repo) YumRepo(rhsm.data.YumRepo) ArrayList(java.util.ArrayList) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 8 with Repo

use of rhsm.data.Repo in project rhsm-qe by RedHatQE.

the class BugzillaTests method testImportedCertGetsDeletedByRepoCommand.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21957", "RHEL7-51819" }, 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 subscription-manager repos --list does not delete an imported entitlement certificate on a system", groups = { "Tier3Tests", "VerifyImportedCertgetsDeletedByRepoCommand", "blockedByBug-1160150" }, enabled = true)
public void testImportedCertGetsDeletedByRepoCommand() throws Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, false, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    // disable
    clienttasks.autoheal(null, null, true, null, null, null, null);
    SubscriptionPool pool = getRandomSubsetOfList(clienttasks.getCurrentlyAvailableSubscriptionPools(), 1).get(0);
    File importEntitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, sm_clientUsername, sm_clientPassword, sm_serverUrl);
    File importEntitlementKeyFile = clienttasks.getEntitlementCertKeyFileCorrespondingToEntitlementCertFile(importEntitlementCertFile);
    File importCertificateFile = new File(importCertificatesDir1 + File.separator + importEntitlementCertFile.getName());
    List<Repo> subscribedReposBefore = clienttasks.getCurrentlySubscribedRepos();
    client.runCommandAndWait("mkdir -p " + importCertificatesDir1);
    client.runCommandAndWait("cat " + importEntitlementCertFile + " " + importEntitlementKeyFile + " > " + importCertificateFile);
    String path = importCertificateFile.getPath();
    clienttasks.clean();
    clienttasks.importCertificate(path);
    int Ceritificate_countBeforeRepoCommand = clienttasks.getCurrentEntitlementCertFiles().size();
    SSHCommandResult Result = clienttasks.repos_(true, null, null, (String) null, null, null, null, null, null);
    int Ceritificate_countAfterRepoCommand = clienttasks.getCurrentEntitlementCertFiles().size();
    List<Repo> subscribedReposAfter = clienttasks.getCurrentlySubscribedRepos();
    Assert.assertEquals(Ceritificate_countBeforeRepoCommand, Ceritificate_countAfterRepoCommand);
    Assert.assertEquals(Result.getExitCode(), new Integer(0));
    Assert.assertTrue(subscribedReposBefore.containsAll(subscribedReposAfter) && subscribedReposAfter.containsAll(subscribedReposBefore), "The list of subscribed repos is the same before and after importing the entitlement certificate.");
}
Also used : BigInteger(java.math.BigInteger) Repo(rhsm.data.Repo) YumRepo(rhsm.data.YumRepo) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SubscriptionPool(rhsm.data.SubscriptionPool) File(java.io.File) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 9 with Repo

use of rhsm.data.Repo in project rhsm-qe by RedHatQE.

the class ReleaseTests method testReleaseverSubstitutionInRepoLists.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20010", "RHEL7-55175" }, 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 = "after subscribing to all available subscriptions, assert that content with url paths that reference $releasever are substituted with the consumers current release preference", groups = { "Tier1Tests", "blockedByBug-807407", "blockedByBug-962520" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReleaseverSubstitutionInRepoLists() throws JSONException, Exception {
    // make sure we are newly registered
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, null, null, null, null, null);
    // subscribe to all available subscriptions
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
    // get current list of Repos and YumRepos before setting a release version preference
    List<Repo> reposBeforeSettingReleaseVer = clienttasks.getCurrentlySubscribedRepos();
    List<YumRepo> yumReposBeforeSettingReleaseVer = clienttasks.getCurrentlySubscribedYumRepos();
    boolean skipTest = true;
    for (Repo repo : reposBeforeSettingReleaseVer) {
        if (repo.repoUrl.contains("$releasever")) {
            skipTest = false;
            break;
        }
    }
    if (skipTest)
        throw new SkipException("After subscribing to all available subscriptions, could not find any enabled content with a repoUrl that employs $releasever");
    Assert.assertEquals(reposBeforeSettingReleaseVer.size(), yumReposBeforeSettingReleaseVer.size(), "The subscription-manager repos list count should match the yum reposlist count.");
    // now let's set a release version preference
    // cannot do this anymore, the value must be valid
    String releaseVer = "TestRelease-1.0";
    List<String> availableReleaseVers = clienttasks.getCurrentlyAvailableReleases(null, null, null, null);
    if (availableReleaseVers.isEmpty())
        throw new SkipException("Cannot complete this test when there are no releases available to set.");
    // randomly pick an available release for testing
    releaseVer = availableReleaseVers.get(randomGenerator.nextInt(availableReleaseVers.size()));
    clienttasks.release(null, null, releaseVer, null, null, null, null, null);
    // assert that each of the Repos after setting a release version preference substitutes the $releasever
    for (Repo repoAfter : clienttasks.getCurrentlySubscribedRepos()) {
        Repo repoBefore = Repo.findFirstInstanceWithMatchingFieldFromList("repoName", repoAfter.repoName, reposBeforeSettingReleaseVer);
        Assert.assertNotNull(repoBefore, "Found the the same repoName from the subscription-manager repos --list after setting a release version preference.");
        if (!repoBefore.repoUrl.contains("$releasever")) {
            Assert.assertEquals(repoAfter.repoUrl, repoBefore.repoUrl, "After setting a release version preference, the subscription-manager repos --list reported repoUrl for '" + repoAfter.repoName + "' should remain unchanged since it did not contain the yum $releasever variable.");
        } else {
            Assert.assertEquals(repoAfter.repoUrl, repoBefore.repoUrl.replaceAll("\\$releasever", releaseVer), "After setting a release version preference, the subscription-manager repos --list reported repoUrl for '" + repoAfter.repoName + "' should have a variable substitution for $releasever.");
        }
    }
    // assert that each of the YumRepos after setting a release version preference actually substitutes the $releasever
    for (YumRepo yumRepoAfter : clienttasks.getCurrentlySubscribedYumRepos()) {
        YumRepo yumRepoBefore = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", yumRepoAfter.id, yumReposBeforeSettingReleaseVer);
        Assert.assertNotNull(yumRepoBefore, "Found the the same repo id from the yum repolist after setting a release version preference.");
        if (!yumRepoBefore.baseurl.contains("$releasever")) {
            Assert.assertEquals(yumRepoAfter.baseurl, yumRepoBefore.baseurl, "After setting a release version preference, the yum repolist reported baseurl for '" + yumRepoAfter.id + "' should remain unchanged since it did not contain the yum $releasever variable.");
        } else {
            Assert.assertEquals(yumRepoAfter.baseurl, yumRepoBefore.baseurl.replaceAll("\\$releasever", releaseVer), "After setting a release version preference, the yum repolist reported baseurl for '" + yumRepoAfter.id + "' should have a variable substitution for $releasever.");
        }
    }
    // now let's unset the release version preference
    clienttasks.release(null, null, null, true, null, null, null, null);
    // assert that each of the Repos and YumRepos after unsetting the release version preference where restore to their original values (containing $releasever)
    List<Repo> reposAfterSettingReleaseVer = clienttasks.getCurrentlySubscribedRepos();
    List<YumRepo> yumReposAfterSettingReleaseVer = clienttasks.getCurrentlySubscribedYumRepos();
    Assert.assertTrue(reposAfterSettingReleaseVer.containsAll(reposBeforeSettingReleaseVer) && reposBeforeSettingReleaseVer.containsAll(reposAfterSettingReleaseVer), "After unsetting the release version preference, all of the subscription-manager repos --list were restored to their original values.");
    Assert.assertTrue(yumReposAfterSettingReleaseVer.containsAll(yumReposBeforeSettingReleaseVer) && yumReposBeforeSettingReleaseVer.containsAll(yumReposAfterSettingReleaseVer), "After unsetting the release version preference, all of the yum repolist were restored to their original values.");
}
Also used : Repo(rhsm.data.Repo) YumRepo(rhsm.data.YumRepo) YumRepo(rhsm.data.YumRepo) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 10 with Repo

use of rhsm.data.Repo in project rhsm-qe by RedHatQE.

the class ReposTests method testReposEnableDisableSomeReposUsingWildcard.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20370", "RHEL7-51680" }, 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 some repos (using wildcard ?)", groups = { "Tier3Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposEnableDisableSomeReposUsingWildcard() throws JSONException, Exception {
    // [root@jsefler-os6 ~]# subscription-manager repos --disable=awesomeos-i???
    // Repository 'awesomeos-i686' is disabled for this system.
    // Repository 'awesomeos-ia64' 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.";
    // get a random subscribedRepo
    Repo randomSubscribedRepo = getRandomListItem(subscribedRepos);
    String randomSubscribedRepoId = randomSubscribedRepo.repoId;
    // e.g. "awesomeos-s390x" to "awes?me?s-s390x"
    String wildcardedRepo = randomSubscribedRepoId.replaceAll(String.valueOf(randomSubscribedRepoId.charAt(randomGenerator.nextInt(randomSubscribedRepoId.length()))), "?");
    String regexRepo = wildcardedRepo.replaceAll("\\?", ".");
    // test: subscription-manager repos --disablerepo=awes?me?s-s390x
    clienttasks.repos_(null, null, null, "*", null, null, null, null, null);
    SSHCommandResult result = clienttasks.repos_(null, null, null, null, wildcardedRepo, null, null, null, null);
    Assert.assertEquals(result.getExitCode(), new Integer(0), "ExitCode from an attempt to enable/disable some 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 (subscribedRepo.repoId.matches(regexRepo)) {
            Assert.assertTrue(result.getStdout().contains(expectedDisableStdoutMsg), "Stdout from an attempt to disable repos '" + wildcardedRepo + "' (using wildcard ?) contains expected message: " + expectedDisableStdoutMsg);
        } else {
            Assert.assertTrue(!result.getStdout().contains(expectedDisableStdoutMsg), "Stdout from an attempt to disable repos '" + wildcardedRepo + "' (using wildcard ?) does NOT contain message: " + expectedDisableStdoutMsg);
        }
    }
    // verify the actual yum repolist disabled
    List<String> yumRepoListDisabled = clienttasks.getYumRepolist("disabled");
    for (Repo subscribedRepo : subscribedRepos) {
        if (subscribedRepo.repoId.matches(regexRepo)) {
            Assert.assertTrue(yumRepoListDisabled.contains(subscribedRepo.repoId), "After calling subscription-manager repos to disable '" + wildcardedRepo + "', entitled repo '" + subscribedRepo.repoId + "' appears on the yum repolist disabled.");
        } else {
            Assert.assertTrue(!yumRepoListDisabled.contains(subscribedRepo.repoId), "After calling subscription-manager repos to disable '" + wildcardedRepo + "', entitled repo '" + subscribedRepo.repoId + "' does NOT appear on the yum repolist disabled.");
        }
    }
    // test: subscription-manager repos --enablerepo=*
    clienttasks.repos_(null, null, null, null, "*", null, null, null, null);
    result = clienttasks.repos_(null, null, null, wildcardedRepo, null, null, null, null, null);
    Assert.assertEquals(result.getExitCode(), new Integer(0), "ExitCode from an attempt to enable/disable some 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 (subscribedRepo.repoId.matches(regexRepo)) {
            Assert.assertTrue(result.getStdout().contains(expectedEnableStdoutMsg), "Stdout from an attempt to enable repos '" + wildcardedRepo + "' (using wildcard ?) contains expected message: " + expectedEnableStdoutMsg);
        } else {
            Assert.assertTrue(!result.getStdout().contains(expectedEnableStdoutMsg), "Stdout from an attempt to enable repos '" + wildcardedRepo + "' (using wildcard ?) does NOT contain message: " + expectedEnableStdoutMsg);
        }
    }
    // verify the actual yum repolist enabled
    yumRepoListDisabled = clienttasks.getYumRepolist("enabled");
    for (Repo subscribedRepo : subscribedRepos) {
        if (subscribedRepo.repoId.matches(regexRepo)) {
            Assert.assertTrue(yumRepoListDisabled.contains(subscribedRepo.repoId), "After calling subscription-manager repos to enable '" + wildcardedRepo + "', entitled repo '" + subscribedRepo.repoId + "' appears on the yum repolist enabled.");
        } else {
            Assert.assertTrue(!yumRepoListDisabled.contains(subscribedRepo.repoId), "After calling subscription-manager repos to enable '" + wildcardedRepo + "', entitled repo '" + subscribedRepo.repoId + "' does NOT appear on the yum repolist enabled.");
        }
    }
}
Also used : BigInteger(java.math.BigInteger) Repo(rhsm.data.Repo) YumRepo(rhsm.data.YumRepo) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Aggregations

Repo (rhsm.data.Repo)30 Test (org.testng.annotations.Test)27 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)26 YumRepo (rhsm.data.YumRepo)20 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)16 SkipException (org.testng.SkipException)14 ArrayList (java.util.ArrayList)13 File (java.io.File)6 SubscriptionPool (rhsm.data.SubscriptionPool)6 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)4 BigInteger (java.math.BigInteger)4 HashMap (java.util.HashMap)4 List (java.util.List)4 JSONObject (org.json.JSONObject)4 EntitlementCert (rhsm.data.EntitlementCert)4 ProductCert (rhsm.data.ProductCert)3 BlockedByBzBug (com.redhat.qe.auto.bugzilla.BlockedByBzBug)2 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)2 JSONArray (org.json.JSONArray)2 ContentNamespace (rhsm.data.ContentNamespace)2