Search in sources :

Example 86 with MaterialRevision

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

the class PipelineHistoryMother method singlePipeline.

public static PipelineInstanceModel singlePipeline(String pipelineName, StageInstanceModels stages, Date modifiedDate) {
    BuildCause manualForced = BuildCause.createManualForced(new MaterialRevisions(new MaterialRevision(MaterialsMother.hgMaterial(), new Modification(modifiedDate, "abc", "MOCK_LABEL-12", null))), Username.ANONYMOUS);
    PipelineInstanceModel model = PipelineInstanceModel.createPipeline(pipelineName, -1, "1", manualForced, stages);
    model.setCounter(1);
    return model;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 87 with MaterialRevision

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

the class AutoBuildCauseTest method shouldFallbackToFanInOffTriangleDependencyBehaviourOnExceptionInFanInOn.

@Test
public void shouldFallbackToFanInOffTriangleDependencyBehaviourOnExceptionInFanInOn() throws Exception {
    PipelineConfigDependencyGraph dependencyGraph = dependencyGraphOfDepthOne(MaterialConfigsMother.hgMaterialConfig());
    String targetPipeline = dependencyGraph.getCurrent().name().toLower();
    MaterialRevisions revisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
    MaterialRevision dependencyRevision = dependencyMaterialRevision("up1", 1, "label", "first", 1, new Date());
    dependencyRevision.markAsChanged();
    revisions.addRevision(dependencyRevision);
    when(goConfigService.upstreamDependencyGraphOf(targetPipeline, cruiseConfig)).thenReturn(dependencyGraph);
    // first time throw exception to check fanin off behavior and server logs. second time return null (no exception) to check that the server health logs are cleared
    when(pipelineService.getRevisionsBasedOnDependencies(eq(revisions), eq(cruiseConfig), eq(dependencyGraph.getCurrent().name()))).thenThrow(new RuntimeException("failed")).thenReturn(null);
    when(systemEnvironment.enforceRevisionCompatibilityWithUpstream()).thenReturn(true);
    when(systemEnvironment.enforceFanInFallbackBehaviour()).thenReturn(true);
    new AutoBuild(goConfigService, pipelineService, targetPipeline, systemEnvironment, materialChecker, serverHealthService).onModifications(revisions, false, null);
    verify(pipelineService, times(1)).getRevisionsBasedOnDependencies(dependencyGraph, revisions);
    assertThat(serverHealthService.getAllLogs().size(), is(1));
    assertThat(serverHealthService.getAllLogs(), hasItem((ServerHealthState.warning("Turning off Fan-In for pipeline: 'current'", "Error occurred during Fan-In resolution for the pipeline.", HealthStateType.general(HealthStateScope.forFanin(targetPipeline))))));
    new AutoBuild(goConfigService, pipelineService, targetPipeline, systemEnvironment, materialChecker, serverHealthService).onModifications(revisions, false, null);
    verify(pipelineService, times(1)).getRevisionsBasedOnDependencies(dependencyGraph, revisions);
    assertThat(serverHealthService.getAllLogs().size(), is(0));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 88 with MaterialRevision

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

the class MaterialCheckerTest method shouldSkipLatestRevisionsForMaterialsThatWereAlreadyChecked.

@Test
public void shouldSkipLatestRevisionsForMaterialsThatWereAlreadyChecked() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    SvnMaterial svnMaterial = new SvnMaterial("svnUrl", null, null, false);
    Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
    Modification dependencyModification = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1[LABEL-1]/stage-name/0");
    Modification svnModification = new Modification("user", "commend", "em@il", new Date(), "1");
    Mockito.when(materialRepository.findLatestModification(svnMaterial)).thenReturn(revisions(dependencyMaterial, svnModification));
    materialChecker.findLatestRevisions(new MaterialRevisions(new MaterialRevision(dependencyMaterial, dependencyModification)), new Materials(dependencyMaterial, svnMaterial));
    Mockito.verify(materialRepository, never()).findLatestModification(dependencyMaterial);
    Mockito.verify(materialRepository).findLatestModification(svnMaterial);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 89 with MaterialRevision

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

the class MaterialCheckerTest method shouldFindSpecificRevisionForDependentPipeline.

@Test
public void shouldFindSpecificRevisionForDependentPipeline() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
    Modification modification = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1/stage-name/0");
    Mockito.when(materialRepository.findModificationWithRevision(dependencyMaterial, "pipeline-name/1/stage-name/0")).thenReturn(modification);
    MaterialRevision actualRevision = materialChecker.findSpecificRevision(dependencyMaterial, "pipeline-name/1/stage-name/0");
    assertThat(actualRevision.getModifications().size(), is(1));
    assertThat(actualRevision.getModification(0).getModifiedTime(), is(passedStage.completedDate()));
    assertThat(actualRevision.getModification(0).getRevision(), is("pipeline-name/1/stage-name/0"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 90 with MaterialRevision

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

the class MaterialCheckerTest method shouldSkipFindingRevisionsSinceForMaterialsThatWereAlreadyChecked.

@Test
public void shouldSkipFindingRevisionsSinceForMaterialsThatWereAlreadyChecked() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    SvnMaterial svnMaterial = new SvnMaterial("svnUrl", null, null, false);
    Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
    MaterialRevision previousDependantRevision = new MaterialRevision(dependencyMaterial, new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1[LABEL-1]/stage-name/0"));
    Modification dependencyModification = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/2[LABEL-2]/stage-name/0");
    MaterialRevision previousSvnRevision = new MaterialRevision(svnMaterial, mod(1L));
    Modification svnModification = new Modification("user", "commend", "em@il", new Date(), "2");
    Mockito.when(materialRepository.findModificationsSince(svnMaterial, previousSvnRevision)).thenReturn(modifications(svnModification));
    MaterialRevisions alreadyFoundRevisions = new MaterialRevisions(new MaterialRevision(dependencyMaterial, dependencyModification));
    // will not be used, as no new materials have appeared
    MaterialRevisions latestRevisions = new MaterialRevisions();
    MaterialRevisions revisionsSince = materialChecker.findRevisionsSince(alreadyFoundRevisions, new Materials(dependencyMaterial, svnMaterial), new MaterialRevisions(previousDependantRevision, previousSvnRevision), latestRevisions);
    assertThat(revisionsSince, is(new MaterialRevisions(new MaterialRevision(dependencyMaterial, dependencyModification), new MaterialRevision(svnMaterial, svnModification))));
    Mockito.verify(materialRepository, never()).findLatestModification(dependencyMaterial);
    Mockito.verify(materialRepository).findModificationsSince(svnMaterial, previousSvnRevision);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Aggregations

MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)185 Test (org.junit.Test)141 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)72 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)68 Modification (com.thoughtworks.go.domain.materials.Modification)65 Date (java.util.Date)50 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)31 Pipeline (com.thoughtworks.go.domain.Pipeline)29 Username (com.thoughtworks.go.server.domain.Username)27 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)21 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)21 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)20 PipelineDependencyNode (com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode)18 SCMDependencyNode (com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode)18 ValueStreamMap (com.thoughtworks.go.domain.valuestreammap.ValueStreamMap)18 File (java.io.File)17 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)16 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)16 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)16