Skip to content
Permalink
Browse files
Master Trends - suites from different servers (#123)
* Selection of service
  • Loading branch information
dspavlov committed May 8, 2019
1 parent 180bb2e commit 9a8ee82699435018985810975288eb64f96be461
Showing 4 changed files with 43 additions and 17 deletions.
@@ -36,6 +36,9 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

import org.apache.ignite.ci.ITeamcity;
import org.apache.ignite.ci.tcbot.conf.ITcBotConfig;
import org.apache.ignite.ci.tcbot.trends.MasterTrendsService;
import org.apache.ignite.ci.teamcity.ignited.BuildRefCompacted;
import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
@@ -52,12 +55,12 @@
* Presents statistic for all valid builds and merged failed unmuted tests in specified time interval. Statistics and
* tests are stored in {@link #buildsStatistics} and {@link #mergedTestsBySuites} properties respectively. Builder
* pattern is used for instance creation. Default values: <br>skipTests = false,<br>projectId="IgniteTests24Java8",
* <br>srvId="apache", <br>buildTypeId="IgniteTests24Java8_RunAll",
* <br>srvCode="apache", <br>buildTypeId="IgniteTests24Java8_RunAll",
* <br>branchName="refs/heads/master".
*/
public class BuildsHistory {
/** */
private String srvId;
private String srvCode;

/** */
public String projectId;
@@ -101,7 +104,7 @@ public class BuildsHistory {
* @param prov Credentials.
*/
public void initialize(ICredentialsProv prov) {
ITeamcityIgnited ignitedTeamcity = tcIgnitedProv.server(srvId, prov);
ITeamcityIgnited ignitedTeamcity = tcIgnitedProv.server(srvCode, prov);

tcHost = ignitedTeamcity.host();

@@ -212,7 +215,7 @@ private void initFailedTests(List<Integer> buildIds,

private BuildsHistory withParameters(Builder builder) {
this.skipTests = builder.skipTests;
this.srvId = builder.srvId;
this.srvCode = builder.srvCode;
this.buildTypeId = builder.buildTypeId;
this.branchName = builder.branchName;
this.sinceDateFilter = builder.sinceDate;
@@ -230,13 +233,13 @@ public static class Builder {
private String projectId = "IgniteTests24Java8";

/** */
private String srvId = "apache";
private String srvCode;

/** */
private String buildTypeId = "IgniteTests24Java8_RunAll";

/** */
private String branchName = "refs/heads/master";
private String branchName = ITeamcity.DEFAULT;

/** */
private Date sinceDate = null;
@@ -247,12 +250,17 @@ public static class Builder {
/** */
private DateFormat dateFormat = new SimpleDateFormat("ddMMyyyyHHmmss");

public Builder(ITcBotConfig cfg) {
srvCode = cfg.primaryServerCode();
// todo may find findDefaultBuildType() from cfg.getTeamcityConfig(srvCode).defaultTrackedBranch()
}

/**
* @param srvId server name.
*/
public Builder server(String srvId) {
if (!isNullOrEmpty(srvId))
this.srvId = srvId;
this.srvCode = srvId;

return this;
}
@@ -103,7 +103,7 @@ public Set<ChainAtServer> getSuites(@Nullable @QueryParam("server") String srvId
}

/**
* Return all servers registered in TC Bot config: Both from tracked branches and from
* Return all accessible servers registered in TC Bot config: Both from tracked branches and from
*/
@GET
@Path("getServerIds")
@@ -213,8 +213,9 @@ public BuildsHistory getBuildsHistory(
@Nullable @QueryParam("skipTests") String skipTests) throws ParseException {

Injector injector = CtxListener.getInjector(ctx);
final ITcBotConfig cfg = injector.getInstance(ITcBotConfig.class);

BuildsHistory.Builder builder = new BuildsHistory.Builder()
BuildsHistory.Builder builder = new BuildsHistory.Builder(cfg)
.branch(branch)
.server(srvCode)
.buildType(buildType)
@@ -188,6 +188,9 @@
testsTrigger = false,
error = $('#loadStatus');

/** Key-value map. Key - Full suite text. Value - {@link org.apache.ignite.ci.tcbot.conf.ChainAtServer} object. */
var suiteFullNameToChain = new Map();

function refreshTests() {
printTests(generateTestsResultsComparison(mergedTestsResults));
}
@@ -557,8 +560,8 @@

function loadTrackedSuites() {
$.ajax({
url: "rest/branches/suites?server=apache",
success: function(result) {
url: "rest/branches/suites",
success: function (result) {
if (!isDefinedAndFilled(result)) {
error.html("Result from " + this.url + " is undefined!");

@@ -573,11 +576,20 @@
});
}

/**
*
* @param result list of {@link org.apache.ignite.ci.tcbot.conf.ChainAtServer} objects as JSON.
*/
function printSuites(result) {
let selectHtml = "<select id='selectSuite'>";

for (let i = 0; i < result.length; i++)
selectHtml += getHtmlOption(result[i].suiteId, false, false, result[i].suiteId);
for (let i = 0; i < result.length; i++) {
let suite = result[i];
let text = suite.suiteId + " (" + suite.serverId + ")";

suiteFullNameToChain.set(text, suite);
selectHtml += getHtmlOption(text, false, false, text);
}

selectHtml += "</select>";

@@ -589,18 +601,23 @@
function loadData(num, sinceDate, untilDate, testsTrigger) {
loadGif(num);

let suiteId = $('#selectSuite').val();
let suiteIdFull = $('#selectSuite').val();


mergedTestsResults[num] = {};

if ((!isDefinedAndFilled(suiteId)) || (suiteId === "")) {
if ((!isDefinedAndFilled(suiteIdFull)) || (suiteIdFull === "")) {
error.html("Suite is " + (isDefinedAndFilled(suiteId) ? "empty" : "undefined") + "!");

return;
}

let url = 'rest/build/history?server=apache&buildType=' + suiteId + '&sinceDate=' +
sinceDate.format("DDMMYYYY") + '000001&untilDate=' + untilDate.format("DDMMYYYY") + '235959';
let chainAtServer = suiteFullNameToChain.get(suiteIdFull);

let url = 'rest/build/history?server=' + chainAtServer.serverId
+ '&buildType=' + chainAtServer.suiteId
+ '&sinceDate=' + sinceDate.format("DDMMYYYY") + '000001'
+ '&untilDate=' + untilDate.format("DDMMYYYY") + '235959';

if (!testsTrigger)
url = url + '&' + SKIP_TESTS;

0 comments on commit 9a8ee82

Please sign in to comment.