Search in sources :

Example 71 with BuildTypeImpl

use of jetbrains.buildServer.serverSide.impl.BuildTypeImpl in project teamcity-rest by JetBrains.

the class TestOccurrenceFinderTest method testSeveralInvocations.

@Test
public void testSeveralInvocations() throws Exception {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build10 = build().in(buildType).withTest("aaa", true).withTest("aaa", true).withTest("bbb", true).withTest("ccc", false).withTest("bbb", true).withTest("aaa", false).withTest("aaa", true).withTest("ddd", true).finish();
    check("build:(id:" + build10.getBuildId() + ")", TEST_MATCHER, t("aaa", Status.FAILURE, 1), t("bbb", Status.NORMAL, 3), t("ccc", Status.FAILURE, 4), t("ddd", Status.NORMAL, 8));
    {
        int testRunId = myTestOccurrenceFinder.getItems("build:(id:" + build10.getBuildId() + ")").myEntries.get(0).getTestRunId();
        check("build:(id:" + build10.getBuildId() + "),id:(" + testRunId + ")", TEST_MATCHER, t("aaa", Status.FAILURE, 1));
        assertEquals(testRunId, myTestOccurrenceFinder.getItems("build:(id:" + build10.getBuildId() + "),id:(" + testRunId + ")").myEntries.get(0).getTestRunId());
        assertEquals(testRunId, myTestOccurrenceFinder.getItem("build:(id:" + build10.getBuildId() + "),id:(" + testRunId + ")").getTestRunId());
    }
    check("build:(id:" + build10.getBuildId() + "),expandInvocations:true", TEST_MATCHER, t("aaa", Status.NORMAL, 1), t("aaa", Status.NORMAL, 2), // ordering so far is grouped by test
    t("aaa", Status.FAILURE, 6), t("aaa", Status.NORMAL, 7), t("bbb", Status.NORMAL, 3), t("bbb", Status.NORMAL, 5), t("ccc", Status.FAILURE, 4), t("ddd", Status.NORMAL, 8));
    {
        int testRunId = myTestOccurrenceFinder.getItems("build:(id:" + build10.getBuildId() + "),expandInvocations:true").myEntries.get(2).getTestRunId();
        check("build:(id:" + build10.getBuildId() + "),id:(" + testRunId + ")", TEST_MATCHER, t("aaa", Status.FAILURE, 6));
        assertEquals(testRunId, myTestOccurrenceFinder.getItems("build:(id:" + build10.getBuildId() + "),id:(" + testRunId + ")").myEntries.get(0).getTestRunId());
        assertEquals(testRunId, myTestOccurrenceFinder.getItem("build:(id:" + build10.getBuildId() + "),id:(" + testRunId + ")").getTestRunId());
    }
    check("build:(id:" + build10.getBuildId() + "),test:(name:aaa)", TEST_MATCHER, t("aaa", Status.FAILURE, 1));
    check("build:(id:" + build10.getBuildId() + "),test:(name:aaa),expandInvocations:true", TEST_MATCHER, t("aaa", Status.NORMAL, 1), t("aaa", Status.NORMAL, 2), t("aaa", Status.FAILURE, 6), t("aaa", Status.NORMAL, 7));
    check("build:(id:" + build10.getBuildId() + "),invocations:(search:(status:FAILURE))", TEST_MATCHER, t("aaa", Status.FAILURE, 1), t("ccc", Status.FAILURE, 4));
    check("build:(id:" + build10.getBuildId() + "),invocations:(search:(count:100),match:(status:SUCCESS))", TEST_MATCHER, t("bbb", Status.NORMAL, 3), t("ddd", Status.NORMAL, 8));
    STestRun testRun = getFinder().getItem("build:(id:" + build10.getBuildId() + ")");
    check("build:(id:" + build10.getBuildId() + "),id:" + testRun.getTestRunId() + "", TEST_MATCHER, t(testRun.getTest().getName().toString(), testRun.getStatus(), testRun.getOrderId()));
    check("id:404,build:(id:" + build10.getBuildId() + ")", TEST_MATCHER);
    check("id:404,build:(id:" + build10.getBuildId() + "),expandInvocations:true", TEST_MATCHER);
    // documenting current behavior: no error, can be useful for "get test runs from such builds
    check("id:404,build:(id:404)", TEST_MATCHER);
    check("id:404,build:(id:404),expandInvocations:true", TEST_MATCHER);
    // documenting current behavior: no error, can be useful for "get test runs for the currently investigated tests, or alike
    check("build:(id:" + build10.getBuildId() + "),test:(name:missing)", TEST_MATCHER);
    // documenting current behavior: no error
    check("test:(name:missing)", TEST_MATCHER);
}
Also used : BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 72 with BuildTypeImpl

use of jetbrains.buildServer.serverSide.impl.BuildTypeImpl in project teamcity-rest by JetBrains.

the class TestOccurrenceFinderTest method testTestOccurrenceEntity_Metadata.

