Skip to content
Permalink
Browse files
Current tracked branch: Option added to show tests longer that N seconds
  • Loading branch information
dspavlov committed Jul 26, 2019
1 parent a163259 commit 3289df74676b819fd9357d001709590e1189f2a1
Showing 15 changed files with 108 additions and 52 deletions.
@@ -579,7 +579,8 @@ protected String checkFailuresEx(String brachName) {
false,
null,
DisplayMode.None,
null);
null,
-1);

DsSummaryUi failures =
tbProc.getTrackedBranchTestFailures(brachName,
@@ -590,7 +591,8 @@ protected String checkFailuresEx(String brachName) {
false,
null,
DisplayMode.OnlyFailures,
null);
null,
-1);

String issRes = registerIssuesAndNotifyLater(failures, backgroundOpsCreds);

@@ -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 = "20190725";
public static final String VERSION = "20190726";

/** Java version, where Web App is running. */
public String javaVer;
@@ -91,7 +91,7 @@ public void showChainOnServersResults(StringBuilder res, Integer buildId, String
status.chainName = ctx.suiteName();

IStringCompactor c = injector.getInstance(IStringCompactor.class);
status.initFromContext(tcIgn, ctx, failRateBranch, c, false, null, null);
status.initFromContext(tcIgn, ctx, failRateBranch, c, false, null, null, -1);

res.append(showChainAtServerData(status));

@@ -140,7 +140,7 @@ public DsSummaryUi getBuildTestFailsNoSync(
if (cnt > 0)
runningUpdates.addAndGet(cnt);

chainStatus.initFromContext(tcIgnited, ctx, failRateBranch, injector.getInstance(IStringCompactor.class), false, null, null);
chainStatus.initFromContext(tcIgnited, ctx, failRateBranch, injector.getInstance(IStringCompactor.class), false, null, null, -1);

res.addChainOnServer(chainStatus);

@@ -69,9 +69,10 @@ public UpdateInfo getTestFailsUpdates(@Nullable @QueryParam("branch") String bra
@Nullable @QueryParam("tagSelected") String tagSelected,
@Nullable @QueryParam("displayMode") String displayMode,
@Nullable @QueryParam("sortOption") String sortOption,
@Nullable @QueryParam("count") Integer mergeCnt) {
@Nullable @QueryParam("count") Integer mergeCnt,
@Nullable @QueryParam("showTestLongerThan") Integer showTestLongerThan) {
return new UpdateInfo().copyFrom(getTestFailsResultsNoSync(branchOrNull, checkAllLogs, trustedTests, tagSelected,
displayMode, sortOption, mergeCnt));
displayMode, sortOption, mergeCnt, showTestLongerThan));
}

@GET
@@ -83,8 +84,9 @@ public String getTestFailsText(@Nullable @QueryParam("branch") String branchOrNu
@Nullable @QueryParam("tagSelected") String tagSelected,
@Nullable @QueryParam("displayMode") String displayMode,
@Nullable @QueryParam("sortOption") String sortOption,
@Nullable @QueryParam("count") Integer mergeCnt) {
return getTestFailsResultsNoSync(branchOrNull, checkAllLogs, trustedTests, tagSelected, displayMode, sortOption, mergeCnt).toString();
@Nullable @QueryParam("count") Integer mergeCnt,
@Nullable @QueryParam("showTestLongerThan") Integer showTestLongerThan) {
return getTestFailsResultsNoSync(branchOrNull, checkAllLogs, trustedTests, tagSelected, displayMode, sortOption, mergeCnt, showTestLongerThan).toString();
}

@GET
@@ -96,8 +98,9 @@ public DsSummaryUi getTestFailsResultsNoSync(
@Nullable @QueryParam("tagSelected") String tagSelected,
@Nullable @QueryParam("displayMode") String displayMode,
@Nullable @QueryParam("sortOption") String sortOption,
@Nullable @QueryParam("count") Integer mergeCnt) {
return latestBuildResults(branch, checkAllLogs, trustedTests, tagSelected, SyncMode.NONE, displayMode, sortOption, mergeCnt);
@Nullable @QueryParam("count") Integer mergeCnt,
@Nullable @QueryParam("showTestLongerThan") Integer showTestLongerThan) {
return latestBuildResults(branch, checkAllLogs, trustedTests, tagSelected, SyncMode.NONE, displayMode, sortOption, mergeCnt, showTestLongerThan);
}

