This is an automated email from the ASF dual-hosted git repository.
dpavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git
The following commit(s) were added to refs/heads/master by this push:
new c6c4b6a Enforce loading builds after trigger to correct display of
queued status of PR
c6c4b6a is described below
commit c6c4b6a82ab2868dca5cd72261f9d99f035fa73c
Author: Dmitriy Pavlov <[email protected]>
AuthorDate: Thu Oct 11 17:22:02 2018 +0300
Enforce loading builds after trigger to correct display of queued status of
PR
---
.../main/java/org/apache/ignite/ci/ITeamcity.java | 9 ------
.../apache/ignite/ci/IgnitePersistentTeamcity.java | 5 ++--
.../apache/ignite/ci/IgniteTeamcityConnection.java | 2 +-
.../ci/github/ignited/GitHubConnIgnitedImpl.java | 10 +++++--
.../ci/github/pure/GitHubConnectionImpl.java | 4 ++-
.../org/apache/ignite/ci/jobs/CheckQueueJob.java | 15 ++++++++--
.../tcbot/visa/TcBotTriggerAndSignOffService.java | 18 +++++++-----
.../ci/teamcity/ignited/ITeamcityIgnited.java | 15 ++++++++--
.../ci/teamcity/ignited/TeamcityIgnitedImpl.java | 34 ++++++++++++++++++----
.../ignite/ci/teamcity/pure/ITcServerProvider.java | 4 +++
.../ignite/ci/teamcity/pure/ITeamcityConn.java | 11 +++++++
.../apache/ignite/ci/web/rest/TriggerBuilds.java | 3 +-
ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js | 4 +--
13 files changed, 99 insertions(+), 35 deletions(-)
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java
index f213ca3..9a84b0c 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java
@@ -256,15 +256,6 @@ public interface ITeamcity extends ITeamcityConn {
void setExecutor(ExecutorService pool);
- /**
- * Trigger build.
- *
- * @param id Build identifier.
- * @param name Branch name.
- * @param cleanRebuild Rebuild all dependencies.
- * @param queueAtTop Put at the top of the build queue.
- */
- Build triggerBuild(String id, String name, boolean cleanRebuild, boolean
queueAtTop);
/**
* @param tok TeamCity authorization token.
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
index 900d562..d1e94e4 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
@@ -141,6 +141,7 @@ public class IgnitePersistentTeamcity implements
IAnalyticsEnabledTeamcity, ITea
private ConcurrentMap<SuiteInBranch, Long> lastQueuedHistory = new
ConcurrentHashMap<>();
//todo: not good code to keep it static
+ @Deprecated
private static long lastTriggerMs = System.currentTimeMillis();
private static final boolean noLocks = true;
@@ -1125,10 +1126,10 @@ public class IgnitePersistentTeamcity implements
IAnalyticsEnabledTeamcity, ITea
/** {@inheritDoc} */
@AutoProfiling
- @Override public Build triggerBuild(String id, String name, boolean
cleanRebuild, boolean queueAtTop) {
+ @Override public Build triggerBuild(String buildTypeId, String branchName,
boolean cleanRebuild, boolean queueAtTop) {
lastTriggerMs = System.currentTimeMillis();
- return teamcity.triggerBuild(id, name, cleanRebuild, queueAtTop);
+ return teamcity.triggerBuild(buildTypeId, branchName, cleanRebuild,
queueAtTop);
}
/** {@inheritDoc} */
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
index cd8b5b5..0cb684b 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
@@ -263,7 +263,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
@AutoProfiling
@Override public Build triggerBuild(
String buildTypeId,
- String branchName,
+ @Nonnull String branchName,
boolean cleanRebuild,
boolean queueAtTop
) {
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/GitHubConnIgnitedImpl.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/GitHubConnIgnitedImpl.java
index 7b0bc5c..d75b056 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/GitHubConnIgnitedImpl.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/GitHubConnIgnitedImpl.java
@@ -37,6 +37,9 @@ import org.apache.ignite.ci.github.pure.IGitHubConnection;
import org.apache.ignite.configuration.CacheConfiguration;
import org.jetbrains.annotations.NotNull;
+/**
+ *
+ */
class GitHubConnIgnitedImpl implements IGitHubConnIgnited {
/** Cache name*/
public static final String GIT_HUB_PR = "gitHubPr";
@@ -126,11 +129,12 @@ class GitHubConnIgnitedImpl implements IGitHubConnIgnited
{
while (outLinkNext.get() != null) {
String nextPageUrl = outLinkNext.get();
ghData = conn.getPullRequests(nextPageUrl, outLinkNext);
- cntSaved += saveChunk(ghData);
+ int savedThisChunk = saveChunk(ghData);
+ cntSaved += savedThisChunk;
totalChecked += ghData.size();
- if(!fullReindex)
- break; // 2 pages
+ if (!fullReindex && savedThisChunk == 0)
+ break;
}
return "Entries saved " + cntSaved + " PRs checked " + totalChecked;
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/pure/GitHubConnectionImpl.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/pure/GitHubConnectionImpl.java
index 3c3c8d4..f591b7f 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/pure/GitHubConnectionImpl.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/pure/GitHubConnectionImpl.java
@@ -180,7 +180,9 @@ class GitHubConnectionImpl implements IGitHubConnection {
if (nextLink != null)
outLinkNext.set(nextLink);
}
- System.err.println(link);
+
+ logger.info("Processing Github link: " + link);
+
return list;
}
catch (IOException e) {
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jobs/CheckQueueJob.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jobs/CheckQueueJob.java
index 5535595..f1cdf72 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jobs/CheckQueueJob.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jobs/CheckQueueJob.java
@@ -25,8 +25,11 @@ import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
import jersey.repackaged.com.google.common.base.Throwables;
import org.apache.ignite.ci.HelperConfig;
+import org.apache.ignite.ci.teamcity.ignited.ITeamcityIgnited;
+import org.apache.ignite.ci.teamcity.ignited.ITeamcityIgnitedProvider;
import org.apache.ignite.ci.teamcity.pure.ITcServerProvider;
import org.apache.ignite.ci.ITeamcity;
import org.apache.ignite.ci.conf.BranchTracked;
@@ -63,6 +66,12 @@ public class CheckQueueJob implements Runnable {
private ITcServerProvider tcHelper;
/** */
+ @Inject private ITeamcityIgnitedProvider tcIgnitedProv;
+
+ /** */
+ @Inject private ITcServerProvider tcPureProv;
+
+ /** */
private final Map<ChainAtServerTracked, Long> startTimes = new HashMap<>();
/**
@@ -148,7 +157,7 @@ public class CheckQueueJob implements Runnable {
@MonitoredTask(name = "Check Server Queue", nameExtArgIndex = 0)
protected String checkQueue(String srvId,
List<ChainAtServerTracked> chains) throws ExecutionException,
InterruptedException {
- ITeamcity teamcity = tcHelper.server(srvId, creds);
+ ITeamcity teamcity = tcPureProv.server(srvId, creds);
List<Agent> agents = teamcity.agents(true, true);
@@ -228,7 +237,9 @@ public class CheckQueueJob implements Runnable {
startTimes.put(chain, curr);
- teamcity.triggerBuild(chain.suiteId, chain.branchForRest, true,
false);
+ ITeamcityIgnited srv = tcIgnitedProv.server(srvId, creds);
+
+ srv.triggerBuild(chain.suiteId, chain.branchForRest, true, false);
res.append(chain.branchForRest).append("
").append(chain.suiteId).append(" triggered; ");
}
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
index 193b3e5..7938bd8 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
@@ -29,8 +29,6 @@ import javax.ws.rs.QueryParam;
import org.apache.ignite.ci.tcmodel.hist.BuildRef;
import org.apache.ignite.ci.teamcity.ignited.ITeamcityIgnited;
import org.apache.ignite.ci.teamcity.ignited.ITeamcityIgnitedProvider;
-import org.apache.ignite.ci.teamcity.pure.ITcServerProvider;
-import org.apache.ignite.ci.ITeamcity;
import org.apache.ignite.ci.github.GitHubUser;
import org.apache.ignite.ci.github.ignited.IGitHubConnIgnitedProvider;
import org.apache.ignite.ci.github.pure.IGitHubConnection;
@@ -52,10 +50,13 @@ public class TcBotTriggerAndSignOffService {
@Inject Provider<BuildObserver> buildObserverProvider;
+ /** Git hub pure http connection provider. */
@Inject IGitHubConnectionProvider gitHubConnectionProvider;
+
+ /** Git hub connection ignited provider. */
@Inject IGitHubConnIgnitedProvider gitHubConnIgnitedProvider;
- @Inject ITcServerProvider tcServerProvider;
+ @Inject ITeamcityIgnitedProvider tcIgnitedProv;
@Inject IJiraIntegration jiraIntegration;
@@ -87,14 +88,14 @@ public class TcBotTriggerAndSignOffService {
@NotNull public String triggerBuildsAndObserve(
@Nullable String srvId,
@Nullable String branchForTc,
- @Nullable String suiteIdList,
+ @Nonnull String suiteIdList,
@Nullable Boolean top,
@Nullable Boolean observe,
@Nullable String ticketId,
ICredentialsProv prov) {
String jiraRes = "";
- final ITeamcity teamcity = tcServerProvider.server(srvId, prov);
+ final ITeamcityIgnited teamcity = tcIgnitedProv.server(srvId, prov);
String[] suiteIds = Objects.requireNonNull(suiteIdList).split(",");
@@ -126,9 +127,9 @@ public class TcBotTriggerAndSignOffService {
) {
if (F.isEmpty(ticketFullName)) {
try {
- IGitHubConnection gitHubConnection =
gitHubConnectionProvider.server(srvId);
+ IGitHubConnection gitHubConn =
gitHubConnectionProvider.server(srvId);
- PullRequest pr = gitHubConnection.getPullRequest(branchForTc);
+ PullRequest pr = gitHubConn.getPullRequest(branchForTc);
ticketFullName = getTicketFullName(pr);
@@ -204,6 +205,9 @@ public class TcBotTriggerAndSignOffService {
return new SimpleResult("JIRA wasn't commented." +
(!jiraRes.isEmpty() ? "<br>" + jiraRes : ""));
}
+ /**
+ * @param srvId Server id.
+ */
public List<ContributionToCheck> getContributionsToCheck(String srvId) {
List<PullRequest> requests =
gitHubConnIgnitedProvider.server(srvId).getPullRequests();
if (requests == null)
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnited.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnited.java
index 4bdd2cf..aacb2d7 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnited.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnited.java
@@ -19,17 +19,28 @@ package org.apache.ignite.ci.teamcity.ignited;
import java.util.List;
import javax.annotation.Nullable;
import org.apache.ignite.ci.tcmodel.hist.BuildRef;
+import org.apache.ignite.ci.tcmodel.result.Build;
/**
*
*/
public interface ITeamcityIgnited {
/**
- * @param buildTypeId
- * @param branchName
+ * @param buildTypeId Build type identifier.
+ * @param branchName Branch name.
* @return list of builds in history, includes all statuses: queued,
running, etc
*/
public List<BuildRef> getBuildHistory(
@Nullable String buildTypeId,
@Nullable String branchName);
+
+ /**
+ * Trigger build. Enforces TC Bot to load all buidls related to this
triggered one.
+ *
+ * @param buildTypeId Build type identifier.
+ * @param branchName Branch name.
+ * @param cleanRebuild Rebuild all dependencies.
+ * @param queueAtTop Put at the top of the build queue.
+ */
+ public Build triggerBuild(String buildTypeId, String branchName, boolean
cleanRebuild, boolean queueAtTop);
}
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/TeamcityIgnitedImpl.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/TeamcityIgnitedImpl.java
index 54b3df4..fba2f1a 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/TeamcityIgnitedImpl.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/TeamcityIgnitedImpl.java
@@ -26,6 +26,7 @@ import org.apache.ignite.ci.di.AutoProfiling;
import org.apache.ignite.ci.di.MonitoredTask;
import org.apache.ignite.ci.di.scheduler.IScheduler;
import org.apache.ignite.ci.tcmodel.hist.BuildRef;
+import org.apache.ignite.ci.tcmodel.result.Build;
public class TeamcityIgnitedImpl implements ITeamcityIgnited {
/** Server id. */
@@ -70,8 +71,21 @@ public class TeamcityIgnitedImpl implements ITeamcityIgnited
{
return buildRefDao.findBuildsInHistory(srvIdMaskHigh, buildTypeId,
bracnhNameQry);
}
+ /** {@inheritDoc} */
+ @Override public Build triggerBuild(String buildTypeId, String branchName,
boolean cleanRebuild, boolean queueAtTop) {
+ Build build = conn.triggerBuild(buildTypeId, branchName, cleanRebuild,
queueAtTop);
+
+ //todo may add additional parameter: load builds into DB in sync/async
fashion
+ runAсtualizeBuilds(srvId, false, build.getId());
+
+ return build;
+ }
+
+ /**
+ *
+ */
private void actualizeRecentBuilds() {
- runAсtualizeBuilds(srvId, false);
+ runAсtualizeBuilds(srvId, false, null);
// schedule full resync later
scheduler.invokeLater(this::sheduleResync, 60, TimeUnit.SECONDS);
@@ -89,22 +103,27 @@ public class TeamcityIgnitedImpl implements
ITeamcityIgnited {
*
*/
private void fullReindex() {
- runAсtualizeBuilds(srvId, true);
+ runAсtualizeBuilds(srvId, true, null);
}
/**
* @param srvId Server id.
- * @param fullReindex Reindex all open PRs
+ * @param fullReindex Reindex all builds from TC history. Ignored if
particular ID provided.
+ * @param buildIdCanFinish Build ID can be used as end of syncing.
*/
@MonitoredTask(name = "Actualize BuildRefs, full resync", nameExtArgIndex
= 1)
@AutoProfiling
- protected String runAсtualizeBuilds(String srvId, boolean fullReindex) {
+ protected String runAсtualizeBuilds(String srvId, boolean fullReindex,
+ @Nullable Integer buildIdCanFinish) {
AtomicReference<String> outLinkNext = new AtomicReference<>();
List<BuildRef> tcDataFirstPage = conn.getBuildRefs(null, outLinkNext);
int cntSaved = buildRefDao.saveChunk(srvIdMaskHigh, tcDataFirstPage);
int totalChecked = tcDataFirstPage.size();
+ boolean noRequiredBuild = buildIdCanFinish == null;
+ boolean requiredBuildFound = false;
+
while (outLinkNext.get() != null) {
String nextPageUrl = outLinkNext.get();
outLinkNext.set(null);
@@ -114,7 +133,12 @@ public class TeamcityIgnitedImpl implements
ITeamcityIgnited {
cntSaved += savedCurChunk;
totalChecked += tcDataNextPage.size();
- if (!fullReindex && savedCurChunk == 0)
+ if (buildIdCanFinish != null) {
+ if
(tcDataNextPage.stream().map(BuildRef::getId).anyMatch(buildIdCanFinish::equals))
+ requiredBuildFound = true; // Syncing till specific build
ID.
+ }
+
+ if (savedCurChunk == 0 && ((requiredBuildFound) ||
(noRequiredBuild && !fullReindex)))
break; // There are no modification at current page, hopefully
no modifications at all
}
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITcServerProvider.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITcServerProvider.java
index cefafac..06beb6f 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITcServerProvider.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITcServerProvider.java
@@ -25,5 +25,9 @@ import javax.annotation.Nullable;
* Provides instance to server with appropriate credentials, may cache
instances to avoid odd server instances.
*/
public interface ITcServerProvider {
+ /**
+ * @param srvId Server id.
+ * @param prov Prov.
+ */
public IAnalyticsEnabledTeamcity server(String srvId, @Nullable
ICredentialsProv prov);
}
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITeamcityConn.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITeamcityConn.java
index d837a5e..9494bd5 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITeamcityConn.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITeamcityConn.java
@@ -19,7 +19,9 @@ package org.apache.ignite.ci.teamcity.pure;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
+import javax.annotation.Nonnull;
import org.apache.ignite.ci.tcmodel.hist.BuildRef;
+import org.apache.ignite.ci.tcmodel.result.Build;
/**
* Pure Teamcity Connection
@@ -28,4 +30,13 @@ import org.apache.ignite.ci.tcmodel.hist.BuildRef;
*/
public interface ITeamcityConn {
public List<BuildRef> getBuildRefs(String fullUrl, AtomicReference<String>
nextPage);
+
+ /**
+ * Trigger build.
+ * @param buildTypeId Build identifier.
+ * @param branchName Branch name.
+ * @param cleanRebuild Rebuild all dependencies.
+ * @param queueAtTop Put at the top of the build queue.
+ */
+ public Build triggerBuild(String buildTypeId, @Nonnull String branchName,
boolean cleanRebuild, boolean queueAtTop);
}
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuilds.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuilds.java
index 111d335..142885a 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuilds.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuilds.java
@@ -22,6 +22,7 @@ import java.util.Arrays;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
@@ -61,7 +62,7 @@ public class TriggerBuilds {
public SimpleResult triggerBuilds(
@Nullable @QueryParam("serverId") String srvId,
@Nullable @QueryParam("branchName") String branchForTc,
- @Nullable @QueryParam("suiteIdList") String suiteIdList,
+ @Nonnull @QueryParam("suiteIdList") String suiteIdList,
@Nullable @QueryParam("top") Boolean top,
@Nullable @QueryParam("observe") Boolean observe,
@Nullable @QueryParam("ticketId") String ticketId
diff --git a/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
b/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
index ca21ef6..527a932 100644
--- a/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
+++ b/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
@@ -213,7 +213,7 @@ function showContributionStatus(status, prId, row, srvId,
suiteId) {
let buildIsCompleted = isDefinedAndFilled(finishedBranch);
let hasJiraIssue = isDefinedAndFilled(row.jiraIssueId);
let hasQueued = status.queuedBuilds > 0 || status.runningBuilds > 0;
- let queuedStatus = "Has queued builds: " + status.queuedBuilds + " queued
" + " ";
+ let queuedStatus = "Has queued builds: " + status.queuedBuilds + " queued
" + " " + status.runningBuilds + " running";
if (buildIsCompleted) {
tdForPr.html("<a id='link_" + prId + "' href='" + prShowHref(srvId,
suiteId, finishedBranch) + "'>" +
"<button id='show_" + prId + "'>Show " + finishedBranch + "
report</button></a>");
@@ -228,7 +228,7 @@ function showContributionStatus(status, prId, row, srvId,
suiteId) {
")'";
if (hasQueued) {
- jiraBtn += " class='disabledbtn' title='Has queued builds'";
+ jiraBtn += " class='disabledbtn' title='" + queuedStatus + "'";
}
jiraBtn += ">Comment JIRA</button>";