Search in sources :

Example 96 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class SubscriptionManagerTasks method isRhnSystemIdRegistered.

public boolean isRhnSystemIdRegistered(String rhnUsername, String rhnPassword, String rhnHostname, String systemId) {
    String serverUrl = rhnHostname;
    if (!serverUrl.startsWith("http"))
        serverUrl = "https://" + serverUrl;
    String command = String.format("rhn-is-registered.py --username=%s --password=%s --serverurl=%s  %s", rhnUsername, rhnPassword, serverUrl, systemId);
    SSHCommandResult result = sshCommandRunner.runCommandAndWait(command);
    return Boolean.valueOf(result.getStdout().trim());
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult)

Example 97 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class SubscriptionManagerTasks method list.

public SSHCommandResult list(Boolean all, Boolean available, Boolean consumed, Boolean installed, String servicelevel, String ondate, Boolean matchInstalled, Boolean noOverlap, String matches, Boolean poolOnly, String proxy, String proxyuser, String proxypassword, String noproxy) {
    SSHCommandResult sshCommandResult = list_(all, available, consumed, installed, servicelevel, ondate, matchInstalled, noOverlap, matches, poolOnly, proxy, proxyuser, proxypassword, noproxy);
    // assert results...
    // assert the exit code was a success
    Assert.assertEquals(sshCommandResult.getExitCode(), Integer.valueOf(0), "The exit code from the list module indicates a success.");
    // from the list command
    return sshCommandResult;
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult)

Example 98 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class SubscriptionManagerTasks method getIPV4Address.

public String getIPV4Address() {
    // stopped working when we started using open stack instances of RHEL7
    String ipv4_address = ipaddr;
    // stopped working when we started using openstack instances of RHEL6
    ipv4_address = getFactValue("network.ipv4_address");
    // when client is an openstack instance, the ipv4_address is private and we need the public address when asserting the proxy logs
    // [root@rhel6-openstack-instance ~]# dmidecode --string system-product-name
    // OpenStack Compute
    // [root@rhel7-openstack-instance ~]# dmidecode --string system-product-name
    // RHEV Hypervisor
    String dmiSystemProduct_name = getFactValue("dmi.system.product_name");
    // if (dmiSystemProduct_name!=null && !dmiSystemProduct_name.equals("Not Specified")) {	// then this is likely an openstack instance		// WRONG, fails on SGI hardware which returns dmi.system.product_name: UV2000
    if ((redhatReleaseX.equals("6") && "OpenStack Compute".equals(dmiSystemProduct_name)) || (redhatReleaseX.equals("7") && "RHEV Hypervisor".equals(dmiSystemProduct_name))) {
        // then this is likely an openstack instance
        // will timeout on a non-openstack instance and then fail the exit code assert (probably with code 7)
        SSHCommandResult ipv4_addressResult = RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "curl --stderr /dev/null http://169.254.169.254/latest/meta-data/public-ipv4", 0);
        ipv4_address = ipv4_addressResult.getStdout().trim();
        Assert.assertMatch(ipv4_address, "\\d+\\.\\d+\\.\\d+\\.\\d+", "Validated format of ipv4 address '" + ipv4_address + "' detected from openstack curl query above.");
    }
    // some beaker systems (e.g. cloud-qe-05.idmqe.lab.eng.bos.redhat.com and tigger.idmqe.lab.eng.bos.redhat.com) started failing with a network.ipv4_address=127.0.0.1 which leads to test failures
    // Solution: https://github.com/martinp/ipd has been installed on auto-services.usersys.redhat.com:5555
    // [root@jsefler-rhel7 ~]# curl auto-services.usersys.redhat.com:5555
    // 10.16.7.221
    ipv4_address = "127.0.0.1";
    if (ipv4_address.equals("127.0.0.1")) {
        log.warning("This system could not determine it's own network.ipv4_address fact.  Assuming https://github.com/martinp/ipd is installed on " + SubscriptionManagerBaseTestScript.getProperty("sm.noauthproxy.hostname", "auto-services.usersys.redhat.comXX") + ":5555 to detect the ipaddress of this system.");
        ipv4_address = RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "curl --stderr /dev/null " + SubscriptionManagerBaseTestScript.getProperty("sm.noauthproxy.hostname", "auto-services.usersys.redhat.comXX") + ":5555", 0).getStdout().trim();
    }
    return ipv4_address;
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult)

