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/01/28 11:49:24 UTC

[ignite-teamcity-bot] branch ignite-11105-alias created (now caa55ca)

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

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


      at caa55ca  IGNITE-11105 Support Teamcity servers aliases: Initial commit

This branch includes the following new commits:

     new caa55ca  IGNITE-11105 Support Teamcity servers aliases: Initial commit

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[ignite-teamcity-bot] 01/01: IGNITE-11105 Support Teamcity servers aliases: Initial commit

Posted by dp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit caa55cafa8746e64d8b727c98cf421f61ba2495d
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Mon Jan 28 14:49:09 2019 +0300

    IGNITE-11105 Support Teamcity servers aliases: Initial commit
---
 .../java/org/apache/ignite/ci/HelperConfig.java    | 35 ++++++----------------
 .../apache/ignite/ci/IgnitePersistentTeamcity.java | 12 --------
 .../apache/ignite/ci/IgniteTeamcityConnection.java | 10 +++----
 .../org/apache/ignite/ci/analysis/RunStat.java     |  7 -----
 .../apache/ignite/ci/tcbot/conf/ITcBotConfig.java  |  3 +-
 .../ci/tcbot/conf/LocalFilesBasedConfig.java       | 12 ++++++++
 .../org/apache/ignite/ci/web/rest/GetBuildLog.java |  3 +-
 .../ci/tcbot/chain/MockBasedTcBotModule.java       | 12 ++++++++
 8 files changed, 41 insertions(+), 53 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/HelperConfig.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/HelperConfig.java
