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

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


The following commit(s) were added to refs/heads/master by this push:
     new a65547b  Base branch specification for PR analysis added to the Bot
a65547b is described below

commit a65547b68c7c4d23cf980a3f29eb592880975469
Author: Dmitriy Pavlov <[email protected]>
AuthorDate: Wed Sep 12 20:56:59 2018 +0300

    Base branch specification for PR analysis added to the Bot
---
 .../org/apache/ignite/ci/BuildChainProcessor.java  | 14 ++++++-
 .../apache/ignite/ci/observer/ObserverTask.java    |  3 +-
 .../ignite/ci/web/rest/parms/FullQueryParams.java  | 20 +++++++--
 .../ignite/ci/web/rest/pr/GetPrTestFailures.java   | 49 ++++++++++++++--------
 ignite-tc-helper-web/src/main/webapp/index.html    |  3 +-
 ignite-tc-helper-web/src/main/webapp/pr.html       |  4 ++
 6 files changed, 67 insertions(+), 26 deletions(-)

diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/BuildChainProcessor.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/BuildChainProcessor.java
index 0a85be1..38f87e8 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/BuildChainProcessor.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/BuildChainProcessor.java
@@ -47,6 +47,16 @@ public class BuildChainProcessor {
     /** Logger. */
     private static final Logger logger = 
LoggerFactory.getLogger(BuildChainProcessor.class);
 
+    /**
+     * @param teamcity Teamcity.
+     * @param includeLatestRebuild Include latest rebuild.
+     * @param builds Builds.
+     * @param procLogs Process logs.
+     * @param includeScheduled Include scheduled.
+     * @param showContacts Show contacts.
+     * @param tcAnalytics Tc analytics.
+     * @param baseBranch Base branch, stable branch to take fail rates from.
+     */
     public static Optional<FullChainRunCtx> processBuildChains(
         ITeamcity teamcity,
         LatestRebuildMode includeLatestRebuild,
@@ -55,14 +65,14 @@ public class BuildChainProcessor {
         boolean includeScheduled,
         boolean showContacts,
         @Nullable ITcAnalytics tcAnalytics,
-        @Nullable String failRateBranch) {
+        @Nullable String baseBranch) {
 
         final Properties responsible = showContacts ? 
getContactPersonProperties(teamcity) : null;
 
         final FullChainRunCtx val = loadChainsContext(teamcity, builds,
             includeLatestRebuild,
             procLogs, responsible, includeScheduled, tcAnalytics,
-            failRateBranch);
+            baseBranch);
 
         return Optional.of(val);
     }
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java
index 7466a30..0c7a04b 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java
@@ -91,7 +91,8 @@ public class ObserverTask extends TimerTask {
     private String generateComment(Build build, BuildInfo info) {
         StringBuilder res = new StringBuilder();
         TestFailuresSummary summary = GetPrTestFailures.getTestFailuresSummary(
-            helper, info.prov, info.srvId, build.getBuildType().getId(), 
build.branchName, "Latest", null);
+            helper, info.prov, info.srvId, build.getBuildType().getId(), 
build.branchName,
+            "Latest", null, null);
 
         if (summary != null) {
             for (ChainAtServerCurrentStatus server : summary.servers) {
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/parms/FullQueryParams.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/parms/FullQueryParams.java
index 80c0598..78b3ccb 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/parms/FullQueryParams.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/parms/FullQueryParams.java
@@ -35,7 +35,7 @@ public class FullQueryParams {
     public static final String CHAIN = "Chain";
     public static final int DEFAULT_COUNT = 10;
 
-    /** Tracked branch name */
+    /** Tracked branch name (branch naming in terms of bot). */
     @Nullable @QueryParam("branch") String branch;
 
     /** Server For not tracked branches. */
@@ -57,15 +57,20 @@ public class FullQueryParams {
     @Nullable @QueryParam("checkAllLogs") Boolean checkAllLogs;
     private Integer buildId;
 
+    /** TC identified base branch: null means the same as &lt;default>, 
master. For not tracked branches. */
+    @Nullable @QueryParam("baseBranchForTc") private String baseBranchForTc;
+
     public FullQueryParams() {
     }
 
-    public FullQueryParams(String serverId, String suiteId, String 
branchForTc, String action, Integer count) {
+    public FullQueryParams(String serverId, String suiteId, String 
branchForTc, String action, Integer count,
+        String baseBranchForTc) {
         this.serverId = serverId;
         this.suiteId = suiteId;
         this.branchForTc = branchForTc;
         this.action = action;
         this.count = count;
+        this.baseBranchForTc = baseBranchForTc;
     }
 
     @Nullable public String getBranch() {
@@ -96,12 +101,15 @@ public class FullQueryParams {
         return checkAllLogs;
     }
 
+    /** {@inheritDoc} */
     @Override public boolean equals(Object o) {
         if (this == o)
             return true;
         if (o == null || getClass() != o.getClass())
             return false;
+
         FullQueryParams param = (FullQueryParams)o;
+
         return Objects.equal(branch, param.branch) &&
             Objects.equal(serverId, param.serverId) &&
             Objects.equal(suiteId, param.suiteId) &&
@@ -109,11 +117,14 @@ public class FullQueryParams {
             Objects.equal(action, param.action) &&
             Objects.equal(count, param.count) &&
             Objects.equal(checkAllLogs, param.checkAllLogs) &&
-            Objects.equal(buildId, param.buildId);
+            Objects.equal(buildId, param.buildId) &&
+            Objects.equal(baseBranchForTc, param.baseBranchForTc);
     }
 
+    /** {@inheritDoc} */
     @Override public int hashCode() {
-        return Objects.hashCode(branch, serverId, suiteId, branchForTc, 
action, count, checkAllLogs, buildId);
+        return Objects.hashCode(branch, serverId, suiteId, branchForTc, 
action, count, checkAllLogs, buildId,
+            baseBranchForTc);
     }
 
     public void setBranch(@Nullable String branch) {
@@ -134,6 +145,7 @@ public class FullQueryParams {
             .add("count", count)
             .add("checkAllLogs", checkAllLogs)
             .add("buildId", buildId)
+            .add("baseBranchForTc", baseBranchForTc)
             .toString();
     }
 
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/pr/GetPrTestFailures.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/pr/GetPrTestFailures.java
index eba2b58..fd45068 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/pr/GetPrTestFailures.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/pr/GetPrTestFailures.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.ci.web.rest.pr;
 
+import com.google.common.base.Strings;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.POST;
 import org.apache.ignite.ci.*;
@@ -65,48 +66,59 @@ public class GetPrTestFailures {
     @GET
     @Path("updates")
     public UpdateInfo getPrFailuresUpdates(
-        @Nullable @QueryParam("serverId") String serverId,
+        @Nullable @QueryParam("serverId") String srvId,
         @Nonnull @QueryParam("suiteId") String suiteId,
         @Nonnull @QueryParam("branchForTc") String branchForTc,
-        @Nonnull @QueryParam("action") String action,
-        @Nullable @QueryParam("count") Integer count) {
+        @Nonnull @QueryParam("action") String act,
+        @Nullable @QueryParam("count") Integer cnt,
+        @Nullable @QueryParam("baseBranchForTc") String baseBranchForTc) {
 
-        return new UpdateInfo().copyFrom(getPrFailures(serverId, suiteId, 
branchForTc, action, count));
+        return new UpdateInfo().copyFrom(getPrFailures(srvId, suiteId, 
branchForTc, act, cnt, baseBranchForTc));
     }
 
     @GET
     @Path("results")
     public TestFailuresSummary getPrFailures(
-        @Nullable @QueryParam("serverId") String serverId,
+        @Nullable @QueryParam("serverId") String srvId,
         @Nonnull @QueryParam("suiteId") String suiteId,
         @Nonnull @QueryParam("branchForTc") String branchForTc,
-        @Nonnull @QueryParam("action") String action,
-        @Nullable @QueryParam("count") Integer count) {
+        @Nonnull @QueryParam("action") String act,
+        @Nullable @QueryParam("count") Integer cnt,
+        @Nullable @QueryParam("baseBranchForTc") String baseBranchForTc) {
 
         final BackgroundUpdater updater = 
CtxListener.getBackgroundUpdater(context);
 
-        final FullQueryParams key = new FullQueryParams(serverId, suiteId, 
branchForTc, action, count);
+        final FullQueryParams key = new FullQueryParams(srvId, suiteId, 
branchForTc, act, cnt, baseBranchForTc);
 
         final ICredentialsProv prov = ICredentialsProv.get(req);
 
         return updater.get(CURRENT_PR_FAILURES, prov, key,
-                (k) -> getPrFailuresNoCache(k.getServerId(), k.getSuiteId(), 
k.getBranchForTc(), k.getAction(), k.getCount()),
+                (k) -> getPrFailuresNoCache(k.getServerId(), k.getSuiteId(), 
k.getBranchForTc(), k.getAction(), k.getCount(), baseBranchForTc),
                 true);
     }
 
+    /**
+     * @param srvId Server id.
+     * @param suiteId Suite id.
+     * @param branchForTc Branch name in TC identification.
+     * @param act Action.
+     * @param cnt Count.
+     * @param baseBranchForTc Base branch name in TC identification.
+     */
     @GET
     @Path("resultsNoCache")
     @NotNull public TestFailuresSummary getPrFailuresNoCache(
         @Nullable @QueryParam("serverId") String srvId,
         @Nonnull @QueryParam("suiteId") String suiteId,
         @Nonnull @QueryParam("branchForTc") String branchForTc,
-        @Nonnull @QueryParam("action") String action,
-        @Nullable @QueryParam("count") Integer count) {
+        @Nonnull @QueryParam("action") String act,
+        @Nullable @QueryParam("count") Integer cnt,
+        @Nullable @QueryParam("baseBranchForTc") String baseBranchForTc) {
 
         final ITcHelper tcHelper = CtxListener.getTcHelper(context);
         final ICredentialsProv creds = ICredentialsProv.get(req);
 
-        return getTestFailuresSummary(tcHelper, creds, srvId, suiteId, 
branchForTc, action, count);
+        return getTestFailuresSummary(tcHelper, creds, srvId, suiteId, 
branchForTc, act, cnt, baseBranchForTc);
     }
 
     /**
@@ -114,9 +126,10 @@ public class GetPrTestFailures {
      * @param creds Credentials.
      * @param srvId Server id.
      * @param suiteId Suite id.
-     * @param branchForTc Branch name.
+     * @param branchForTc Branch name in TC identification.
      * @param act Action.
      * @param cnt Count.
+     * @param baseBranchForTc Base branch name in TC identification.
      * @return Test failures summary.
      */
     public static TestFailuresSummary getTestFailuresSummary(
@@ -126,8 +139,8 @@ public class GetPrTestFailures {
         String suiteId,
         String branchForTc,
         String act,
-        Integer cnt
-    ) {
+        Integer cnt,
+        @Nullable String baseBranchForTc) {
         final TestFailuresSummary res = new TestFailuresSummary();
         final AtomicInteger runningUpdates = new AtomicInteger();
 
@@ -166,12 +179,12 @@ public class GetPrTestFailures {
                 ? ProcessLogsMode.SUITE_NOT_COMPLETE
                 : ProcessLogsMode.DISABLED;
 
-            String failRateBranch = ITeamcity.DEFAULT;
+            String baseBranch = Strings.isNullOrEmpty(baseBranchForTc) ? 
ITeamcity.DEFAULT : baseBranchForTc;
 
             Optional<FullChainRunCtx> pubCtx = 
BuildChainProcessor.processBuildChains(teamcity, rebuild, chains,
                 logs,
                 singleBuild,
-                true, teamcity, failRateBranch);
+                true, teamcity, baseBranch);
 
             final ChainAtServerCurrentStatus chainStatus = new 
ChainAtServerCurrentStatus(teamcity.serverId(), branchForTc);
             pubCtx.ifPresent(ctx -> {
@@ -184,7 +197,7 @@ public class GetPrTestFailures {
                         runningUpdates.addAndGet(cnt0);
 
                     //fail rate reference is always default (master)
-                    chainStatus.initFromContext(teamcity, ctx, teamcity, 
failRateBranch);
+                    chainStatus.initFromContext(teamcity, ctx, teamcity, 
baseBranch);
                 }
             });
 
diff --git a/ignite-tc-helper-web/src/main/webapp/index.html 
b/ignite-tc-helper-web/src/main/webapp/index.html
index cd0cac0..fa3454b 100644
--- a/ignite-tc-helper-web/src/main/webapp/index.html
+++ b/ignite-tc-helper-web/src/main/webapp/index.html
@@ -85,8 +85,9 @@ function showSuitesForPrCheckData(result) {
 
         res+="<form action='pr.html'>";
         res+="Server: <input type='text' name='serverId' value=" + 
chainAtServer.serverId +" readonly>" ;
-        res+="Chain: <input type='text' name='suiteId' style='width: 30%;' 
value=" + chainAtServer.suiteId +" readonly>" ;
+        res+="Chain: <input type='text' name='suiteId' style='width: 30%;' 
value=" + chainAtServer.suiteId +">" ;
         res+="Branch: <input type='text' name='branchForTc' required> "
+        res+="Base branch: <input type='text' name='baseBranchForTc'> "
         res+="<input type='submit' name='action' value='Latest'>";
         // res+="<input type='submit' name='action' value='Chain'>";
         res+="<input type='submit' name='action' value='History'>";
diff --git a/ignite-tc-helper-web/src/main/webapp/pr.html 
b/ignite-tc-helper-web/src/main/webapp/pr.html
index 0176789..70d71ce 100644
--- a/ignite-tc-helper-web/src/main/webapp/pr.html
+++ b/ignite-tc-helper-web/src/main/webapp/pr.html
@@ -51,6 +51,10 @@ function parmsForRest() {
         curReqParms += "&count=" + count;
     }
 
+    var baseBranchForTc = findGetParameter("baseBranchForTc");
+    if(baseBranchForTc != null) {
+        curReqParms += "&baseBranchForTc=" + baseBranchForTc;
+    }
     return curReqParms;
 }
 

Reply via email to