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;
}
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));
}
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);
}
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"));
}
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);
}
Aggregations