@Test
public void testTestOccurrenceEntity_Metadata() throws Exception {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final RunningBuildEx build = startBuild(buildType);
    myFixture.doTestPassed(build, "testName");
    myFixture.doTestMetadata(build, new TestMetadata("testName", "some key", "link", "value"));
    myFixture.doTestMetadata(build, new TestMetadata("testName", "some key3", "number", new BigDecimal("44")));
    STestRun testRun = finishBuild().getFullStatistics().getAllTests().get(0);
    TestOccurrence testOccurrence = new TestOccurrence(testRun, getBeanContext(myServer), new Fields("metadata"));
    assertEquals(Integer.valueOf(2), testOccurrence.getMetadata().count);
    final List<TypedValue> items = testOccurrence.getMetadata().typedValues;
    assertEquals(items.size(), 2);
    System.out.println("items = " + StringUtil.join("\n", items));
    assertTrue(items.contains(new TypedValue("some key", "link", "value", Fields.LONG)));
    assertTrue(items.contains(new TypedValue("some key3", "number", String.valueOf(44f), Fields.LONG)));
}
Also used : TestOccurrence(jetbrains.buildServer.server.rest.model.problem.TestOccurrence) Fields(jetbrains.buildServer.server.rest.model.Fields) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) TestMetadata(jetbrains.buildServer.messages.TestMetadata) BigDecimal(java.math.BigDecimal) TypedValue(jetbrains.buildServer.server.rest.model.problem.TypedValue) Test(org.testng.annotations.Test)

Example 73 with BuildTypeImpl

use of jetbrains.buildServer.serverSide.impl.BuildTypeImpl in project teamcity-rest by JetBrains.

the class TestOccurrenceFinderTest method testShortStatisticsIsNotEnoughWhenNoBuildInRequest.

@Test
public void testShortStatisticsIsNotEnoughWhenNoBuildInRequest() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build = createBuildWithSuccessFailedIgnoredTests(buildType);
    assertNull("ShortStatistics can be used only if the build is specified.", myTestOccurrenceFinder.tryGetCachedInfo("test:(status:failed,affectedProject:project)", "count,passed,failed,newFailed,ignored,muted").getShortStatistics());
}
Also used : BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 74 with BuildTypeImpl

use of jetbrains.buildServer.serverSide.impl.BuildTypeImpl in project teamcity-rest by JetBrains.

the class TestOccurrenceFinderTest method testByTestName.

