Search in sources :

Example 6 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition 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 TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class ServiceLevelTests method testAutoSubscribeAgainAssertingServiceLevelIsPersisted.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21861", "RHEL7-51724" }, 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: after autosubscribing with a service level, assert that another autosubscribe (without specifying service level) uses the service level persisted from the first sutosubscribe", groups = { "Tier3Tests", "blockedByBug-859652", "blockedByBug-977321" }, dependsOnMethods = {}, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testAutoSubscribeAgainAssertingServiceLevelIsPersisted() throws JSONException, Exception {
    // Reference: https://engineering.redhat.com/trac/Entitlement/wiki/SlaSubscribe
    // get all the valid service levels available to this org
    List<String> serviceLevelsExpected = CandlepinTasks.getServiceLevelsForOrgKey(/*sm_serverAdminUsername*/
    sm_clientUsername, /*sm_serverAdminPassword*/
    sm_clientPassword, sm_serverUrl, sm_clientOrg);
    String serviceLevel = serviceLevelsExpected.get(randomGenerator.nextInt(serviceLevelsExpected.size()));
    // clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, serviceLevel, null, (String)null, null, false, null, null, null);
    testAutoSubscribeWithServiceLevel(null, serviceLevel);
    // return all entitlements
    clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    // autosubscribe again without specifying a service level
    clienttasks.subscribe(true, null, (String) null, (String) null, (String) null, null, null, null, null, null, null, null, null);
    // get the current consumer object and assert that the serviceLevel persisted even though the subscribe did NOT specify a service level
    Assert.assertEquals(clienttasks.getCurrentServiceLevel(), serviceLevel, "The call to subscribe with auto (without specifying a servicelevel) did not alter current servicelevel.");
    // assert that each of the autosubscribed entitlements come from a pool that supports the original service level
    for (EntitlementCert entitlementCert : clienttasks.getCurrentEntitlementCerts()) {
        // tolerate entitlements granted from pools with null/no support_level regardless of the specified service level
        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 (entitlementCert.orderNamespace.supportLevel == null || entitlementCert.orderNamespace.supportLevel.isEmpty()) {
                log.warning("Regardless of the consumer's original service level '" + serviceLevel + "', this EntitlementCert provides a support_level of '" + entitlementCert.orderNamespace.supportLevel + "'. (New behavior modification from Bug 1223560)");
                continue;
            }
        }
        // tolerate exemptServiceLevels
        if (sm_exemptServiceLevelsInUpperCase.contains(entitlementCert.orderNamespace.supportLevel.toUpperCase())) {
            log.warning("Regardless of the consumer's original service level '" + serviceLevel + "', this EntitlementCert provides an exempt service level '" + entitlementCert.orderNamespace.supportLevel + "'.");
            continue;
        }
        // CASE SENSITIVE ASSERTION Assert.assertEquals(entitlementCert.orderNamespace.supportLevel, serviceLevel,"This autosubscribed EntitlementCert was filled from a subscription order that provides the original service level '"+serviceLevel+"': "+entitlementCert.orderNamespace);
        Assert.assertTrue(entitlementCert.orderNamespace.supportLevel.equalsIgnoreCase(serviceLevel), "Ignoring case, this autosubscribed EntitlementCert was filled from a subscription order that provides the original service level '" + serviceLevel + "': " + entitlementCert.orderNamespace);
    }
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 8 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition 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.");
}
Also used : BigInteger(java.math.BigInteger) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 9 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class ServiceLevelTests method testRegisterWithAvailableServiceLevel.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19991", "RHEL7-51023" }, 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 service level; assert the entitlements granted match the requested service level", groups = { "Tier1Tests", "blockedByBug-859652", "blockedByBug-919700" }, // dataProvider="getAllAvailableServiceLevelData",	// 06/05/2014 takes too long; rarely reveals a bug
dataProvider = "getRandomSubsetOfAllAvailableServiceLevelData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRegisterWithAvailableServiceLevel(Object bugzilla, String serviceLevel) throws JSONException, Exception {
    // Reference: https://engineering.redhat.com/trac/Entitlement/wiki/SlaSubscribe
    // register with autosubscribe specifying a valid service level
    String consumerId = clienttasks.getCurrentConsumerId(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));
    // get the current consumer object and assert that the serviceLevel persisted
    JSONObject jsonConsumer = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/consumers/" + consumerId));
    Assert.assertEquals(jsonConsumer.get("serviceLevel"), serviceLevel, "The call to register with autosubscribe and a servicelevel persisted the servicelevel setting on the current consumer object.");
    // assert that each of the autosubscribed entitlements come from a pool that supports the specified service level
    clienttasks.listConsumedProductSubscriptions();
    for (EntitlementCert entitlementCert : clienttasks.getCurrentEntitlementCerts()) {
        // tolerate entitlements granted from pools with null/"" support_level regardless of the specified service level
        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 (entitlementCert.orderNamespace.supportLevel == null || entitlementCert.orderNamespace.supportLevel.isEmpty()) {
                log.warning("Regardless of the consumer's service-level preference '" + jsonConsumer.get("serviceLevel") + "' or the requested service-level '" + serviceLevel + "', this EntitlementCert provides a support_level of '" + entitlementCert.orderNamespace.supportLevel + "'. (New behavior modification from Bug 1223560)");
                continue;
            }
        }
        if (sm_exemptServiceLevelsInUpperCase.contains(entitlementCert.orderNamespace.supportLevel.toUpperCase())) {
            log.warning("After autosubscribed registration with service level '" + serviceLevel + "', this autosubscribed entitlement provides an exempt service level '" + entitlementCert.orderNamespace.supportLevel + "' from entitled orderNamespace: " + entitlementCert.orderNamespace);
        } else {
            // CASE SENSITIVE ASSERTION Assert.assertEquals(entitlementCert.orderNamespace.supportLevel, serviceLevel,"This autosubscribed entitlement provides the requested service level '"+serviceLevel+"' from entitled orderNamespace: "+entitlementCert.orderNamespace);
            Assert.assertTrue(entitlementCert.orderNamespace.supportLevel.equalsIgnoreCase(serviceLevel), "Ignoring case, this autosubscribed entitlement provides the requested service level '" + serviceLevel + "' from entitled orderNamespace: " + entitlementCert.orderNamespace);
        }
    }
}
Also used : JSONObject(org.json.JSONObject) EntitlementCert(rhsm.data.EntitlementCert) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 10 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class ServiceLevelTests method testServiceLevelListWithInvalidOrg.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21865", "RHEL7-51721" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "subscription-manager: service-level --list (with invalid org)", groups = { "Tier3Tests", "blockedByBug-796468", "blockedByBug-815479", "blockedByBug-1256960", /*is a duplicate of*/
"blockedByBug-1254349" }, enabled = true)
@ImplementsNitrateTest(caseId = 165509)
public void testServiceLevelListWithInvalidOrg() {
    String x = String.valueOf(getRandInt());
    SSHCommandResult result;
    // test while unregistered
    clienttasks.unregister(null, null, null, null);
    result = clienttasks.service_level_(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg + x, null, null, null, null, null, null);
    if (sm_serverOld) {
        Assert.assertEquals(result.getStderr().trim(), "ERROR: The service-level command is not supported by the server.");
        throw new SkipException("Skipping this test since service-level is gracefully not supported when configured against an old candlepin server.");
    }
    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(result.getExitCode(), expectedExitCode, "ExitCode from service-level --list with invalid org");
    Assert.assertEquals(result.getStderr().trim(), String.format("Organization with id %s could not be found.", sm_clientOrg + x), "Stderr from service-level --list with invalid org");
    Assert.assertEquals(result.getStdout().trim(), "", "Stdout from service-level --list with invalid credentials");
    // test while registered
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, null, null, null, null, null, null);
    result = clienttasks.service_level_(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg + x, null, null, null, null, null, null);
    Assert.assertEquals(result.getExitCode(), expectedExitCode, "ExitCode from service-level --list with invalid org");
    Assert.assertEquals(result.getStderr().trim(), String.format("Organization with id %s could not be found.", sm_clientOrg + x), "Stderr from service-level --list with invalid org");
    Assert.assertEquals(result.getStdout().trim(), "", "Stdout from service-level --list with invalid credentials");
}
Also used : BigInteger(java.math.BigInteger) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) 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)

Aggregations

TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)687 Test (org.testng.annotations.Test)687 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)401 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)366 SkipException (org.testng.SkipException)328 ArrayList (java.util.ArrayList)144 SubscriptionPool (rhsm.data.SubscriptionPool)137 JSONObject (org.json.JSONObject)95 BigInteger (java.math.BigInteger)90 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)88 HashMap (java.util.HashMap)78 File (java.io.File)74 ProductSubscription (rhsm.data.ProductSubscription)72 InstalledProduct (rhsm.data.InstalledProduct)66 EntitlementCert (rhsm.data.EntitlementCert)58 ProductCert (rhsm.data.ProductCert)54 YumRepo (rhsm.data.YumRepo)34 Repo (rhsm.data.Repo)26 Calendar (java.util.Calendar)25 List (java.util.List)24