Search in sources :

Example 36 with StageInstanceModels

use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.

the class StageSqlMapDaoIntegrationTest method shouldGetDetailedStageHistory.

@Test
public void shouldGetDetailedStageHistory() throws Exception {
    HgMaterial hg = new HgMaterial("url", null);
    String[] hg_revs = { "h1", "h2", "h3" };
    scheduleUtil.checkinInOrder(hg, hg_revs);
    String pipelineName = "p1";
    String stageName = "stage_name";
    ScheduleTestUtil.AddedPipeline p1 = scheduleUtil.saveConfigWith(pipelineName, stageName, scheduleUtil.m(hg), new String[] { "job1", "job2" });
    scheduleUtil.runAndPass(p1, "h1");
    scheduleUtil.runAndPass(p1, "h2");
    scheduleUtil.runAndPass(p1, "h3");
    Pagination pagination = Pagination.pageStartingAt(0, 3, 2);
    StageInstanceModels stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertThat(stageInstanceModels.size()).isEqualTo(2);
    assertThat(stageInstanceModels.get(0).getResult()).isEqualTo(StageResult.Passed);
    assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineName()).isEqualTo(pipelineName);
    assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineCounter()).isEqualTo(3);
    assertThat(stageInstanceModels.get(0).getIdentifier().getStageName()).isEqualTo(stageName);
    assertThat(stageInstanceModels.get(0).getIdentifier().getStageCounter()).isEqualTo("1");
    assertJobDetails(stageInstanceModels.get(0).getBuildHistory());
    assertThat(stageInstanceModels.get(1).getResult()).isEqualTo(StageResult.Passed);
    assertThat(stageInstanceModels.get(1).getIdentifier().getPipelineName()).isEqualTo(pipelineName);
    assertThat(stageInstanceModels.get(1).getIdentifier().getPipelineCounter()).isEqualTo(2);
    assertThat(stageInstanceModels.get(1).getIdentifier().getStageName()).isEqualTo(stageName);
    assertThat(stageInstanceModels.get(1).getIdentifier().getStageCounter()).isEqualTo("1");
    assertJobDetails(stageInstanceModels.get(1).getBuildHistory());
    pagination = Pagination.pageStartingAt(2, 3, 2);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertThat(stageInstanceModels.size()).isEqualTo(1);
    assertThat(stageInstanceModels.get(0).getResult()).isEqualTo(StageResult.Passed);
    assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineName()).isEqualTo(pipelineName);
    assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineCounter()).isEqualTo(1);
    assertThat(stageInstanceModels.get(0).getIdentifier().getStageName()).isEqualTo(stageName);
    assertThat(stageInstanceModels.get(0).getIdentifier().getStageCounter()).isEqualTo("1");
    assertJobDetails(stageInstanceModels.get(0).getBuildHistory());
}
Also used : Pagination(com.thoughtworks.go.server.util.Pagination) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) Test(org.junit.jupiter.api.Test)

Example 37 with StageInstanceModels

use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.

the class StageSqlMapDaoIntegrationTest method stageHistoryViaCursor_shouldReturnListWithTheRecordsAfterTheSpecifiedCursor.

@Test
public void stageHistoryViaCursor_shouldReturnListWithTheRecordsAfterTheSpecifiedCursor() {
    // older records
    HgMaterial hg = new HgMaterial("url", null);
    String[] hg_revs = { "h1", "h2", "h3" };
    scheduleUtil.checkinInOrder(hg, hg_revs);
    String pipelineName = PIPELINE_NAME + "-" + UUID.randomUUID();
    ScheduleTestUtil.AddedPipeline p1 = scheduleUtil.saveConfigWith(pipelineName, STAGE_DEV, scheduleUtil.m(hg));
    Date date = new Date();
    Pipeline run1 = scheduleUtil.runAndPassAndReturnPipelineInstance(p1, date, "h1");
    Pipeline run2 = scheduleUtil.runAndPassAndReturnPipelineInstance(p1, date, "h2");
    Pipeline run3 = scheduleUtil.runAndPassAndReturnPipelineInstance(p1, date, "h3");
    Pipeline run4 = scheduleUtil.runAndPassAndReturnPipelineInstance(p1, date, "h1", "h2");
    Pipeline run5 = scheduleUtil.runAndPassAndReturnPipelineInstance(p1, date, "h2", "h3");
    StageInstanceModels stageHistory = stageDao.findDetailedStageHistoryViaCursor(pipelineName, STAGE_DEV, FeedModifier.After, run4.getFirstStage().getId(), 3);
    assertThat(stageHistory.size()).isEqualTo(3);
    assertThat(stageHistory.get(0).getId()).isEqualTo(run3.getFirstStage().getId());
    assertThat(stageHistory.get(1).getId()).isEqualTo(run2.getFirstStage().getId());
    assertThat(stageHistory.get(2).getId()).isEqualTo(run1.getFirstStage().getId());
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) Test(org.junit.jupiter.api.Test)

Example 38 with StageInstanceModels

use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.

the class StageSqlMapDaoIntegrationTest method shouldPaginateBasedOnOffset.

