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 2018/10/27 15:35:59 UTC
[ignite-teamcity-bot] 01/02: IGNITE-10030 problems done in tests:
Background upload of changes, problems, and statistics
This is an automated email from the ASF dual-hosted git repository.
dpavlov pushed a commit to branch ignite-10030
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git
commit 0144d9730939315bea6dac09e62891828e33615c
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Sat Oct 27 18:04:11 2018 +0300
IGNITE-10030 problems done in tests: Background upload of changes, problems, and statistics
---
.../tcmodel/result/problems/ProblemOccurrence.java | 8 ++
.../ignited/fatbuild/FatBuildCompacted.java | 24 +++-
.../ignited/fatbuild/ProblemCompacted.java | 142 +++++++++++++++++++++
.../teamcity/ignited/fatbuild/TestCompacted.java | 2 +-
.../ignited/IgnitedTcInMemoryIntegrationTest.java | 6 +-
.../src/test/resources/problemList.xml | 21 ++-
6 files changed, 195 insertions(+), 8 deletions(-)
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/problems/ProblemOccurrence.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/problems/ProblemOccurrence.java
index 72433f4..efbd438 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/problems/ProblemOccurrence.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/problems/ProblemOccurrence.java
@@ -77,4 +77,12 @@ public class ProblemOccurrence {
public boolean isJavaLevelDeadlock() {
return JAVA_LEVEL_DEADLOCK.equals(type);
}
+
+ public String id() {
+ return id;
+ }
+
+ public void id(String fullStrId) {
+ this.id = fullStrId;
+ }
}
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/FatBuildCompacted.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/FatBuildCompacted.java
index bcad28e..dbb23b3 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/FatBuildCompacted.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/FatBuildCompacted.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.List;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.ignite.ci.analysis.IVersionedEntity;
import org.apache.ignite.ci.db.Persisted;
@@ -41,7 +42,7 @@ import org.jetbrains.annotations.Nullable;
@Persisted
public class FatBuildCompacted extends BuildRefCompacted implements IVersionedEntity {
/** Latest version. */
- private static final int LATEST_VERSION = 2;
+ private static final int LATEST_VERSION = 3;
/** Default branch flag offset. */
public static final int DEF_BR_F = 0;
@@ -76,6 +77,8 @@ public class FatBuildCompacted extends BuildRefCompacted implements IVersionedEn
private BitSet flags = new BitSet();
+ @Nullable private List<ProblemCompacted> problems;
+
/** {@inheritDoc} */
@Override public int version() {
return _ver;
@@ -301,10 +304,23 @@ public class FatBuildCompacted extends BuildRefCompacted implements IVersionedEn
}
public List<ProblemOccurrence> problems(IStringCompactor compactor) {
- return Collections.emptyList(); //todo
+ if (this.problems == null)
+ return Collections.emptyList();
+
+ return this.problems.stream()
+ .map(pc -> pc.toProblemOccurrence(compactor, id()))
+ .collect(Collectors.toList());
}
- public void addProblems(IStringCompactor compactor, List<ProblemOccurrence> problems) {
- //todo
+ public void addProblems(IStringCompactor compactor, List<ProblemOccurrence> occurrences) {
+ if (occurrences.isEmpty())
+ return;
+
+ if (this.problems == null)
+ this.problems = new ArrayList<>();
+
+ occurrences.stream()
+ .map(p -> new ProblemCompacted(compactor, p))
+ .forEach(this.problems::add);
}
}
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/ProblemCompacted.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/ProblemCompacted.java
new file mode 100644
index 0000000..85e6792
--- /dev/null
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/ProblemCompacted.java
@@ -0,0 +1,142 @@
+/*
+ * 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.Objects;
+import com.google.common.base.Strings;
+import org.apache.ignite.ci.analysis.RunStat;
+import org.apache.ignite.ci.tcmodel.hist.BuildRef;
+import org.apache.ignite.ci.tcmodel.result.problems.ProblemOccurrence;
+import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrence;
+import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrenceFull;
+import org.apache.ignite.ci.tcmodel.result.tests.TestRef;
+import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
+import org.jetbrains.annotations.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xerial.snappy.Snappy;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.BitSet;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+import static org.apache.ignite.ci.analysis.RunStat.extractIdPrefixed;
+
+/**
+ *
+ */
+public class ProblemCompacted {
+ /** Id */
+ private int id = -1;
+ private int type = -1;
+ private int identity = -1;
+
+ /** Actual build id. */
+ private int actualBuildId = -1;
+
+ // later details may be needed @Nullable private byte[] details;
+
+ /** Logger. */
+ private static final Logger logger = LoggerFactory.getLogger(ProblemCompacted.class);
+
+ /**
+ * Default constructor.
+ */
+ public ProblemCompacted() {
+ }
+
+ /**
+ * @param compactor Compactor.
+ * @param problemOccurrence TestOccurrence.
+ */
+ public ProblemCompacted(IStringCompactor compactor, ProblemOccurrence problemOccurrence) {
+ String problemIdStr = problemOccurrence.id();
+ if (!Strings.isNullOrEmpty(problemIdStr)) {
+ try {
+ final Integer problemId = extractIdPrefixed(problemIdStr, "problem:(id:", ")");
+ if (problemId != null)
+ id = problemId ;
+ } catch (Exception e) {
+ logger.error("Failed to handle TC response: " + problemIdStr, e);
+ }
+ }
+
+ type = compactor.getStringId(problemOccurrence.type);
+ identity = compactor.getStringId(problemOccurrence.identity);
+
+
+ if (problemOccurrence.buildRef != null && problemOccurrence.buildRef.getId() != null)
+ actualBuildId = problemOccurrence.buildRef.getId();
+
+ }
+
+
+ public ProblemOccurrence toProblemOccurrence(IStringCompactor compactor, int buildId) {
+ ProblemOccurrence occurrence = new ProblemOccurrence();
+
+ String fullStrId =
+ "problem:(id:" + id + ")," +
+ " build:(id:" + buildId + ")";
+ occurrence.id(fullStrId);
+ occurrence.type = compactor.getStringFromId(type);
+ occurrence.identity = compactor.getStringFromId(identity);
+ occurrence.href = "problemOccurrences?locator=" + fullStrId;
+
+ if (actualBuildId > 0) {
+ BuildRef buildRef = new BuildRef();
+
+ buildRef.setId(actualBuildId);
+
+ occurrence.buildRef = buildRef;
+ }
+
+ return occurrence;
+ }
+
+ private int id() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ProblemCompacted that = (ProblemCompacted) o;
+ return id == that.id &&
+ type == that.type &&
+ identity == that.identity &&
+ actualBuildId == that.actualBuildId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, type, identity, actualBuildId);
+ }
+
+ public boolean isExecutionTimeout(IStringCompactor compactor) {
+ return compactor.getStringId(ProblemOccurrence.TC_EXECUTION_TIMEOUT) == type;
+ }
+
+ public String type(IStringCompactor compactor) {
+ return compactor.getStringFromId(type);
+ }
+}
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
index 37a32bc..573b87c 100644
--- 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
@@ -55,7 +55,7 @@ public class TestCompacted {
public static final int COMPRESS_TYPE_RFU3 = 10;
public static final int COMPRESS_TYPE_RFU4 = 11;
- /** Id in this build only. Does not idenfity test for its history */
+ /** Id in this build only. Does not identify test for its history */
private int idInBuild = -1;
private int name = -1;
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 6427cb4..88bb399 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
@@ -306,7 +306,11 @@ public class IgnitedTcInMemoryIntegrationTest {
assertEquals(testNamesRef, testNamesAct);
final List<ProblemOccurrence> problems = buildCompacted.problems(compactor);
- assertEquals(1, problems.size());
+ assertEquals(2, problems.size());
+
+ assertTrue(problems.stream().anyMatch(ProblemOccurrence::isFailedTests));
+ assertTrue(problems.stream().anyMatch(ProblemOccurrence::isExitCode));
+ assertTrue(problems.stream().noneMatch(ProblemOccurrence::isJvmCrash));
}
public void saveTmpFile(Object obj, String name) throws IOException, JAXBException {
diff --git a/ignite-tc-helper-web/src/test/resources/problemList.xml b/ignite-tc-helper-web/src/test/resources/problemList.xml
index 6bf4ca9..4a770f2 100644
--- a/ignite-tc-helper-web/src/test/resources/problemList.xml
+++ b/ignite-tc-helper-web/src/test/resources/problemList.xml
@@ -1,3 +1,20 @@
-<problemOccurrences count="1" href="http://ci.ignite.apache.org:443/app/rest/problemOccurrences?locator=build:(id:2153237)">
- <problemOccurrence id="problem:(id:3733),build:(id:2153237)" type="TC_FAILED_TESTS" identity="TC_FAILED_TESTS_bt1053" href="/app/rest/latest/problemOccurrences/problem:(id:3733),build:(id:2153237)"/>
+<!-- Syntetic list from:
+ https://ci.ignite.apache.org/app/rest/latest/problemOccurrences?locator=build:(id:2153237)&fields=problemOccurrence(id,type,identity,href,details,build(id))-->
+<problemOccurrences>
+ <problemOccurrence id="problem:(id:3481),build:(id:2136678)" type="TC_EXIT_CODE" identity="Inspection1"
+ href="/app/rest/latest/problemOccurrences/problem:(id:3481),build:(id:2136678)">
+ <details>Process exited with code 1</details>
+ <additionalData>teamcity.process.flow.id=1200755009805251</additionalData>
+ <problem id="3481" type="TC_EXIT_CODE" identity="Inspection1" href="/app/rest/latest/problems/id:3481"/>
+ <build id="2136678" buildTypeId="IgniteTests24Java8_InspectionsAop" number="165" status="FAILURE"
+ state="finished" branchName="refs/heads/master" defaultBranch="true"
+ href="/app/rest/latest/builds/id:2136678"
+ webUrl="http://ci.ignite.apache.org/viewLog.html?buildId=2136678&buildTypeId=IgniteTests24Java8_InspectionsAop"/>
+ </problemOccurrence>
+ <problemOccurrence id="problem:(id:3733),build:(id:2153237)" type="TC_FAILED_TESTS"
+ identity="TC_FAILED_TESTS_bt1053"
+ href="/app/rest/latest/problemOccurrences/problem:(id:3733),build:(id:2153237)">
+ <details>1 failed test detected</details>
+ <build id="2153237"/>
+ </problemOccurrence>
</problemOccurrences>
\ No newline at end of file