use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.
the class AgentFinderTest method testLocatorCompatibleSnapshotDep.
@Test
@TestFor(issues = { "TW-49934" })
public void testLocatorCompatibleSnapshotDep() throws Exception {
ProjectEx project10 = createProject("project10", "project 10");
BuildTypeEx bt10 = project10.createBuildType("bt10", "bt 10");
BuildTypeEx bt20 = project10.createBuildType("bt20", "bt 20");
createDependencyChain(bt20, bt10);
checkAgents(null, myAgent1, myAgent2);
checkAgents("compatible:(buildType:(id:" + bt20.getExternalId() + "))", myAgent1);
SQueuedBuild queuedBuild = build().in(bt20).addToQueue();
// queued snapshot dependency does not affect the compatibility
checkAgents("compatible:(build:(id:" + queuedBuild.getItemId() + "))", myAgent1);
myServer.flushQueue();
final RunningBuildEx build = myFixture.waitForQueuedBuildToStart(queuedBuild.getBuildPromotion().getDependencies().iterator().next().getDependOn());
checkAgents("compatible:(build:(id:" + queuedBuild.getItemId() + "))", myAgent1);
finishBuild();
checkAgents("compatible:(build:(id:" + queuedBuild.getItemId() + "))", myAgent1);
}
use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.
the class TestOccurrenceRequestTest method testInvocationsAreFoundCorrectly.
@Test
@TestFor(issues = { "TW-70206" })
public void testInvocationsAreFoundCorrectly() {
if (true)
throw new SkipException("Ignored as current implementation does work only in a very specific number of cases when specific build is available when preparing TestOccurrences");
final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
final SFinishedBuild build = build().in(buildType).withTest("aaa", false).withTest("aaa", true).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 TestOccurrenceRequestTest method testShouldRespectExpandInvocationsDimension.
@Test
@TestFor(issues = { "TW-70331" })
public void testShouldRespectExpandInvocationsDimension() {
final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
final SFinishedBuild build = build().in(buildType).withTest("aaa", false).withTest("aaa", false).withTest("aaa", true).finish();
FakeHttpServletRequest mockRequest = new FakeHttpServletRequest();
String fields = "testCounters(all,success,failed)";
String locator = "build:" + build.getBuildId() + ",expandInvocations:true";
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(new Integer(3), testOccurrences.getTestCounters().getAll());
assertEquals(new Integer(2), testOccurrences.getTestCounters().getFailed());
assertEquals(new Integer(1), testOccurrences.getTestCounters().getSuccess());
}
use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.
the class UserRequestTest method testUnauthorizedUsersList.
@Test
@TestFor(issues = { "TW-44842" })
void testUnauthorizedUsersList() throws Throwable {
final SUser user1 = createUser("user1");
final SUser user2 = createUser("user2");
SecurityContextImpl securityContext = myFixture.getSecurityContext();
user2.addRole(RoleScope.globalScope(), getProjectAdminRole());
securityContext.runAs(user2, new SecurityContextEx.RunAsAction() {
@Override
public void run() throws Throwable {
User result = myRequest.serveUser("id:" + user1.getId(), "$long,groups(group(users(user)))");
assertNotNull(result);
assertNotNull(result.getGroups());
assertNotNull(result.getGroups().groups);
assertEquals(1, result.getGroups().groups.size());
assertNotNull(result.getGroups().groups.get(0).users);
assertNotNull(result.getGroups().groups.get(0).users.users);
}
});
securityContext.runAs(user1, new SecurityContextEx.RunAsAction() {
@Override
public void run() throws Throwable {
User result = myRequest.serveUser("username:user1", "$long,groups(group)");
assertNotNull(result);
assertNotNull(result.getGroups());
assertNotNull(result.getGroups().groups);
assertEquals(1, result.getGroups().groups.size());
}
});
securityContext.runAs(user1, new SecurityContextEx.RunAsAction() {
@Override
public void run() throws Throwable {
User result = myRequest.serveUser("username:user1", "$long,groups(group(users(user)))");
assertNotNull(result);
assertNotNull(result.getGroups());
assertNotNull(result.getGroups().groups);
assertEquals(1, result.getGroups().groups.size());
// on getting users, AuthorizationFailedException is thrown so users are not included
assertNull(result.getGroups().groups.get(0).users);
}
});
}
use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.
the class CollectChangesTest method collect_changes_with_branch_pointing_to_a_non_commit.
@TestFor(issues = "TW-29770")
public void collect_changes_with_branch_pointing_to_a_non_commit() throws Exception {
// setup remote repo with a branch pointing to a non commit
VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
File brokenRef = new File(myRepo, "refs" + File.separator + "heads" + File.separator + "broken_branch");
brokenRef.getParentFile().mkdirs();
// it's a tree, not a commit
FileUtil.writeFileAndReportErrors(brokenRef, "1fefad14fba39ac378e4e345e295fa1f90e343ae\n");
RepositoryStateData state1 = createVersionState("refs/heads/master", map("refs/heads/master", "2c7e90053e0f7a5dd25ea2a16ef8909ba71826f6", "refs/heads/broken_branch", "1fefad14fba39ac378e4e345e295fa1f90e343ae"));
RepositoryStateData state2 = createVersionState("refs/heads/master", map("refs/heads/master", "465ad9f630e451b9f2b782ffb09804c6a98c4bb9", "refs/heads/broken_branch", "1fefad14fba39ac378e4e345e295fa1f90e343ae"));
// collect changes in this repo, no exception should be thrown
git().getCollectChangesPolicy().collectChanges(root, state1, state2, CheckoutRules.DEFAULT);
}
Aggregations