@GET
@@ -110,8 +113,9 @@ public DsSummaryUi getTestFailsNoCache(
@Nullable @QueryParam("tagSelected") String tagSelected,
@Nullable @QueryParam("displayMode") String displayMode,
@Nullable @QueryParam("sortOption") String sortOption,
@Nullable @QueryParam("count") Integer mergeCnt) {
return latestBuildResults(branch, checkAllLogs, trustedTests, tagSelected, SyncMode.RELOAD_QUEUED, displayMode, sortOption, mergeCnt);
@Nullable @QueryParam("count") Integer mergeCnt,
@Nullable @QueryParam("showTestLongerThan") Integer showTestLongerThan) {
return latestBuildResults(branch, checkAllLogs, trustedTests, tagSelected, SyncMode.RELOAD_QUEUED, displayMode, sortOption, mergeCnt, showTestLongerThan);
}

@NotNull private DsSummaryUi latestBuildResults(
@@ -122,18 +126,22 @@ public DsSummaryUi getTestFailsNoCache(
@Nonnull SyncMode mode,
@Nullable String displayMode,
@Nullable String sortOption,
@Nullable Integer mergeCnt) {
@Nullable Integer mergeCnt,
@Nullable Integer showTestLongerThan) {
ITcBotUserCreds creds = ITcBotUserCreds.get(req);

Injector injector = CtxListener.getInjector(ctx);

int actualMergeBuilds = (mergeCnt == null || mergeCnt < 1) ? 1 : mergeCnt;

int maxDurationSec = (showTestLongerThan == null || showTestLongerThan < 1) ? 0 : showTestLongerThan;

return injector.getInstance(IDetailedStatusForTrackedBranch.class)
.getTrackedBranchTestFailures(branch, checkAllLogs, actualMergeBuilds, creds, mode,
Boolean.TRUE.equals(trustedTests), tagSelected,
DisplayMode.parseStringValue(displayMode),
SortOption.parseStringValue(sortOption));
SortOption.parseStringValue(sortOption),
maxDurationSec);
}

