Search in sources :

Example 6 with SimpleIssue

use of io.syndesis.qe.issue.SimpleIssue in project syndesis-qe by syndesisio.

the class IssueHooks method skipTestsWithOpenIssues.

/**
 * This hook skips tests that have open github and ENTESB jira issues
 * <p>
 * Only runs when {@link TestConfiguration#SKIP_TESTS_WITH_OPEN_ISSUES} property is set to true
 *
 * @param scenario scenario
 */
@Before
public void skipTestsWithOpenIssues(Scenario scenario) {
    if (TestConfiguration.skipTestsWithOpenIssues()) {
        log.info(scenario.getName());
        if (scenario.getSourceTagNames().contains("@notIgnoreOpenIssue")) {
            return;
        }
        List<SimpleIssue> issues = getAllIssues(scenario);
        for (SimpleIssue issue : issues) {
            // assumeFalse will skip the test if the argument evaluates to true, i.e. when the issue is open
            Assumptions.assumeThat(issue.getState()).isNotEqualTo(IssueState.OPEN);
        }
    }
}
Also used : SimpleIssue(io.syndesis.qe.issue.SimpleIssue) Before(io.cucumber.java.Before)

Example 7 with SimpleIssue

use of io.syndesis.qe.issue.SimpleIssue in project syndesis-qe by syndesisio.

the class IssueHooks method logIssues.

private static void logIssues(Scenario scenario, List<SimpleIssue> issues) {
    for (SimpleIssue issue : issues) {
        IssueHooksUtils.logError(scenario, "#### Title: " + issue.getIssueSummary());
        IssueHooksUtils.logError(scenario, "#### Link: " + issue.getUrl());
        IssueHooksUtils.logError(scenario, "----------------------------------------");
    }
}
Also used : SimpleIssue(io.syndesis.qe.issue.SimpleIssue)

Example 8 with SimpleIssue

use of io.syndesis.qe.issue.SimpleIssue in project syndesis-qe by syndesisio.

the class IssueHooks method checkIssues.

/**
 * This hook checks and reports status of linked github and ENTESB Jira issues.
 * <p>
 * Each failed scenario is checked if it contains a tag in the form @gh-&lt;issue-number&gt; or @ENTESB-&lt;issue-number&gt;.
 * If it does, Jira or GitHub and ZenHub are queried for the status of each issue and a summary is written into log and cucumber report.
 * <p>
 * For the purposes of this report, the following issue states are recognized:
 * <ol>
 * <li>Open - an issue that was reported and not yet fixed</li>
 * <li>Done - an issue that was reported and supposedly fixed</li>
 * <li>Closed - and issue that was fixed and verified by QE</li>
 * </ol>
 * <p>
 * <p>
 * No effort is made to reason about the impact of the found issues (e.g. is it ok that a test fails if there's one open and one done issue?).
 * Also, this hook completely ignores passed tests (i.e. nothing happens when a tests with open issues passes).
 *
 * @param scenario scenario
 */
@After
public void checkIssues(Scenario scenario) {
    if (!scenario.isFailed()) {
        return;
    }
    List<SimpleIssue> issues = getAllIssues(scenario);
    if (issues.isEmpty()) {
        IssueHooksUtils.logError(scenario, "############ No GitHub or Jira issue annotations found ############");
        return;
    }
    try {
        List<SimpleIssue> openIssues = new ArrayList<>();
        List<SimpleIssue> doneIssues = new ArrayList<>();
        List<SimpleIssue> closedIssues = new ArrayList<>();
        for (SimpleIssue issue : issues) {
            switch(issue.getState()) {
                case DONE:
                    doneIssues.add(issue);
                    break;
                case OPEN:
                    openIssues.add(issue);
                    break;
                case CLOSED:
                    closedIssues.add(issue);
                    break;
            }
        }
        IssueHooksUtils.logError(scenario, "############ FAILED PROBABLY DUE TO: ################");
        IssueHooksUtils.logError(scenario, "######## DONE issues ########");
        IssueHooks.logIssues(scenario, doneIssues);
        IssueHooksUtils.logError(scenario, "######## CLOSED issues ########");
        IssueHooks.logIssues(scenario, closedIssues);
        IssueHooksUtils.logError(scenario, "######## OPEN issues ########");
        IssueHooks.logIssues(scenario, openIssues);
        embedIssues(scenario, issues);
    } catch (Exception e) {
        log.error("Error while processing GH & Jira issues", e);
        scenario.attach("Error while processing GH & Jira issues".getBytes(), "text/plain", "ErrorMessage");
        e.printStackTrace();
    }
}
Also used : SimpleIssue(io.syndesis.qe.issue.SimpleIssue) ArrayList(java.util.ArrayList) IOException(java.io.IOException) After(io.cucumber.java.After)

Example 9 with SimpleIssue

use of io.syndesis.qe.issue.SimpleIssue in project syndesis-qe by syndesisio.

the class MailFormatter method reportOpenIssues.

private void reportOpenIssues() {
    List<SimpleIssue> allOpenIssues = new ArrayList<>();
    results.forEach(scenarioResult -> {
        if (scenarioResult.getIssues() != null) {
            scenarioResult.getIssues().forEach(issue -> {
                if (IssueState.OPEN == issue.getState()) {
                    allOpenIssues.add(issue);
                }
            });
        }
    });
    if (allOpenIssues.isEmpty()) {
        return;
    }
    try (FileWriter out = new FileWriter(new File(path, "issues.html"))) {
        for (SimpleIssue issue : allOpenIssues) {
            out.write(String.format("%s - %s\n", issue.toLink(), issue.getIssueSummary()));
        }
    } catch (IOException e) {
        log.error("Error writing issues report file", e);
    }
}
Also used : SimpleIssue(io.syndesis.qe.issue.SimpleIssue) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File)

Aggregations

SimpleIssue (io.syndesis.qe.issue.SimpleIssue)9 ArrayList (java.util.ArrayList)4 IOException (java.io.IOException)3 IssueRestClient (com.atlassian.jira.rest.client.api.IssueRestClient)1 JiraRestClient (com.atlassian.jira.rest.client.api.JiraRestClient)1 RestClientException (com.atlassian.jira.rest.client.api.RestClientException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 After (io.cucumber.java.After)1 Before (io.cucumber.java.Before)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 StringWriter (java.io.StringWriter)1 Issue (org.eclipse.egit.github.core.Issue)1 Repository (org.eclipse.egit.github.core.Repository)1 GitHubClient (org.eclipse.egit.github.core.client.GitHubClient)1 IssueService (org.eclipse.egit.github.core.service.IssueService)1 RepositoryService (org.eclipse.egit.github.core.service.RepositoryService)1