Search in sources :

Example 6 with VcsRootInstance

use of jetbrains.buildServer.vcs.VcsRootInstance in project teamcity-rest by JetBrains.

the class BuildPromotionFinderTest method testBranchDimension.

@Test
public void testBranchDimension() throws ExecutionException, InterruptedException {
    final BuildTypeImpl buildConf1 = registerBuildType("buildConf1", "project");
    final BuildPromotion build10 = build().in(buildConf1).finish().getBuildPromotion();
    final BuildPromotion build20 = build().in(buildConf1).withBranch("branch").finish().getBuildPromotion();
    MockVcsSupport vcs = vcsSupport().withName("vcs").dagBased(true).register();
    BuildFinderTestBase.MockCollectRepositoryChangesPolicy collectChangesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(collectChangesPolicy);
    buildConf1.addVcsRoot(buildConf1.getProject().createVcsRoot("vcs", "extId", "name"));
    final VcsRootInstance vcsRootInstance = buildConf1.getVcsRootInstances().get(0);
    collectChangesPolicy.setCurrentState(vcsRootInstance, createVersionState("master", map("master", "1", "branch1", "2", "branch2", "3")));
    setBranchSpec(vcsRootInstance, "+:*");
    myFixture.getVcsModificationChecker().checkForModifications(buildConf1.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    final BuildPromotion build30 = build().in(buildConf1).finish().getBuildPromotion();
    final BuildPromotion build40 = build().in(buildConf1).withDefaultBranch().finish().getBuildPromotion();
    final BuildPromotion build50 = build().in(buildConf1).withBranch("branch").finish().getBuildPromotion();
    final BuildPromotion build60 = build().in(buildConf1).withBranch("branch1").finish().getBuildPromotion();
    // right way to run unspecified?
    final BuildPromotion build65 = build().in(buildConf1).withBranch(Branch.UNSPECIFIED_BRANCH_NAME).finish().getBuildPromotion();
    final RunningBuildEx running70 = build().withBranch("branch1").in(buildConf1).run();
    running70.stop(getOrCreateUser("user1"), "cancel comment");
    final BuildPromotion build70 = finishBuild(running70, true).getBuildPromotion();
    final BuildPromotion build80 = build().in(buildConf1).withBranch("branch1").run().getBuildPromotion();
    final BuildPromotion build90 = build().in(buildConf1).withBranch("branch1").addToQueue().getBuildPromotion();
    checkBuilds("defaultFilter:false", build90, build80, build70, build65, build60, build50, build40, build30, build20, build10);
    checkBuilds(null, build40, build30, build10);
    checkBuilds("branch:(default:any)", build65, build60, build50, build40, build30, build20, build10);
    checkBuilds("branch:(default:true)", build40, build30, build10);
    checkBuilds("branch:(default:false)", build65, build60, build50, build20);
    checkBuilds("branch:(branched:true)", build65, build60, build50, build40, build30, build20);
    checkBuilds("branch:(branched:false)", build10);
    checkBuilds("branch:(unspecified:true)", build65);
    checkBuilds("branch:(name:<unspecified>)", build65);
    checkBuilds("branch:(unspecified:false)", build60, build50, build40, build30, build20, build10);
    checkBuilds("branch:(name:branch1)", build60);
    checkBuilds("branch:branch1", build60);
    checkBuilds("branch:Branch1", build60);
    checkBuilds("branch:(name:master)", build40, build30);
    checkBuilds("branch:(name:Master)", build40, build30);
    checkBuilds("branch:(name:<default>)", build40, build30);
    checkBuilds("branch:(name:<Default>)", build40, build30);
    checkBuilds("branch:<default>", build40, build30);
    checkBuilds("branch:<Default>", build40, build30);
    checkBuilds("branch:(name:<any>)", build65, build60, build50, build40, build30, build20, build10);
    checkBuilds("branch:<any>", build65, build60, build50, build40, build30, build20, build10);
    checkBuilds("branch:(name:branch1)", build60);
    checkBuilds("branch:(name:master)", build40, build30);
    checkBuilds("branch:(name:(value:branch1))", build60);
    checkBuilds("branch:(name:(value:Branch1))");
    checkBuilds("branch:(name:(value:branch1,matchType:equals))", build60);
    checkBuilds("branch:branch", build50, build20);
    checkBuilds("branch:(name:(value:branch,matchType:starts-with))", build60, build50, build20);
    checkBuilds("branch:(name:(<default>))", build40, build30);
    // when full value condition syntax is used, <default> has no special meaning as we compare displayName, use "default" dimension instead
    checkBuilds("branch:(name:(value:<default>))");
    checkBuilds("branch:(name:(value:<Default>))");
    checkBuilds("branch:(name:(value:<any>))");
    checkBuilds("branch:(buildType:(id:" + buildConf1.getExternalId() + "),policy:ALL_BRANCHES)", build65, build60, build50, build40, build30, build20, build10);
    checkBuilds("branch:(buildType:(id:" + buildConf1.getExternalId() + "),policy:ALL_BRANCHES),branched:true", build65, build60, build50, build40, build30, build20);
    checkBuilds("branch:(buildType:(id:" + buildConf1.getExternalId() + "),policy:VCS_BRANCHES)", build60, build40, build30, build10);
    checkBuilds("branch:(buildType:(id:" + buildConf1.getExternalId() + "),policy:VCS_BRANCHES),branched:true", build60, build40, build30);
    checkBuilds("buildType:(id:" + buildConf1.getExternalId() + "),branch:(policy:ALL_BRANCHES)", build65, build60, build50, build40, build30, build20, build10);
    checkBuilds("buildType:(id:" + buildConf1.getExternalId() + "),branch:(policy:ALL_BRANCHES),branched:true", build65, build60, build50, build40, build30, build20);
    checkBuilds("buildType:(id:" + buildConf1.getExternalId() + "),branch:(policy:VCS_BRANCHES)", build60, build40, build30, build10);
    checkBuilds("buildType:(id:" + buildConf1.getExternalId() + "),branch:(policy:VCS_BRANCHES),branched:true", build60, build40, build30);
    checkBuilds("buildType:(id:" + buildConf1.getExternalId() + "),branch:(default:true)", build40, build30, build10);
    // policy is not supported for the build's branch locator
    checkExceptionOnItemsSearch(BadRequestException.class, "branch:(policy:ALL_BRANCHES)");
    checkExceptionOnItemsSearch(BadRequestException.class, "branch:(aaa:bbb)");
    // check that no filtering is done when not necessary
    assertEquals(0, ((MultiCheckerFilter) myBranchFinder.getFilter(new Locator("<any>"))).getSubFiltersCount());
    assertEquals(0, ((MultiCheckerFilter) myBranchFinder.getFilter(new Locator("default:any"))).getSubFiltersCount());
}
Also used : VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) Test(org.testng.annotations.Test)

