Search in sources :

Example 1 with BugzillaAPIException

use of com.redhat.qe.auto.bugzilla.BugzillaAPIException 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 2 with BugzillaAPIException

use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.

the class ServiceLevelTests method testAutoSubscribeWithServiceLevelIsCaseInsensitive.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19994", "RHEL7-51026" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "subscription-manager: autosubscribe while specifying an valid service level; assert the installed product status is independent of the specified SerViceLeVEL case.", groups = { "Tier1Tests", "blockedByBug-818319", "blockedByBug-859652" }, // dataProvider="getAllAvailableServiceLevelData",	// 06/05/2014 takes too long; rarely reveals a bug
dataProvider = "getRandomSubsetOfAllAvailableServiceLevelData", enabled = true)
// 157226 //157225
@ImplementsNitrateTest(caseId = 157227)
public void testAutoSubscribeWithServiceLevelIsCaseInsensitive(Object bugzilla, String serviceLevel) throws JSONException, Exception {
    // TEMPORARY WORKAROUND FOR BUG
    if (sm_serverType.equals(CandlepinType.hosted)) {
        String bugId = "818319";
        boolean invokeWorkaroundWhileBugIsOpen = true;
        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) {
            throw new SkipException("This test is blocked by Bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId);
        }
    }
    // system was already registered by dataProvider="getSubscribeWithAutoAndServiceLevelData"
    if (clienttasks.getCurrentConsumerId() == null) {
        clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    }
    // start fresh by returning all entitlements
    clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    // autosubscribe specifying a valid service level and get the installed product status
    List<InstalledProduct> installedProductsAfterAutosubscribingWithServiceLevel = InstalledProduct.parse(clienttasks.subscribe(true, serviceLevel, (String) null, (String) null, (String) null, null, null, null, null, null, null, null, null).getStdout());
    // unsubscribe from all entitlements
    clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    // autosubscribe specifying a mixed case service level and get the installed product status
    String mixedCaseServiceLevel = randomizeCaseOfCharactersInString(serviceLevel);
    List<InstalledProduct> installedProductsAfterAutosubscribingWithMixedCaseServiceLevel = InstalledProduct.parse(clienttasks.subscribe(true, mixedCaseServiceLevel, (String) null, (String) null, (String) null, null, null, null, null, null, null, null, null).getStdout());
    // assert that the two lists are identical (independent of the serviceLevel case specified during autosubscribe)
    Assert.assertEquals(installedProductsAfterAutosubscribingWithMixedCaseServiceLevel.size(), clienttasks.getCurrentProductIds().size(), "The subscribe output displayed the same number of installed product status's as the current number of installed product certs.");
    Assert.assertTrue(installedProductsAfterAutosubscribingWithServiceLevel.containsAll(installedProductsAfterAutosubscribingWithMixedCaseServiceLevel) && installedProductsAfterAutosubscribingWithMixedCaseServiceLevel.containsAll(installedProductsAfterAutosubscribingWithServiceLevel), "Autosubscribe with serviceLevel '" + mixedCaseServiceLevel + "' yielded the same installed product status as autosubscribe with serviceLevel '" + serviceLevel + "'.");
    // get the current exempt service levels
    List<String> exemptServiceLevels = CandlepinTasks.getServiceLevelsForOrgKey(sm_clientUsername, sm_clientPassword, sm_serverUrl, clienttasks.getCurrentlyRegisteredOwnerKey(), true);
    List<String> exemptServiceLevelsInUpperCase = new ArrayList<String>();
    for (String exemptServiceLevel : exemptServiceLevels) exemptServiceLevelsInUpperCase.add(exemptServiceLevel.toUpperCase());
    // assert that each of the consumed ProductSubscriptions match the specified service level
    List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    if (consumedProductSubscriptions.isEmpty())
        log.warning("No entitlements were granted after autosubscribing with service level '" + mixedCaseServiceLevel + "'.");
    for (ProductSubscription productSubscription : consumedProductSubscriptions) {
        // tolerate ProductSubscriptions with a null/"" serviceLevel. (result of candlepin Bug 1223560)
        if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", /*TODO ">" is technically correct*/
        "2.0.2-1")) {
            // commit 9cefb6e23baefcc4ee2e14423f205edd37eecf22	// Bug 1223560 - Service levels on an activation key prevent custom products from attaching at registration if auto-attach enabled
            if (productSubscription.serviceLevel == null || productSubscription.serviceLevel.isEmpty()) {
                log.warning("After autosubscribe with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides no service level '" + productSubscription.serviceLevel + "'.  (New behavior modification from Bug 1223560)");
                continue;
            }
        }
        // tolerate ProductSubscriptions with exemptServiceLevels
        if (/*sm_*/
        exemptServiceLevelsInUpperCase.contains(productSubscription.serviceLevel.toUpperCase())) {
            log.warning("After autosubscribe with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides an exempt service level '" + productSubscription.serviceLevel + "'.");
            continue;
        }
        Assert.assertTrue(productSubscription.serviceLevel.equalsIgnoreCase(mixedCaseServiceLevel), "After autosubscribe with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides a service level '" + productSubscription.serviceLevel + "' that is a case insensitive match to '" + mixedCaseServiceLevel + "'.");
    }
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 3 with BugzillaAPIException

