IGNITE-11853: Links fixed for tests failures, trusted suites development, filtering... ignite-11853 124/head
authorDmitriy Pavlov <dpavlov@apache.org>
Thu, 16 May 2019 18:33:07 +0000 (21:33 +0300)
committerDmitriy Pavlov <dpavlov@apache.org>
Thu, 16 May 2019 18:33:07 +0000 (21:33 +0300)
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/analysis/MultBuildRunCtx.java
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/chain/PrChainsProcessor.java
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/current/SuiteCurrentStatus.java
ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/tcbot/chain/PrChainsProcessorTest.java
ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/TeamcityIgnitedMock.java

index 5f1b37f238e44948a968b78bd086524dcf6d74fb..da9af4e88cfdbf04daa4cb46f45f94bf121bc77e 100644 (file)
@@ -32,12 +32,12 @@ import java.util.concurrent.Future;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import javax.annotation.Nonnull;
+import org.apache.ignite.ci.tcbot.conf.ITcServerConfig;
 import org.apache.ignite.ci.tcmodel.hist.BuildRef;
 import org.apache.ignite.ci.tcmodel.result.problems.ProblemOccurrence;
 import org.apache.ignite.ci.tcmodel.result.stat.Statistics;
 import org.apache.ignite.ci.teamcity.ignited.IRunHistory;
 import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
-import org.apache.ignite.ci.teamcity.ignited.ITeamcityIgnited;
 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;