Example 7 with VcsRootInstance

use of jetbrains.buildServer.vcs.VcsRootInstance in project teamcity-rest by JetBrains.

the class BuildPromotionFinderTest method testSnapshotDependenciesAndBranches.

@Test
public void testSnapshotDependenciesAndBranches() throws Exception {
    final BuildTypeImpl buildConf0 = registerBuildType("buildConf0", "project");
    final BuildTypeImpl buildConf1 = registerBuildType("buildConf1", "project");
    final BuildTypeImpl buildConf2 = registerBuildType("buildConf2", "project");
    addDependency(buildConf2, buildConf1);
    addDependency(buildConf1, buildConf0);
    MockVcsSupport vcs = vcsSupport().withName("vcs").dagBased(true).register();
    BuildFinderTestBase.MockCollectRepositoryChangesPolicy collectChangesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(collectChangesPolicy);
    final SVcsRoot vcsRoot = buildConf0.getProject().createVcsRoot("vcs", "extId", "name");
    buildConf0.addVcsRoot(vcsRoot);
    buildConf1.addVcsRoot(vcsRoot);
    buildConf2.addVcsRoot(vcsRoot);
    final VcsRootInstance vcsRootInstance = buildConf0.getVcsRootInstances().get(0);
    collectChangesPolicy.setCurrentState(vcsRootInstance, createVersionState("master", map("master", "1", "branch1", "2", "branch2", "3")));
    setBranchSpec(vcsRootInstance, "+:*");
    final BuildPromotion build20 = build().in(buildConf2).finish().getBuildPromotion();
    final BuildPromotion build10 = build20.getDependencies().iterator().next().getDependOn();
    final BuildPromotion build00 = build10.getDependencies().iterator().next().getDependOn();
    final BuildPromotion build2_20 = build().in(buildConf2).withBranch("branch1").finish().getBuildPromotion();
    final BuildPromotion build2_10 = build2_20.getDependencies().iterator().next().getDependOn();
    final BuildPromotion build2_00 = build2_10.getDependencies().iterator().next().getDependOn();
    checkBuilds("snapshotDependency:(to:(id:" + build10.getId() + "))", build00);
    checkBuilds("snapshotDependency:(to:(id:" + build2_10.getId() + "))", build2_00);
    final BuildPromotion build3_20 = build().in(buildConf2).withBranch("branch1").finish().getBuildPromotion();
    checkBuilds("snapshotDependency:(from:(id:" + build2_00.getId() + ")),equivalent:(id:" + build3_20.getId() + ")", build2_20);
}
Also used : SVcsRoot(jetbrains.buildServer.vcs.SVcsRoot) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) Test(org.testng.annotations.Test)