@Test
public void testByTestName() throws Exception {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build10 = build().in(buildType).withTest("bbb", true).withTest("(bbb)", true).withTest("((bbb))", true).withTest("ccc(ddd)", true).withTest("ccc(ddd)", true).withTest("(aaa(bbb))", true).withTest("(aaa)(bbb)", true).withTest("aaa:bbb", true).withTest("(aaa:bbb)", true).withTest("((::,,", true).withTest("::,,", true).withTest("(::,,)", true).withTest("((::,,))", true).finish();
    int idx = 1;
    check("build:(id:" + build10.getBuildId() + "),expandInvocations:true", TEST_MATCHER, t("bbb", Status.NORMAL, idx++), t("(bbb)", Status.NORMAL, idx++), t("((bbb))", Status.NORMAL, idx++), t("ccc(ddd)", Status.NORMAL, idx++), t("ccc(ddd)", Status.NORMAL, idx++), t("(aaa(bbb))", Status.NORMAL, idx++), t("(aaa)(bbb)", Status.NORMAL, idx++), t("aaa:bbb", Status.NORMAL, idx++), t("(aaa:bbb)", Status.NORMAL, idx++), t("((::,,", Status.NORMAL, idx++), t("::,,", Status.NORMAL, idx++), t("(::,,)", Status.NORMAL, idx++), t("((::,,))", Status.NORMAL, idx++));
    Checker test = new Checker<TestRunData, String>(nameDimension -> "build:(id:" + build10.getBuildId() + "),expandInvocations:true,test:(name:" + nameDimension + ")", testName -> t(testName, Status.NORMAL, null), TEST_MATCHER);
    test.check("bbb", "bbb");
    test.check("(bbb)", "bbb");
    test.check("((bbb))", "(bbb)");
    test.check("(((bbb)))", "((bbb))");
    check("build:(id:" + build10.getBuildId() + "),expandInvocations:true,test:(name:" + "ccc(ddd)" + ")", TEST_MATCHER, t("ccc(ddd)", Status.NORMAL, null), t("ccc(ddd)", Status.NORMAL, null));
    check("build:(id:" + build10.getBuildId() + "),expandInvocations:true,test:(name:" + "(ccc(ddd))" + ")", TEST_MATCHER, t("ccc(ddd)", Status.NORMAL, null), t("ccc(ddd)", Status.NORMAL, null));
    test.check("((ccc(ddd)))");
    checkExceptionOnItemsSearch(LocatorProcessException.class, "build:(id:" + build10.getBuildId() + "),expandInvocations:true,test:(name:" + "(aaa)(bbb)" + ")");
    test.check("((aaa)(bbb))", "(aaa)(bbb)");
    test.check("((aaa)(bbb))", "(aaa)(bbb)");
    test.check("aaa:bbb", "aaa:bbb");
    test.check("(aaa:bbb)", "aaa:bbb");
    test.check("((aaa:bbb))", "(aaa:bbb)");
    test.check("(((aaa:bbb)))");
    checkExceptionOnItemsSearch(LocatorProcessException.class, "build:(id:" + build10.getBuildId() + "),expandInvocations:true,test:(name:" + "((::,," + ")");
    checkExceptionOnItemsSearch(LocatorProcessException.class, "build:(id:" + build10.getBuildId() + "),expandInvocations:true,test:(name:" + "::,," + ")");
    test.check("(::,,)", "::,,");
    test.check("((::,,))", "(::,,)");
    test.check("(((::,,)))", "((::,,))");
    test.check("($base64:" + new String(Base64.getUrlEncoder().encode("::,,".getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8) + ")", "::,,");
    test.check("($base64:" + new String(Base64.getUrlEncoder().encode("((::,,".getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8) + ")", "((::,,");
}
Also used : BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 75 with BuildTypeImpl

use of jetbrains.buildServer.serverSide.impl.BuildTypeImpl in project teamcity-rest by JetBrains.

the class TestOccurrenceFinderTest method testSameTestInDifferentBuilds.

@Test
public void testSameTestInDifferentBuilds() throws Exception {
    final BuildTypeImpl buildType1 = registerBuildType("buildConf1", "project1");
    final BuildTypeImpl buildType2 = registerBuildType("buildConf2", "project2");
    final SFinishedBuild build10 = build().in(buildType1).withTest("aaa", false).finish();
    final SFinishedBuild build20 = build().in(buildType2).withTest("aaa", false).finish();
    check("currentlyFailing:true", TEST_MATCHER, t("aaa", Status.FAILURE, 1), t("aaa", Status.FAILURE, 1));
    check("currentlyFailing:true,buildType:(id:" + buildType1.getExternalId() + ")", TEST_MATCHER, t("aaa", Status.FAILURE, 1));
    STestRun testRun1 = getFinder().getItems("currentlyFailing:true").myEntries.get(0);
    STestRun testRun2 = getFinder().getItems("currentlyFailing:true").myEntries.get(1);
    assertEquals(testRun1.getBuildId(), build10.getBuildId());
    assertEquals(testRun2.getBuildId(), build20.getBuildId());
    check("currentlyFailing:true,currentlyInvestigated:false", TEST_MATCHER, t("aaa", Status.FAILURE, 1), t("aaa", Status.FAILURE, 1));
    long nameId = myFixture.getSingletonService(TestName2Index.class).getOrSaveTestNameId("aaa");
    SUser user = createUser("user");
    ProjectEx project = myServer.getProjectManager().getRootProject().findProjectByName("project1");
    TestNameResponsibilityEntryImpl testNameResponsibilityEntry = new TestNameResponsibilityEntryImpl(new TestName("aaa"), nameId, ResponsibilityEntry.State.TAKEN, user, user, new Date(), "Please, fix", project, ResponsibilityEntry.RemoveMethod.MANUALLY);
    myFixture.getSingletonService(TestNameResponsibilityFacade.class).setTestNameResponsibility(new TestName("aaa"), project.getProjectId(), testNameResponsibilityEntry);
    check("currentlyFailing:true,currentlyInvestigated:false", TEST_MATCHER, t("aaa", Status.FAILURE, 1));
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) TestName(jetbrains.buildServer.tests.TestName) TestNameResponsibilityFacade(jetbrains.buildServer.responsibility.TestNameResponsibilityFacade) SUser(jetbrains.buildServer.users.SUser) TestNameResponsibilityEntryImpl(jetbrains.buildServer.responsibility.impl.TestNameResponsibilityEntryImpl) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Date(java.util.Date) Test(org.testng.annotations.Test)

Aggregations

BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)80 Test (org.testng.annotations.Test)68 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)19 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)12 ChangeStatus (jetbrains.buildServer.server.rest.model.change.ChangeStatus)12 SVcsModification (jetbrains.buildServer.vcs.SVcsModification)12 VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)12 SUser (jetbrains.buildServer.users.SUser)11 MockVcsSupport (jetbrains.buildServer.serverSide.impl.MockVcsSupport)10 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)9 TestOccurrence (jetbrains.buildServer.server.rest.model.problem.TestOccurrence)7 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)7 TestFor (jetbrains.buildServer.util.TestFor)7 BuildPromotionEx (jetbrains.buildServer.serverSide.BuildPromotionEx)6 TestOccurrences (jetbrains.buildServer.server.rest.model.problem.TestOccurrences)5 RunningBuildEx (jetbrains.buildServer.serverSide.RunningBuildEx)5 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 FakeHttpServletRequest (jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest)4 TestScope (jetbrains.buildServer.server.rest.data.problem.scope.TestScope)4