use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.
the class ChangeFinderTest method testChangesByBuildIdFromDependenciesHaveDescriptor.
@Test
@TestFor(issues = "TW-60774")
public void testChangesByBuildIdFromDependenciesHaveDescriptor() {
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, "+:*");
SVcsModification m1 = myFixture.addModification(modification().in(root1).version("1").parentVersions("0"));
SVcsModification m2 = myFixture.addModification(modification().in(root2).version("2").parentVersions("0"));
SQueuedBuild qb1 = build().in(buildConf1).onModifications(m1).addToQueue();
SQueuedBuild qb2 = build().in(buildConf2).onModifications(m2).snapshotDepends(qb1.getBuildPromotion()).addToQueue();
SFinishedBuild build1 = finishBuild(myFixture.flushQueueAndWait(), false);
SFinishedBuild build2 = finishBuild(myFixture.flushQueueAndWait(), false);
List<SVcsModificationOrChangeDescriptor> items = getFinder().getItems("build:" + build2.getBuildId() + ",changesFromDependencies:true,vcsRoot:(id:" + root1.getExternalId() + ")").myEntries;
assertEquals("There is exactly one change coming from dependency.", 1, items.size());
ChangeDescriptor descriptor = items.get(0).getChangeDescriptor();
assertNotNull("Change descriptor must be present when looking for changes using build id.", descriptor);
assertEquals(ChangeDescriptorConstants.SNAPSHOT_DEPENDENCY_VCS_CHANGE, descriptor.getType());
SVcsModification modification = items.get(0).getSVcsModification();
assertEquals("1", modification.getDisplayVersion());
}
use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.
the class BuildTest method testDownloadedArtifactsPermission.
@Test
@TestFor(issues = "TW-21036")
public void testDownloadedArtifactsPermission() throws Throwable {
myFixture.getServerSettings().setPerProjectPermissionsEnabled(true);
DownloadedArtifactsLoggerImpl artifactsLogger = myFixture.getSingletonService(DownloadedArtifactsLoggerImpl.class);
SBuildType bt0 = registerBuildType("bt0", "project0", "Ant");
SBuild build0 = createBuild(bt0, Status.NORMAL);
SBuildType bt1 = registerBuildType("bt1", "project1", "Ant");
SBuild build1 = createBuild(bt1, Status.NORMAL);
SBuildType bt2 = registerBuildType("bt2", "project2", "Ant");
SBuild build2 = createBuild(bt2, Status.NORMAL);
final SUser user = createUser("user1");
myFixture.getSecurityContext().runAsSystem(new SecurityContextEx.RunAsAction() {
@Override
public void run() throws Throwable {
user.addRole(RoleScope.projectScope(build1.getProjectId()), getTestRoles().getProjectViewerRole());
}
});
artifactsLogger.logArtifactDownload(build2.getBuildId(), build1.getBuildId(), "path1");
artifactsLogger.logArtifactDownload(build2.getBuildId(), build0.getBuildId(), "path0");
artifactsLogger.waitForQueuePersisting();
myFixture.getSecurityContext().setAuthorityHolder(user);
Build build2model = new Build(build2, Fields.ALL_NESTED, getBeanContext(myFixture));
jetbrains.buildServer.server.rest.model.build.downloadedArtifacts.DownloadedArtifacts build2Artifacts = build2model.getDownloadedArtifacts();
assertEquals("There are 2 builds as a source of artifacts", 2, (int) build2Artifacts.getUnfilteredCount());
assertEquals("There is only 1 visible build as a source of artifacts", 1, (int) build2Artifacts.getCount());
assertEquals("There is only 1 visible build as a source of artifacts", 1, build2Artifacts.getDownloadInfo().size());
}
use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.
the class BuildTest method testBuildTriggeringWithBuildTypeAndCustomDefaultParameter.
@Test(enabled = false)
@TestFor(issues = "TW-48945")
public void testBuildTriggeringWithBuildTypeAndCustomDefaultParameter() {
BuildTypeImpl buildType1 = registerBuildType("buildType1", "projectName");
buildType1.addParameter(new SimpleParameter("name", "value"));
final SUser user = getOrCreateUser("user");
// end of setup
final Build build = new Build();
final BuildType buildTypeEntity = new BuildType();
buildTypeEntity.setId(buildType1.getExternalId());
buildTypeEntity.setDescription("some description");
build.setBuildType(buildTypeEntity);
build.setProperties(new Properties(createMap("name", "value"), null, Fields.ALL, getBeanContext(myFixture)));
SQueuedBuild result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
assertEquals("value", result.getBuildPromotion().getParameterValue("name"));
}
use of jetbrains.buildServer.util.TestFor 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.util.TestFor in project teamcity-rest by JetBrains.
the class TestOccurrenceFinderTest method testShortStatisticsIsNotEnoughWhenNoFieldsGiven.
@Test
@TestFor(issues = { "TW-71738" })
public void testShortStatisticsIsNotEnoughWhenNoFieldsGiven() {
final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
final SFinishedBuild build = createBuildWithSuccessFailedIgnoredTests(buildType);
assertNull("When fields are not given we can't use short statistics", myTestOccurrenceFinder.tryGetCachedInfo("build:" + build.getBuildId(), null).getShortStatistics());
}
Aggregations