ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpav...@apache.org
Subject [ignite-teamcity-bot] branch ignite-10095 updated: IGNITE-10095: Direct specification for filtering parameters.
Date Wed, 08 May 2019 17:12:11 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/ignite-10095 by this push:
     new ebb6e21  IGNITE-10095: Direct specification for filtering parameters.
ebb6e21 is described below

commit ebb6e21b3b50169fdebde49a9c040bc275f6e6c2
Author: Dmitriy Pavlov <dpavlov@apache.org>
AuthorDate: Wed May 8 20:10:43 2019 +0300

    IGNITE-10095: Direct specification for filtering parameters.
---
 conf/apache.auth.properties                        | 14 ---------
 conf/branches.json                                 | 16 ++++++----
 ...BuildParameter.java => BuildParameterSpec.java} | 34 +++++++++++++---------
 .../ignite/ci/tcbot/conf/ChainAtServerTracked.java |  4 +--
 .../ignite/ci/tcbot/conf/ITcServerConfig.java      |  2 ++
 ...TcServerConfig.java => ParameterValueSpec.java} | 32 +++++---------------
 .../ignite/ci/tcbot/conf/TcServerConfig.java       | 16 ++++++++++
 .../ci/teamcity/ignited/runhist/RunHistSync.java   | 28 +++++++++++-------
 8 files changed, 77 insertions(+), 69 deletions(-)

diff --git a/conf/apache.auth.properties b/conf/apache.auth.properties
index 974ba25..d16f920 100644
--- a/conf/apache.auth.properties
+++ b/conf/apache.auth.properties
@@ -16,17 +16,3 @@ github.auth_token=
 ## Branch identification rules
 # PR-less contribution branch name mandatory prefix
 git.branch_prefix=ignite-
-
-## JIRA integration parameters.
-jira.api_url=https://issues.apache.org/jira/rest/api/2/
-
-# JIRA Url, HTTPs is highly recommended because of Basic Auth used.
-jira.url=https://issues.apache.org/jira/
-
-# Ticket template: project code and dash.
-jira.ticket_template=IGNITE-
-
-# Specify JIRA Auth token (if needed).
-# Base-64 pre-encoded username and password, which will be included into Basic Auth requests.
-# Encoded token needs to be encrypted using org.apache.ignite.ci.tcbot.conf.PasswordEncoder
-jira.auth_token=
\ No newline at end of file
diff --git a/conf/branches.json b/conf/branches.json
index 3039641..11adf90 100644
--- a/conf/branches.json
+++ b/conf/branches.json
@@ -22,7 +22,10 @@
       // "branchNumPrefix": "IGNITE-",
       /* JIRA Url, HTTPs is highly recommended because of Basic Auth used. */
       "url": "https://issues.apache.org/jira/",
-      /** JIRA Auth token to access, use PasswordEncoder#encodeJiraTok to get from clear
username/password */
+      /** JIRA Auth token to access,
+        Base-64 pre-encoded username and password, which will be included into Basic Auth
requests.
+        Encoded token needs to be encrypted using org.apache.ignite.ci.tcbot.conf.PasswordEncoder,
+        use PasswordEncoder#encodeJiraTok to get from clear username/password */
       "authTok": "" //todo specify
     }
   ],
