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/06 19:06:43 UTC

[ignite-teamcity-bot] branch srv-selector updated: Selection of service code - started

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

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


The following commit(s) were added to refs/heads/srv-selector by this push:
     new 68cf439  Selection of service code - started
68cf439 is described below

commit 68cf43913e65b2737ac370052e35efc24b8ce437
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Mon May 6 22:06:37 2019 +0300

    Selection of service code - started
---
 .../ignite/ci/web/model/hist/BuildsHistory.java    | 18 +++++---
 .../ignite/ci/web/rest/GetTrackedBranches.java     |  2 +-
 .../ci/web/rest/build/GetBuildTestFailures.java    |  3 +-
 .../src/main/webapp/comparison.html                | 50 +++++++++++++++++++---
 4 files changed, 59 insertions(+), 14 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/hist/BuildsHistory.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/hist/BuildsHistory.java
index 3534f8d..b2ede5b 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/hist/BuildsHistory.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/hist/BuildsHistory.java
@@ -36,6 +36,8 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.stream.Collectors;
+
+import org.apache.ignite.ci.tcbot.conf.ITcBotConfig;
 import org.apache.ignite.ci.tcbot.trends.MasterTrendsService;
 import org.apache.ignite.ci.teamcity.ignited.BuildRefCompacted;
 import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
