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

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


The following commit(s) were added to refs/heads/ignite-12010-1min by this push:
     new fc98574  IGNITE-12010: Consider newly contributed test as blocker if 
it runs more that 1 minute
fc98574 is described below

commit fc985745fb154ee9e2a2565ce4aea56dea9aa758
Author: Dmitriy Pavlov <[email protected]>
AuthorDate: Wed Jul 24 21:47:04 2019 +0300

    IGNITE-12010: Consider newly contributed test as blocker if it runs more 
that 1 minute
---
 .../tcbot/visa/TcBotTriggerAndSignOffService.java  | 22 ++----------
 ignite-tc-helper-web/src/main/webapp/pr.html       |  8 ++---
 .../ignite/tcbot/engine/chain/FullChainRunCtx.java |  8 ++++-
 .../ignite/tcbot/engine/chain/MultBuildRunCtx.java | 42 ++++++++++++----------
 .../tcbot/engine/chain/TestCompactedMult.java      | 29 ++++++++++++++-
 .../ignite/tcbot/engine/pr/PrChainsProcessor.java  | 36 +++++++++++--------
 .../apache/ignite/tcbot/engine/ui/DsChainUi.java   |  3 +-
 .../apache/ignite/tcbot/engine/ui/DsSuiteUi.java   | 11 +-----
 8 files changed, 88 insertions(+), 71 deletions(-)

diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
index 0ea1dbc..9917e6b 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
@@ -810,14 +810,7 @@ public class TcBotTriggerAndSignOffService {
                 return new Visa("JIRA wasn't commented - no finished builds to 
analyze." +
                     " Check builds availabiliy for branch: " + 
build.branchName + "/" + baseBranch);
 
-            blockers = suitesStatuses.stream()
-                .mapToInt(suite -> {
-                    if (suite.testFailures.isEmpty())
-                        return 1;
-
-                    return suite.testFailures.size();
-                })
-                .sum();
+            blockers = 
suitesStatuses.stream().mapToInt(DsSuiteUi::totalBlockers).sum();
 
             String comment = generateJiraComment(suitesStatuses, build.webUrl, 
buildTypeId, tcIgnited, blockers, build.branchName, baseBranch);
 
@@ -879,18 +872,7 @@ public class TcBotTriggerAndSignOffService {
                 else
                     res.append(jiraEscText(failure.name));
 
-                DsHistoryStatUi recent = failure.histBaseBranch.recent;
-
-                if (recent != null) {
-                    if (recent.failureRate != null) {
-                        res.append(" - ").append(recent.failureRate).append("% 
fails in last ")
-                            .append(recent.runs).append(" 
").append(jiraEscText(baseBranchDisp)).append(" runs.");
-                    }
-                    else if (recent.failures != null && recent.runs != null) {
-                        res.append(" - ").append(recent.failures).append(" 
fails / ")
-                            .append(recent.runs).append(" 
").append(jiraEscText(baseBranchDisp)).append(" runs.");
-                    }
-                }
+                res.append(" - ").append(jiraEscText(failure.blockerComment));
 
                 res.append("\\n");
 
diff --git a/ignite-tc-helper-web/src/main/webapp/pr.html 
b/ignite-tc-helper-web/src/main/webapp/pr.html
index e05a730..a68f766 100644
--- a/ignite-tc-helper-web/src/main/webapp/pr.html
+++ b/ignite-tc-helper-web/src/main/webapp/pr.html
@@ -191,7 +191,7 @@ function showData(result) {
 
 <div id="vueQueryForm">
     <v-app id="prQueryForm" name="prQueryForm">
-        <span class="formgroup" style="margin: 14px">
+        <div class="formgroup">
             <span>Base branch: </span>
             <select v-model="baseBranchSelected" @change="formChanged">
                 <option disabled value="">Please select one</option>
@@ -200,9 +200,9 @@ function showData(result) {
                     {{ option }}
                 </option>
             </select>
-        </span>
-        &nbsp;&nbsp;
-        <span id="loadStatus"></span>
+            &nbsp;&nbsp;
+            <span id="loadStatus"></span>
+        </div>
         <div id="divFailures"></div>
     </v-app>
 </div>
diff --git 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/FullChainRunCtx.java
 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/FullChainRunCtx.java
index 849ce9a..a59e210 100644
--- 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/FullChainRunCtx.java
+++ 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/FullChainRunCtx.java
@@ -63,7 +63,13 @@ public class FullChainRunCtx {
     }
 
     public Stream<MultBuildRunCtx> failedChildSuites() {
-        return suites().filter(MultBuildRunCtx::isFailed);
+        Predicate<MultBuildRunCtx> filter = MultBuildRunCtx::isFailed;
+
+        return filteredChildSuites(filter);
+    }
+
+    public Stream<MultBuildRunCtx> 
filteredChildSuites(Predicate<MultBuildRunCtx> filter) {
+        return suites().filter(filter);
     }
 
     /**
diff --git 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/MultBuildRunCtx.java
 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/MultBuildRunCtx.java
index 41b4fc9..cd5524f 100644
--- 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/MultBuildRunCtx.java
+++ 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/MultBuildRunCtx.java
@@ -40,6 +40,7 @@ import javax.annotation.Nullable;
 import org.apache.ignite.ci.teamcity.ignited.change.ChangeCompacted;
 import org.apache.ignite.ci.teamcity.ignited.fatbuild.ProblemCompacted;
 import org.apache.ignite.ci.teamcity.ignited.fatbuild.TestCompacted;
+import org.apache.ignite.tcbot.common.TcBotConst;
 import org.apache.ignite.tcbot.common.conf.ITcServerConfig;
 import org.apache.ignite.tcbot.common.exeption.ExceptionUtil;
 import org.apache.ignite.tcbot.common.util.CollectionUtil;
@@ -323,9 +324,7 @@ public class MultBuildRunCtx implements ISuiteResults {
     }
 
     public List<TestCompactedMult> getFailedTests() {
-        Predicate<TestCompactedMult> filter = 
TestCompactedMult::isFailedButNotMuted;
-
-        return getFilteredTests(filter);
+        return getFilteredTests(TestCompactedMult::isFailedButNotMuted);
     }
 
     public List<TestCompactedMult> 
getFilteredTests(Predicate<TestCompactedMult> filter) {
@@ -629,27 +628,28 @@ public class MultBuildRunCtx implements ISuiteResults {
         return testsMerged;
     }
 
-    public int trustedTests(ITeamcityIgnited tcIgnited,
-        @Nullable Integer branchName) {
-
+    /**
+     * @param tcIgnited Tc ignited.
+     * @param branchName Branch name.
+     */
+    public int trustedTests(ITeamcityIgnited tcIgnited, @Nullable Integer 
branchName) {
         AtomicInteger trustedCnt = new AtomicInteger();
-        Map<Integer, TestCompactedMult> res = new HashMap<>();
 
-        //todo can cache mult occurrences in ctx
-        builds.forEach(singleBuildRunCtx -> {
-            saveToMap(res,
-                singleBuildRunCtx.getAllTests().filter(t -> !t.isIgnoredTest() 
&& !t.isMutedTest()));
-        });
+        getFilteredTests(t -> !t.isMutedOrIgored()).forEach((testMult) -> {
+            IRunHistory baseBranchStat = testMult.history(tcIgnited, 
branchName);
 
-        Stream<TestCompactedMult> stream = getTestsMerged().values().stream();
+            boolean testWillBeBlockerIfFailed = false;
 
-        stream.filter(mtest-> mtest.isFailedButNotMuted());
+            if (baseBranchStat == null)
+                testWillBeBlockerIfFailed = true;
 
-        res.forEach((testNameId, compactedMult) -> {
-            IRunHistory stat = compactedMult.history(tcIgnited, branchName);
-            String testBlockerComment = 
compactedMult.getPossibleBlockerComment(stat);
-            boolean b = testBlockerComment != null;
-            if (b) // this test will be considered as blocker if will fail
+            float failRate = baseBranchStat.getFailRate();
+            boolean lowFailureRate = failRate * 100.0f < 
TcBotConst.NON_FLAKY_TEST_FAIL_RATE_BLOCKER_BORDER_PERCENTS;
+
+            if (lowFailureRate && !baseBranchStat.isFlaky())
+                testWillBeBlockerIfFailed = true;
+
+            if (testWillBeBlockerIfFailed) // this test will be considered as 
blocker if will fail
                 trustedCnt.addAndGet(1);
         });
 
@@ -702,4 +702,8 @@ public class MultBuildRunCtx implements ISuiteResults {
             throw  ExceptionUtil.propagateException(e);
         }
     }
+
+    public boolean hasTestToReport(ITeamcityIgnited tcIgnited, Integer 
baseBranchId) {
+        return !getFilteredTests(test -> test.includeIntoReport(tcIgnited, 
baseBranchId)).isEmpty();
+    }
 }
diff --git 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/TestCompactedMult.java
 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/TestCompactedMult.java
index 7084c88..f54a509 100644
--- 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/TestCompactedMult.java
+++ 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/TestCompactedMult.java
@@ -107,7 +107,9 @@ public class TestCompactedMult {
              if (baseBranchStat == null) {
                  long durationMs = getAvgDurationMs();
                  if (durationMs > 
TcBotConst.MAX_NEW_TEST_DURATION_FOR_RUNALL_MS)
-                     return "Newly contributed test " + 
TimeUnit.MILLISECONDS.toSeconds(durationMs) + "s duration is more that 1 
minute";
+                     return "New test duration " +
+                         TimeUnit.MILLISECONDS.toSeconds(durationMs) + "s" +
+                         " is more that 1 minute";
              }
 
              return null;
@@ -154,4 +156,29 @@ public class TestCompactedMult {
     public boolean isFailedButNotMuted() {
         return occurrences.stream().anyMatch(o -> 
o.isFailedButNotMuted(STATUS_SUCCESS));
     }
+
+    /**
+     *
+     */
+    public boolean isMutedOrIgored() {
+        return occurrences.stream().anyMatch(TestCompacted::isMutedOrIgnored);
+    }
+
+    /**
+     * Filter to determine if this test execution should be shown in the 
report of failures.
+     *
+     * @param tcIgnited Tc ignited.
+     * @param baseBranchId Base branch id.
+     */
+    public boolean includeIntoReport(ITeamcityIgnited tcIgnited, Integer 
baseBranchId) {
+        if (isFailedButNotMuted())
+            return true;
+
+        boolean longRun = getAvgDurationMs() > 
TcBotConst.MAX_NEW_TEST_DURATION_FOR_RUNALL_MS;
+
+        if (longRun)
+            return history(tcIgnited, baseBranchId) == null;
+
+        return false;
+    }
 }
diff --git 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/pr/PrChainsProcessor.java
 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/pr/PrChainsProcessor.java
index 6081055..23b1cc5 100644
--- 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/pr/PrChainsProcessor.java
+++ 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/pr/PrChainsProcessor.java
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import javax.annotation.Nullable;
 import javax.inject.Inject;
@@ -34,8 +35,8 @@ import 
org.apache.ignite.tcbot.common.interceptor.AutoProfiling;
 import org.apache.ignite.tcbot.engine.chain.BuildChainProcessor;
 import org.apache.ignite.tcbot.engine.chain.FullChainRunCtx;
 import org.apache.ignite.tcbot.engine.chain.LatestRebuildMode;
+import org.apache.ignite.tcbot.engine.chain.MultBuildRunCtx;
 import org.apache.ignite.tcbot.engine.chain.ProcessLogsMode;
-import org.apache.ignite.tcbot.engine.chain.TestCompactedMult;
 import org.apache.ignite.tcbot.engine.conf.ITcBotConfig;
 import org.apache.ignite.tcbot.engine.conf.ITrackedBranch;
 import org.apache.ignite.tcbot.engine.conf.ITrackedChain;
@@ -252,7 +253,6 @@ public class PrChainsProcessor {
         ICredentialsProv prov,
         SyncMode syncMode,
         @Nullable String baseBranchForTc) {
-        //using here non persistent TC allows to skip update statistic
         ITeamcityIgnited tcIgnited = tcIgnitedProvider.server(srvId, prov);
 
         List<Integer> hist = tcIgnited.getLastNBuildsFromHistory(buildTypeId, 
branchForTc, 1);
@@ -285,28 +285,33 @@ public class PrChainsProcessor {
     private List<DsSuiteUi> findBlockerFailures(FullChainRunCtx 
fullChainRunCtx,
         ITeamcityIgnited tcIgnited,
         String baseBranch) {
+        String normalizedBaseBranch = RunHistSync.normalizeBranch(baseBranch);
+        Integer baseBranchId = 
compactor.getStringIdIfPresent(normalizedBaseBranch);
+
+        Predicate<MultBuildRunCtx> filter = suite -> 
suite.hasTestToReport(tcIgnited, baseBranchId);
+
         return fullChainRunCtx
-            .failedChildSuites()
+            .filteredChildSuites(filter)
             .map((ctx) -> {
-                String normalizedBaseBranch = 
RunHistSync.normalizeBranch(baseBranch);
-                Integer baseBranchId = 
compactor.getStringIdIfPresent(normalizedBaseBranch);
                 IRunHistory statInBaseBranch = ctx.history(tcIgnited, 
baseBranchId);
 
                 String suiteComment = ctx.getPossibleBlockerComment(compactor, 
statInBaseBranch, tcIgnited.config());
 
-                List<DsTestFailureUi> failures = 
ctx.getFailedTests().stream().map(occurrence -> {
-                    IRunHistory stat = occurrence.history(tcIgnited, 
baseBranchId);
-                    String testBlockerComment = 
occurrence.getPossibleBlockerComment(stat);
+                List<DsTestFailureUi> failures = ctx.getFilteredTests(test -> 
test.includeIntoReport(tcIgnited, baseBranchId))
+                    .stream()
+                    .map(occurrence -> {
+                        IRunHistory stat = occurrence.history(tcIgnited, 
baseBranchId);
+                        String testBlockerComment = 
occurrence.getPossibleBlockerComment(stat);
 
-                    if (!Strings.isNullOrEmpty(testBlockerComment)) {
-                        final DsTestFailureUi failure = new DsTestFailureUi();
+                        if (!Strings.isNullOrEmpty(testBlockerComment)) {
+                            final DsTestFailureUi failure = new 
DsTestFailureUi();
 
-                        failure.initFromOccurrence(occurrence, tcIgnited, 
ctx.projectId(), ctx.branchName(), baseBranch, baseBranchId);
+                            failure.initFromOccurrence(occurrence, tcIgnited, 
ctx.projectId(), ctx.branchName(), baseBranch, baseBranchId);
 
-                        return failure;
-                    }
-                    return null;
-                }).filter(Objects::nonNull).collect(Collectors.toList());
+                            return failure;
+                        }
+                        return null;
+                    }).filter(Objects::nonNull).collect(Collectors.toList());
 
 
                 // test failure based blockers and/or blocker found by suite 
results
@@ -325,4 +330,5 @@ public class PrChainsProcessor {
             .filter(Objects::nonNull)
             .collect(Collectors.toList());
     }
+
 }
diff --git 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsChainUi.java 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsChainUi.java
index 4f1994e..2b62ffd 100644
--- 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsChainUi.java
+++ 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsChainUi.java
@@ -198,7 +198,8 @@ public class DsChainUi {
                 if (dModeToUse == DisplayMode.None)
                     return; //don't convert any suite for UI
 
-                if (suite.isFailed() || dModeToUse == 
DisplayMode.ShowAllSuites) {
+                if (suite.isFailed() || dModeToUse == DisplayMode.ShowAllSuites
+                    || suite.hasTestToReport(tcIgnited, baseBranchId)) {
                     final DsSuiteUi suiteCurStatus = new DsSuiteUi();
 
                     suiteCurStatus.initFromContext(tcIgnited, suite, 
baseBranchTc, compactor, true, calcTrustedTests);
diff --git 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsSuiteUi.java 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsSuiteUi.java
index 4a6b09d..58dac7e 100644
--- 
a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsSuiteUi.java
+++ 
b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsSuiteUi.java
@@ -194,16 +194,7 @@ public class DsSuiteUi extends DsHistoryStatUi {
 
         Integer buildTypeIdId = suite.buildTypeIdId();
         if (includeTests) {
-            List<TestCompactedMult> tests = suite.getFilteredTests(test -> {
-                if (test.isFailedButNotMuted())
-                    return true;
-
-                boolean longRun = test.getAvgDurationMs() > 
TcBotConst.MAX_NEW_TEST_DURATION_FOR_RUNALL_MS;
-                if (longRun)
-                    return test.history(tcIgnited, baseBranchId) == null;
-
-                return false;
-            });
+            List<TestCompactedMult> tests = suite.getFilteredTests(test -> 
test.includeIntoReport(tcIgnited, baseBranchId));
 
             Function<TestCompactedMult, Float> function = testCompactedMult -> 
{
                 IRunHistory res = testCompactedMult.history(tcIgnited, 
baseBranchId);

Reply via email to