Search in sources :

Example 76 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class PipelineServiceTriangleDependencyTest method shouldGetTheRevisionsForDependencyMaterialFromUpStreamPipeline.

@Test
public void shouldGetTheRevisionsForDependencyMaterialFromUpStreamPipeline() throws Exception {
    Date modifiedTime = new Date();
    MaterialRevisions expected = new MaterialRevisions();
    expected.addRevision(dependencyMaterialRevision("up1", 1, "label", "stage", 1, modifiedTime));
    expected.addRevision(dependencyMaterialRevision("common", 3, "label", "first", 1, modifiedTime));
    MaterialRevisions actual = new MaterialRevisions();
    actual.addRevision(changedDependencyMaterialRevision("up1", 1, "label", "stage", 1, modifiedTime));
    actual.addRevision(dependencyMaterialRevision("common", 4, "label", "first", 1, modifiedTime));
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", new DependencyMaterialConfig(new CaseInsensitiveString("common"), new CaseInsensitiveString("first")), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")));
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", new DependencyMaterialConfig(new CaseInsensitiveString("common"), new CaseInsensitiveString("first")));
    PipelineConfig common = createPipelineConfigWithMaterialConfig("common", MaterialConfigsMother.hgMaterialConfig());
    Pipeline pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
    pipeline.setId(10);
    when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(pipeline);
    MaterialRevisions upStreamPipelinesRevisions = new MaterialRevisions();
    upStreamPipelinesRevisions.addRevision(dependencyMaterialRevision("common", 3, "label", "first", 1, modifiedTime));
    when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(upStreamPipelinesRevisions);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1, new PipelineConfigDependencyGraph(common)));
    MaterialRevisions finalRevisions = service.getRevisionsBasedOnDependencies(dependencyGraph, actual);
    assertThat(finalRevisions, is(expected));
    for (int i = 0; i < expected.numberOfRevisions(); i++) {
        assertTrue(finalRevisions.getMaterialRevision(i) == actual.getMaterialRevision(i));
    }
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 77 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class PipelineServiceTriangleDependencyTest method stubPipelineSaveForStatusListener.

private Pipeline stubPipelineSaveForStatusListener(StageStatusListener stageStatusListener, JobStatusListener jobStatusListener) {
    StageDao stageDao = mock(StageDao.class);
    ServerHealthService serverHealthService = mock(ServerHealthService.class);
    when(serverHealthService.logs()).thenReturn(new ServerHealthStates());
    JobInstanceService jobInstanceService = new JobInstanceService(mock(JobInstanceDao.class), mock(PropertiesService.class), mock(JobResultTopic.class), mock(JobStatusCache.class), actualTransactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService, jobStatusListener);
    StageService stageService = new StageService(stageDao, jobInstanceService, mock(StageStatusTopic.class), mock(StageStatusCache.class), mock(SecurityService.class), mock(PipelineDao.class), mock(ChangesetService.class), mock(GoConfigService.class), actualTransactionTemplate, transactionSynchronizationManager, goCache);
    Stage savedStage = StageMother.passedStageInstance("stage", "job", "pipeline-name");
    when(stageDao.save(any(Pipeline.class), any(Stage.class))).thenReturn(savedStage);
    stageService.addStageStatusListener(stageStatusListener);
    service = new PipelineService(pipelineDao, stageService, mock(PipelineLockService.class), pipelineTimeline, materialRepository, actualTransactionTemplate, systemEnvironment, null, materialConfigConverter);
    Pipeline pipeline = PipelineMother.pipeline("cruise", savedStage);
    when(pipelineDao.save(pipeline)).thenReturn(pipeline);
    when(pipelineTimeline.pipelineBefore(anyLong())).thenReturn(9L);
    when(pipelineTimeline.pipelineAfter(pipeline.getId())).thenReturn(-1L);
    when(materialRepository.findMaterialRevisionsForPipeline(9L)).thenReturn(MaterialRevisions.EMPTY);
    return pipeline;
}
Also used : StageDao(com.thoughtworks.go.server.dao.StageDao) JobResultTopic(com.thoughtworks.go.server.messaging.JobResultTopic) StageStatusTopic(com.thoughtworks.go.server.messaging.StageStatusTopic) ServerHealthStates(com.thoughtworks.go.serverhealth.ServerHealthStates) JobInstanceDao(com.thoughtworks.go.server.dao.JobInstanceDao) Pipeline(com.thoughtworks.go.domain.Pipeline) StageStatusCache(com.thoughtworks.go.domain.activity.StageStatusCache) JobStatusCache(com.thoughtworks.go.domain.activity.JobStatusCache) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) PipelineDao(com.thoughtworks.go.server.dao.PipelineDao) Stage(com.thoughtworks.go.domain.Stage)

Example 78 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class PipelineServiceTriangleDependencyTest method shouldGetTheRevisionsFromTheUpStreamPipelineFor2SameMaterial.

@Test
public void shouldGetTheRevisionsFromTheUpStreamPipelineFor2SameMaterial() throws Exception {
    MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
    up1Revision.markAsChanged();
    MaterialRevisions expected = new MaterialRevisions();
    expected.addRevision(up1Revision);
    expected.addAll(createHgMaterialWithMultipleRevisions(1L, first));
    expected.addAll(createSvnMaterialWithMultipleRevisions(2L, first));
    MaterialRevisions actual = new MaterialRevisions();
    actual.addRevision(up1Revision);
    actual.addAll(createHgMaterialWithMultipleRevisions(1L, third));
    actual.addAll(createSvnMaterialWithMultipleRevisions(2L, third));
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
    Pipeline pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
    pipeline.setId(10);
    when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(pipeline);
    when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(expected);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1));
    assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(expected));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ModificationsMother.dependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision) ModificationsMother.changedDependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 79 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class PropertiesServiceTest method shouldReturnEmptyListIfLimitCountIsNotPositive.

@Test
public void shouldReturnEmptyListIfLimitCountIsNotPositive() {
    Pipeline pipeline1 = createNewPipeline();
    Pipeline pipeline2 = createNewPipeline();
    List<Properties> propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), -1);
    assertThat(propertiesList.size(), is(0));
    propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), 0);
    assertThat(propertiesList.size(), is(0));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 80 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class PropertiesServiceTest method shouldLoadHistoryUptoSpecifiedPipeline.

@Test
public void shouldLoadHistoryUptoSpecifiedPipeline() {
    Pipeline pipeline1 = createNewPipeline();
    Pipeline pipeline2 = createNewPipeline();
    List<Properties> propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), 1);
    assertThat(propertiesList.size(), is(1));
    assertThat(propertiesList.get(0).getValue("cruise_pipeline_counter"), is(String.valueOf(pipeline2.getCounter())));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

Pipeline (com.thoughtworks.go.domain.Pipeline)184 Test (org.junit.Test)122 Stage (com.thoughtworks.go.domain.Stage)33 Username (com.thoughtworks.go.server.domain.Username)30 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)29 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)24 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)24 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)21 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)20 JobInstance (com.thoughtworks.go.domain.JobInstance)19 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)13 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)13 Modification (com.thoughtworks.go.domain.materials.Modification)13 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)13 Date (java.util.Date)13 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)11 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)10 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)8 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)7 PipelineState (com.thoughtworks.go.domain.PipelineState)6