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

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


The following commit(s) were added to refs/heads/ignite-9848-load-all-builds by 
this push:
     new fdf9bea  Test occurrences preparation for saving to fat build
fdf9bea is described below

commit fdf9bea5e52b6a697730d371cad24aba261e6536
Author: Dmitriy Pavlov <dpav...@apache.org>
AuthorDate: Wed Oct 24 20:21:14 2018 +0300

    Test occurrences preparation for saving to fat build
---
 .../apache/ignite/ci/IgnitePersistentTeamcity.java |  2 -
 .../org/apache/ignite/ci/analysis/RunStat.java     |  2 +-
 .../org/apache/ignite/ci/tcmodel/result/Build.java | 15 +++++
 .../ci/teamcity/ignited/BuildRefCompacted.java     |  1 +
 .../ignite/ci/teamcity/ignited/FatBuildDao.java    |  4 ++
 .../ci/teamcity/ignited/IgniteStringCompactor.java |  4 +-
 .../ignited/{ => fatbuild}/FatBuildCompacted.java  | 41 +++++++++++++-
 .../teamcity/ignited/fatbuild/TestCompacted.java   | 66 ++++++++++++++++++++++
 .../ignited/IgnitedTcInMemoryIntegrationTest.java  |  1 +
 9 files changed, 128 insertions(+), 8 deletions(-)

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 8977517..5cfbd30 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
@@ -94,8 +94,6 @@ import static 
org.apache.ignite.ci.tcbot.chain.BuildChainProcessor.normalizeBran
  */
 @Deprecated
 public class IgnitePersistentTeamcity implements IAnalyticsEnabledTeamcity, 
