Skip to content
Permalink
Browse files
More metrics added to UI related to build duration
  • Loading branch information
dspavlov committed Apr 30, 2019
1 parent 5b72557 commit e47cef3a08976b74f7aea101368de53dbc019e4c
Showing 10 changed files with 236 additions and 45 deletions.
@@ -68,7 +68,7 @@ public Stream<MultBuildRunCtx> failedChildSuites() {
* @return may return less time than actual duration if not all statistic is provided
*/
public Long getTotalDuration() {
return getDurations().filter(Objects::nonNull).mapToLong(t -> t).sum();
return sumOfNonNulls(getDurations());
}

public boolean hasFullDurationInfo() {
@@ -79,7 +79,7 @@ public boolean hasFullDurationInfo() {
* @return returns durations of all suites (last builds)
*/
private Stream<Long> getDurations() {
return suites().filter(ctx -> !ctx.isComposite()).map(MultBuildRunCtx::getBuildDuration);
return suitesNonComposite().map(MultBuildRunCtx::buildDuration);
}

/**
@@ -107,17 +107,42 @@ public boolean isFakeStub() {
}

public String getTestsDurationPrintable() {
long tests = suites().filter(ctx -> !ctx.isComposite())
.map(MultBuildRunCtx::getAvgTestsDuration)
.filter(Objects::nonNull).mapToLong(t -> t).sum();
long tests = sumOfNonNulls(suitesNonComposite().map(MultBuildRunCtx::getAvgTestsDuration));

return (TimeUtil.millisToDurationPrintable(tests));
}

@NotNull public Stream<MultBuildRunCtx> suitesNonComposite() {
return suites().filter(ctx -> !ctx.isComposite());
}

public String getLostInTimeoutsPrintable() {
long timeouts = suites().filter(ctx -> !ctx.isComposite())
.mapToLong(MultBuildRunCtx::getLostInTimeouts).sum();
long timeouts = suitesNonComposite().mapToLong(MultBuildRunCtx::getLostInTimeouts).sum();

return TimeUtil.millisToDurationPrintable(timeouts);
}

public String durationNetTimePrintable() {
return TimeUtil.millisToDurationPrintable(
sumOfNonNulls(suitesNonComposite().map(MultBuildRunCtx::buildDurationNetTime)));
}

public String sourceUpdateDurationPrintable() {
return TimeUtil.millisToDurationPrintable(
sumOfNonNulls(suitesNonComposite().map(MultBuildRunCtx::sourceUpdateDuration)));
}

public String artifcactPublishingDurationPrintable() {
return TimeUtil.millisToDurationPrintable(
sumOfNonNulls(suitesNonComposite().map(MultBuildRunCtx::artifcactPublishingDuration)));
}

public String dependeciesResolvingDurationPrintable() {
return TimeUtil.millisToDurationPrintable(
sumOfNonNulls(suitesNonComposite().map(MultBuildRunCtx::dependeciesResolvingDuration)));
}

public long sumOfNonNulls(Stream<Long> st) {
return st.filter(Objects::nonNull).mapToLong(t -> t).sum();
}
}
@@ -34,6 +34,7 @@
import javax.annotation.Nonnull;
import org.apache.ignite.ci.tcmodel.hist.BuildRef;
import org.apache.ignite.ci.tcmodel.result.problems.ProblemOccurrence;
import org.apache.ignite.ci.tcmodel.result.stat.Statistics;
import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
import org.apache.ignite.ci.teamcity.ignited.change.ChangeCompacted;
import org.apache.ignite.ci.teamcity.ignited.fatbuild.ProblemCompacted;
@@ -307,11 +308,42 @@ public String branchName() {
}

/**
* @return average build duration.
* @return average build duration, see {@link Statistics#BUILD_DURATION}.
*/
@Nullable public Long getBuildDuration() {
final OptionalDouble average = buildsStream()
.map(SingleBuildRunCtx::getBuildDuration)
@Nullable public Long buildDuration() {
return calcAverage(buildsStream().map(SingleBuildRunCtx::buildDuration));
}

/**
* @return average build duration, see {@link Statistics#BUILD_DURATION_NET_TIME}.
*/
@Nullable public Long buildDurationNetTime() {
return calcAverage(buildsStream().map(SingleBuildRunCtx::buildDurationNetTime));
}

/**
* @return average build duration, see {@link Statistics#SOURCES_UPDATE_DURATION}.
*/
@Nullable public Long sourceUpdateDuration() {
return calcAverage(buildsStream().map(SingleBuildRunCtx::sourceUpdateDuration));
}

/**
* @return average build duration, see {@link Statistics#ARTIFACTS_PUBLISHING_DURATION}.
*/
@Nullable public Long artifcactPublishingDuration() {
return calcAverage(buildsStream().map(SingleBuildRunCtx::artifcactPublishingDuration));
}

/**
* @return average build duration, see {@link Statistics#DEPENDECIES_RESOLVING_DURATION}.
*/
@Nullable public Long dependeciesResolvingDuration() {
return calcAverage(buildsStream().map(SingleBuildRunCtx::dependeciesResolvingDuration));
}

@Nullable public Long calcAverage(Stream<Long> stream) {
final OptionalDouble average = stream
.filter(Objects::nonNull)
.mapToLong(l -> l)
.average();
@@ -345,7 +377,7 @@ public long getLostInTimeouts() {

long allTimeoutsDuration = buildsStream()
.filter(SingleBuildRunCtx::hasTimeoutProblem)
.map(SingleBuildRunCtx::getBuildDuration)
.map(SingleBuildRunCtx::buildDuration)
.filter(Objects::nonNull)
.mapToLong(l -> l)
.sum();
@@ -204,10 +204,26 @@ public String projectId() {
return buildCompacted.projectId(compactor);
}

public Long getBuildDuration() {
@Nullable public Long buildDuration() {
return buildCompacted.buildDuration(compactor);
}

@Nullable public Long buildDurationNetTime() {
return buildCompacted.buildDurationNetTime(compactor);
}

@Nullable public Long sourceUpdateDuration() {
return buildCompacted.sourceUpdateDuration(compactor);
}

@Nullable public Long artifcactPublishingDuration() {
return buildCompacted.artifcactPublishingDuration(compactor);
}

@Nullable public Long dependeciesResolvingDuration() {
return buildCompacted.dependeciesResolvingDuration(compactor);
}

public void setChanges(Collection<ChangeCompacted> changes) {
this.changes.clear();
this.changes.addAll(changes);
@@ -29,30 +29,18 @@
@XmlRootElement(name = "properties")
@XmlAccessorType(XmlAccessType.FIELD)
public class Statistics extends Parameters {
/** The build duration (all build stages). */
public static final String BUILD_DURATION = "BuildDuration";
public static final String BUILD_STAGE_DURATION_SOURCES_UPDATE = "buildStageDuration:sourcesUpdate";

/**
* @return build duration in millis or null.
*/
@Nullable public Long getBuildDuration() {
String duration = getParameter(BUILD_DURATION);
if (duration == null)
return null;
/** Build duration self time: The build steps duration (excluding the checkout and artifact publishing time, etc.) */
public static final String BUILD_DURATION_NET_TIME = "BuildDurationNetTime";

return Long.parseLong(duration);
}
/** Build stage duration sources update. */
public static final String SOURCES_UPDATE_DURATION = "buildStageDuration:sourcesUpdate";

/**
* @return source update duration in millis.
*/
@Nullable public Long getSourceUpdateDuration() {
String duration = getParameter(BUILD_STAGE_DURATION_SOURCES_UPDATE);

if (duration == null)
return null;

return Long.parseLong(duration);
}
/** Artifacts publishing. */
public static final String ARTIFACTS_PUBLISHING_DURATION = "buildStageDuration:artifactsPublishing";

/** Dependecies resolving. */
public static final String DEPENDECIES_RESOLVING_DURATION = "buildStageDuration:dependenciesResolving";
}
@@ -527,6 +527,22 @@ public Long buildDuration(IStringCompactor compactor) {
return statistics == null ? null : statistics.buildDuration(compactor);
}

public Long buildDurationNetTime(IStringCompactor compactor) {
return statistics == null ? null : statistics.buildDurationNetTime(compactor);
}

public Long artifcactPublishingDuration(IStringCompactor compactor) {
return statistics == null ? null : statistics.artifcactPublishingDuration(compactor);
}

public Long dependeciesResolvingDuration(IStringCompactor compactor) {
return statistics == null ? null : statistics.dependeciesResolvingDuration(compactor);
}

public Long sourceUpdateDuration(IStringCompactor compactor) {
return statistics == null ? null : statistics.sourceUpdateDuration(compactor);
}

public void statistics(IStringCompactor compactor, Statistics statistics) {
this.statistics = new StatisticsCompacted(compactor, statistics);
}
@@ -67,16 +67,81 @@ public StatisticsCompacted(IStringCompactor compactor, Statistics statistics) {
}
}

/**
* Provides build duration in millis or null.
*
* @param compactor Compactor.
* @return see {@link Statistics#BUILD_DURATION}
*/
public Long buildDuration(IStringCompactor compactor) {
final Integer buildDurationId = compactor.getStringIdIfPresent(Statistics.BUILD_DURATION);
Integer buildDurationId = compactor.getStringIdIfPresent(Statistics.BUILD_DURATION);

if (buildDurationId == null)
return null;

long val = findPropertyValue(buildDurationId);

if (val < 0) return null;
return val >= 0 ? val : null;
}

/**
* @param compactor Compactor.
* @return see {@link Statistics#BUILD_DURATION}
*/
public Long buildDurationNetTime(IStringCompactor compactor) {
Integer buildDurationNetId = compactor.getStringIdIfPresent(Statistics.BUILD_DURATION_NET_TIME);

if (buildDurationNetId == null)
return null;

long val = findPropertyValue(buildDurationNetId);

return val >= 0 ? val : null;
}

/**
* @param compactor Compactor.
* @return see {@link Statistics#ARTIFACTS_PUBLISHING_DURATION}
*/
public Long artifcactPublishingDuration(IStringCompactor compactor) {
Integer buildDurationNetId = compactor.getStringIdIfPresent(Statistics.ARTIFACTS_PUBLISHING_DURATION);

if (buildDurationNetId == null)
return null;

long val = findPropertyValue(buildDurationNetId);

return val >= 0 ? val : null;
}

/**
* @param compactor Compactor.
* @return see {@link Statistics#DEPENDECIES_RESOLVING_DURATION}
*/
public Long dependeciesResolvingDuration(IStringCompactor compactor) {
Integer buildDurationNetId = compactor.getStringIdIfPresent(Statistics.DEPENDECIES_RESOLVING_DURATION);

if (buildDurationNetId == null)
return null;

long val = findPropertyValue(buildDurationNetId);

return val >= 0 ? val : null;
}

/**
* @param compactor Compactor.
* @return source update duration in millis.{@link Statistics#SOURCES_UPDATE_DURATION}
*/
public Long sourceUpdateDuration(IStringCompactor compactor) {
Integer buildDurationNetId = compactor.getStringIdIfPresent(Statistics.SOURCES_UPDATE_DURATION);

if (buildDurationNetId == null)
return null;

long val = findPropertyValue(buildDurationNetId);

return val;
return val >= 0 ? val : null;
}

private long findPropertyValue(int propCode) {
@@ -28,7 +28,7 @@
public static final String GITHUB_REF = "https://github.com/apache/ignite-teamcity-bot";

/** TC Bot Version. */
public static final String VERSION = "20190427";
public static final String VERSION = "20190430";

/** Java version, where Web App is running. */
public String javaVer;
@@ -87,6 +87,15 @@ public class ChainAtServerCurrentStatus {
/** Duration printable. */
public String durationPrintable;

/** Duration net time printable. */
public String durationNetTimePrintable;

public String sourceUpdateDurationPrintable;

public String artifcactPublishingDurationPrintable;

public String dependeciesResolvingDurationPrintable;

/** Tests duration printable. */
public String testsDurationPrintable;

@@ -178,6 +187,10 @@ public void initFromContext(ITeamcityIgnited tcIgnited,
);
durationPrintable = ctx.getDurationPrintable();
testsDurationPrintable = ctx.getTestsDurationPrintable();
durationNetTimePrintable = ctx.durationNetTimePrintable();
sourceUpdateDurationPrintable = ctx.sourceUpdateDurationPrintable();
artifcactPublishingDurationPrintable = ctx.artifcactPublishingDurationPrintable();
dependeciesResolvingDurationPrintable = ctx.dependeciesResolvingDurationPrintable();
lostInTimeouts = ctx.getLostInTimeoutsPrintable();
webToHist = buildWebLink(tcIgnited, ctx);
webToBuild = buildWebLinkToBuild(tcIgnited, ctx);
@@ -260,6 +273,10 @@ public String serverName() {
Objects.equals(failedTests, status.failedTests) &&
Objects.equals(failedToFinish, status.failedToFinish) &&
Objects.equals(durationPrintable, status.durationPrintable) &&
Objects.equals(durationNetTimePrintable, status.durationNetTimePrintable) &&
Objects.equals(sourceUpdateDurationPrintable, status.sourceUpdateDurationPrintable) &&
Objects.equals(artifcactPublishingDurationPrintable, status.artifcactPublishingDurationPrintable) &&
Objects.equals(dependeciesResolvingDurationPrintable, status.dependeciesResolvingDurationPrintable) &&
Objects.equals(testsDurationPrintable, status.testsDurationPrintable) &&
Objects.equals(lostInTimeouts, status.lostInTimeouts) &&
Objects.equals(topLongRunning, status.topLongRunning) &&
@@ -270,7 +287,9 @@ public String serverName() {
/** {@inheritDoc} */
@Override public int hashCode() {
return Objects.hash(chainName, serverId, branchName, webToHist, webToBuild, ticketFullName, webToTicket, prNum,
webToPr, suites, failedTests, failedToFinish, durationPrintable, testsDurationPrintable, lostInTimeouts, topLongRunning, logConsumers, buildNotFound, baseBranchForTc);
webToPr, suites, failedTests, failedToFinish, durationPrintable, durationNetTimePrintable,
sourceUpdateDurationPrintable, artifcactPublishingDurationPrintable, dependeciesResolvingDurationPrintable,
testsDurationPrintable, lostInTimeouts, topLongRunning, logConsumers, buildNotFound, baseBranchForTc);
}

public void setBuildNotFound(boolean buildNotFound) {

0 comments on commit e47cef3

Please sign in to comment.