@GET
@@ -171,7 +179,8 @@ public DsSummaryUi getAllTestFailsForMergedBuidls(@Nullable @QueryParam("branch"
Injector injector = CtxListener.getInjector(ctx);

return injector.getInstance(TrackedBranchChainsProcessor.class)
.getTrackedBranchTestFailures(branchOpt, checkAllLogs, cntLimit, creds, mode, false, null, DisplayMode.OnlyFailures, null);
.getTrackedBranchTestFailures(branchOpt, checkAllLogs, cntLimit, creds, mode,
false, null, DisplayMode.OnlyFailures, null, -1);
}

/**
@@ -38,11 +38,11 @@
}

function showQueryForm() {
let min,max;
let min, max;

let minFailRate = findGetParameter("minFailRate");
if (minFailRate != null) {
min = parseInt(minFailRate) ;
min = parseInt(minFailRate);
} else {
min = 0;
}
@@ -51,7 +51,7 @@
if (maxFailRate != null) {
max = parseInt(maxFailRate);
} else {
max=100;
max = 100;
}


@@ -72,6 +72,11 @@
absMinFailRate: 0,
absMaxFailRate: 100,
failRateRange: [min, max],

showTestLongerThan: '',

tagForHistorySelected: '',
tagsForHistoryPresent: []
},
methods: {
formChanged: function () {
@@ -105,19 +110,18 @@
gVue.$data.count = count;
}

let trustedTests = findGetParameter("trustedTests");
if (trustedTests != null) {
gVue.$data.trustedTests = trustedTests==="true";
}
gVue.$data.trustedTests = findGetParameter("trustedTests") === "true";
gVue.$data.checkAllLogs = findGetParameter("checkAllLogs") === "true";
gVue.$data.hideFlakyFailures = findGetParameter("hideFlakyFailures") === "true";

let checkAllLogs = findGetParameter("checkAllLogs");
if (checkAllLogs != null) {
gVue.$data.checkAllLogs = checkAllLogs==="true";
}
let showTestLongerThan = findGetParameter("showTestLongerThan");
if (showTestLongerThan != null)
gVue.$data.showTestLongerThan = showTestLongerThan;

var hideFlakyFailuresP = findGetParameter("hideFlakyFailures");
if (hideFlakyFailuresP != null) {
gVue.$data.hideFlakyFailures = hideFlakyFailuresP==="true";
let tagForHistorySelected = findGetParameter("tagForHistorySelected");
if (tagForHistorySelected != null) {
gVue.$data.tagsForHistoryPresent.push(tagForHistorySelected);
gVue.$data.tagForHistorySelected = tagForHistorySelected;
}

genLink();
@@ -173,6 +177,12 @@

curReqParms += "&hideFlakyFailures=" + gVue.$data.hideFlakyFailures;

if (gVue.$data.tagForHistorySelected != null)
curReqParms += "&tagForHistorySelected=" + gVue.$data.tagForHistorySelected;

if (gVue.$data.showTestLongerThan != null)
curReqParms += "&showTestLongerThan=" + gVue.$data.showTestLongerThan;

return curReqParms;
}

@@ -257,6 +267,7 @@

function showData(result) {
let setOfTags = new Set(gVue.$data.tagsPresent);
let setOfHistTags = new Set(gVue.$data.tagForHistorySelected);
for (let i = 0; i < result.servers.length; i++) {
let chain = result.servers[i];

@@ -268,12 +279,14 @@
const tag = suite.tags[k];

setOfTags.add(tag);
setOfHistTags.add(tag);
}
}
}
}

gVue.$data.tagsPresent = Array.from(setOfTags);
gVue.$data.tagsForHistoryPresent = Array.from(setOfHistTags);

//var txtUrl = "rest/tracked/results/txt" + parmsForRest();

@@ -317,12 +330,15 @@
<option value="SuiteDuration">Suite Duration</option>
</select>
<br>
<span>Merge Builds: </span> <input v-model.number="count" type="number" @change="formChanged">
<span>Merge Builds: </span>
<input v-model.number="count" type="number" @change="formChanged">
&nbsp;&nbsp;<span title="Show trusted tests count">Trusted tests: </span>
<input type="checkbox" v-model="trustedTests" @change="formChanged">
&nbsp;&nbsp;<span title="Download and parse all logs">Check logs: </span>
<input type="checkbox" v-model="checkAllLogs" @change="formChanged">

<br>
<span>Show test longer than, seconds: </span>
<input v-model.number="showTestLongerThan" type="number" @change="formChanged">
</td>

<td style="width: 50%">
@@ -350,7 +366,8 @@
hide-details
single-line
type="number"
style="width: 60px"></v-text-field>
style="width: 60px"
@change="formChanged"></v-text-field>

<span>Max failure rate: </span>
<v-text-field
@@ -359,7 +376,8 @@
hide-details
single-line
type="number"
style="width: 60px"></v-text-field>
style="width: 60px"
@change="formChanged"></v-text-field>
</template>
<template v-slot:append>

@@ -949,7 +949,9 @@ function showTestFailData(testFail, isFailureShown, settings) {
}


if (!isFailureShown && isDefinedAndFilled(testFail.durationPrintable))
let showDuration = (isDefinedAndFilled(testFail.success) && testFail.success === true) || !isFailureShown;

if (showDuration && isDefinedAndFilled(testFail.durationPrintable))
res += " duration " + testFail.durationPrintable;

if (bold)
@@ -121,7 +121,8 @@ public void testTrackedBranchChainsProcessor() {
false,
1,
mock, SyncMode.RELOAD_QUEUED,
false, null, DisplayMode.OnlyFailures, null);
false, null, DisplayMode.OnlyFailures, null,
-1);

Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println(gson.toJson(failures));
@@ -707,4 +707,11 @@ ISuiteRunHistory suiteHist(ITeamcityIgnited tcIgn, @Nullable Integer baseBranchI
public boolean hasTestToReport(ITeamcityIgnited tcIgnited, Integer baseBranchId) {
return !getFilteredTests(test -> test.includeIntoReport(tcIgnited, baseBranchId)).isEmpty();
}

public boolean hasLongRunningTest(int maxSec) {
if (maxSec < 1)
return false;

return !getFilteredTests(test -> test.hasLongRunningTest(maxSec)).isEmpty();
}
}
@@ -181,4 +181,11 @@ public boolean includeIntoReport(ITeamcityIgnited tcIgnited, Integer baseBranchI

return false;
}

public boolean hasLongRunningTest(int sec) {
if (sec < 1)
return false;

return getAvgDurationMs() > TimeUnit.SECONDS.toMillis(sec);
}
}
@@ -165,7 +165,7 @@ else if (Action.CHAIN.equals(act))
runningUpdates.addAndGet(cnt0);

//fail rate reference is always default (master)
chainStatus.initFromContext(tcIgnited, ctx, baseBranchForTc, compactor, false, null, null); // don't need for PR
chainStatus.initFromContext(tcIgnited, ctx, baseBranchForTc, compactor, false, null, null, -1); // don't need for PR

initJiraAndGitInfo(chainStatus, jiraIntegration, gitHubConnIgnited);
}
@@ -329,7 +329,7 @@ private List<DsSuiteUi> findBlockerFailures(FullChainRunCtx fullChainRunCtx,
DsSuiteUi suiteUi = new DsSuiteUi();
suiteUi.testFailures = failures;

suiteUi.initFromContext(tcIgnited, ctx, baseBranch, compactor, false, false);
suiteUi.initFromContext(tcIgnited, ctx, baseBranch, compactor, false, false, -1);

return suiteUi;
}
@@ -36,6 +36,7 @@ public interface IDetailedStatusForTrackedBranch {
* @param tagSelected Selected tag based filter. If null or empty all data is returned.
* @param displayMode Suites and tests display mode. Default - failures only.
* @param sortOption Sort mode
* @param maxDurationSec Show test as failed if duration is greater than provided seconds count.
*/
public DsSummaryUi getTrackedBranchTestFailures(
@Nullable String branch,
@@ -46,7 +47,7 @@ public DsSummaryUi getTrackedBranchTestFailures(
boolean calcTrustedTests,
@Nullable String tagSelected,
@Nullable DisplayMode displayMode,
@Nullable SortOption sortOption);
@Nullable SortOption sortOption, int maxDurationSec);

// * @param baseTrackedBranch Branch tracked branch in Bot, has a priority if both TC & Bot branches (baseBranchForTcParm) present.
}
@@ -70,7 +70,8 @@ public class TrackedBranchChainsProcessor implements IDetailedStatusForTrackedBr
boolean calcTrustedTests,
@Nullable String tagSelected,
@Nullable DisplayMode displayMode,
@Nullable SortOption sortOption) {
@Nullable SortOption sortOption,
int maxDurationSec) {
final DsSummaryUi res = new DsSummaryUi();
final AtomicInteger runningUpdates = new AtomicInteger();

@@ -126,7 +127,7 @@ public class TrackedBranchChainsProcessor implements IDetailedStatusForTrackedBr
if (cnt > 0)
runningUpdates.addAndGet(cnt);

chainStatus.initFromContext(tcIgnited, ctx, baseBranchTc, compactor, calcTrustedTests, tagSelected, displayMode);
chainStatus.initFromContext(tcIgnited, ctx, baseBranchTc, compactor, calcTrustedTests, tagSelected, displayMode, maxDurationSec);

return chainStatus;
})
@@ -165,7 +165,8 @@ public void initFromContext(ITeamcityIgnited tcIgnited,
IStringCompactor compactor,
boolean calcTrustedTests,
@Nullable String tagSelected,
@Nullable DisplayMode displayMode) {
@Nullable DisplayMode displayMode,
int maxDurationSec) {
failedTests = 0;
failedToFinish = 0;
totalTests = 0;
@@ -198,11 +199,14 @@ public void initFromContext(ITeamcityIgnited tcIgnited,
if (dModeToUse == DisplayMode.None)
return; //don't convert any suite for UI

if (suite.isFailed() || dModeToUse == DisplayMode.ShowAllSuites
|| suite.hasTestToReport(tcIgnited, baseBranchId)) {
if (suite.isFailed()
|| dModeToUse == DisplayMode.ShowAllSuites
|| suite.hasTestToReport(tcIgnited, baseBranchId)
|| suite.hasLongRunningTest(maxDurationSec)) {
final DsSuiteUi suiteCurStatus = new DsSuiteUi();

suiteCurStatus.initFromContext(tcIgnited, suite, baseBranchTc, compactor, true, calcTrustedTests);
suiteCurStatus.initFromContext(tcIgnited, suite, baseBranchTc, compactor, true, calcTrustedTests,
maxDurationSec);

failedTests += suiteCurStatus.failedTests != null ? suiteCurStatus.failedTests : 0;

0 comments on commit 3289df7

Please sign in to comment.