Skip to content
Permalink
Browse files
TC Bot refactoring: deprecated class usages removal
  • Loading branch information
dspavlov committed Jun 1, 2019
1 parent dc45d34 commit 78f1b7b87fb546dd5334a2f6198359b826ee1a47
Show file tree
Hide file tree
Showing 20 changed files with 103 additions and 142 deletions.
@@ -22,7 +22,6 @@
import java.util.Map;
import java.util.SortedSet;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
@@ -140,8 +139,8 @@ private IgniteCache<Integer, LogCheckResult> logCheckResultCache() {
}

/** {@inheritDoc} */
@Override public CompletableFuture<File> downloadBuildLogZip(int id) {
return teamcity.downloadBuildLogZip(id);
@Override public CompletableFuture<File> downloadBuildLogZip(int buildId) {
return teamcity.downloadBuildLogZip(buildId);
}

/** {@inheritDoc} */
@@ -195,10 +194,6 @@ public <K, V extends IVersionedEntity> CompletableFuture<V> loadFutureIfAbsentVe
});
}

public Executor getExecutor() {
return this.teamcity.getExecutor();
}

/** {@inheritDoc} */
@Override public void setExecutor(ExecutorService executor) {
this.teamcity.setExecutor(executor);
@@ -17,6 +17,7 @@
package org.apache.ignite.ci.jira.ignited;

import com.google.inject.AbstractModule;
import com.google.inject.internal.SingletonScope;
import org.apache.ignite.ci.jira.pure.JiraIntegrationModule;

/**
@@ -27,6 +28,9 @@ public class JiraIgnitedModule extends AbstractModule {
@Override protected void configure() {
bind(IJiraIgnitedProvider.class).to(JiraIgnitedProvider.class);

bind(JiraTicketDao.class).in(new SingletonScope());
bind(JiraTicketSync.class).in(new SingletonScope());

install(new JiraIntegrationModule());
}
}
@@ -16,7 +16,7 @@
*/

/**
* This package is inteneded for interacting with Jira servers. It contains classes which is needed for injection Jira
* This package is intended for interacting with Jira servers. It contains classes which is needed for injection Jira
* integration service instance via Guice. And interfaces and classes which provide specified functionality.
*/
package org.apache.ignite.ci.jira;
@@ -134,7 +134,6 @@ public List<SuiteLRTestsSummary> loadLongRunningTestsSummary(
}

/**
* @param teamcity Teamcity.
* @param tcIgn Teamcity Ignited.
* @param entryPoints Entry point(s): Build(s) to start scan from.
* @param includeLatestRebuild Include latest rebuild.
@@ -145,14 +144,13 @@ public List<SuiteLRTestsSummary> loadLongRunningTestsSummary(
*/
@AutoProfiling
public FullChainRunCtx loadFullChainContext(
IAnalyticsEnabledTeamcity teamcity,
ITeamcityIgnited tcIgn,
Collection<Integer> entryPoints,
LatestRebuildMode includeLatestRebuild,
ProcessLogsMode procLog,
boolean includeScheduledInfo,
@Nullable String failRateBranch,
SyncMode mode) {
ITeamcityIgnited tcIgn,
Collection<Integer> entryPoints,
LatestRebuildMode includeLatestRebuild,
ProcessLogsMode procLog,
boolean includeScheduledInfo,
@Nullable String failRateBranch,
SyncMode mode) {

if (entryPoints.isEmpty())
return new FullChainRunCtx(Build.createFakeStub());
@@ -190,7 +188,7 @@ public FullChainRunCtx loadFullChainContext(

buildsForSuite.forEach(buildCompacted -> ctx.addBuild(loadChanges(buildCompacted, tcIgn)));

analyzeTests(ctx, teamcity, procLog);
analyzeTests(ctx, tcIgn, procLog);

fillBuildCounts(ctx, tcIgn, includeScheduledInfo);

@@ -364,24 +362,24 @@ protected void fillBuildCounts(MultBuildRunCtx outCtx,

@SuppressWarnings("WeakerAccess")
@AutoProfiling
protected void analyzeTests(MultBuildRunCtx outCtx, ITeamcity teamcity,
ProcessLogsMode procLog) {
protected void analyzeTests(MultBuildRunCtx outCtx, ITeamcityIgnited teamcity,
ProcessLogsMode procLog) {
for (SingleBuildRunCtx ctx : outCtx.getBuilds()) {
if ((procLog == ProcessLogsMode.SUITE_NOT_COMPLETE && ctx.hasSuiteIncompleteFailure())
|| procLog == ProcessLogsMode.ALL)
ctx.setLogCheckResFut(analyzeBuildLog(teamcity, ctx.buildId(), ctx));
}
}

private CompletableFuture<LogCheckTask> checkBuildLogNoCache(ITeamcity teamcity, int buildId, ISuiteResults ctx) {
private CompletableFuture<LogCheckTask> checkBuildLogNoCache(ITeamcityIgnited teamcity, int buildId, ISuiteResults ctx) {
final CompletableFuture<File> zipFut = teamcity.downloadBuildLogZip(buildId);
boolean dumpLastTest = ctx.hasSuiteIncompleteFailure();

if (zipFut == null)
return null;

return zipFut.thenApplyAsync(zipFile -> runCheckForZippedLog(dumpLastTest, zipFile),
teamcity.getExecutor());
tcUpdatePool.getService());
}


@@ -419,7 +417,7 @@ private CompletableFuture<LogCheckTask> checkBuildLogNoCache(ITeamcity teamcity,

//todo implement persistent cache for build results
@AutoProfiling
public CompletableFuture<LogCheckResult> analyzeBuildLog(ITeamcity teamcity, Integer buildId, SingleBuildRunCtx ctx) {
public CompletableFuture<LogCheckResult> analyzeBuildLog(ITeamcityIgnited teamcity, Integer buildId, SingleBuildRunCtx ctx) {
final Stopwatch started = Stopwatch.createStarted();

CompletableFuture<LogCheckTask> fut = buildLogProcessingRunning.computeIfAbsent(buildId,
@@ -57,9 +57,6 @@ public class PrChainsProcessor {
/** Build chain processor. */
@Inject private BuildChainProcessor buildChainProcessor;

/** Tc server provider. */
@Inject private ITcServerProvider tcSrvProvider;

/** Tc server provider. */
@Inject private ITeamcityIgnitedProvider tcIgnitedProvider;

@@ -100,14 +97,13 @@ public TestFailuresSummary getTestFailuresSummary(
final AtomicInteger runningUpdates = new AtomicInteger();

//using here non persistent TC allows to skip update statistic
IAnalyticsEnabledTeamcity teamcity = tcSrvProvider.server(srvCode, creds);
ITeamcityIgnited tcIgnited = tcIgnitedProvider.server(srvCode, creds);

IGitHubConnIgnited gitHubConnIgnited = gitHubConnIgnitedProvider.server(srvCode);

IJiraIgnited jiraIntegration = jiraIgnProv.server(srvCode);

res.setJavaFlags(teamcity, gitHubConnIgnited, jiraIntegration);
res.setJavaFlags(gitHubConnIgnited, jiraIntegration);

LatestRebuildMode rebuild;
if (FullQueryParams.HISTORY.equals(act))
@@ -135,16 +131,16 @@ else if (FullQueryParams.CHAIN.equals(act))

String baseBranch = Strings.isNullOrEmpty(baseBranchForTc) ? ITeamcity.DEFAULT : baseBranchForTc;

final FullChainRunCtx ctx = buildChainProcessor.loadFullChainContext(teamcity,
tcIgnited,
final FullChainRunCtx ctx = buildChainProcessor.loadFullChainContext(
tcIgnited,
hist,
rebuild,
logs,
buildResMergeCnt == 1,
baseBranch,
mode);

final ChainAtServerCurrentStatus chainStatus = new ChainAtServerCurrentStatus(teamcity.serverCode(), branchForTc);
final ChainAtServerCurrentStatus chainStatus = new ChainAtServerCurrentStatus(tcIgnited.serverCode(), branchForTc);

chainStatus.baseBranchForTc = baseBranch;

@@ -187,15 +183,14 @@ else if (FullQueryParams.CHAIN.equals(act))
public List<SuiteCurrentStatus> getBlockersSuitesStatuses(String buildTypeId, String branchForTc, String srvId,
ICredentialsProv prov, SyncMode syncMode) {
//using here non persistent TC allows to skip update statistic
IAnalyticsEnabledTeamcity teamcity = tcSrvProvider.server(srvId, prov);
ITeamcityIgnited tcIgnited = tcIgnitedProvider.server(srvId, prov);

List<Integer> hist = tcIgnited.getLastNBuildsFromHistory(buildTypeId, branchForTc, 1);

String baseBranch = ITeamcity.DEFAULT;

final FullChainRunCtx ctx = buildChainProcessor.loadFullChainContext(teamcity,
tcIgnited,
final FullChainRunCtx ctx = buildChainProcessor.loadFullChainContext(
tcIgnited,
hist,
LatestRebuildMode.LATEST,
ProcessLogsMode.SUITE_NOT_COMPLETE,
@@ -46,9 +46,6 @@
* Process failures for some setup tracked branch, which may be triggered/monitored by TC Bot.
*/
public class TrackedBranchChainsProcessor {
/** TC Server prov. */
@Inject private ITcServerProvider srvProv;

/** TC ignited server provider. */
@Inject private ITeamcityIgnitedProvider tcIgnitedProv;

@@ -90,8 +87,6 @@ public TestFailuresSummary getTrackedBranchTestFailures(

chainStatus.baseBranchForTc = baseBranchTc;

IAnalyticsEnabledTeamcity teamcity = srvProv.server(srvId, creds);

ITeamcityIgnited tcIgnited = tcIgnitedProv.server(srvId, creds);

String suiteIdMandatory = chainTracked.getSuiteIdMandatory();
@@ -108,8 +103,8 @@ public TestFailuresSummary getTrackedBranchTestFailures(

boolean includeScheduled = buildResMergeCnt == 1;

final FullChainRunCtx ctx = chainProc.loadFullChainContext(teamcity,
tcIgnited,
final FullChainRunCtx ctx = chainProc.loadFullChainContext(
tcIgnited,
chains,
rebuild,
logs,
@@ -17,12 +17,15 @@
package org.apache.ignite.ci.teamcity.ignited;

import com.google.common.base.Strings;

import java.io.File;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nullable;
import org.apache.ignite.ci.analysis.SuiteInBranch;
import org.apache.ignite.ci.analysis.TestInBranch;
@@ -44,9 +47,9 @@
*/
public interface ITeamcityIgnited {
/**
* @return Internal server ID as string
* @return Internal serverID (Code) as string
*/
public String serverId();
public String serverCode();

/**
* @return TeamCity configuration.
@@ -250,4 +253,6 @@ public default String getLatestCommitVersion(FatBuildCompacted build) {

return null;
}

CompletableFuture<File> downloadBuildLogZip(int buildId);
}
@@ -18,45 +18,17 @@

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.OptionalInt;
import java.util.Set;
import java.util.SortedSet;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import javax.inject.Inject;
import org.apache.ignite.tcservice.ITeamcity;
import org.apache.ignite.ci.analysis.SuiteInBranch;
import org.apache.ignite.ci.analysis.TestInBranch;
import org.apache.ignite.tcbot.common.interceptor.AutoProfiling;
import org.apache.ignite.ci.di.MonitoredTask;
import org.apache.ignite.ci.di.cache.GuavaCached;
import org.apache.ignite.ci.di.scheduler.IScheduler;
import org.apache.ignite.tcbot.common.conf.ITcServerConfig;
import org.apache.ignite.ci.tcbot.trends.MasterTrendsService;
import org.apache.ignite.tcservice.model.agent.Agent;
import org.apache.ignite.tcservice.model.conf.Project;
import org.apache.ignite.tcservice.model.hist.BuildRef;
import org.apache.ignite.tcservice.model.mute.MuteInfo;
import org.apache.ignite.tcservice.model.result.Build;
import org.apache.ignite.ci.teamcity.ignited.buildcondition.BuildCondition;
import org.apache.ignite.ci.teamcity.ignited.buildcondition.BuildConditionDao;
import org.apache.ignite.ci.teamcity.ignited.buildref.BuildRefDao;
import org.apache.ignite.ci.teamcity.ignited.buildref.BuildRefSync;
import org.apache.ignite.ci.teamcity.ignited.buildtype.BuildTypeCompacted;
import org.apache.ignite.ci.teamcity.ignited.buildtype.BuildTypeDao;
import org.apache.ignite.ci.teamcity.ignited.buildtype.BuildTypeRefCompacted;
import org.apache.ignite.ci.teamcity.ignited.buildtype.BuildTypeRefDao;
import org.apache.ignite.ci.teamcity.ignited.buildtype.BuildTypeSync;
import org.apache.ignite.ci.teamcity.ignited.buildtype.*;
import org.apache.ignite.ci.teamcity.ignited.change.ChangeCompacted;
import org.apache.ignite.ci.teamcity.ignited.change.ChangeDao;
import org.apache.ignite.ci.teamcity.ignited.change.ChangeSync;
@@ -67,12 +39,29 @@
import org.apache.ignite.ci.teamcity.ignited.mute.MuteSync;
import org.apache.ignite.ci.teamcity.ignited.runhist.RunHistCompactedDao;
import org.apache.ignite.ci.teamcity.ignited.runhist.RunHistSync;
import org.apache.ignite.tcservice.ITeamcityConn;
import org.apache.ignite.ci.user.ICredentialsProv;
import org.apache.ignite.tcbot.common.conf.ITcServerConfig;
import org.apache.ignite.tcbot.common.interceptor.AutoProfiling;
import org.apache.ignite.tcservice.ITeamcity;
import org.apache.ignite.tcservice.ITeamcityConn;
import org.apache.ignite.tcservice.model.agent.Agent;
import org.apache.ignite.tcservice.model.conf.Project;
import org.apache.ignite.tcservice.model.hist.BuildRef;
import org.apache.ignite.tcservice.model.mute.MuteInfo;
import org.apache.ignite.tcservice.model.result.Build;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nullable;
import javax.inject.Inject;
import java.io.File;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import static org.apache.ignite.tcservice.model.hist.BuildRef.STATUS_UNKNOWN;

/**
@@ -175,7 +164,7 @@ private String taskName(String taskName) {
}

/** {@inheritDoc} */
@Override public String serverId() {
@Override public String serverCode() {
return srvCode;
}

@@ -430,6 +419,15 @@ public List<Agent> agents(boolean connected, boolean authorized) {
return conn.agents(connected, authorized);
}

@Override
@Deprecated
public CompletableFuture<File> downloadBuildLogZip(int buildId) {
if (conn instanceof ITeamcity)
return ((ITeamcity) conn).downloadBuildLogZip(buildId);

return null;
}

/** {@inheritDoc} */
@Override public List<String> getCompositeBuildTypesIdsSortedByBuildNumberCounter(String projectId) {
return buildTypeSync.getCompositeBuildTypesIdsSortedByBuildNumberCounter(srvIdMaskHigh, projectId, conn);
@@ -62,8 +62,6 @@ public class TeamcityIgnitedModule extends AbstractModule {
bind(RunHistSync.class).in(new SingletonScope());
bind(MuteDao.class).in(new SingletonScope());
bind(MuteSync.class).in(new SingletonScope());
bind(JiraTicketDao.class).in(new SingletonScope());
bind(JiraTicketSync.class).in(new SingletonScope());

bind(IStringCompactor.class).to(IgniteStringCompactor.class).in(new SingletonScope());

@@ -18,6 +18,7 @@

import org.apache.ignite.ci.IAnalyticsEnabledTeamcity;
import org.apache.ignite.ci.user.ICredentialsProv;
import org.apache.ignite.tcservice.ITeamcity;

import javax.annotation.Nullable;

@@ -29,5 +30,5 @@ public interface ITcServerProvider {
* @param srvId Server id.
* @param prov Prov.
*/
public IAnalyticsEnabledTeamcity server(String srvId, @Nullable ICredentialsProv prov);
public ITeamcity server(String srvId, @Nullable ICredentialsProv prov);
}

0 comments on commit 78f1b7b

Please sign in to comment.