@Test
public void shouldPaginateBasedOnOffset() throws Exception {
    HgMaterial hg = new HgMaterial("url", null);
    String[] hg_revs = { "h1", "h2", "h3" };
    scheduleUtil.checkinInOrder(hg, hg_revs);
    String pipelineName = "p1";
    String stageName = "stage_name";
    ScheduleTestUtil.AddedPipeline p1 = scheduleUtil.saveConfigWith(pipelineName, stageName, scheduleUtil.m(hg));
    String run1 = scheduleUtil.runAndPass(p1, "h1");
    String run2 = scheduleUtil.runAndPass(p1, "h2");
    String run3 = scheduleUtil.runAndPass(p1, "h3");
    String run4 = scheduleUtil.runAndPass(p1, "h1", "h2");
    String run5 = scheduleUtil.runAndPass(p1, "h2", "h3");
    String run6 = scheduleUtil.runAndPass(p1, "h3", "h1");
    String run7 = scheduleUtil.runAndPass(p1, "h1", "h2", "h3");
    Pagination pagination = Pagination.pageStartingAt(0, 7, 3);
    StageInstanceModels stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertStageModels(stageInstanceModels, run7, run6, run5);
    pagination = Pagination.pageStartingAt(1, 7, 3);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertStageModels(stageInstanceModels, run6, run5, run4);
    pagination = Pagination.pageStartingAt(2, 7, 3);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertStageModels(stageInstanceModels, run5, run4, run3);
    pagination = Pagination.pageStartingAt(3, 7, 3);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertStageModels(stageInstanceModels, run4, run3, run2);
    pagination = Pagination.pageStartingAt(4, 7, 3);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertStageModels(stageInstanceModels, run3, run2, run1);
    pagination = Pagination.pageStartingAt(5, 7, 3);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertStageModels(stageInstanceModels, run2, run1);
    pagination = Pagination.pageStartingAt(6, 7, 3);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertStageModels(stageInstanceModels, run1);
    pagination = Pagination.pageStartingAt(7, 7, 3);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertThat(stageInstanceModels.size()).as("Expected no models. Found: " + stageInstanceModels).isEqualTo(0);
    pagination = Pagination.pageStartingAt(20, 7, 3);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertThat(stageInstanceModels.size()).as("Expected no models. Found: " + stageInstanceModels).isEqualTo(0);
    pagination = Pagination.pageStartingAt(1, 7, 4);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertStageModels(stageInstanceModels, run6, run5, run4, run3);
}
Also used : Pagination(com.thoughtworks.go.server.util.Pagination) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) Test(org.junit.jupiter.api.Test)

Example 39 with StageInstanceModels

use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldLoadPipelineHistories.

@Test
public void shouldLoadPipelineHistories() throws Exception {
    String dev = "dev";
    PipelineConfig mingleConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", dev);
    Pipeline mingle = schedulePipelineWithStages(mingleConfig);
    Stage firstStage = mingle.getFirstStage();
    Pipeline mingle2 = schedulePipelineWithStages(mingleConfig);
    JobInstance instance = firstStage.getJobInstances().first();
    jobInstanceDao.ignore(instance);
    PipelineInstanceModels pipelineHistories = pipelineDao.loadHistory(mingle.getName(), 10, 0);
    assertThat(pipelineHistories.size(), is(2));
    StageInstanceModels stageHistories = pipelineHistories.first().getStageHistory();
    assertThat(stageHistories.size(), is(1));
    StageInstanceModel history = stageHistories.first();
    assertThat(history.getName(), is(dev));
    assertThat(history.getApprovalType(), is(GoConstants.APPROVAL_SUCCESS));
    assertThat(history.getBuildHistory().size(), is(2));
    assertThat(pipelineHistories.get(1).getName(), is("mingle"));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel) Test(org.junit.jupiter.api.Test)

Example 40 with StageInstanceModels

use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.

the class StageServiceIntegrationTest method shouldReturnThePipelineHistoryBeforeTheSpecifiedCursor.

@Test
public void shouldReturnThePipelineHistoryBeforeTheSpecifiedCursor() {
    StageHistoryEntry[] stages = createFiveStages();
    StageInstanceModels history = stageService.findStageHistoryViaCursor(new Username(new CaseInsensitiveString("admin1")), savedPipeline.getName(), savedPipeline.getFirstStage().getName(), 0, stages[2].getId(), 10);
    assertThat(history.size(), is(2));
    assertThat(history.get(0).getId(), is(stages[4].getId()));
    assertThat(history.get(1).getId(), is(stages[3].getId()));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageHistoryEntry(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry) Test(org.junit.jupiter.api.Test)

Aggregations

StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)41 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)14 Test (org.junit.Test)14 Test (org.junit.jupiter.api.Test)14 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)13 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)8 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)7 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)6 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)6 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)6 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)5 Username (com.thoughtworks.go.server.domain.Username)4 Pagination (com.thoughtworks.go.server.util.Pagination)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)3 StageHistoryEntry (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)2 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)2 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)2