Skip to content
Permalink
Browse files
Removal of unused code
  • Loading branch information
dspavlov committed May 29, 2019
1 parent d419ebc commit 0bca9d21e6aa647408759f070a83a2717d7a3bc2
Showing 11 changed files with 145 additions and 670 deletions.

This file was deleted.

@@ -20,10 +20,10 @@
import com.google.common.collect.Lists;
import java.util.ArrayList;

import static org.apache.ignite.ci.analysis.RunStat.RunStatus.RES_CRITICAL_FAILURE;
import static org.apache.ignite.ci.analysis.RunStat.RunStatus.RES_FAILURE;
import static org.apache.ignite.ci.analysis.RunStat.RunStatus.RES_OK;
import static org.apache.ignite.ci.analysis.RunStat.RunStatus.RES_OK_OR_FAILURE;
import static org.apache.ignite.ci.teamcity.ignited.runhist.RunStatus.RES_CRITICAL_FAILURE;
import static org.apache.ignite.ci.teamcity.ignited.runhist.RunStatus.RES_FAILURE;
import static org.apache.ignite.ci.teamcity.ignited.runhist.RunStatus.RES_OK;
import static org.apache.ignite.ci.teamcity.ignited.runhist.RunStatus.RES_OK_OR_FAILURE;

public class EventTemplates {
private static final int OK = RES_OK.getCode();
@@ -20,7 +20,6 @@
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import org.apache.ignite.ci.analysis.RunStat;

/**
* Test occurrence. Can be provided by build as list of occurrences.
@@ -101,13 +100,6 @@ public TestOccurrence setStatus(String status) {
return this;
}

/**
* @return BuildId which that test occurrence belongs to
*/
public Integer getBuildId() {
return RunStat.extractIdPrefixed(id, "build:(id:", ")");
}

public void id(String s) {
id = s;
}
@@ -26,7 +26,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.apache.ignite.ci.analysis.RunStat.extractIdPrefixed;
import static org.apache.ignite.ci.teamcity.ignited.fatbuild.TestCompacted.extractIdPrefixed;

/**
*
@@ -26,7 +26,6 @@
import java.util.Objects;
import java.util.TreeMap;
import java.util.function.BiPredicate;
import org.apache.ignite.ci.analysis.RunStat;
import org.apache.ignite.ci.tcbot.common.StringFieldCompacted;
import org.apache.ignite.ci.tcmodel.hist.BuildRef;
import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrence;
@@ -36,6 +35,7 @@
import org.apache.ignite.ci.teamcity.ignited.buildtype.ParametersCompacted;
import org.apache.ignite.ci.teamcity.ignited.runhist.Invocation;
import org.apache.ignite.ci.teamcity.ignited.runhist.InvocationData;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -91,7 +91,7 @@ public TestCompacted(IStringCompactor compactor, TestOccurrenceFull testOccurren
String testOccurrenceId = testOccurrence.getId();
if (!Strings.isNullOrEmpty(testOccurrenceId)) {
try {
final RunStat.TestId testId = RunStat.extractFullId(testOccurrenceId);
final TestId testId = extractFullId(testOccurrenceId);
if (testId != null)
idInBuild = testId.getTestId();
} catch (Exception e) {
@@ -117,6 +117,42 @@ public TestCompacted(IStringCompactor compactor, TestOccurrenceFull testOccurren
setDetails(testOccurrence.details);
}

public static TestId extractFullId(String id) {
Integer buildId = extractIdPrefixed(id, "build:(id:", ")");

if (buildId == null)
return null;

Integer testId = extractIdPrefixed(id, "id:", ",");

if (testId == null)
return null;

return new TestId(buildId, testId);

}

public static Integer extractIdPrefixed(String id, String prefix, String postfix) {
try {
int buildIdIdx = id.indexOf(prefix);
if (buildIdIdx < 0)
return null;

int buildIdPrefixLen = prefix.length();
int absBuildIdx = buildIdIdx + buildIdPrefixLen;
int buildIdEndIdx = id.substring(absBuildIdx).indexOf(postfix);
if (buildIdEndIdx < 0)
return null;

String substring = id.substring(absBuildIdx, absBuildIdx + buildIdEndIdx);

return Integer.valueOf(substring);
}
catch (Exception ignored) {
return null;
}
}

private void setFlag(int off, Boolean val) {
flags.clear(off, off + 2);

@@ -402,4 +438,35 @@ public Invocation toInvocation(IStringCompactor compactor,

return invocation.withParameters(importantParms);
}

/**
* Pair of build and test Ids.
*/
private static class TestId {
int buildId;
int testId;

public TestId(Integer buildId, Integer testId) {
this.buildId = buildId;
this.testId = testId;
}

public int getBuildId() {
return buildId;
}

public int getTestId() {
return testId;
}

/**
* {@inheritDoc}
*/
@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("buildId", buildId)
.add("testId", testId)
.toString();
}
}
}
@@ -25,7 +25,6 @@
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.ignite.ci.analysis.RunStat;
import org.apache.ignite.ci.db.Persisted;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.NotNull;
@@ -38,13 +37,13 @@ public class InvocationData {
/** Max days to keep test invocatoin data in run statistics: affects Bot Visa. */
public static final int MAX_DAYS = 21;
/** Muted. */
public static final int MUTED = RunStat.RunStatus.RES_MUTED_FAILURE.getCode();
public static final int MUTED = RunStatus.RES_MUTED_FAILURE.getCode();
/** Failure. */
public static final int FAILURE = RunStat.RunStatus.RES_FAILURE.getCode();
public static final int FAILURE = RunStatus.RES_FAILURE.getCode();
/** Ok. */
public static final int OK = RunStat.RunStatus.RES_OK.getCode();
public static final int OK = RunStatus.RES_OK.getCode();
/** Ok. */
public static final int CRITICAL_FAILURE = RunStat.RunStatus.RES_CRITICAL_FAILURE.getCode();
public static final int CRITICAL_FAILURE = RunStatus.RES_CRITICAL_FAILURE.getCode();

/**
* Runs registered all the times.
@@ -23,7 +23,6 @@
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.apache.ignite.ci.analysis.IVersionedEntity;
import org.apache.ignite.ci.analysis.RunStat;
import org.apache.ignite.ci.db.Persisted;
import org.apache.ignite.ci.issue.EventTemplate;
import org.apache.ignite.ci.teamcity.ignited.IRunHistory;
@@ -176,9 +175,9 @@ private static Integer checkTemplateAtPos(int[] template, int centralEvtBuild, L
if (curStatus == null)
break;

RunStat.RunStatus tmpl = RunStat.RunStatus.byCode(template[tIdx]);
RunStatus tmpl = RunStatus.byCode(template[tIdx]);

if ((tmpl == RunStat.RunStatus.RES_OK_OR_FAILURE && (curStatus.status() == InvocationData.OK || curStatus.status() == InvocationData.FAILURE))
if ((tmpl == RunStatus.RES_OK_OR_FAILURE && (curStatus.status() == InvocationData.OK || curStatus.status() == InvocationData.FAILURE))
|| curStatus.status() == tmpl.getCode()) {
if (tIdx == template.length - 1)
return histAsArr.get(idx + centralEvtBuild).buildId();
@@ -75,6 +75,7 @@ public class RunHistSync {
/** Build DAO. */
@Inject private FatBuildDao fatBuildDao;

/** Config. */
@Inject private ITcBotConfig cfg;

/** Build to save to history. */
@@ -0,0 +1,64 @@
/*
* 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.runhist;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Status of run: Generalized result of execution of Suite/Test.
*/
public enum RunStatus {
/** Result: success. */
RES_OK(0),
/** Result: general failure of test or suite. */
RES_FAILURE(1),
/** RES OK or RES FAILURE */
RES_OK_OR_FAILURE(10),
/** Result of test execution, muted failure found. */
RES_MUTED_FAILURE(2),
/** Result of suite: Critical failure, no results. */
RES_CRITICAL_FAILURE(3);

/** Mapping of status int -> object. */
private static Map<Integer, RunStatus> holder = Stream.of(values()).collect(Collectors.toMap(RunStatus::getCode, i -> i));

/** Represent status in int. */
int code;

/** */
RunStatus(int code) {
this.code = code;
}

/**
* @return Status as int.
*/
public int getCode() {
return code;
}

/**
* @param code Status as int.
* @return Status of build.
*/
public static RunStatus byCode(int code) {
return holder.get(code);
}
}

0 comments on commit 0bca9d2

Please sign in to comment.