Search in sources :

Example 21 with BugzillaAPIException

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

the class BashCompletionTests method testBashCompletion.

// Test Methods ***********************************************************************
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19942", "RHEL7-68140" }, 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 = "when subscription-manager is run with no args, it should default to the help report", groups = { "Tier1Tests" }, dataProvider = "BashCompletionData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testBashCompletion(Object bugzilla, String bashCommand, Set<String> expectedCompletions) {
    // inspired by https://github.com/lacostej/unity3d-bash-completion/blob/master/lib/completion.py
    List<String> program_args = Arrays.asList(bashCommand.split("\\s+"));
    String program = program_args.get(0);
    List<String> args = program_args.subList(1, program_args.size());
    String COMP_LINE = bashCommand;
    String COMP_WORDS = COMP_LINE.trim();
    Integer COMP_CWORD = args.size();
    Integer COMP_POINT = COMP_LINE.length();
    if (COMP_LINE.endsWith(" ")) {
        COMP_WORDS += " ";
        COMP_CWORD += 1;
    }
    // String script = "bash -i -c 'COMP_LINE=\"subscription-manager attach --\" COMP_WORDS=(subscription-manager attach --) COMP_CWORD=2 COMP_POINT=30; $(complete -p subscription-manager | sed \"s/.*-F \\([^ ]*\\) .*/\\1/\") && echo ${COMPREPLY[*]}'";
    String script = String.format("bash -i -c 'COMP_LINE=\"%s\" COMP_WORDS=(%s) COMP_CWORD=%d COMP_POINT=%d; $(complete -p %s | sed \"s/.*-F \\([^ ]*\\) .*/\\1/\") && echo ${COMPREPLY[*]}'", COMP_LINE, COMP_WORDS, COMP_CWORD, COMP_POINT, program);
    SSHCommandResult result = client.runCommandAndWait(script);
    // IGNORE: Stderr:
    // bash: cannot set terminal process group (-1): Invalid argument
    // bash: no job control in this shell
    log.info(result.toString());
    Set<String> actualCompletions = new HashSet<String>(Arrays.asList(result.getStdout().trim().split("\\s+")));
    // assert all of the expectedOptions were found and that no unexpectedOptions were found
    for (String expectedCompletion : expectedCompletions) {
        if (!actualCompletions.contains(expectedCompletion)) {
            log.warning("Was not presented with the expected bash-completion '" + expectedCompletion + "' for command '" + bashCommand + "'.");
        } else {
            Assert.assertTrue(actualCompletions.contains(expectedCompletion), "The expected command '" + bashCommand + "' option '" + expectedCompletion + "' is available.");
        }
    }
    for (String actualCompletion : actualCompletions) {
        if (!expectedCompletions.contains(actualCompletion))
            log.warning("Was presented with an unexpected bash-completion '" + actualCompletion + "' for command '" + bashCommand + "'.");
    }
    // PERMANENT WORKAROUND FOR CLOSED/WONTFIX Bug 1004402 - rhsmd and rhsmcertd-worker does not bash complete its options
    if ((bashCommand.startsWith("/usr/libexec/rhsmcertd-worker ") || bashCommand.startsWith("/usr/libexec/rhsmd ")) && !actualCompletions.containsAll(expectedCompletions)) {
        String bugId = "1004402";
        try {
            if (!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 {
            }
        } catch (BugzillaAPIException be) {
        /* ignore exception */
        } catch (RuntimeException re) {
        /* ignore exception */
        }
        throw new SkipException("Bash completion for '" + bashCommand + "' is broken and bug '" + bugId + "' was CLOSED/WONTFIX.");
    }
    // PERMANENT WORKAROUND
    if ((bashCommand.equals("rct stat-cert -")) && actualCompletions.contains("--no-content") && !expectedCompletions.contains("--no-content")) {
        if (clienttasks.isPackageVersion("subscription-manager", "<", "1.18.2-1")) {
            // commit ac70fc3a50e172030c042bd5f18d78256c56470c // 1374389: rm --no-content from stat-cert completion
            throw new SkipException("Bash completion for '" + bashCommand + "' is broken in this version of subscription-manager '" + clienttasks.installedPackageVersionMap.get("subscription-manager") + "' and was not fixed until subscription-manager-1.18.2-1 by Bug 1374389.");
        }
    }
    // END OF WORKAROUND
    Assert.assertTrue(actualCompletions.containsAll(expectedCompletions), "All of the expected bash-completions for command '" + bashCommand + "' were presented.");
    Assert.assertTrue(expectedCompletions.containsAll(actualCompletions), "All of the presented bash-completions for command '" + bashCommand + "' were expected.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) HashSet(java.util.HashSet) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 22 with BugzillaAPIException

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

the class BugzillaTests method testBindAndUnbindInSyslog.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21940", "RHEL7-51802" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "verify that bind and unbind event is recorded in syslog", groups = { "Tier3Tests", "VerifyBindAndUnbindInSyslog", "blockedByBug-919700" }, enabled = true)
@ImplementsNitrateTest(caseId = 68740)
public void testBindAndUnbindInSyslog() throws JSONException, Exception {
    clienttasks.clean();
    // clienttasks.unregister(null, null, null, null);
    String logMarker, expectedSyslogMessage, tailFromSyslogFile;
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    logMarker = System.currentTimeMillis() + " Testing Subscribe **********************";
    RemoteFileTasks.markFile(client, clienttasks.messagesLogFile, logMarker);
    List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    List<String> poolIds = new ArrayList<String>();
    for (SubscriptionPool pool : pools) poolIds.add(pool.poolId);
    clienttasks.subscribe(null, null, poolIds, null, null, null, null, null, null, null, null, null, null);
    tailFromSyslogFile = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.messagesLogFile, logMarker, null);
    for (SubscriptionPool pool : pools) {
        expectedSyslogMessage = String.format("%s: Added subscription for '%s' contract '%s'", clienttasks.command, pool.subscriptionName, pool.contract.isEmpty() ? "None" : pool.contract);
        Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After subscribing to '" + pool.subscriptionName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        for (String providedProduct : pool.provides) {
            // https://bugzilla.redhat.com/show_bug.cgi?id=1016300
            if (providedProduct.equals("Awesome OS Server Bundled")) {
                boolean invokeWorkaroundWhileBugIsOpen = true;
                String bugId = "1016300";
                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 the provided MKT product '" + providedProduct + "'.  No syslog assertion for this product will be made.");
                    continue;
                }
            }
            // END OF WORKAROUND
            expectedSyslogMessage = String.format("%s: Added subscription for product '%s'", clienttasks.command, providedProduct);
            Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After subscribing to '" + pool.subscriptionName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        }
    }
    logMarker = System.currentTimeMillis() + " Testing Unsubscribe **********************";
    RemoteFileTasks.markFile(client, clienttasks.messagesLogFile, logMarker);
    List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    tailFromSyslogFile = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.messagesLogFile, logMarker, null);
    for (ProductSubscription productSubscription : productSubscriptions) {
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for 'Awesome OS Server Bundled (2 Sockets, Standard
        // Support)' contract '3'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Clustering Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Awesome OS Server Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Load Balancing Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Large File Support Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Shared Storage Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Management Bits'
        expectedSyslogMessage = String.format("%s: Removed subscription for '%s' contract '%s'", clienttasks.command, productSubscription.productName, // Note
        productSubscription.contractNumber == null ? "None" : productSubscription.contractNumber);
        // that
        // a
        // null/missing
        // contract
        // will
        // be
        // reported
        // as
        // None.
        // Seems
        // reasonable.
        Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After unsubscribing from '" + productSubscription.productName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        for (String providedProduct : productSubscription.provides) {
            expectedSyslogMessage = String.format("%s: Removed subscription for product '%s'", clienttasks.command, providedProduct);
            Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After unsubscribing from '" + productSubscription.productName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) SubscriptionPool(rhsm.data.SubscriptionPool) 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 23 with BugzillaAPIException

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

the class SubscriptionManagerTasks method getCurrentRhelProductCert.

/**
 * @return the currently installed ProductCert that provides a known base RHEL OS tag "rhel-5", "rhel-6", "rhel-7", "rhel-alt-7", etc.
 * Also asserts that at most only one RHEL product cert is installed; returns null if not found
 */
public ProductCert getCurrentRhelProductCert() {
    // get the current base RHEL product cert that provides a predictable tag
    String providingTag;
    // consider the major rhel version tags
    // Product:
    // ID: 69
    // Name: Red Hat Enterprise Linux 6 Server
    // Version: 6.1
    // Arch: i386
    // Tags: rhel-6,rhel-6-server
    // Brand Type:
    // Brand Name:
    providingTag = "rhel-" + redhatReleaseX;
    // also consider rhel-5-client-workstation tag
    // Product:
    // ID: 71
    // Name: Red Hat Enterprise Linux Workstation
    // Version: 5.10
    // Arch: i386
    // Tags: rhel-5-client-workstation,rhel-5-workstation
    providingTag += "|" + "rhel-5-client-workstation";
    // also consider tags used for rhel 7 beta
    // [root@ibm-p8-kvm-09-guest-08 rhel-7.0-beta]# for f in $(ls *.pem); do rct cat-cert $f | egrep -A7 'Product:'; done;
    // Product:
    // ID: 227
    // Name: Red Hat Enterprise Linux 7 for IBM POWER Public Beta
    // Version: 7.0 Beta
    // Arch: ppc64
    // Tags: rhel-7-ibm-power-everything
    // Brand Type:
    // Brand Name:
    // Product:
    // ID: 228
    // Name: Red Hat Enterprise Linux 7 for IBM System z Public Beta
    // Version: 7.0 Beta
    // Arch: s390x
    // Tags: rhel-7-ibm-system-z-everything
    // Brand Type:
    // Brand Name:
    // Product:
    // ID: 226
    // Name: Red Hat Enterprise Linux 7 Public Beta
    // Version: 7.0 Beta
    // Arch: x86_64
    // Tags: rhel-7-everything
    // Brand Type:
    // Brand Name:
    providingTag += "|" + "rhel-7-.*everything";
    // also consider tags used for rhelsa-dp Development Preview
    // [root@ibm-p8-kvm-09-guest-08 rhelsa-dp]# for f in $(ls *.pem); do rct cat-cert $f | egrep -A7 'Product:'; done;
    // Product:
    // ID: 261
    // Name: Red Hat Enterprise Linux Server for ARM Development Preview
    // Version: Snapshot
    // Arch: aarch64
    // Tags: rhsa-dp-server,rhsa-dp-server-7
    // Brand Type:
    // Brand Name:
    providingTag += "|" + "rhelsa-dp-.+";
    // also consider tags used for rhel-alt
    // [root@ibm-p8-kvm-09-guest-08 tmp]# git clone git://git.host.prod.eng.bos.redhat.com/rcm/rcm-metadata.git
    // [root@ibm-p8-kvm-09-guest-08 tmp]# cd rcm-metadata/product_ids/rhel-alt-7.4/
    // [root@ibm-p8-kvm-09-guest-08 rhel-alt-7.4]# for f in $(ls *.pem); do rct cat-cert $f | egrep -A7 'Product:'; done;
    // Product:
    // ID: 419
    // Name: Red Hat Enterprise Linux for ARM 64
    // Version: 7.4
    // Arch: aarch64
    // Tags: rhel-alt-7,rhel-alt-7-armv8-a
    // Brand Type:
    // Brand Name:
    // Product:
    // ID: 420
    // Name: Red Hat Enterprise Linux for Power 9
    // Version: 7.4
    // Arch: ppc64le
    // Tags: rhel-alt-7,rhel-alt-7-power9
    // Brand Type:
    // Brand Name:
    providingTag += "|" + "rhel-alt-" + redhatReleaseX;
    // also consider tags used for rhel-htb High Touch Beta
    // [root@dell-pem610-01 tmp]# git clone git://git.host.prod.eng.bos.redhat.com/rcm/rcm-metadata.git
    // [root@dell-pem610-01 tmp]# cd rcm-metadata/product_ids/rhel-7.5-htb/
    // [root@dell-pem610-01 rhel-7.5-htb]# for f in $(ls *.pem); do rct cat-cert $f | egrep -A7 'Product:'; done;
    // Product:
    // ID: 230
    // Name: Red Hat Enterprise Linux 7 Server High Touch Beta
    // Version: 7.5 Beta					// Ref Bug 1538957 - product-default .pem files do not contain expected data
    // Arch: x86_64
    // Tags: rhel-7-htb,rhel-7-server
    // Brand Type:
    // Brand Name:
    // Product:
    // ID: 231
    // Name: Red Hat Enterprise Linux 7 Workstation High Touch Beta
    // Version: 7.5 Beta					// Ref Bug 1538957 - product-default .pem files do not contain expected data
    // Arch: x86_64
    // Tags: rhel-7-htb,rhel-7-workstation
    // Brand Type:
    // Brand Name:
    providingTag += "|" + "rhel-" + redhatReleaseX + "-htb";
    // get the product certs matching the rhel regex tag
    List<ProductCert> rhelProductCerts = getCurrentProductCerts(providingTag);
    // by a rhel product cert in /etc/pki/product, otherwise the subsequent asserts will fail
    for (ProductCert productDefaultCert : getProductCerts(productCertDefaultDir)) {
        if (ProductCert.findAllInstancesWithCaseInsensitiveMatchingFieldFromList("productId", productDefaultCert.productId, rhelProductCerts).size() >= 2) {
            rhelProductCerts.remove(productDefaultCert);
        }
    }
    // log a warning when more than one product cert providing tag rhel-X is installed
    if (rhelProductCerts.size() > 1)
        log.warning("These " + rhelProductCerts.size() + " RHEL tagged '" + providingTag + "' product certs are installed: " + rhelProductCerts);
    // TEMPORARY WORKAROUND
    if (rhelProductCerts.size() > 1) {
        boolean invokeWorkaroundWhileBugIsOpen = true;
        // Bug 1506271 - redhat-release is providing more than 1 variant specific product cert
        String bugId = "1506271";
        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("The remainder of this test is blocked by bug '" + bugId + "' because multiple base RHEL product certs are installed.");
        }
    }
    // END OF WORKAROUND
    // assert that only one rhel product cert is installed (after purging HTB and an untrumped product-default cert)
    Assert.assertEquals(rhelProductCerts.size(), 1, "Only one product cert is installed that provides RHEL tag '" + providingTag + "' (this assert tolerates /etc/pki/product-default/ certs that are trumped by /etc/pki/product/ certs)");
    // return it
    if (rhelProductCerts.isEmpty())
        return null;
    return rhelProductCerts.get(0);
}
Also used : ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException)