use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.

the class ServiceLevelTests method testRegisterWithServiceLevelIsCaseInsensitive.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19995", "RHEL7-51028" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "subscription-manager: register with autosubscribe while specifying an valid random case SeRviCEleVel; assert the installed product status is independent of the specified service level case.", groups = { "Tier1Tests", "blockedByBug-859652", "blockedByBug-859652", "blockedByBug-919700" }, // dataProvider="getAllAvailableServiceLevelData",	// 06/05/2014 takes too long; rarely reveals a bug
dataProvider = "getRandomSubsetOfAllAvailableServiceLevelData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRegisterWithServiceLevelIsCaseInsensitive(Object bugzilla, String serviceLevel) {
    // TEMPORARY WORKAROUND FOR BUG
    if (sm_serverType.equals(CandlepinType.hosted)) {
        String bugId = "818319";
        boolean invokeWorkaroundWhileBugIsOpen = true;
        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) {
            throw new SkipException("Hosted candlepin server '" + sm_serverHostname + "' does not yet support this test execution.");
        }
    }
    // END OF WORKAROUND
    // register with autosubscribe specifying a valid service level and get the installed product status
    List<InstalledProduct> installedProductsAfterAutosubscribedRegisterWithServiceLevel = InstalledProduct.parse(clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, serviceLevel, null, (String) null, null, null, null, true, null, null, null, null, null).getStdout());
    // register with autosubscribe specifying a mixed case service level and get the installed product status
    String mixedCaseServiceLevel = randomizeCaseOfCharactersInString(serviceLevel);
    List<InstalledProduct> installedProductsAfterAutosubscribedRegisterWithMixedCaseServiceLevel = InstalledProduct.parse(clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, mixedCaseServiceLevel, null, (String) null, null, null, null, true, null, null, null, null, null).getStdout());
    // assert that the two lists are identical (independent of the serviceLevel case specified during registration)
    Assert.assertEquals(installedProductsAfterAutosubscribedRegisterWithMixedCaseServiceLevel.size(), clienttasks.getCurrentProductIds().size(), "The registration output displayed the same number of installed product status's as the number of installed product certs.");
    Assert.assertTrue(installedProductsAfterAutosubscribedRegisterWithServiceLevel.containsAll(installedProductsAfterAutosubscribedRegisterWithMixedCaseServiceLevel) && installedProductsAfterAutosubscribedRegisterWithMixedCaseServiceLevel.containsAll(installedProductsAfterAutosubscribedRegisterWithServiceLevel), "Autosubscribed registration with serviceLevel '" + mixedCaseServiceLevel + "' yielded the same installed product status as autosubscribed registration with serviceLevel '" + serviceLevel + "'.");
    // assert that each of the consumed ProductSubscriptions match the specified service level
    List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    if (consumedProductSubscriptions.isEmpty())
        log.warning("No entitlements were granted after registering with autosubscribe and service level '" + mixedCaseServiceLevel + "'.");
    for (ProductSubscription productSubscription : consumedProductSubscriptions) {
        // tolerate ProductSubscriptions with a null/"" serviceLevel. (result of candlepin Bug 1223560)
        if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", /*TODO ">" is technically correct*/
        "2.0.2-1")) {
            // commit 9cefb6e23baefcc4ee2e14423f205edd37eecf22	// Bug 1223560 - Service levels on an activation key prevent custom products from attaching at registration if auto-attach enabled
            if (productSubscription.serviceLevel == null || productSubscription.serviceLevel.isEmpty()) {
                log.warning("After autosubscribed registration with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides no service level '" + productSubscription.serviceLevel + "'.  (New behavior modification from Bug 1223560)");
                continue;
            }
        }
        // tolerate exemptServiceLevels
        if (sm_exemptServiceLevelsInUpperCase.contains(productSubscription.serviceLevel.toUpperCase())) {
            log.warning("After autosubscribed registration with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides an exempt service level '" + productSubscription.serviceLevel + "'.");
            continue;
        }
        Assert.assertTrue(productSubscription.serviceLevel.equalsIgnoreCase(mixedCaseServiceLevel), "After autosubscribed registration with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides a service level '" + productSubscription.serviceLevel + "' that is a case insensitive match to '" + mixedCaseServiceLevel + "'.");
    }
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ProductSubscription(rhsm.data.ProductSubscription) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 4 with BugzillaAPIException

use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.