Example 99 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class SubscriptionManagerTasks method yumConfigManagerEnableRepos.

public void yumConfigManagerEnableRepos(List<String> repos, String options) {
    // optional options like --disablerepo=beaker*
    if (options == null)
        options = "";
    String command = "yum-config-manager " + options + " --enable";
    for (String repo : repos) command += " " + repo;
    SSHCommandResult result = sshCommandRunner.runCommandAndWait(command);
    Assert.assertEquals(result.getExitCode(), Integer.valueOf(0), "ExitCode from command '" + command + "'.");
    if (this.isPackageVersion("subscription-manager", ">=", "1.20.1-1")) {
        // commit afbc7fd31a27c7eba26fe4b0cc6840228678bfa8	RFE Bug 1329349: Add subscription-manager plugin to yum-config-manager
        // FINE: ssh root@jsefler-rhel7.usersys.redhat.com yum-config-manager  --enable rhel-7-server-openstack-7.0-tools-source-rpms rhel-7-server-optional-beta-rpms
        // FINE: Stdout:
        // Loaded plugins: langpacks, product-id, subscription-manager
        // ============
        Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(result.getStdout(), "Loaded plugins: .*subscription-manager"), "yum-config-manager loaded plugins includes subscription-manager");
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult)

Example 100 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class SubscriptionManagerTasks method getYumRepolist.

/**
 * @param options [all|enabled|disabled] [--option=...]
 * @return array of repo labels returned from a call to yum repolist [options]
 */
public ArrayList<String> getYumRepolist(String options) {
    if (options == null)
        options = "";
    ArrayList<String> repoList = new ArrayList<String>();
    sshCommandRunner.runCommandAndWaitWithoutLogging("killall -9 yum");
    // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
    sshCommandRunner.runCommandAndWait("yum repolist " + options + " --disableplugin=rhnplugin");
    // TEMPORARY WORKAROUND FOR BUG
    if (this.redhatReleaseX.equals("5")) {
        boolean invokeWorkaroundWhileBugIsOpen = true;
        // Bug 697087 - yum repolist is not producing a list when one of the repo baseurl causes a forbidden 403
        String bugId = "697087";
        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) {
            // avoid "yum repolist" and assemble the list of repos directly from the redhat repo file
            List<YumRepo> yumRepoList = getCurrentlySubscribedYumRepos();
            for (YumRepo yumRepo : yumRepoList) {
                if (options.startsWith("all"))
                    repoList.add(yumRepo.id);
                else if (options.startsWith("enabled") && yumRepo.enabled.equals(Boolean.TRUE))
                    repoList.add(yumRepo.id);
                else if (options.startsWith("disabled") && yumRepo.enabled.equals(Boolean.FALSE))
                    repoList.add(yumRepo.id);
                else if (options.equals("") && yumRepo.enabled.equals(Boolean.TRUE))
                    repoList.add(yumRepo.id);
            }
            // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
            sshCommandRunner.runCommandAndWait("yum repolist " + options + " --disableplugin=rhnplugin");
            return repoList;
        }
    }
    // repolist: 9,497
    return getYumRepolistFromSSHCommandResult(new SSHCommandResult(sshCommandRunner.getExitCode(), sshCommandRunner.getStdout(), sshCommandRunner.getStderr()));
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) YumRepo(rhsm.data.YumRepo) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException)

Aggregations

SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)553 Test (org.testng.annotations.Test)416 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)401 SkipException (org.testng.SkipException)219 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)201 ArrayList (java.util.ArrayList)101 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)79 BigInteger (java.math.BigInteger)68 File (java.io.File)58 SubscriptionPool (rhsm.data.SubscriptionPool)53 JSONObject (org.json.JSONObject)47 HashMap (java.util.HashMap)42 ProductSubscription (rhsm.data.ProductSubscription)31 EntitlementCert (rhsm.data.EntitlementCert)30 List (java.util.List)21 YumRepo (rhsm.data.YumRepo)18 ProductCert (rhsm.data.ProductCert)17 Repo (rhsm.data.Repo)16 InstalledProduct (rhsm.data.InstalledProduct)15 Calendar (java.util.Calendar)13