@@ -52,12 +54,12 @@ import static com.google.common.base.Strings.isNullOrEmpty;
  * Presents statistic for all valid builds and merged failed unmuted tests in specified time interval. Statistics and
  * tests are stored in {@link #buildsStatistics} and {@link #mergedTestsBySuites} properties respectively. Builder
  * pattern is used for instance creation. Default values: <br>skipTests = false,<br>projectId="IgniteTests24Java8",
- * <br>srvId="apache", <br>buildTypeId="IgniteTests24Java8_RunAll",
+ * <br>srvCode="apache", <br>buildTypeId="IgniteTests24Java8_RunAll",
  * <br>branchName="refs/heads/master".
  */
 public class BuildsHistory {
     /** */
-    private String srvId;
+    private String srvCode;
 
     /** */
     public String projectId;
@@ -101,7 +103,7 @@ public class BuildsHistory {
      * @param prov Credentials.
      */
     public void initialize(ICredentialsProv prov) {
-        ITeamcityIgnited ignitedTeamcity = tcIgnitedProv.server(srvId, prov);
+        ITeamcityIgnited ignitedTeamcity = tcIgnitedProv.server(srvCode, prov);
 
         tcHost = ignitedTeamcity.host();
 
@@ -212,7 +214,7 @@ public class BuildsHistory {
 
     private BuildsHistory withParameters(Builder builder) {
         this.skipTests = builder.skipTests;
-        this.srvId = builder.srvId;
+        this.srvCode = builder.srvCode;
         this.buildTypeId = builder.buildTypeId;
         this.branchName = builder.branchName;
         this.sinceDateFilter = builder.sinceDate;
@@ -230,7 +232,7 @@ public class BuildsHistory {
         private String projectId = "IgniteTests24Java8";
 
         /** */
-        private String srvId = "apache";
+        private String srvCode;
 
         /** */
         private String buildTypeId = "IgniteTests24Java8_RunAll";
@@ -247,12 +249,16 @@ public class BuildsHistory {
         /** */
         private DateFormat dateFormat = new SimpleDateFormat("ddMMyyyyHHmmss");
 
+        public Builder(ITcBotConfig cfg) {
+            srvCode = cfg.primaryServerCode();
+        }
+
         /**
          * @param srvId server name.
          */
         public Builder server(String srvId) {
             if (!isNullOrEmpty(srvId))
-                this.srvId = srvId;
+                this.srvCode = srvId;
 
             return this;
         }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetTrackedBranches.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetTrackedBranches.java
index ed366db..3611068 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetTrackedBranches.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetTrackedBranches.java
@@ -103,7 +103,7 @@ public class GetTrackedBranches {
     }
 
     /**
-     * Return all servers registered in TC Bot config: Both from tracked branches and from
+     * Return all accessible servers registered in TC Bot config: Both from tracked branches and from
      */
     @GET
     @Path("getServerIds")
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/build/GetBuildTestFailures.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/build/GetBuildTestFailures.java
index 3ed0179..ca4f259 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/build/GetBuildTestFailures.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/build/GetBuildTestFailures.java
@@ -213,8 +213,9 @@ public class GetBuildTestFailures {
         @Nullable @QueryParam("skipTests") String skipTests)  throws ParseException {
 
         Injector injector = CtxListener.getInjector(ctx);
+        final ITcBotConfig cfg = injector.getInstance(ITcBotConfig.class);
 
-        BuildsHistory.Builder builder = new BuildsHistory.Builder()
+        BuildsHistory.Builder builder = new BuildsHistory.Builder(cfg)
             .branch(branch)
             .server(srvCode)
             .buildType(buildType)
diff --git a/ignite-tc-helper-web/src/main/webapp/comparison.html b/ignite-tc-helper-web/src/main/webapp/comparison.html
index d2a008f..f7d7fda 100644
--- a/ignite-tc-helper-web/src/main/webapp/comparison.html
+++ b/ignite-tc-helper-web/src/main/webapp/comparison.html
@@ -28,7 +28,8 @@
         <th style="text-align: center;" width="42%"><input type='text' name='daterange2'/></th>
     </tr><tr></tr><tr></tr>
     <tr id="showError">
-        <td class="section" colspan="2" id="choiceSuite"></td>
+        <td class="section" colspan="1" id="choiceServer"></td>
+        <td class="section" colspan="1" id="choiceSuite"></td>
         <td colspan="2" id="loadStatus" style="text-align: center; color: red;"></td>
     </tr><tr></tr>
     <tr id="showInfo">
@@ -555,9 +556,9 @@
         $('.' + cssClass + '.data.' + num).prop('title', title);
     }
 
-    function loadTrackedSuites() {
+    function loadServers() {
         $.ajax({
-            url: "rest/branches/suites?server=apache",
+            url: "rest/branches/getServerIds",
             success: function(result) {
                 if (!isDefinedAndFilled(result)) {
                     error.html("Result from " + this.url + " is undefined!");
@@ -565,6 +566,25 @@
                     return;
                 }
 
+                printServers(result);
+
+                loadTrackedSuites();
+            },
+            error: showErrInLoadStatus
+        });
+    }
+
+    function loadTrackedSuites() {
+        let server = $('#selectServer').val();
+        $.ajax({
+            url: "rest/branches/suites" + (isDefinedAndFilled(server) ? "?server=" + server + "" : ""),
+            success: function (result) {
+                if (!isDefinedAndFilled(result)) {
+                    error.html("Result from " + this.url + " is undefined!");
+
+                    return;
+                }
+
                 printSuites(result);
 
                 reloadAll();
@@ -573,7 +593,7 @@
         });
     }
 
-    function printSuites(result) {
+     function printSuites(result) {
         let selectHtml = "<select id='selectSuite'>";
 
         for (let i = 0; i < result.length; i++)
@@ -586,6 +606,21 @@
         $('#selectSuite').change(function () { reloadAll(); });
     }
 
+    // @param array of strings
+    function printServers(result) {
+        let selectHtml = "<select id='selectServer'>";
+
+        for (let i = 0; i < result.length; i++)
+            selectHtml += getHtmlOption(result[i], false, false, result[i]);
+
+        selectHtml += "</select>";
+
+        $('#choiceServer').html(selectHtml);
+
+        $('#selectServer').change(function () { loadTrackedSuites(); });
+    }
+
+
     function loadData(num, sinceDate, untilDate, testsTrigger) {
         loadGif(num);
 
@@ -599,7 +634,10 @@
             return;
         }
 
-        let url = 'rest/build/history?server=apache&buildType=' + suiteId + '&sinceDate=' +
+
+        let server = $('#selectServer').val();
+
+        let url = 'rest/build/history?server='+server+'&buildType=' + suiteId + '&sinceDate=' +
             sinceDate.format("DDMMYYYY") + '000001&untilDate=' + untilDate.format("DDMMYYYY") + '235959';
 
         if (!testsTrigger)
@@ -661,7 +699,7 @@
     }
 
     $(document).ready(function() {
-        loadTrackedSuites();
+        loadServers();
 
         $.ajax({ url: "rest/branches/version",  success: showVersionInfo, error: showErrInLoadStatus });
     });