Class TestHistoryImpl
- java.lang.Object
-
- jetbrains.buildServer.serverSide.tests.TestHistoryImpl
-
- All Implemented Interfaces:
TestHistory
public class TestHistoryImpl extends Object implements TestHistory
This is facade class that should accumulate all methods to write and access test information. Internally uses caching to speedup avoid slow database operations. TODO: extract and document public interface and contract State is changed:- running build state restored
- running inserts test
- lisneter.buildFailed
- lisneter.buildCancelled
- calculating first failed in/fixed in for builds
- we should monitor running build directly tests
- fixed/failed information should be written into database
-
-
Constructor Summary
Constructors Constructor Description TestHistoryImpl(BuildServerEx server, EventDispatcher<BuildServerListener> dispatcher, SQLRunnerEx sqlRunner, ResetCacheRegister cacheRegistry, STestManager testManager, ProblemMutingService mutingService, TestName2Index testName2Index, QueryRunnerFactory queryRunnerFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Long2StatusCollection
getBuild2StatusMapForTest(long testNameId, Set<String> buildTypeIds, long minBuildId)
Loads test statuses across all builds in the given build configurations.Collection<SBuildType>
getBuildTypesForTests(Collection<Long> testNameIds, SProject project)
Returns the collection of build types, in which the tests that correspond totestNameIds
were executed (the union, not intersection).Collection<SBuildType>
getBuildTypesForTests(Collection<STest> tests)
Returns the collection of build types, in which thetests
were executed (the union, not intersection).Collection<SBuildType>
getBuildTypesForTests(SProject project, Collection<TestName> testNames)
Returns the collection of build types, in which the tests that correspond totestNames
were executed (the union, not intersection).Collection<SBuildType>
getBuildTypesWithTest(SProject project, long testNameId)
BuildTypeTests
getBuildTypeTests(String buildTypeId)
Collection<SBuild>
getLastBuildsForTestsActiveBranches(Collection<Long> testNameIds, SProject project)
Same as TestsHistory#getLastBuildsForTestsDefaultBranch for all active branches.Collection<SBuild>
getLastBuildsForTestsDefaultBranch(Collection<Long> testNameIds, SProject project)
Returns the last finished builds in the project that have any of the tests specified either passed or failed (ignored tests are not considered).Collection<SBuildType>
getRelevantBuildTypes(SBuild build)
Return build types which should be treated equally when calculating "isNew" and "isFixedIn" status for a test.List<STestRun>
getTestHistory(long testNameId, String buildTypeId, long userId, String branchName)
Order of the returned TestRuns is recent runs first, according to the starting order of the builds.List<STestRun>
getTestHistory(long testNameId, String buildTypeId, Filter<STestRun> filter)
Order of the returned TestRuns is recent runs first, according to the starting order of the builds.List<STestRun>
getTestHistory(long testNameId, SProject project, long userId, String branchName)
Order of the returned TestRuns is recent runs first, according to the starting order of the builds.List<STestRun>
getTestHistory(long testNameId, SProject project, Filter<STestRun> filter)
Order of the returned TestRuns is recent runs first, according to the starting order of the builds.Long2StatusCollection
getTestStatuses(Collection<Long> testNameIds, long buildId, boolean cacheResults)
Return a Long2StatusCollection which contains statuses of test runs for build from testNameIds collectionboolean
hasBuildsWithTests(BuildType buildType)
Returns the number of builds of the given Build Type that have at leat one test run.void
resetCaches()
void
unregisterBuildTypeTests(String buildTypeId)
-
-
-
Constructor Detail
-
TestHistoryImpl
public TestHistoryImpl(@NotNull BuildServerEx server, @NotNull EventDispatcher<BuildServerListener> dispatcher, @NotNull SQLRunnerEx sqlRunner, @NotNull ResetCacheRegister cacheRegistry, @NotNull STestManager testManager, @NotNull ProblemMutingService mutingService, @NotNull TestName2Index testName2Index, @NotNull QueryRunnerFactory queryRunnerFactory)
-
-
Method Detail
-
resetCaches
public void resetCaches()
-
getBuildTypeTests
public BuildTypeTests getBuildTypeTests(@NotNull String buildTypeId)
- Specified by:
getBuildTypeTests
in interfaceTestHistory
-
unregisterBuildTypeTests
public void unregisterBuildTypeTests(@NotNull String buildTypeId)
-
getBuild2StatusMapForTest
public Long2StatusCollection getBuild2StatusMapForTest(long testNameId, @NotNull Set<String> buildTypeIds, long minBuildId)
Description copied from interface:TestHistory
Loads test statuses across all builds in the given build configurations.Return a map structure: buildId -> Status for test statuses of a test with given testNameId, in no particular order
- Specified by:
getBuild2StatusMapForTest
in interfaceTestHistory
minBuildId
- Minimal value of buildId for which the data will be obtained (inclusive)- Returns:
- see above
-
getRelevantBuildTypes
@NotNull public Collection<SBuildType> getRelevantBuildTypes(@NotNull SBuild build)
Description copied from interface:TestHistory
Return build types which should be treated equally when calculating "isNew" and "isFixedIn" status for a test.- Specified by:
getRelevantBuildTypes
in interfaceTestHistory
- Parameters:
build
- build for which the scope should be calculated. This build may belong to any of the configurations from the scope, or maybe some parent configuration.- Returns:
- see above
- See Also:
BuildTypesTestScope
-
hasBuildsWithTests
public boolean hasBuildsWithTests(@NotNull BuildType buildType)
Returns the number of builds of the given Build Type that have at leat one test run.- Specified by:
hasBuildsWithTests
in interfaceTestHistory
- Parameters:
buildType
- Build Type- Returns:
- true if build configuration has builds with tests.
-
getLastBuildsForTestsDefaultBranch
@NotNull public Collection<SBuild> getLastBuildsForTestsDefaultBranch(@NotNull Collection<Long> testNameIds, @Nullable SProject project)
Returns the last finished builds in the project that have any of the tests specified either passed or failed (ignored tests are not considered).- Specified by:
getLastBuildsForTestsDefaultBranch
in interfaceTestHistory
- Parameters:
testNameIds
- the ids of the testsproject
- the project to search in, `null` project means all active build types under `root` project on buildserver- Returns:
- required builds
-
getLastBuildsForTestsActiveBranches
@NotNull public Collection<SBuild> getLastBuildsForTestsActiveBranches(@NotNull Collection<Long> testNameIds, @Nullable SProject project)
Same as TestsHistory#getLastBuildsForTestsDefaultBranch for all active branches. One build for every pair of build configuration and branch name.- Specified by:
getLastBuildsForTestsActiveBranches
in interfaceTestHistory
-
getBuildTypesForTests
@NotNull public Collection<SBuildType> getBuildTypesForTests(@NotNull Collection<Long> testNameIds, @Nullable SProject project)
Returns the collection of build types, in which the tests that correspond totestNameIds
were executed (the union, not intersection). If theproject
is specified, the result is filtered by it.Currently running builds are not considered.
- Specified by:
getBuildTypesForTests
in interfaceTestHistory
- Parameters:
testNameIds
- the tests collectionproject
- the project (nullable)- Returns:
- collection of build types
- Since:
- 7.1
-
getBuildTypesForTests
@NotNull public Collection<SBuildType> getBuildTypesForTests(@NotNull Collection<STest> tests)
Returns the collection of build types, in which thetests
were executed (the union, not intersection). If all tests are from one project, the result is filtered by it.Currently running builds are not considered.
- Specified by:
getBuildTypesForTests
in interfaceTestHistory
- Parameters:
tests
- the tests collection- Returns:
- collection of build types
- Since:
- 7.1
-
getBuildTypesForTests
@NotNull public Collection<SBuildType> getBuildTypesForTests(@Nullable SProject project, @NotNull Collection<TestName> testNames)
Returns the collection of build types, in which the tests that correspond totestNames
were executed (the union, not intersection). If theproject
is specified, the result is filtered by it.Currently running builds are not considered.
- Specified by:
getBuildTypesForTests
in interfaceTestHistory
- Parameters:
project
- the project (nullable)testNames
- the tests collection- Returns:
- collection of build types
- Since:
- 7.1
-
getTestStatuses
public Long2StatusCollection getTestStatuses(@NotNull Collection<Long> testNameIds, long buildId, boolean cacheResults)
Return a Long2StatusCollection which contains statuses of test runs for build from testNameIds collection- Specified by:
getTestStatuses
in interfaceTestHistory
- Parameters:
buildId
- build to analyzetestNameIds
- collection of testscacheResults
- should be false if build is running- Returns:
- see above
-
getTestHistory
@NotNull public List<STestRun> getTestHistory(long testNameId, @NotNull String buildTypeId, long userId, @Nullable String branchName)
Description copied from interface:TestHistory
Order of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently- Specified by:
getTestHistory
in interfaceTestHistory
buildTypeId
- required to set the build configuration for the test historyuserId
- if > 0, includes personal builds of the given userbranchName
- if not null, returns only builds which match given branchName- Returns:
- Test run objects for given test, recent builds go first
-
getTestHistory
@NotNull public List<STestRun> getTestHistory(long testNameId, @NotNull String buildTypeId, Filter<STestRun> filter)
Description copied from interface:TestHistory
Order of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently- Specified by:
getTestHistory
in interfaceTestHistory
buildTypeId
- required to set the build configuration for the test historyfilter
- additional filter for the returned test runs- Returns:
- Test run objects for given test, recent builds go first
-
getTestHistory
@NotNull public List<STestRun> getTestHistory(long testNameId, @NotNull SProject project, long userId, @Nullable String branchName)
Description copied from interface:TestHistory
Order of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently- Specified by:
getTestHistory
in interfaceTestHistory
project
- required to set the parent project, all returned test runs will belong to build configurations under this project and its subprojectsuserId
- if > 0, includes personal builds of the given userbranchName
- if not null, returns only builds which match given branchName- Returns:
- Test run objects for given test, recent builds go first
-
getTestHistory
@NotNull public List<STestRun> getTestHistory(long testNameId, @NotNull SProject project, Filter<STestRun> filter)
Description copied from interface:TestHistory
Order of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently- Specified by:
getTestHistory
in interfaceTestHistory
project
- required to set the parent project, all returned test runs will belong to build configurations under this project and its subprojectsfilter
- additional filter for the returned test runs- Returns:
- Test run objects for given test, recent builds go first
-
getBuildTypesWithTest
@NotNull public Collection<SBuildType> getBuildTypesWithTest(@NotNull SProject project, long testNameId)
- Specified by:
getBuildTypesWithTest
in interfaceTestHistory
-
-