Example 8 with VcsRootInstance

use of jetbrains.buildServer.vcs.VcsRootInstance in project teamcity-rest by JetBrains.

the class BuildPromotionFinderTest method testBranchDimensionWithSeveralRoots.

@Test
public void testBranchDimensionWithSeveralRoots() throws ExecutionException, InterruptedException {
    final BuildTypeImpl buildConf2 = registerBuildType("buildConf2", "project");
    MockVcsSupport vcs = vcsSupport().withName("vcs").dagBased(true).register();
    BuildFinderTestBase.MockCollectRepositoryChangesPolicy collectChangesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(collectChangesPolicy);
    SVcsRoot vcsRoot10 = buildConf2.getProject().createVcsRoot("vcs", "extId10", "name10");
    buildConf2.addVcsRoot(vcsRoot10);
    SVcsRoot vcsRoot20 = buildConf2.getProject().createVcsRoot("vcs", "extId20", "name20");
    buildConf2.addVcsRoot(vcsRoot20);
    final VcsRootInstance vcsRootInstance10 = buildConf2.getVcsRootInstanceForParent(vcsRoot10);
    assert vcsRootInstance10 != null;
    final VcsRootInstance vcsRootInstance20 = buildConf2.getVcsRootInstanceForParent(vcsRoot20);
    assert vcsRootInstance20 != null;
    collectChangesPolicy.setCurrentState(vcsRootInstance10, createVersionState("refs/heads/master", map("refs/heads/master", "a1", "refs/heads/branch1", "a2", "refs/heads/branch2", "a3")));
    collectChangesPolicy.setCurrentState(vcsRootInstance20, createVersionState("refs/heads/master", map("refs/heads/master", "b1", "refs/heads/branch1", "b2", "refs/heads/branch2", "b3")));
    setBranchSpec(vcsRootInstance10, "+:refs/heads/(*)");
    setBranchSpec(vcsRootInstance20, "+:refs/heads/(*)");
    myFixture.getVcsModificationChecker().checkForModifications(buildConf2.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    final BuildPromotion build30 = build().in(buildConf2).finish().getBuildPromotion();
    final BuildPromotion build40 = build().in(buildConf2).withDefaultBranch().finish().getBuildPromotion();
    // not existing branch
    final BuildPromotion build50 = build().in(buildConf2).withBranch("branch").finish().getBuildPromotion();
    final BuildPromotion build60 = build().in(buildConf2).withBranch("branch1").finish().getBuildPromotion();
    // not existing branch
    final BuildPromotion build70 = build().in(buildConf2).withBranch("master").finish().getBuildPromotion();
    checkBuilds(null, build40, build30);
    checkBuilds("branch:(default:any)", build70, build60, build50, build40, build30);
    checkBuilds("branch:(name:<default>)", build40, build30);
    checkBuilds("buildType:(id:" + buildConf2.getExternalId() + "),branch:(name:<default>)", build40, build30);
    checkBuilds("branch:(name:master)", build70, build40, build30);
    checkBuilds("branch:(name:master,default:true)", build40, build30);
    checkBuilds("branch:(name:master,default:false)", build70);
    checkBuilds("buildType:(id:" + buildConf2.getExternalId() + "),branch:(name:master)", build70, build40, build30);
    checkBuilds("branch:(name:branch1)", build60);
    final BuildTypeImpl buildConf3 = registerBuildType("buildConf3", "project");
    SVcsRoot vcsRoot30 = buildConf3.getProject().createVcsRoot("vcs", "extId30", "name30");
    buildConf3.addVcsRoot(vcsRoot30);
    SVcsRoot vcsRoot40 = buildConf3.getProject().createVcsRoot("vcs", "extId40", "name40");
    buildConf3.addVcsRoot(vcsRoot40);
    final VcsRootInstance vcsRootInstance30 = buildConf3.getVcsRootInstanceForParent(vcsRoot30);
    assert vcsRootInstance30 != null;
    final VcsRootInstance vcsRootInstance40 = buildConf3.getVcsRootInstanceForParent(vcsRoot40);
    assert vcsRootInstance40 != null;
    collectChangesPolicy.setCurrentState(vcsRootInstance30, createVersionState("refs/heads/master", map("refs/heads/master", "a1", "refs/heads/branch1", "a2", "refs/heads/branch2", "a3")));
    collectChangesPolicy.setCurrentState(vcsRootInstance40, createVersionState("refs/heads/branch1", map("refs/heads/master", "b1", "refs/heads/branch1", "b2", "refs/heads/branch2", // different default branch
    "b3")));
    setBranchSpec(vcsRootInstance30, "+:refs/heads/(*)");
    setBranchSpec(vcsRootInstance40, "+:refs/heads/(*)");
    myFixture.getVcsModificationChecker().checkForModifications(buildConf3.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    final BuildPromotion build230 = build().in(buildConf3).finish().getBuildPromotion();
    final BuildPromotion build240 = build().in(buildConf3).withDefaultBranch().finish().getBuildPromotion();
    // not existing branch
    final BuildPromotion build250 = build().in(buildConf3).withBranch("branch").finish().getBuildPromotion();
    final BuildPromotion build260 = build().in(buildConf3).withBranch("branch1").finish().getBuildPromotion();
    // not existing branch
    final BuildPromotion build270 = build().in(buildConf3).withBranch("master").finish().getBuildPromotion();
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + ")", build240, build230);
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(default:any)", build270, build260, build250, build240, build230);
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:<default>)", build240, build230);
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:<Default>)", build240, build230);
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:(value:<default>))", build240, build230);
    // case sensitive in this syntax
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:(value:<Default>))");
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:master)", build270);
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:Master)", build270);
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:master,default:true)");
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:master,default:false)", build270);
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:(value:master))", build270);
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:(value:Master))");
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:branch)", build250);
    checkBuilds("buildType:(id:" + buildConf3.getExternalId() + "),branch:(name:branch1)", build260);
}
Also used : SVcsRoot(jetbrains.buildServer.vcs.SVcsRoot) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) Test(org.testng.annotations.Test)

