You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2019/05/16 12:22:42 UTC

[ignite-teamcity-bot] branch ignite-11853 created (now 4c2977e)

This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a change to branch ignite-11853
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git.


      at 4c2977e  IGNITE-11853: Links fixed for tests failures, trusted suites development.

This branch includes the following new commits:

     new 4c2977e  IGNITE-11853: Links fixed for tests failures, trusted suites development.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[ignite-teamcity-bot] 01/01: IGNITE-11853: Links fixed for tests failures, trusted suites development.

Posted by dp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch ignite-11853
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git

commit 4c2977e31b5e712520b664225ae91e846512932f
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Thu May 16 15:22:39 2019 +0300

    IGNITE-11853: Links fixed for tests failures, trusted suites development.
---
 .../java/org/apache/ignite/ci/issue/Issue.java     |  3 +
 .../java/org/apache/ignite/ci/issue/IssueType.java | 31 ++++++++--
 .../tcbot/chain/TrackedBranchChainsProcessor.java  |  6 +-
 .../ignite/ci/tcbot/conf/ITcServerConfig.java      | 13 ++++-
 .../ignite/ci/tcbot/conf/TcServerConfig.java       | 11 ++++
 .../ignite/ci/tcbot/issue/IssueDetector.java       | 66 ++++++++++++++++------
 .../teamcity/ignited/ITeamcityIgnitedProvider.java |  2 +-
 .../ci/teamcity/ignited/runhist/RunHistSync.java   |  2 +-
 .../ci/web/model/current/SuiteCurrentStatus.java   |  2 +-
 9 files changed, 107 insertions(+), 29 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/issue/Issue.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/issue/Issue.java