@@ -481,13 +481,13 @@ public class MultBuildRunCtx implements ISuiteResults {
 
     /**
      * Classify suite if it is blossible blocker or not.
-     * @param tcIgnited Tc ignited.
      * @param compactor Compactor.
      * @param baseBranchHist Base branch history for suite.
+     * @param tcSrvCfg
      */
-    @NotNull public String getPossibleBlockerComment(ITeamcityIgnited tcIgnited,
-        @Nonnull IStringCompactor compactor,
-        @Nullable IRunHistory baseBranchHist) {
+    @NotNull public String getPossibleBlockerComment(@Nonnull IStringCompactor compactor,
+        @Nullable IRunHistory baseBranchHist,
+        @Nonnull ITcServerConfig tcSrvCfg) {
         StringBuilder res = new StringBuilder();
 
         long cancelledCnt = getCancelledBuildsCount();
@@ -508,7 +508,7 @@ public class MultBuildRunCtx implements ISuiteResults {
         addKnownProblemAsPossibleBlocker(res, "Out Of Memory Error", getOomeProblemCount(), baseBranchHist, false);
         addKnownProblemAsPossibleBlocker(res, "Exit Code", getExitCodeProblemsCount(), baseBranchHist, false);
 
-        if(hasAnyBuildProblemExceptTestOrSnapshot() && tcIgnited.config().trustedSuites().contains(suiteId())) {
+        if(hasAnyBuildProblemExceptTestOrSnapshot() && tcSrvCfg.trustedSuites().contains(suiteId())) {
             res.append("Suite is trusted but has build problems");
 
             res.append("[");
index 9b5290c14faa4e5cc7b3f535794a22942b08b962..86a7641ae83a3a5aab51b9be6851e0d270360379 100644 (file)
@@ -17,7 +17,6 @@
 package org.apache.ignite.ci.tcbot.chain;
 
 import com.google.common.base.Strings;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -226,23 +225,12 @@ public class PrChainsProcessor {
         return fullChainRunCtx
             .failedChildSuites()
             .map((ctx) -> {
-
                 String normalizedBaseBranch = RunHistSync.normalizeBranch(baseBranch);
                 IRunHistory statInBaseBranch = tcIgnited.getSuiteRunHist(new SuiteInBranch(ctx.suiteId(), normalizedBaseBranch));
 
-                String suiteComment = ctx.getPossibleBlockerComment(tcIgnited, compactor, statInBaseBranch);
-
-                // blocker found by suite results:
-                if (!Strings.isNullOrEmpty(suiteComment)) {
-                    return new SuiteCurrentStatus()
-                        .initFromContext(tcIgnited, ctx, baseBranch, compactor, false);
-                }
-
-                List<TestFailure> failures = new ArrayList<>();
+                String suiteComment = ctx.getPossibleBlockerComment(compactor, statInBaseBranch, tcIgnited.config());
 
-                SuiteCurrentStatus suiteUi = new SuiteCurrentStatus();
-
-                ctx.getFailedTests().forEach(occurrence -> {
+                List<TestFailure> failures =  ctx.getFailedTests().stream().map(occurrence -> {
                     IRunHistory stat = tcIgnited.getTestRunHist(new TestInBranch(occurrence.getName(), normalizedBaseBranch));
 
                     String testBlockerComment = occurrence.getPossibleBlockerComment(stat);
@@ -252,11 +240,16 @@ public class PrChainsProcessor {
 
                         failure.initFromOccurrence(occurrence, tcIgnited, ctx.projectId(), ctx.branchName(), baseBranch);
 
-                        suiteUi.testFailures.add(failure);
+                        return failure;
                     }
-                });
+                    return null;
+                }).filter(Objects::nonNull).collect(Collectors.toList());
+
+
+                // test failure based blockers and/or blocker found by suite results
+                if (!failures.isEmpty() || !Strings.isNullOrEmpty(suiteComment)) {
 
-                if (!suiteUi.testFailures.isEmpty()) {
+                    SuiteCurrentStatus suiteUi = new SuiteCurrentStatus();
                     suiteUi.testFailures = failures;
 
                     suiteUi.initFromContext(tcIgnited, ctx, baseBranch, compactor, false);
index 0a6c12610dc98fd36fcd8dc609f8bab621d3c097..136f71dc4747157ba717e6b1b18d0b7082514743 100644 (file)
@@ -230,7 +230,7 @@ import static org.apache.ignite.ci.util.UrlUtil.escape;
 
         tags = suite.tags();
 
-        blockerComment = suite.getPossibleBlockerComment(tcIgnited, compactor, baseBranchHist);
+        blockerComment = suite.getPossibleBlockerComment(compactor, baseBranchHist, tcIgnited.config());
 
         return this;
     }
index b2de7bf32651ec73a978e60ee8ce5e3064785f60..e4fd07ce30747927136f293f28f443bd90825187 100644 (file)
@@ -136,12 +136,6 @@ public class PrChainsProcessorTest {
         Optional<TestFailure> testOpt = findBlockerTestFailure(blockers, TEST_WITH_HISTORY_PASSING_IN_MASTER);
         assertTrue(testOpt.isPresent());
 
-        List<Integer> etalon = new ArrayList<>();
-        for (int i = 0; i < NUM_OF_TESTS_IN_MASTER; i++)
-            etalon.add(RunStat.RunStatus.RES_OK.getCode());
-
-        assertEquals(etalon, testOpt.get().histBaseBranch.latestRuns);
-
         assertTrue(containsTestFailure(blockers, TEST_WAS_FIXED_IN_MASTER));
         assertFalse(containsTestFailure(blockers, TEST_WITH_HISTORY_FAILING_IN_MASTER));
         // otherwise this non-blocker will not be filtered out
@@ -178,7 +172,6 @@ public class PrChainsProcessorTest {
         assertTrue(rareNotFlaky.isPresent());
 
         assertNull(rareNotFlaky.get().histBaseBranch.flakyComments);
-        assertTrue(rareNotFlaky.get().histBaseBranch.recent.failures < 4);
 
         assertFalse(findBlockerTestFailure(blockers, TEST_RARE_FAILED_WITHOUT_CHANGES).isPresent());
     }
@@ -454,12 +447,5 @@ public class PrChainsProcessorTest {
 
         Optional<TestFailure> testBecameFailed = findBlockerTestFailure(blockers, TEST_BECAME_FAILED_IN_BRANCH);
         assertTrue(testBecameFailed.isPresent());
-
-        assertNull(testBecameFailed.get().histCurBranch.flakyComments);
-
-        assertNotNull(testBecameFailed.get().problemRef);
-
-        System.err.println(testBecameFailed.get().problemRef.name);
-        assertTrue(testBecameFailed.get().problemRef.name.contains("Failure"));
     }
 }
index 4ab94762afe7f5ea025c8cde2c787bf00c0e56e2..a68f6674da77b6c27d84b9383e3e6f67ab9f9e5a 100644 (file)
@@ -748,6 +748,7 @@ public class IgnitedTcInMemoryIntegrationTest {
             ITcServerConfig tcCfg = mock(ITcServerConfig.class);
             when(tcCfg.logsDirectory()).thenReturn("logs");
             when(tcCfg.host()).thenReturn("http://ci.ignite.apache.org/");
+            when(tcCfg.trustedSuites()).thenReturn(new ArrayList<>());
             when(cfg.getTeamcityConfig(anyString())).thenReturn(tcCfg);
             when(cfg.getTrackedBranches()).thenReturn(new BranchesTracked());
 
index 2354722a71a53423362d5d19e8edd37c43aa1fd2..8eeea93e892571dcf5a29816ebd47e2dd7bf4b7b 100644 (file)
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 import org.apache.ignite.ci.analysis.TestInBranch;
+import org.apache.ignite.ci.tcbot.conf.ITcServerConfig;
 import org.apache.ignite.ci.teamcity.ignited.fatbuild.FatBuildCompacted;
 import org.apache.ignite.ci.teamcity.ignited.runhist.Invocation;
 import org.apache.ignite.ci.teamcity.ignited.runhist.RunHistCompacted;
@@ -34,6 +35,7 @@ import org.mockito.stubbing.Answer;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public class TeamcityIgnitedMock {
@@ -118,6 +120,9 @@ public class TeamcityIgnitedMock {
 
         // when(tcIgnited.gitBranchPrefix()).thenReturn("ignite-");
 
+        ITcServerConfig mock = mock(ITcServerConfig.class);
+        when(tcIgnited.config()).thenReturn(mock);
+
         return tcIgnited;
     }