Example 24 with BugzillaAPIException

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

the class SubscriptionManagerTasks method getCurrentEntitlementCertFiles.

/**
 * @param lsOptions - options used when calling ls to populate the order of the returned List (man ls for more info)
 * <br>Possibilities:
 * <br>"" no sort order preferred
 * <br>"-t" sort by modification time
 * <br>"-v" natural sort of (version) numbers within text
 * @return List of /etc/pki/entitlement/*.pem files sorted using lsOptions (excluding a key.pem file)
 */
public List<File> getCurrentEntitlementCertFiles(String lsOptions) {
    List<File> files = new ArrayList<File>();
    if (entitlementCertDir == null) {
        log.warning("The entitlementCertDir has not yet been defined.");
        return files;
    }
    if (lsOptions == null)
        lsOptions = "";
    // sshCommandRunner.runCommandAndWait("find /etc/pki/entitlement/ -name '*.pem'");
    // sshCommandRunner.runCommandAndWait("ls -1 "+lsOptions+" "+entitlementCertDir+"/*.pem");
    sshCommandRunner.runCommandAndWait("ls -1 " + lsOptions + " " + entitlementCertDir + "/*.pem | grep -v key.pem");
    String lsFiles = sshCommandRunner.getStdout().trim();
    if (!lsFiles.isEmpty()) {
        for (String lsFile : Arrays.asList(lsFiles.split("\n"))) {
            // exclude the the key.pem file
            if (lsFile.endsWith("key.pem"))
                continue;
            // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=640338 - jsefler 10/7/2010
            if (lsFile.matches(".*\\(\\d+\\)\\.pem")) {
                boolean invokeWorkaroundWhileBugIsOpen = true;
                String bugId = "640338";
                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) {
                    continue;
                }
            }
            // END OF WORKAROUND
            files.add(new File(lsFile));
        }
    }
    return files;
}
Also used : ArrayList(java.util.ArrayList) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) File(java.io.File)

Example 25 with BugzillaAPIException

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

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