index 2c492d2..dfed18d 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/issue/Issue.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/issue/Issue.java
@@ -55,7 +55,10 @@ public class Issue {
     @Nullable
     public String displayName;
 
+    /** Build start timestamp. */
     @Nullable public Long buildStartTs;
+
+    /** Detected timestamp. */
     @Nullable public Long detectedTs;
 
     public Issue(IssueKey issueKey, IssueType type) {
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/issue/IssueType.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/issue/IssueType.java
index 59fcb75..a690614 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/issue/IssueType.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/issue/IssueType.java
@@ -17,28 +17,49 @@
 
 package org.apache.ignite.ci.issue;
 
+/**
+ * Type of Issue detectable by the Bot.
+ */
 public enum IssueType {
+    /** New failure. */
     newFailure("newFailure", "New test failure"),
-    newContributedTestFailure("newContributedTestFailure",
-        "Recently contributed test failed"),
 
-    newFailureForFlakyTest("newFailureForFlakyTest",
-        "New stable failure of a flaky test"),
+    /** New contributed test failure. */
+    newContributedTestFailure("newContributedTestFailure", "Recently contributed test failed"),
+
+    /** New failure for flaky test. */
+    newFailureForFlakyTest("newFailureForFlakyTest", "New stable failure of a flaky test"),
+
+    /** New critical failure. */
+    newCriticalFailure("newCriticalFailure", "New Critical Failure"),
 
-    newCriticalFailure("newCriticalFailure", "New Critical Failure");
+    /** New trusted suite failure. */
+    newTrustedSuiteFailure("newTrustedSuiteFailure", "New Trusted Suite failure");
 
+    /** Code. */
     private final String code;
+    /** Display name. */
     private final String displayName;
 
+    /**
+     * @param code Code.
+     * @param displayName Display name.
+     */
     private IssueType(String code, String displayName) {
         this.code = code;
         this.displayName = displayName;
     }
 
+    /**
+     *
+     */
     public String code() {
         return code;
     }
 
+    /**
+     *
+     */
     public String displayName() {
         return displayName;
     }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/chain/TrackedBranchChainsProcessor.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/chain/TrackedBranchChainsProcessor.java
index c118411..4ce6e65 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/chain/TrackedBranchChainsProcessor.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/chain/TrackedBranchChainsProcessor.java
@@ -52,7 +52,7 @@ public class TrackedBranchChainsProcessor {
     @Inject private ITeamcityIgnitedProvider tcIgnitedProv;
 
     /** Tc Bot config. */
-    @Inject private ITcBotConfig tcBotConfig;
+    @Inject private ITcBotConfig tcBotCfg;
 
     /** Chains processor. */
     @Inject private BuildChainProcessor chainProc;
@@ -71,7 +71,7 @@ public class TrackedBranchChainsProcessor {
         final String branchNn = isNullOrEmpty(branch) ? TcServerConfig.DEFAULT_TRACKED_BRANCH_NAME : branch;
         res.setTrackedBranch(branchNn);
 
-        final BranchTracked tracked = tcBotConfig.getTrackedBranches().getBranchMandatory(branchNn);
+        final BranchTracked tracked = tcBotCfg.getTrackedBranches().getBranchMandatory(branchNn);
 
         tracked.chains.stream()
             .filter(chainTracked -> tcIgnitedProv.hasAccess(chainTracked.serverId, creds))
@@ -144,7 +144,7 @@ public class TrackedBranchChainsProcessor {
         FullLRTestsSummary summary = new FullLRTestsSummary();
 
         final String branchNn = isNullOrEmpty(branch) ? TcServerConfig.DEFAULT_TRACKED_BRANCH_NAME : branch;
-        final BranchTracked tracked = tcBotConfig.getTrackedBranches().getBranchMandatory(branchNn);
+        final BranchTracked tracked = tcBotCfg.getTrackedBranches().getBranchMandatory(branchNn);
 
         tracked.chains.stream()
             .filter(chainTracked -> tcIgnitedProv.hasAccess(chainTracked.serverId, creds))
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java
index a03b66e..e370501 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java
@@ -40,11 +40,22 @@ public interface ITcServerConfig {
     @NotNull public String logsDirectory();
 
     /**
-     * @return
+     * @return internal naming of default tracked branch for this server.
      */
     @NotNull public String defaultTrackedBranch();
 
+    /**
+     * @return set of build parameters codes, which could be used for filtering builds in RunHist/Invocations.
+     */
     @NotNull public Collection<String> filteringParametersKeys();
 
+    /**
+     * @return set of build parameters, which could be used for filtering builds in RunHist/Invocations.
+     */
     @NotNull public Collection<BuildParameterSpec> filteringParameters();
+
+    /**
+     * @return set of suite codes (build type IDs), failures in which should be threated as critical and notified.
+     */
+    @NotNull public Collection<String> trustedSuites();
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java
index a6660ac..0b2b8d8 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java
@@ -56,6 +56,9 @@ public class TcServerConfig implements ITcServerConfig {
     /** Build parameters which may be used for filtering. */
     @Nullable private List<BuildParameterSpec> filteringParameters = new ArrayList<>();
 
+    /** Trused suites. */
+    @Nullable private List<String> trusedSuites = new ArrayList<>();
+
     public TcServerConfig() {
 
     }
@@ -127,6 +130,14 @@ public class TcServerConfig implements ITcServerConfig {
         return Collections.unmodifiableList(filteringParameters);
     }
 
+    /** {@inheritDoc} */
+    @NotNull @Override public Collection<String> trustedSuites() {
+        if (trusedSuites == null || trusedSuites.isEmpty())
+            return Collections.emptySet();
+
+        return Collections.unmodifiableList(trusedSuites);
+    }
+
     /**
      * @param props Properties.
      */
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/issue/IssueDetector.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/issue/IssueDetector.java
index ed830fc..f74f43c 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/issue/IssueDetector.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/issue/IssueDetector.java
@@ -47,6 +47,7 @@ import org.apache.ignite.ci.mail.SlackSender;
 import org.apache.ignite.ci.tcbot.chain.TrackedBranchChainsProcessor;
 import org.apache.ignite.ci.tcbot.conf.INotificationChannel;
 import org.apache.ignite.ci.tcbot.conf.ITcBotConfig;
+import org.apache.ignite.ci.tcbot.conf.ITcServerConfig;
 import org.apache.ignite.ci.tcbot.conf.NotificationsConfig;
 import org.apache.ignite.ci.tcbot.user.IUserStorage;
 import org.apache.ignite.ci.teamcity.ignited.IRunHistory;
@@ -62,6 +63,7 @@ import org.apache.ignite.ci.web.model.current.ChainAtServerCurrentStatus;
 import org.apache.ignite.ci.web.model.current.SuiteCurrentStatus;
 import org.apache.ignite.ci.web.model.current.TestFailure;
 import org.apache.ignite.ci.web.model.current.TestFailuresSummary;
+import org.jetbrains.annotations.NotNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -242,7 +244,6 @@ public class IssueDetector {
             ITeamcityIgnited tcIgnited = tcProv.server(srvId, creds);
 
             for (SuiteCurrentStatus suiteCurrentStatus : next.suites) {
-
                 String normalizeBranch = normalizeBranch(suiteCurrentStatus.branchName());
 
                 final String trackedBranch = res.getTrackedBranch();
@@ -260,8 +261,17 @@ public class IssueDetector {
         return "New issues found " + newIssues;
     }
 
+    /**
+     * Checks and persists suites failure.
+     *
+     * @param tcIgnited Tc ignited.
+     * @param srvCode Server code.
+     * @param normalizeBranch Normalize branch.
+     * @param suiteFailure Suite failure.
+     * @param trackedBranch Tracked branch.
+     */
     private boolean registerSuiteFailIssues(ITeamcityIgnited tcIgnited,
-        String srvId,
+        String srvCode,
         String normalizeBranch,
         SuiteCurrentStatus suiteFailure,
         String trackedBranch) {
@@ -279,30 +289,52 @@ public class IssueDetector {
 
         Integer firstFailedBuildId = runStat.detectTemplate(EventTemplates.newCriticalFailure);
 
-        if (firstFailedBuildId != null && suiteFailure.hasCriticalProblem != null && suiteFailure.hasCriticalProblem) {
-            IssueKey issueKey = new IssueKey(srvId, firstFailedBuildId, suiteId);
+        if (firstFailedBuildId != null && Boolean.TRUE.equals(suiteFailure.hasCriticalProblem)) {
+            IssueKey issueKey = new IssueKey(srvCode, firstFailedBuildId, suiteId);
+
+            if (!issuesStorage.containsIssueKey(issueKey)) {
+                issuesStorage.saveIssue(createIssueForSuite(tcIgnited, suiteFailure, trackedBranch,
+                    issueKey, IssueType.newCriticalFailure));
 
-            if (issuesStorage.containsIssueKey(issueKey))
-                return false; //duplicate
+                issueFound = true;
+            }
+        }
 
-            Issue issue = new Issue(issueKey, IssueType.newCriticalFailure);
-            issue.trackedBranchName = trackedBranch;
-            issue.displayName = suiteFailure.name;
-            issue.webUrl = suiteFailure.webToHist;
-            issue.buildStartTs = tcIgnited.getBuildStartTs(issueKey.buildId);
+        ITcServerConfig tcCfg = cfg.getTeamcityConfig(srvCode);
 
-            locateChanges(tcIgnited, firstFailedBuildId, issue);
+        if (tcCfg.trustedSuites().contains(suiteId)) {
+            Integer firstTrustedSuiteFailue = runStat.detectTemplate(EventTemplates.newFailure);
 
-            logger.info("Register new issue for suite fail: " + issue);
+            if (firstTrustedSuiteFailue != null) {
+                IssueKey issueKey = new IssueKey(srvCode, firstTrustedSuiteFailue, suiteId);
 
-            issuesStorage.saveIssue(issue);
+                if (!issuesStorage.containsIssueKey(issueKey)) {
+                    issuesStorage.saveIssue(createIssueForSuite(tcIgnited, suiteFailure, trackedBranch,
+                        issueKey, IssueType.newTrustedSuiteFailure));
 
-            issueFound = true;
+                    issueFound = true;
+                }
+            }
         }
 
         return issueFound;
     }
 
+    @NotNull
+    private Issue createIssueForSuite(ITeamcityIgnited tcIgnited, SuiteCurrentStatus suiteFailure, String trackedBranch,
+        IssueKey issueKey, IssueType issType) {
+        Issue issue = new Issue(issueKey, issType);
+        issue.trackedBranchName = trackedBranch;
+        issue.displayName = suiteFailure.name;
+        issue.webUrl = suiteFailure.webToHist;
+        issue.buildStartTs = tcIgnited.getBuildStartTs(issueKey.buildId);
+
+        locateChanges(tcIgnited, issueKey.buildId, issue);
+
+        logger.info("Register new issue for suite fail: " + issue);
+        return issue;
+    }
+
     private void locateChanges(ITeamcityIgnited teamcity, int buildId, Issue issue) {
         final FatBuildCompacted fatBuild = teamcity.getFatBuild(buildId);
         final int[] changes = fatBuild.changes();
@@ -460,9 +492,9 @@ public class IssueDetector {
                 SyncMode.RELOAD_QUEUED
             );
 
-        String issResult = registerIssuesAndNotifyLater(failures, backgroundOpsCreds);
+        String issRes = registerIssuesAndNotifyLater(failures, backgroundOpsCreds);
 
-        return "Tests " + failures.failedTests + " Suites " + failures.failedToFinish + " were checked. " + issResult;
+        return "Tests " + failures.failedTests + " Suites " + failures.failedToFinish + " were checked. " + issRes;
     }
 
     public void stop() {
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnitedProvider.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnitedProvider.java
index 24e2a19..f4c5920 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnitedProvider.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnitedProvider.java
@@ -32,7 +32,7 @@ public interface ITeamcityIgnitedProvider {
      */
     public ITeamcityIgnited server(String srvCode, @Nullable ICredentialsProv prov);
 
-    default void checkAccess(@Nullable String srvCode, ICredentialsProv credsProv) {
+    public default void checkAccess(@Nullable String srvCode, ICredentialsProv credsProv) {
         if (!hasAccess(srvCode, credsProv))
             throw ServiceUnauthorizedException.noCreds(srvCode);
     }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/runhist/RunHistSync.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/runhist/RunHistSync.java
index b0662cd..f733b9a 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/runhist/RunHistSync.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/runhist/RunHistSync.java
@@ -90,7 +90,7 @@ public class RunHistSync {
         if (ITeamcity.REFS_HEADS_MASTER.equals(branch))
             return ITeamcity.DEFAULT;
 
-        if ("master".equals(branch))
+        if (ITeamcity.MASTER.equals(branch))
             return ITeamcity.DEFAULT;
 
         return branch;
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/current/SuiteCurrentStatus.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/current/SuiteCurrentStatus.java
index 454f9dc..d8e0c61 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/current/SuiteCurrentStatus.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/current/SuiteCurrentStatus.java
@@ -333,7 +333,7 @@ import static org.apache.ignite.ci.util.UrlUtil.escape;
     }
 
     public static String branchForLink(@Nullable String branchName) {
-        return branchName == null || "refs/heads/master".equals(branchName) ? ITeamcity.DEFAULT : branchName;
+        return normalizeBranch(branchName);
     }
 
     /** {@inheritDoc} */