@@ -84,11 +87,12 @@
           "triggerParameters": [
             {
               name: "reverse.dep.*.env.JAVA_HOME",
-              randomValues: [
-                "%env.JDK_ORA_18%",
-                "%env.JDK_ORA_9%",
-                "%env.JDK_ORA_10%",
-                "%env.JDK_OPEN_11%"
+              randomValue: true,
+              "selection": [
+                {value:"%env.JDK_ORA_18%", label:"JDK8"},
+                {value:"%env.JDK_ORA_9%", label:"JDK9"},
+                {value:"%env.JDK_ORA_10%", label:"JDK10"},
+                {value:"%env.JDK_OPEN_11%", label:"JDK11"}
               ]
             }
           ]
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/BuildParameter.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/BuildParameterSpec.java
similarity index 62%
rename from ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/BuildParameter.java
rename to ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/BuildParameterSpec.java
index b7fbb6c..e886c11 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/BuildParameter.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/BuildParameterSpec.java
@@ -17,20 +17,25 @@
 
 package org.apache.ignite.ci.tcbot.conf;
 
-import com.google.common.base.Strings;
-import java.util.LinkedList;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
+import org.jetbrains.annotations.Nullable;
 
-public class BuildParameter {
+public class BuildParameterSpec {
     /** Name. */
     private String name;
 
     /** Value. */
     private String value;
 
-    /** Random values. Ignored if exact values were specified */
-    private List<String> randomValues = new LinkedList<>();
+    @Nullable private Boolean randomValue;
+
+    /**
+     * For triggering parameters: possble random values.
+     * For filtering parameters: used as value for selection and displaying result.
+     */
+    @Nullable private List<ParameterValueSpec> selectionValues = new ArrayList<>();
 
     /** {@inheritDoc} */
     @Override public boolean equals(Object o) {
@@ -38,15 +43,16 @@ public class BuildParameter {
             return true;
         if (o == null || getClass() != o.getClass())
             return false;
-        BuildParameter param = (BuildParameter)o;
+        BuildParameterSpec param = (BuildParameterSpec)o;
         return Objects.equals(name, param.name) &&
             Objects.equals(value, param.value) &&
-            Objects.equals(randomValues, param.randomValues);
+            Objects.equals(randomValue, param.randomValue) &&
+            Objects.equals(selectionValues, param.selectionValues);
     }
 
     /** {@inheritDoc} */
     @Override public int hashCode() {
-        return Objects.hash(name, value, randomValues);
+        return Objects.hash(name, value, randomValue, selectionValues);
     }
 
     public String name() {
@@ -54,14 +60,16 @@ public class BuildParameter {
     }
 
     public Object generateValue() {
-        if (!Strings.isNullOrEmpty(value))
+        if (!randomValue)
+            return value;
+
+        if (selectionValues.isEmpty())
             return value;
 
-        if (randomValues.isEmpty())
-            return null;
+        int idx = (int)(Math.random() * selectionValues.size());
 
-        int idx = (int)(Math.random() * randomValues.size());
+        ParameterValueSpec spec = selectionValues.get(idx);
 
-        return randomValues.get(idx);
+        return spec.value();
     }
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ChainAtServerTracked.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ChainAtServerTracked.java
index 82d3570..f60cd2e 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ChainAtServerTracked.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ChainAtServerTracked.java
@@ -50,7 +50,7 @@ public class ChainAtServerTracked extends ChainAtServer {
     @Nullable private Integer triggerBuildQuietPeriod;
 
     /** Build parameters for Triggerring. */
-    @Nullable private List<BuildParameter> triggerParameters;
+    @Nullable private List<BuildParameterSpec> triggerParameters;
 
     /** @return {@link #suiteId} */
     @Nonnull public String getSuiteIdMandatory() {
@@ -139,7 +139,7 @@ public class ChainAtServerTracked extends ChainAtServer {
         if (triggerParameters == null || triggerParameters.isEmpty())
             return Stream.empty();
 
-        return triggerParameters.stream().map(BuildParameter::name);
+        return triggerParameters.stream().map(BuildParameterSpec::name);
     }
 
     /** */
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 e08a21b..dbc7641 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
@@ -16,6 +16,7 @@
  */
 package org.apache.ignite.ci.tcbot.conf;
 
+import java.util.Collection;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -43,4 +44,5 @@ public interface ITcServerConfig {
      */
     @NotNull public String defaultTrackedBranch();
 
+    public Collection<String> filteringParametersKeys();
 }
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/ParameterValueSpec.java
similarity index 56%
copy from ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java
copy to ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ParameterValueSpec.java
index e08a21b..03bf553 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/ParameterValueSpec.java
@@ -14,33 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.ignite.ci.tcbot.conf;
 
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+package org.apache.ignite.ci.tcbot.conf;
 
 /**
- * Teamcity Server configuration.
+ *
  */
-public interface ITcServerConfig {
-    /**
-     * @return Another TC Server (service) config name to use settings from. Filled only
for server aliases.
-     */
-    @Nullable public String reference();
-
-    /**
-     * @return Normalized Host address, ends with '/'.
-     */
-    @NotNull public String host();
-
-    /**
-     * @return Directory for downloading build logs (will contain ZIP files).
-     */
-    @NotNull public String logsDirectory();
-
-    /**
-     * @return
-     */
-    @NotNull public String defaultTrackedBranch();
+public class ParameterValueSpec {
+    private String value;
+    private String label;
 
+    public String value() {
+        return value;
+    }
 }
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 fe078ee..8479ccd 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
@@ -17,7 +17,12 @@
 package org.apache.ignite.ci.tcbot.conf;
 
 import com.google.common.base.Strings;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 import java.util.Properties;
+import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
 import org.apache.ignite.ci.HelperConfig;
 import org.jetbrains.annotations.NotNull;
@@ -48,6 +53,9 @@ public class TcServerConfig implements ITcServerConfig {
     /** Default tracked branch name in internal identification of TC bot. */
     @Nullable private String defaultTrackedBranch;
 
+    /** Build parameters which may be used for filtering. */
+    @Nullable private List<BuildParameterSpec> filteringParameters = new ArrayList<>();
+
     public TcServerConfig() {
 
     }
@@ -103,6 +111,14 @@ public class TcServerConfig implements ITcServerConfig {
         return DEFAULT_TRACKED_BRANCH_NAME;
     }
 
+    /** {@inheritDoc} */
+    @Override public Collection<String> filteringParametersKeys() {
+        if (filteringParameters == null || filteringParameters.isEmpty())
+            return Collections.emptySet();
+
+        return filteringParameters.stream().map(BuildParameterSpec::name).collect(Collectors.toSet());
+    }
+
     /**
      * @param props Properties.
      */
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 aecd618..d5f804d 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
@@ -18,6 +18,7 @@
 package org.apache.ignite.ci.teamcity.ignited.runhist;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -38,6 +39,7 @@ import org.apache.ignite.ci.di.scheduler.IScheduler;
 import org.apache.ignite.ci.tcbot.TcBotSystemProperties;
 import org.apache.ignite.ci.tcbot.conf.ChainAtServerTracked;
 import org.apache.ignite.ci.tcbot.conf.ITcBotConfig;
+import org.apache.ignite.ci.tcbot.conf.ITcServerConfig;
 import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
 import org.apache.ignite.ci.teamcity.ignited.ITeamcityIgnited;
 import org.apache.ignite.ci.teamcity.ignited.buildref.BuildRefDao;
@@ -105,7 +107,7 @@ public class RunHistSync {
         if (histDao.buildWasProcessed(srvId, build.id()))
             return;
 
-        Set<Integer> allTriggeringBuildParameters = getSuitePossibleParameters(srvCode);
+        Set<Integer> allTriggeringBuildParameters = getFilteringParameters(srvCode);
 
         boolean saveNow = false;
 
@@ -150,15 +152,21 @@ public class RunHistSync {
         }
     }
 
-    @NotNull public Set<Integer> getSuitePossibleParameters(String srvCode) {
-        return cfg.getTrackedBranches().getBranches().stream().flatMap(
-                b -> b.getChainsStream()
-                    .filter(ChainAtServerTracked::isTriggerBuild)
-                    .filter(chain -> Objects.equals(chain.getServerId(), srvCode))
-                    .flatMap(ChainAtServerTracked::buildParametersKeys)
-            )
-            .map(k -> compactor.getStringId(k))
-            .collect(Collectors.toSet());
+    @NotNull public Set<Integer> getFilteringParameters(String srvCode) {
+        Set<String> triggerParameters = this.cfg.getTrackedBranches().getBranches().stream().flatMap(
+            b -> b.getChainsStream()
+                .filter(ChainAtServerTracked::isTriggerBuild)
+                .filter(chain -> Objects.equals(chain.getServerId(), srvCode))
+                .flatMap(ChainAtServerTracked::buildParametersKeys)
+        ).collect(Collectors.toSet());
+
+        ITcServerConfig tcCfg = cfg.getTeamcityConfig(srvCode);
+
+        Collection<String> filtering = tcCfg.filteringParametersKeys();
+
+        triggerParameters.addAll(filtering);
+
+        return triggerParameters.stream().map(k -> compactor.getStringId(k)).collect(Collectors.toSet());
     }
 
     @MonitoredTask(name = "Save Builds To History(srv, runner)", nameExtArgsIndexes = {0,
1})


Mime
View raw message