Search in sources :

Example 16 with StageInstanceModels

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

the class PipelineHistoryItemMother method custom.

public static PipelineInstanceModel custom(StageInstanceModel... stages) {
    PipelineInstanceModel pipelineInstanceModel = PipelineInstanceModel.createEmptyModel();
    pipelineInstanceModel.setStageHistory(new StageInstanceModels());
    for (StageInstanceModel stage : stages) {
        pipelineInstanceModel.getStageHistory().add(stage);
    }
    return pipelineInstanceModel;
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)

Example 17 with StageInstanceModels

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

the class StageSqlMapDao method findDetailedStageHistory.

StageInstanceModels findDetailedStageHistory(String pipelineName, String stageName, Pagination pagination) {
    Map<String, Object> args = arguments("pipelineName", pipelineName).and("stageName", stageName).and("limit", pagination.getPageSize()).and("offset", pagination.getOffset()).asMap();
    List<StageInstanceModel> detailedStageHistory = (List<StageInstanceModel>) getSqlMapClientTemplate().queryForList("getDetailedStageHistory", args);
    StageInstanceModels stageInstanceModels = new StageInstanceModels();
    stageInstanceModels.addAll(detailedStageHistory);
    return stageInstanceModels;
}
Also used : StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) ArrayList(java.util.ArrayList) List(java.util.List) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)

Example 18 with StageInstanceModels

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

the class StageSqlMapDao method findDetailedStageHistoryByOffset.

public StageInstanceModels findDetailedStageHistoryByOffset(String pipelineName, String stageName, final Pagination pagination) {
    String mutex = mutexForStageHistory(pipelineName, stageName);
    readWriteLock.acquireReadLock(mutex);
    try {
        String subKey = String.format("%s-%s", pagination.getOffset(), pagination.getPageSize());
        String key = cacheKeyForDetailedStageHistories(pipelineName, stageName);
        StageInstanceModels stageInstanceModels = (StageInstanceModels) goCache.get(key, subKey);
        if (stageInstanceModels == null) {
            stageInstanceModels = findDetailedStageHistory(pipelineName, stageName, pagination);
            goCache.put(key, subKey, stageInstanceModels);
        }
        return cloner.deepClone(stageInstanceModels);
    } finally {
        readWriteLock.releaseReadLock(mutex);
    }
}
Also used : StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 19 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(), is(2));
    assertThat(stageInstanceModels.get(0).getResult(), is(StageResult.Passed));
    assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineName(), is(pipelineName));
    assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineCounter(), is(3));
    assertThat(stageInstanceModels.get(0).getIdentifier().getStageName(), is(stageName));
    assertThat(stageInstanceModels.get(0).getIdentifier().getStageCounter(), is("1"));
    assertJobDetails(stageInstanceModels.get(0).getBuildHistory());
    assertThat(stageInstanceModels.get(1).getResult(), is(StageResult.Passed));
    assertThat(stageInstanceModels.get(1).getIdentifier().getPipelineName(), is(pipelineName));
    assertThat(stageInstanceModels.get(1).getIdentifier().getPipelineCounter(), is(2));
    assertThat(stageInstanceModels.get(1).getIdentifier().getStageName(), is(stageName));
    assertThat(stageInstanceModels.get(1).getIdentifier().getStageCounter(), is("1"));
    assertJobDetails(stageInstanceModels.get(1).getBuildHistory());
    pagination = Pagination.pageStartingAt(2, 3, 2);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertThat(stageInstanceModels.size(), is(1));
    assertThat(stageInstanceModels.get(0).getResult(), is(StageResult.Passed));
    assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineName(), is(pipelineName));
    assertThat(stageInstanceModels.get(0).getIdentifier().getPipelineCounter(), is(1));
    assertThat(stageInstanceModels.get(0).getIdentifier().getStageName(), is(stageName));
    assertThat(stageInstanceModels.get(0).getIdentifier().getStageCounter(), is("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.Test)

Example 20 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("Expected no models. Found: " + stageInstanceModels, stageInstanceModels.size(), is(0));
    pagination = Pagination.pageStartingAt(20, 7, 3);
    stageInstanceModels = stageDao.findDetailedStageHistoryByOffset(pipelineName, stageName, pagination);
    assertThat("Expected no models. Found: " + stageInstanceModels, stageInstanceModels.size(), is(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.Test)

Aggregations

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