use of jetbrains.buildServer.serverSide.impl.BuildTypeImpl in project teamcity-rest by JetBrains.
the class TestOccurrenceRequestTest method testTestOccurrenceFields.
@Test
public void testTestOccurrenceFields() {
final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
final SFinishedBuild build10 = build().in(buildType).withTest(BuildBuilder.TestData.test("aaa").duration(76)).withTest(BuildBuilder.TestData.test("bbb").out("std out").errorOut("str err").failed("error message", "stacktrace\nline 1\r\nline2").duration(67)).finish();
{
TestOccurrences testOccurrences = myRequest.getTestOccurrences("build:(id:" + build10.getBuildId() + "),status:FAILURE", "**", null, null);
assertEquals(Integer.valueOf(1), testOccurrences.getCount());
assertEquals(1, testOccurrences.items.size());
TestOccurrence testOccurrence = testOccurrences.items.get(0);
assertEquals("bbb", testOccurrence.getName());
// "2" should actually be here, but API cannot guarantee preservation of the number when not all tests are retrieved, so documenting the current behavior.
assertEquals("1", testOccurrence.getRunOrder());
assertEquals(Integer.valueOf(67), testOccurrence.getDuration());
assertEquals("FAILURE", testOccurrence.getStatus());
assertEquals(Boolean.valueOf(false), testOccurrence.getIgnored());
assertNull(testOccurrence.getIgnoreDetails());
assertEquals("error message\nstacktrace\nline 1\r\nline2\n------- Stdout: -------\nstd out\n------- Stderr: -------\nstr err", testOccurrence.getDetails());
}
final SFinishedBuild build20 = build().in(buildType).withTest(BuildBuilder.TestData.test("aaa").duration(76)).withTest(BuildBuilder.TestData.test("bbb").failed("error message", "stacktrace\nline 1\nline2").duration(67)).withTest(BuildBuilder.TestData.test("ccc").ignored("Ignore reason").out("std\r\nout").duration(67)).finish();
{
TestOccurrences testOccurrences = myRequest.getTestOccurrences("build:(id:" + build20.getBuildId() + "),ignored:true", "**", null, null);
assertEquals(Integer.valueOf(1), testOccurrences.getCount());
assertEquals(1, testOccurrences.items.size());
TestOccurrence testOccurrence = testOccurrences.items.get(0);
assertEquals("ccc", testOccurrence.getName());
assertEquals("3", testOccurrence.getRunOrder());
assertEquals(Integer.valueOf(0), testOccurrence.getDuration());
assertEquals("UNKNOWN", testOccurrence.getStatus());
assertEquals(Boolean.valueOf(true), testOccurrence.getIgnored());
assertEquals("Ignore reason", testOccurrence.getIgnoreDetails());
assertNull(testOccurrence.getDetails());
}
// checking how ignored and failed test looks like. Just asserting current behavior
final SFinishedBuild build30 = build().in(buildType).withTest(BuildBuilder.TestData.test("aaa").duration(76)).withTest(BuildBuilder.TestData.test("bbb").failed("error message", "stacktrace\nline 1\nline2").duration(67)).withTest(BuildBuilder.TestData.test("ccc").failed("error message", "stacktrace\nline 1\nline2").duration(67)).withTest(BuildBuilder.TestData.test("ccc").ignored("Ignore reason")).finish();
{
TestOccurrences testOccurrences = myRequest.getTestOccurrences("build:(id:" + build30.getBuildId() + "),test:(name:ccc)", "**", null, null);
assertEquals(Integer.valueOf(1), testOccurrences.getCount());
assertEquals(1, testOccurrences.items.size());
TestOccurrence testOccurrence = testOccurrences.items.get(0);
assertEquals("ccc", testOccurrence.getName());
assertEquals("3", testOccurrence.getRunOrder());
assertEquals(Integer.valueOf(67), testOccurrence.getDuration());
assertEquals("FAILURE", testOccurrence.getStatus());
assertEquals(Boolean.valueOf(false), testOccurrence.getIgnored());
assertEquals("error message\nstacktrace\nline 1\nline2", testOccurrence.getDetails());
}
}
use of jetbrains.buildServer.serverSide.impl.BuildTypeImpl in project teamcity-rest by JetBrains.
the class TestOccurrenceRequestTest method testInvocationsAreFoundCorrectly2.
@Test
@TestFor(issues = { "TW-70206" })
public void testInvocationsAreFoundCorrectly2() {
if (true)
throw new SkipException("Reverted correct behaviour due to TW-70587");
final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
final SFinishedBuild build = build().in(buildType).withTest("aaa", false).withTest("aaa", false).withTest("aaa", true).finish();
String fields = "testCounters(failed,success,all,duration),testOccurrence(id,name,muted,status,invocations($locator(count:90000),testCounters(all,success,failed),testOccurrence(id,name,status,muted)))";
String locator = "currentlyFailing:true,affectedProject:" + buildType.getProject().getExternalId();
FakeHttpServletRequest mockRequest = new FakeHttpServletRequest();
mockRequest.setRequestURL(String.format("http://test/httpAuth/app/rest/testOccurrences?locator=%s&fields=%s", locator, fields));
TestOccurrences testOccurrences = myRequest.getTestOccurrences(locator, fields, null, mockRequest);
assertEquals("Should return exactly one 'grouping' test run.", 1, testOccurrences.items.size());
TestOccurrence grouping = testOccurrences.items.get(0);
assertNotNull("Should contain invocations node.", grouping.getInvocations());
assertEquals("Should contain exactly 3 occurrences.", 3, grouping.getInvocations().items.size());
}
use of jetbrains.buildServer.serverSide.impl.BuildTypeImpl in project teamcity-rest by JetBrains.
the class ChangeFinderTest method testChangedVcsRootAndDAG.
@Test
public void testChangedVcsRootAndDAG() {
final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
MockVcsSupport vcs = new MockVcsSupport("vcs");
vcs.setDAGBased(true);
myFixture.getVcsManager().registerVcsSupport(vcs);
SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", buildConf);
VcsRootInstance root1 = buildConf.getVcsRootInstanceForParent(parentRoot1);
assert root1 != null;
setBranchSpec(root1, "+:*");
final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
vcs.setCollectChangesPolicy(changesPolicy);
SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
SVcsModification m30 = myFixture.addModification(modification().in(root1).version("30").parentVersions("20"));
SVcsModification m40 = myFixture.addModification(modification().in(root1).version("40").parentVersions("10"));
SVcsModification m45 = myFixture.addModification(modification().in(root1).version("45").parentVersions("40"));
SVcsModification m50 = myFixture.addModification(modification().in(root1).version("50").parentVersions("10"));
SVcsModification m60 = myFixture.addModification(modification().in(root1).version("60").parentVersions("20"));
changesPolicy.setCurrentState(root1, RepositoryStateData.createVersionState("master", Util.map("master", "30", "branch1", "45", "branch2", "50", "branch3", "60")));
myFixture.getVcsModificationChecker().checkForModifications(buildConf.getVcsRootInstances(), OperationRequestor.UNKNOWN);
build().in(buildConf).onModifications(m20).finish();
build().in(buildConf).withBranch("branch1").onModifications(m40).finish();
String btLocator = "buildType:(id:" + buildConf.getExternalId() + ")";
check(null, m60, m50, m45, m40, m30, m20);
// documenting current behavior should be check(btLocator, m30, m20);
check(btLocator, m60, m50, m45, m40, m30, m20);
check(btLocator + ",branch:(default:any)", m60, m50, m45, m40, m30, m20);
check(btLocator + ",pending:true", m30);
check(btLocator + ",pending:true,branch:branch1", m45);
check(btLocator + ",pending:true,branch:(default:false)", m60, m50, m45);
check(btLocator + ",pending:true,branch:(default:any)", m60, m50, m45, m30);
buildConf.removeVcsRoot(parentRoot1);
SVcsRootEx parentRoot2 = myFixture.addVcsRoot(vcs.getName(), "", buildConf);
VcsRootInstance root2 = buildConf.getVcsRootInstanceForParent(parentRoot2);
assert root2 != null;
setBranchSpec(root2, "+:*");
SVcsModification m200 = myFixture.addModification(modification().in(root2).version("200").parentVersions("199"));
SVcsModification m210 = myFixture.addModification(modification().in(root2).version("210").parentVersions("199"));
changesPolicy.setCurrentState(root2, RepositoryStateData.createVersionState("master", Util.map("master", "210", "branch1", "200")));
myFixture.getVcsModificationChecker().checkForModifications(buildConf.getVcsRootInstances(), OperationRequestor.UNKNOWN);
check(null, m210, m200, m60, m50, m45, m40, m30, m20);
check(btLocator, m210, m200, m60, m50, m45, m40, m30, m20);
check(btLocator + ",branch:(default:any)", m210, m200, m60, m50, m45, m40, m30, m20);
check(btLocator + ",pending:true", m210);
check(btLocator + ",pending:true,branch:branch1", m200);
check(btLocator + ",pending:true,branch:(default:true)", m210);
check(btLocator + ",pending:true,branch:(default:false)", m200);
check(btLocator + ",pending:true,branch:(default:any)", m210, m200);
}
use of jetbrains.buildServer.serverSide.impl.BuildTypeImpl in project teamcity-rest by JetBrains.
the class ChangeFinderTest method testBranches1.
@Test
public void testBranches1() {
final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
MockVcsSupport vcs = new MockVcsSupport("vcs");
vcs.setDAGBased(true);
myFixture.getVcsManager().registerVcsSupport(vcs);
SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", buildConf);
SVcsRootEx parentRoot2 = myFixture.addVcsRoot(vcs.getName(), "", buildConf);
VcsRootInstance root1 = buildConf.getVcsRootInstanceForParent(parentRoot1);
VcsRootInstance root2 = buildConf.getVcsRootInstanceForParent(parentRoot2);
assert root1 != null;
assert root2 != null;
setBranchSpec(root1, "+:*\n" + "+:prefix/*");
final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
vcs.setCollectChangesPolicy(changesPolicy);
SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
SVcsModification m30 = myFixture.addModification(modification().in(root1).version("30").parentVersions("20"));
SVcsModification m40 = myFixture.addModification(modification().in(root1).version("40").parentVersions("10"));
SVcsModification m50 = myFixture.addModification(modification().in(root1).version("50").parentVersions("40"));
SVcsModification m60 = myFixture.addModification(modification().in(root1).version("60").parentVersions("15"));
SVcsModification m70 = myFixture.addModification(modification().in(root1).version("70").parentVersions("10"));
changesPolicy.setCurrentState(root1, RepositoryStateData.createVersionState("master", Util.map("master", "30", "branch1", "40", "branch2", "50", "branch3", "60", "prefix/aaa", "70", "branch10", "100")));
myFixture.getVcsModificationChecker().checkForModifications(buildConf.getVcsRootInstances(), OperationRequestor.UNKNOWN);
check(null, m70, m60, m50, m40, m30, m20);
String btLocator = "buildType:(id:" + buildConf.getExternalId() + ")";
// documenting current behavior, should be check(btLocator, m30, m20);
check(btLocator, m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:<any>", m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:(default:any)", m70, m60, m50, m40, m30, m20);
checkExceptionOnItemsSearch(BadRequestException.class, "branch:(aaa:bbb)");
// no buildType is not supported
checkExceptionOnItemsSearch(BadRequestException.class, "branch:(default:true)");
checkExceptionOnItemsSearch(BadRequestException.class, "branch:(name:branch1)");
checkExceptionOnItemsSearch(BadRequestException.class, btLocator + ",branch:(name:master,aaa:bbb)");
// no branches match here
check(btLocator + ",branch:(name:master,default:false)");
check(btLocator + ",branch:(name:master)", m30, m20);
check(btLocator + ",branch:(name:<default>)", m30, m20);
checkExceptionOnItemsSearch(BadRequestException.class, "branch:(branch1)");
check(btLocator + ",branch:(master)", m30, m20);
check(btLocator + ",branch:(<default>)", m30, m20);
check(btLocator + ",branch:(name:aaa)", m70);
check(btLocator + ",branch:(aaa)", m70);
check(btLocator + ",branch:(name:<any>)", m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:(default:any)", m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:(<any>)", m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:(name:bbb)");
check(btLocator + ",branch:(prefix/aaa)");
check(btLocator + ",branch:(name:branch1)", m40);
check(btLocator + ",branch:(default:true)", m30, m20);
check(btLocator + ",branch:(default:false)", m70, m60, m50, m40);
check(btLocator + ",branch:(default:false),unique:true", m70, m60, m50, m40);
// test pending
check(btLocator + ",branch:(name:master),pending:true", m30, m20);
check(btLocator + ",branch:(name:<default>),pending:true", m30, m20);
check(btLocator + ",branch:(name:branch1),pending:true", m40);
check(btLocator + ",branch:(name:master),pending:false");
check(btLocator + ",branch:(name:<default>),pending:false");
check(btLocator + ",branch:(name:branch1),pending:false");
check(btLocator + ",branch:(name:branch1),pending:any", m40);
changesPolicy.setCurrentState(root2, RepositoryStateData.createVersionState("master", Util.map("master", "11")));
build().in(buildConf).withDefaultBranch().finish();
build().in(buildConf).withBranch("branch1").finish();
SVcsModification m80 = myFixture.addModification(modification().in(root1).version("80").parentVersions("30"));
SVcsModification m90 = myFixture.addModification(modification().in(root1).version("90").parentVersions("40"));
changesPolicy.setCurrentState(root1, RepositoryStateData.createVersionState("master", Util.map("master", "80", "branch1", "90", "branch2", "50", "branch3", "60", "prefix/aaa", "70", "branch10", "100")));
myFixture.getVcsModificationChecker().checkForModifications(buildConf.getVcsRootInstances(), OperationRequestor.UNKNOWN);
check(null, m90, m80, m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:(name:master)", m80, m30, m20);
check(btLocator + ",branch:(name:<default>)", m80, m30, m20);
check(btLocator + ",branch:(name:branch1)", m90, m40);
check(btLocator + ",branch:(name:master),pending:true", m80);
check(btLocator + ",branch:(name:<default>),pending:true", m80);
check(btLocator + ",branch:(name:branch1),pending:true", m90);
check(btLocator + ",branch:(name:master),pending:false", m30, m20);
check(btLocator + ",branch:(name:<default>),pending:false", m30, m20);
check(btLocator + ",branch:(name:branch1),pending:false", m40);
check(btLocator + ",branch:(name:branch1),pending:any", m90, m40);
}
use of jetbrains.buildServer.serverSide.impl.BuildTypeImpl in project teamcity-rest by JetBrains.
the class ChangeFinderTest method testChangesFromDependenciesDAG.
@Test
public void testChangesFromDependenciesDAG() {
final BuildTypeImpl buildConf1 = registerBuildType("buildConf1", "project");
final BuildTypeImpl buildConf2 = registerBuildType("buildConf2", "project");
createDependencyChain(buildConf2, buildConf1);
MockVcsSupport vcs = new MockVcsSupport("vcs");
vcs.setDAGBased(true);
myFixture.getVcsManager().registerVcsSupport(vcs);
SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", buildConf1);
SVcsRootEx parentRoot2 = myFixture.addVcsRoot(vcs.getName(), "", buildConf2);
VcsRootInstance root1 = buildConf1.getVcsRootInstanceForParent(parentRoot1);
VcsRootInstance root2 = buildConf2.getVcsRootInstanceForParent(parentRoot2);
assert root1 != null;
assert root2 != null;
setBranchSpec(root1, "+:*");
setBranchSpec(root2, "+:*");
final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
vcs.setCollectChangesPolicy(changesPolicy);
SVcsModification m120 = myFixture.addModification(modification().in(root1).version("120").parentVersions("10"));
SVcsModification m250 = myFixture.addModification(modification().in(root2).version("250").parentVersions("10"));
changesPolicy.setCurrentState(root1, RepositoryStateData.createVersionState("master", Util.map("master", "120")));
changesPolicy.setCurrentState(root2, RepositoryStateData.createVersionState("master", Util.map("master", "250")));
myFixture.getVcsModificationChecker().checkForModifications(buildConf1.getVcsRootInstances(), OperationRequestor.UNKNOWN);
myFixture.getVcsModificationChecker().checkForModifications(buildConf2.getVcsRootInstances(), OperationRequestor.UNKNOWN);
String btLocator1 = "buildType:(id:" + buildConf1.getExternalId() + ")";
String btLocator2 = "buildType:(id:" + buildConf2.getExternalId() + ")";
check(null, m250, m120);
check(btLocator1, m120);
check(btLocator1 + ",branch:(default:true)", m120);
check(btLocator1 + ",branch:(name:master)", m120);
check(btLocator1 + ",branch:(name:branch1)");
check(btLocator1 + ",pending:true", m120);
check(btLocator1 + ",pending:true,branch:(default:true)", m120);
check(btLocator1 + ",pending:true,branch:(default:any)", m120);
check(btLocator1 + ",pending:true,branch:(name:branch1)");
check(btLocator1 + ",pending:true,branch:(policy:ACTIVE_VCS_BRANCHES)", m120);
check(btLocator2, m250);
check(btLocator2 + ",branch:(default:true)", m250);
check(btLocator2 + ",branch:(name:master)", m250);
check(btLocator2 + ",branch:(name:branch1)");
check(btLocator2 + ",pending:true", m250);
check(btLocator2 + ",pending:true,branch:(default:true)", m250);
check(btLocator2 + ",pending:true,branch:(default:any)", m250);
check(btLocator2 + ",pending:true,branch:(name:branch1)");
check(btLocator2 + ",pending:true,branch:(policy:ACTIVE_VCS_BRANCHES)", m250);
build().in(buildConf1).onModifications(m120).finish();
SFinishedBuild build20 = build().in(buildConf2).onModifications(m250).finish();
assertEquals("120", build20.getBuildPromotion().getDependencies().iterator().next().getDependOn().getRevisions().get(0).getRevision());
SVcsModification m130 = myFixture.addModification(modification().in(root1).version("130").parentVersions("120"));
SVcsModification m140 = myFixture.addModification(modification().in(root1).version("140").parentVersions("10"));
SVcsModification m150 = myFixture.addModification(modification().in(root1).version("150").parentVersions("140"));
SVcsModification m260 = myFixture.addModification(modification().in(root2).version("260").parentVersions("250"));
SVcsModification m270 = myFixture.addModification(modification().in(root2).version("270").parentVersions("10"));
changesPolicy.setCurrentState(root1, RepositoryStateData.createVersionState("master", Util.map("master", "130", "branch1", "150")));
changesPolicy.setCurrentState(root2, RepositoryStateData.createVersionState("master", Util.map("master", "260", "branch1", "270")));
myFixture.getVcsModificationChecker().checkForModifications(buildConf1.getVcsRootInstances(), OperationRequestor.UNKNOWN);
myFixture.getVcsModificationChecker().checkForModifications(buildConf2.getVcsRootInstances(), OperationRequestor.UNKNOWN);
check(null, m270, m260, m150, m140, m130, m250, m120);
// documenting current behavior, should be check(btLocator1, m130, m120);
check(btLocator1, m150, m140, m130, m120);
check(btLocator1 + ",branch:(default:true)", m130, m120);
check(btLocator1 + ",branch:(default:any)", m150, m140, m130, m120);
check(btLocator1 + ",branch:(name:master)", m130, m120);
check(btLocator1 + ",branch:(name:branch1)", m150, m140);
check(btLocator1 + ",pending:true", m130);
check(btLocator1 + ",pending:true,branch:(default:true)", m130);
check(btLocator1 + ",pending:true,branch:(default:any)", m150, m140, m130);
check(btLocator1 + ",pending:true,branch:(name:branch1)", m150, m140);
check(btLocator1 + ",pending:true,branch:(policy:ACTIVE_VCS_BRANCHES)", m150, m140, m130);
// documenting current behavior should be check(btLocator2, m260, m250);
check(btLocator2, m270, m260, m250);
check(btLocator2 + ",branch:(default:true)", m260, m250);
check(btLocator2 + ",branch:(name:master)", m260, m250);
check(btLocator2 + ",branch:(name:branch1)", m270);
check(btLocator2 + ",pending:true", m260);
check(btLocator2 + ",pending:true,branch:(default:true)", m260);
check(btLocator2 + ",pending:true,branch:(default:any)", m270, m260);
check(btLocator2 + ",pending:true,branch:(name:branch1)", m270);
check(btLocator2 + ",pending:true,branch:(policy:ACTIVE_VCS_BRANCHES)", m270, m260);
check("build:(" + build20.getBuildId() + ")", m250);
buildConf2.setOption(BuildTypeOptions.BT_SHOW_DEPS_CHANGES, true);
check(btLocator2, m260, m130, m250, m120);
check(btLocator2 + ",branch:(default:true)", m260, m130, m250, m120);
check(btLocator2 + ",branch:(name:master)", m260, m130, m250, m120);
check(btLocator2 + ",branch:(name:branch1)", m270, m150, m140);
check(btLocator2 + ",pending:true", m260, m130);
check(btLocator2 + ",pending:true,branch:(default:true)", m260, m130);
check(btLocator2 + ",pending:true,branch:(default:any)", m270, m260, m150, m140, m130);
check(btLocator2 + ",pending:true,branch:(name:branch1)", m270, m150, m140);
check(btLocator2 + ",pending:true,branch:(policy:ACTIVE_VCS_BRANCHES)", m270, m260, m150, m140, m130);
check("build:(" + build20.getBuildId() + ")", m250, m120);
}
Aggregations