Search in sources :

Example 16 with TestFor

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);
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 17 with TestFor

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());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) TestOccurrence(jetbrains.buildServer.server.rest.model.problem.TestOccurrence) FakeHttpServletRequest(jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest) TestOccurrences(jetbrains.buildServer.server.rest.model.problem.TestOccurrences) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) SkipException(org.testng.SkipException) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 18 with TestFor

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());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) FakeHttpServletRequest(jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest) TestOccurrences(jetbrains.buildServer.server.rest.model.problem.TestOccurrences) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 19 with TestFor

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);
        }
    });
}
Also used : SecurityContextImpl(jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl) User(jetbrains.buildServer.server.rest.model.user.User) SUser(jetbrains.buildServer.users.SUser) SecurityContextEx(jetbrains.buildServer.serverSide.SecurityContextEx) SUser(jetbrains.buildServer.users.SUser) Test(org.testng.annotations.Test) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) TestFor(jetbrains.buildServer.util.TestFor)

Example 20 with TestFor

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);
}
Also used : GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

TestFor (jetbrains.buildServer.util.TestFor)130 Test (org.testng.annotations.Test)82 File (java.io.File)66 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)56 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)26 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)21 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)17 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)12 VcsException (jetbrains.buildServer.vcs.VcsException)11 URIish (org.eclipse.jgit.transport.URIish)11 Repository (org.eclipse.jgit.lib.Repository)9 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)7 AfterMethod (org.testng.annotations.AfterMethod)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 Method (java.lang.reflect.Method)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 GitTestUtil.copyRepository (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.copyRepository)6 Build (jetbrains.buildServer.server.rest.model.build.Build)6 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)6 FileUtil.writeFile (jetbrains.buildServer.util.FileUtil.writeFile)6