index ebdb919..e0a0c76 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/HelperConfig.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/HelperConfig.java
@@ -45,8 +45,6 @@ public class HelperConfig {
     public static final String MAIL_PROPS = "mail.auth.properties";
     public static final String HOST = "host";
     public static final String USERNAME = "username";
-    @Deprecated
-    private static final String PASSWORD = "password";
     public static final String ENCODED_PASSWORD = "encoded_password";
 
     /** GitHub authorization token property name. */
@@ -178,26 +176,19 @@ public class HelperConfig {
      * Extract TeamCity authorization token from properties.
      *
      * @param props Properties, where token is placed.
-     * @param configName Configuration name.
+     * @param cfgName Configuration name.
      * @return Null or decoded auth token for Github.
      */
-    @Nullable static String prepareBasicHttpAuthToken(Properties props, String configName) {
-        final String user = getMandatoryProperty(props, USERNAME, configName);
-        String pwd = props.getProperty(PASSWORD);
-        boolean filled = !isNullOrEmpty(pwd);
+    @Nullable static String prepareBasicHttpAuthToken(Properties props, String cfgName) {
+        final String user = getMandatoryProperty(props, USERNAME, cfgName);
 
-        if (!filled) {
-            String enc = props.getProperty(ENCODED_PASSWORD);
+        String enc = props.getProperty(ENCODED_PASSWORD);
 
-            if(!isNullOrEmpty(enc)) {
-                pwd = PasswordEncoder.decode(enc);
-                filled = true;
-            }
-        }
-
-        if (!filled)
+        if (isNullOrEmpty(enc))
             return null;
 
+        String pwd = PasswordEncoder.decode(enc);
+
         return userPwdToToken(user, pwd);
     }
 
@@ -205,9 +196,9 @@ public class HelperConfig {
         return Base64Util.encodeUtf8String(user + ":" + pwd);
     }
 
-    public static String getMandatoryProperty(Properties props, String key, String configName) {
+    public static String getMandatoryProperty(Properties props, String key, String cfgName) {
         final String user = props.getProperty(key);
-        Preconditions.checkState(!isNullOrEmpty(user), key + " property should be filled in " + configName);
+        Preconditions.checkState(!isNullOrEmpty(user), key + " property should be filled in " + cfgName);
         return user;
     }
 
@@ -235,14 +226,6 @@ public class HelperConfig {
         }
     }
 
-
-    @NotNull public static File getLogsDirForServer(@QueryParam("serverId") String serverId) {
-        final File workDir = resolveWorkDir();
-        final String configName = prepareConfigName(serverId);
-        final Properties props = loadAuthProperties(workDir, configName);
-        return resolveLogs(workDir, props);
-    }
-
     @NotNull static File resolveLogs(File workDir, Properties props) {
         final String logsProp = props.getProperty(LOGS, "logs");
         final File logsDirFileConfigured = new File(logsProp);
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
index 3d53e45..31b70c5 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
@@ -79,10 +79,6 @@ public class IgnitePersistentTeamcity implements IAnalyticsEnabledTeamcity, ITea
     @Nullable
     private String serverId;
 
-    //todo: remove triggering dependency from getTrackedBranch processing, use TC Bot DB data.
-    @Deprecated
-    private static long lastTriggerMs = System.currentTimeMillis();
-
     @Override public void init(ITeamcity conn) {
         this.teamcity = conn;
         this.serverId = conn.serverId();
@@ -125,12 +121,6 @@ public class IgnitePersistentTeamcity implements IAnalyticsEnabledTeamcity, ITea
         return serverId;
     }
 
-    public static int getTriggerRelCacheValidSecs(int defaultSecs) {
-        long msSinceTrigger = System.currentTimeMillis() - lastTriggerMs;
-        long secondsSinceTrigger = TimeUnit.MILLISECONDS.toSeconds(msSinceTrigger);
-        return Math.min((int) secondsSinceTrigger, defaultSecs);
-    }
-
     @NotNull private String ignCacheNme(String cache) {
         return ignCacheNme(cache, serverId);
     }
@@ -226,8 +216,6 @@ public class IgnitePersistentTeamcity implements IAnalyticsEnabledTeamcity, ITea
     /** {@inheritDoc} */
     @AutoProfiling
     @Override public Build triggerBuild(String buildTypeId, @NotNull String branchName, boolean cleanRebuild, boolean queueAtTop) {
-        lastTriggerMs = System.currentTimeMillis();
-
         return teamcity.triggerBuild(buildTypeId, branchName, cleanRebuild, queueAtTop);
     }
 
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
index c667d66..ae425c2 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
@@ -27,6 +27,7 @@ import org.apache.ignite.ci.analysis.LogCheckTask;
 import org.apache.ignite.ci.analysis.SingleBuildRunCtx;
 import org.apache.ignite.ci.di.AutoProfiling;
 import org.apache.ignite.ci.logs.BuildLogStreamChecker;
+import org.apache.ignite.ci.tcbot.conf.ITcBotConfig;
 import org.apache.ignite.ci.tcmodel.agent.Agent;
 import org.apache.ignite.ci.tcmodel.agent.AgentsRef;
 import org.apache.ignite.ci.tcmodel.changes.Change;
@@ -99,8 +100,8 @@ public class IgniteTeamcityConnection implements ITeamcity {
     /** Teamcity http connection. */
     @Inject private ITeamcityHttpConnection teamcityHttpConn;
 
+    @Inject private ITcBotConfig config;
 
-    private String configName; //main properties file name
     private String tcName;
 
     /** Build logger processing running. */
@@ -117,11 +118,9 @@ public class IgniteTeamcityConnection implements ITeamcity {
     /** {@inheritDoc} */
     public void init(@Nullable String tcName) {
         this.tcName = tcName;
-        final File workDir = HelperConfig.resolveWorkDir();
 
-        this.configName = HelperConfig.prepareConfigName(tcName);
+        final Properties props = config.getTeamcityConfig(tcName);
 
-        final Properties props = HelperConfig.loadAuthProperties(workDir, configName);
         final String hostConf = props.getProperty(HelperConfig.HOST, "https://ci.ignite.apache.org/");
 
         this.host = hostConf.trim() + (hostConf.endsWith("/") ? "" : "/");
@@ -129,7 +128,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
         try {
             if (!Strings.isNullOrEmpty(props.getProperty(HelperConfig.USERNAME))
                     && props.getProperty(HelperConfig.ENCODED_PASSWORD) != null)
-                setAuthToken(HelperConfig.prepareBasicHttpAuthToken(props, configName));
+                setAuthToken(HelperConfig.prepareBasicHttpAuthToken(props, "TC Config"));
         } catch (Exception e) {
             e.printStackTrace();
             logger.error("Failed to set credentials", e);
@@ -137,6 +136,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
 
         this.gitBranchPrefix = props.getProperty(HelperConfig.GIT_BRANCH_PREFIX, "ignite-");
 
+        final File workDir = HelperConfig.resolveWorkDir();
         final File logsDirFile = HelperConfig.resolveLogs(workDir, props);
 
         logsDir = ensureDirExist(logsDirFile);
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/analysis/RunStat.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/analysis/RunStat.java
index ed035eb..60187e6 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/analysis/RunStat.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/analysis/RunStat.java
@@ -73,13 +73,6 @@ public class RunStat implements IRunHistory {
         this.name = name;
     }
 
-    private ChangesState changesStatus(Boolean changesExist) {
-        if (changesExist == null)
-            return ChangesState.UNKNOWN;
-
-        return changesExist ? ChangesState.EXIST : ChangesState.NONE;
-    }
-
     public void addTestRunToLatest(TestOccurrence testOccurrence, ChangesState changesState) {
         TestId id = extractFullId(testOccurrence.getId());
         if (id == null) {
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcBotConfig.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcBotConfig.java
index 95948da..b849173 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcBotConfig.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcBotConfig.java
@@ -18,6 +18,7 @@ package org.apache.ignite.ci.tcbot.conf;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Properties;
 import org.apache.ignite.ci.conf.BranchesTracked;
 
 /**
@@ -49,5 +50,5 @@ public interface ITcBotConfig {
         return getTrackedBranches().getServerIds();
     }
 
-
+    public Properties getTeamcityConfig(String srvName);
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/LocalFilesBasedConfig.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/LocalFilesBasedConfig.java
index f510061..1e537dd 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/LocalFilesBasedConfig.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/LocalFilesBasedConfig.java
@@ -16,6 +16,8 @@
  */
 package org.apache.ignite.ci.tcbot.conf;
 
+import java.io.File;
+import java.util.Properties;
 import org.apache.ignite.ci.HelperConfig;
 import org.apache.ignite.ci.conf.BranchesTracked;
 import org.apache.ignite.ci.di.cache.GuavaCached;
@@ -30,6 +32,16 @@ public class LocalFilesBasedConfig implements ITcBotConfig {
         return HelperConfig.getTrackedBranches();
     }
 
+    /** {@inheritDoc} */
+    @Override public Properties getTeamcityConfig(String srvName) {
+        File workDir = HelperConfig.resolveWorkDir();
+
+        String cfgName = HelperConfig.prepareConfigName(srvName);
+
+        return HelperConfig.loadAuthProperties(workDir, cfgName);
+    }
+
+    /** {@inheritDoc} */
     @Override public String primaryServerId() {
         return ITcBotConfig.DEFAULT_SERVER_ID;
     }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetBuildLog.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetBuildLog.java
index 0a141d9..03e00fb 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetBuildLog.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetBuildLog.java
@@ -64,8 +64,7 @@ public class GetBuildLog {
     @PermitAll
     public Response getThreadDump(
         @QueryParam(SERVER_ID) String srvId,
-        @QueryParam(BUILD_NO) Integer buildNo,
-        @Deprecated @QueryParam(FILE_IDX) Integer fileIdx) {
+        @QueryParam(BUILD_NO) Integer buildNo) {
 
         ITcServerProvider helper = CtxListener.getInjector(ctx).getInstance(ITcServerProvider.class);
         ITcAnalytics srv = helper.server(srvId, null);
diff --git a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/tcbot/chain/MockBasedTcBotModule.java b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/tcbot/chain/MockBasedTcBotModule.java
index 77fd7c2..36225f4 100644
--- a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/tcbot/chain/MockBasedTcBotModule.java
+++ b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/tcbot/chain/MockBasedTcBotModule.java
@@ -20,6 +20,9 @@ package org.apache.ignite.ci.tcbot.chain;
 import com.google.common.base.Preconditions;
 import com.google.inject.AbstractModule;
 import com.google.inject.internal.SingletonScope;
+import java.io.File;
+import java.util.Properties;
+import org.apache.ignite.ci.HelperConfig;
 import org.apache.ignite.ci.IAnalyticsEnabledTeamcity;
 import org.apache.ignite.ci.conf.BranchesTracked;
 import org.apache.ignite.ci.github.PullRequest;
@@ -105,6 +108,15 @@ public class MockBasedTcBotModule extends AbstractModule {
             @Override public BranchesTracked getTrackedBranches() {
                 return tracked;
             }
+
+            /** {@inheritDoc} */
+            @Override public Properties getTeamcityConfig(String srvName) {
+                File workDir = HelperConfig.resolveWorkDir();
+
+                String cfgName = HelperConfig.prepareConfigName(srvName);
+
+                return HelperConfig.loadAuthProperties(workDir, cfgName);
+            }
         });
 
         bind(IIssuesStorage.class).toInstance(Mockito.mock(IIssuesStorage.class));