ITeamcity, ITcAnalytics {
-    /** Logger. */
-    private static final Logger logger = 
LoggerFactory.getLogger(IgnitePersistentTeamcity.class);
 
     //V2 caches, 32 parts (V1 caches were 1024 parts)
     private static final String TESTS_OCCURRENCES = "testOccurrences";
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 5332c25..7bed35a 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
@@ -117,7 +117,7 @@ public class RunStat {
         addRunToLatest(id, new RunInfo(testToResCode(testOccurrence), 
changesState));
     }
 
-    private static TestId extractFullId(String id) {
+    public static TestId extractFullId(String id) {
         Integer buildId = extractIdPrefixed(id, "build:(id:", ")");
 
         if (buildId == null)
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/Build.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/Build.java
index b4b1c9b..9eaa544 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/Build.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/Build.java
@@ -123,6 +123,21 @@ public class Build extends BuildRef implements 
IVersionedEntity {
         finishDate = ts < 0 ? null : fmtLoc.get().format(new Date(ts));
     }
 
+
+    /**
+     *
+     */
+    public Date getQueuedDate() {
+        return getDate(queuedDate);
+    }
+
+    /**
+     * @param ts Timestamp.
+     */
+    public void setQueuedDateTs(long ts) {
+        queuedDate = ts < 0 ? null : fmtLoc.get().format(new Date(ts));
+    }
+
     /**
      * @param date Date as string.
      */
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefCompacted.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefCompacted.java
index 3c455d3..b63b03b 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefCompacted.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefCompacted.java
@@ -72,6 +72,7 @@ public class BuildRefCompacted {
         res.branchName = compactor.getStringFromId(branchName);
         res.status = compactor.getStringFromId(status);
         res.state = compactor.getStringFromId(state);
+        res.href = "/app/rest/latest/builds/id:" + id();
     }
 
     /** {@inheritDoc} */
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/FatBuildDao.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/FatBuildDao.java
index 427980f..d2151f9 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/FatBuildDao.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/FatBuildDao.java
@@ -32,6 +32,7 @@ import org.apache.ignite.ci.db.TcHelperDb;
 import org.apache.ignite.ci.tcmodel.hist.BuildRef;
 import org.apache.ignite.ci.tcmodel.result.Build;
 import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrences;
+import org.apache.ignite.ci.teamcity.ignited.fatbuild.FatBuildCompacted;
 
 /**
  *
@@ -75,6 +76,9 @@ public class FatBuildDao {
 
         FatBuildCompacted compacted = new FatBuildCompacted(compactor, build);
 
+        for (TestOccurrences next : tests)
+            compacted.addTests(compactor, next.getTests());
+
         long cacheKey = buildIdToCacheKey(srvIdMaskHigh, compacted.id());
         FatBuildCompacted buildPersisted = existingEntries.get(cacheKey);
 
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/IgniteStringCompactor.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/IgniteStringCompactor.java
index 906b0d5..07d0036 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/IgniteStringCompactor.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/IgniteStringCompactor.java
@@ -39,8 +39,8 @@ import org.apache.ignite.configuration.CacheConfiguration;
 import org.jetbrains.annotations.NotNull;
 
 public class IgniteStringCompactor implements IStringCompactor {
-    AtomicBoolean initGuard = new AtomicBoolean();
-    CountDownLatch initLatch = new CountDownLatch(1);
+    private final AtomicBoolean initGuard = new AtomicBoolean();
+    private final CountDownLatch initLatch = new CountDownLatch(1);
 
     /** Cache name */
     public static final String STRINGS_CACHE = "stringsCache";
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/FatBuildCompacted.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/FatBuildCompacted.java
similarity index 68%
rename from 
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/FatBuildCompacted.java
rename to 
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/FatBuildCompacted.java
index 461f774..657d45a 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/FatBuildCompacted.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/FatBuildCompacted.java
@@ -14,13 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.ignite.ci.teamcity.ignited;
+package org.apache.ignite.ci.teamcity.ignited.fatbuild;
 
+import java.util.ArrayList;
+import java.util.List;
 import org.apache.ignite.ci.analysis.IVersionedEntity;
 import org.apache.ignite.ci.db.Persisted;
 import org.apache.ignite.ci.tcmodel.conf.BuildType;
-import org.apache.ignite.ci.tcmodel.hist.BuildRef;
 import org.apache.ignite.ci.tcmodel.result.Build;
+import org.apache.ignite.ci.tcmodel.result.TestOccurrencesRef;
+import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrence;
+import org.apache.ignite.ci.teamcity.ignited.BuildRefCompacted;
+import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
+import org.jetbrains.annotations.Nullable;
 
 /**
  *
@@ -39,9 +45,14 @@ public class FatBuildCompacted extends BuildRefCompacted 
implements IVersionedEn
     /** Finish date. The number of milliseconds since January 1, 1970, 
00:00:00 GMT */
     private long finishDate;
 
+    /** Finish date. The number of milliseconds since January 1, 1970, 
00:00:00 GMT */
+    private long queuedDate;
+
     private int projectId = -1;
     private int name = -1;
 
+    @Nullable private List<TestCompacted> tests;
+
     /** {@inheritDoc} */
     @Override public int version() {
         return _ver;
@@ -67,6 +78,8 @@ public class FatBuildCompacted extends BuildRefCompacted 
implements IVersionedEn
 
         startDate = ref.getStartDate() == null ? -1L : 
ref.getStartDate().getTime();
         finishDate = ref.getFinishDate() == null ? -1L : 
ref.getFinishDate().getTime();
+        queuedDate = ref.getQueuedDate() == null ? -1L : 
ref.getQueuedDate().getTime();
+
 
         BuildType type = ref.getBuildType();
         if (type != null) {
@@ -99,13 +112,35 @@ public class FatBuildCompacted extends BuildRefCompacted 
implements IVersionedEn
         if (finishDate > 0)
             res.setFinishDateTs(finishDate);
 
+        if (queuedDate > 0)
+            res.setQueuedDateTs(queuedDate);
+
         BuildType type = new BuildType();
         type.id(res.buildTypeId());
         type.name(compactor.getStringFromId(name));
         type.projectId(compactor.getStringFromId(projectId));
         res.setBuildType(type);
 
-        res.href = "/app/rest/latest/builds/id:" + id();
+        if (tests != null) {
+            TestOccurrencesRef testOccurrencesRef = new TestOccurrencesRef();
+            testOccurrencesRef.href = 
"/app/rest/latest/testOccurrences?locator=build:(id:" + id() + ")";
+            testOccurrencesRef.count = tests.size();
+            res.testOccurrences = testOccurrencesRef;
+        }
     }
 
+    /**
+     * @param compactor Compactor.
+     * @param page Page.
+     */
+    public void addTests(IStringCompactor compactor, List<TestOccurrence> 
page) {
+        for (TestOccurrence next : page) {
+            TestCompacted compacted = new TestCompacted(compactor, next);
+
+            if (tests == null)
+                tests = new ArrayList<>();
+
+            tests.add(compacted);
+        }
+    }
 }
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/TestCompacted.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/TestCompacted.java
new file mode 100644
index 0000000..429b60d
--- /dev/null
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/TestCompacted.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ci.teamcity.ignited.fatbuild;
+
+import com.google.common.base.Strings;
+import org.apache.ignite.ci.analysis.RunStat;
+import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrence;
+import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class TestCompacted {
+    /** Id in this build only. Does not idenfity test for its history */
+    private int idInBuild = -1;
+
+    private int name = -1;
+    private int status = -1;
+    private int duration = -1;
+
+    /** Logger. */
+    private static final Logger logger = 
LoggerFactory.getLogger(TestCompacted.class);
+
+    /**
+     * Default constructor.
+     */
+    public TestCompacted() {
+    }
+
+    /**
+     * @param compactor Compactor.
+     * @param testOccurrence TestOccurrence.
+     */
+    public TestCompacted(IStringCompactor compactor, TestOccurrence 
testOccurrence) {
+        String testOccurrenceId = testOccurrence.getId();
+        if (!Strings.isNullOrEmpty(testOccurrenceId)) {
+            try {
+                idInBuild = 
RunStat.extractFullId(testOccurrenceId).getTestId();
+            }
+            catch (Exception e) {
+                logger.error("Failed to handle TC response: " + 
testOccurrenceId, e);
+            }
+        }
+
+        name = compactor.getStringId(testOccurrence.name);
+        status = compactor.getStringId(testOccurrence.status);
+        duration = testOccurrence.duration == null ? -1 : 
testOccurrence.duration;
+    }
+}
diff --git 
a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
 
b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
index 3772983..cdbff4b 100644
--- 
a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
+++ 
b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
@@ -38,6 +38,7 @@ import org.apache.ignite.ci.tcmodel.conf.BuildType;
 import org.apache.ignite.ci.tcmodel.hist.BuildRef;
 import org.apache.ignite.ci.tcmodel.result.Build;
 import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrences;
+import org.apache.ignite.ci.teamcity.ignited.fatbuild.FatBuildCompacted;
 import org.apache.ignite.ci.teamcity.pure.BuildHistoryEmulator;
 import org.apache.ignite.ci.teamcity.pure.ITeamcityHttpConnection;
 import org.apache.ignite.ci.user.ICredentialsProv;

Reply via email to