Example 9 with VcsRootInstance

use of jetbrains.buildServer.vcs.VcsRootInstance in project teamcity-rest by JetBrains.

the class ChangeStatusTest method testSomeNewFailedTests.

public void testSomeNewFailedTests() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    SVcsModification m30 = myFixture.addModification(modification().in(root1).version("30").parentVersions("20"));
    build().in(buildConf).onModifications(m20).withFailedTests("failedTestName").finish();
    // same test failed
    build().in(buildConf).onModifications(m30).withFailedTests("failedTestName", "newFailedTestName").finish();
    ChangeStatus status = new ChangeStatus(myFixture.getChangeStatusProvider().getMergedChangeStatus(m30), Fields.ALL_NESTED, getBeanContext(myFixture));
    assertEquals(1, (int) status.getFinished());
    assertEquals(0, (int) status.getSuccessful());
    assertEquals(1, (int) status.getFailed());
    assertEquals(1, (int) status.getNewFailedTests());
    assertEquals(1, (int) status.getOtherFailedTests());
    assertEquals(1, (int) status.getNewTestsFailedBuilds().count);
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.server.rest.model.change.ChangeStatus) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance)

Example 10 with VcsRootInstance

use of jetbrains.buildServer.vcs.VcsRootInstance in project teamcity-rest by JetBrains.

the class ChangeStatusTest method testNoNewFailedTests.

public void testNoNewFailedTests() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    SVcsModification m30 = myFixture.addModification(modification().in(root1).version("30").parentVersions("20"));
    build().in(buildConf).onModifications(m20).withFailedTests("failedTestName").finish();
    // same test failed
    build().in(buildConf).onModifications(m30).withFailedTests("failedTestName").finish();
    ChangeStatus status = new ChangeStatus(myFixture.getChangeStatusProvider().getMergedChangeStatus(m30), Fields.ALL_NESTED, getBeanContext(myFixture));
    assertEquals(1, (int) status.getFinished());
    assertEquals(0, (int) status.getSuccessful());
    assertEquals(1, (int) status.getFailed());
    assertEquals(0, (int) status.getNewFailedTests());
    assertEquals(1, (int) status.getOtherFailedTests());
    assertEquals(0, (int) status.getNewTestsFailedBuilds().count);
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.server.rest.model.change.ChangeStatus) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance)

Aggregations

VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)31 Test (org.testng.annotations.Test)15 SVcsModification (jetbrains.buildServer.vcs.SVcsModification)14 ChangeStatus (jetbrains.buildServer.server.rest.model.change.ChangeStatus)12 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)12 SVcsRoot (jetbrains.buildServer.vcs.SVcsRoot)9 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)6 RunningBuildEx (jetbrains.buildServer.serverSide.RunningBuildEx)5 BuildFinderTestBase (jetbrains.buildServer.server.rest.data.BuildFinderTestBase)4 Nullable (org.jetbrains.annotations.Nullable)4 SUser (jetbrains.buildServer.users.SUser)3 NotNull (org.jetbrains.annotations.NotNull)3 Logger (com.intellij.openapi.diagnostic.Logger)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 ActionErrors (jetbrains.buildServer.controllers.ActionErrors)2 Branches (jetbrains.buildServer.server.rest.model.build.Branches)2 jetbrains.buildServer.serverSide (jetbrains.buildServer.serverSide)2