the class SpellCheckTests method testSpellingsOnManPageForSubscriptionManagerGui.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21784", "RHEL7-51601" }, 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 = "check the subscription-manager-gui man page for misspelled words and typos", groups = { "Tier3Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSpellingsOnManPageForSubscriptionManagerGui() throws IOException {
    if (clienttasks == null)
        throw new SkipException("A client connection is needed for this test.");
    String tool = "subscription-manager-gui";
    SSHCommandResult manPageResult = client.runCommandAndWait("man " + tool);
    Assert.assertEquals(manPageResult.getExitCode(), Integer.valueOf(0), "ExitCode from man page for '" + tool + "'.");
    // modify the contents of manPageResult for acceptable word spellings
    String modifiedManPage = manPageResult.getStdout();
    // unhyphenate all words at the ends of a line
    modifiedManPage = modifiedManPage.replaceAll("(\\w+)(?:‐|-)\\n\\s+(\\w+)", "$1$2");
    modifiedManPage = modifiedManPage.replaceAll("System Manager's Manual", " bugzilla1192574comment2isNotFixed ");
    modifiedManPage = modifiedManPage.replaceAll("https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Subscription_Management/1.0/html/Subscription_Management_Guide/index.html", " bugzilla1192574comment3isNotFixed ");
    modifiedManPage = modifyMisspellingsInManPage(modifiedManPage);
    // TEMPORARY WORKAROUND FOR BUG
    for (String word : Arrays.asList(new String[] { "bugzilla1192574comment2isNotFixed", "bugzilla1192574comment3isNotFixed" })) {
        if (modifiedManPage.contains(word)) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1192574 - typos and poor grammar in subscription-manager-gui man page
            String bugId = "1192574";
            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) {
                log.warning("Ignoring known misspelling of '" + word + "' while bug '" + bugId + "' is open.");
                modifiedManPage = modifiedManPage.replace(word, "TYPO");
            }
            if (word.equals("bugzilla1192574comment3isNotFixed") && clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1")) {
                // commit 589bf7debe8702d147f3a69f61f34c44ab47ef63
                log.fine("Invoking workaround for Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                log.warning("Ignoring known misspelling of '" + word + "' which is fixed in newer release subscription-manager-1.15.1-1.");
                modifiedManPage = modifiedManPage.replace(word, "TYPO");
            }
        }
    }
    // END OF WORKAROUND
    // assert that there were no unexpected hunspell check failures in the modified man page
    Assert.assertEquals(getSpellCheckFailuresForModifiedManPage(tool, manPageResult.getStdout(), modifiedManPage).size(), 0, "There are zero unexpected hunspell check failures in the man page for '" + tool + "'.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 5 with BugzillaAPIException

use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.

the class SpellCheckTests method testSpellingsOnManPageForRct.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21778", "RHEL7-51595" }, 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 = "check the rct man page for misspelled words and typos", groups = { "Tier3Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSpellingsOnManPageForRct() throws IOException {
    if (clienttasks == null)
        throw new SkipException("A client connection is needed for this test.");
    String tool = "rct";
    SSHCommandResult manPageResult = client.runCommandAndWait("man " + tool);
    Assert.assertEquals(manPageResult.getExitCode(), Integer.valueOf(0), "ExitCode from man page for '" + tool + "'.");
    // modify the contents of manPageResult for acceptable word spellings
    String modifiedManPage = manPageResult.getStdout();
    modifiedManPage = modifyMisspellingsInManPage(manPageResult.getStdout());
    modifiedManPage = modifiedManPage.replaceAll("System Manager's Manual", " bugzilla1193991comment3isNotFixed ");
    // TEMPORARY WORKAROUND FOR BUG
    for (String word : Arrays.asList(new String[] { "certficate", "filesystem", "bugzilla1193991comment3isNotFixed" })) {
        if (modifiedManPage.contains(word)) {
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1193991 - typos and poor grammar in rct man page
            String bugId = "1193991";
            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) {
                log.warning("Ignoring known misspelling of '" + word + "' while bug '" + bugId + "' is open.");
                modifiedManPage = modifiedManPage.replace(word, "TYPO");
            }
            if (word.equals("certficate") && clienttasks.isPackageVersion("subscription-manager", "<", "1.15.1-1")) {
                // commit a7a358714b66faf1ba2031f2e9918e1078756efa
                log.fine("Invoking workaround for Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                log.warning("Ignoring known misspelling of '" + word + "' which is fixed in newer release subscription-manager-1.15.1-1.");
                modifiedManPage = modifiedManPage.replace(word, "TYPO");
            }
        }
    }
    // END OF WORKAROUND
    // assert that there were no unexpected hunspell check failures in the modified man page
    Assert.assertEquals(getSpellCheckFailuresForModifiedManPage(tool, manPageResult.getStdout(), modifiedManPage).size(), 0, "There are zero unexpected hunspell check failures in the man page for '" + tool + "'.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Aggregations

BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)134 Test (org.testng.annotations.Test)91 SkipException (org.testng.SkipException)89 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)88 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)77 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)55 ArrayList (java.util.ArrayList)44 SubscriptionPool (rhsm.data.SubscriptionPool)28 File (java.io.File)23 ProductSubscription (rhsm.data.ProductSubscription)23 ProductCert (rhsm.data.ProductCert)22 JSONObject (org.json.JSONObject)20 EntitlementCert (rhsm.data.EntitlementCert)16 InstalledProduct (rhsm.data.InstalledProduct)14 BigInteger (java.math.BigInteger)13 List (java.util.List)12 ConsumerCert (rhsm.data.ConsumerCert)11 SyndFeed (com.sun.syndication.feed.synd.SyndFeed)10 Calendar (java.util.Calendar)10 HashMap (java.util.HashMap)10