use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldCacheModificationCountsForMaterialCorrectly.
@Test
public void shouldCacheModificationCountsForMaterialCorrectly() throws Exception {
ScmMaterial material = material();
MaterialInstance materialInstance = material.createMaterialInstance();
repo.saveOrUpdate(materialInstance);
saveOneScmModification("1", material, "user1", "1.txt", "comment1");
saveOneScmModification("2", material, "user2", "2.txt", "comment2");
saveOneScmModification("3", material, "user3", "3.txt", "comment3");
saveOneScmModification("4", material, "user4", "4.txt", "comment4");
saveOneScmModification("5", material, "user5", "5.txt", "comment5");
Long totalCount = repo.getTotalModificationsFor(materialInstance);
assertThat(totalCount, is(5L));
}
use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class ValueStreamMapPerformanceTest method shouldTestVSMForMeshInUpstreamAndDownstream.
@Test(timeout = 240000)
@RunIf(value = DatabaseChecker.class, arguments = { DatabaseChecker.H2 })
public void shouldTestVSMForMeshInUpstreamAndDownstream() throws Exception {
int numberOfNodesPerLevel = 5;
int numberOfLevels = 5;
int numberOfInstancesForUpstream = 1;
int numberOfInstancesForDownstream = 10;
ScmMaterial svn = u.wf((ScmMaterial) MaterialsMother.defaultMaterials().get(0), "folder1");
String[] svn_revs = { "svn_1" };
u.checkinInOrder(svn, svn_revs);
PipelineConfig upstreamConfig = graphGenerator.createPipelineWithInstances("upstream", new ArrayList<>(), 1);
PipelineConfig currentConfig = graphGenerator.createMesh(upstreamConfig, "current", "up", numberOfInstancesForUpstream, numberOfNodesPerLevel, numberOfLevels);
graphGenerator.createMesh(currentConfig, "downstream", "down", numberOfInstancesForDownstream, numberOfNodesPerLevel, numberOfLevels);
long start = System.currentTimeMillis();
DefaultLocalizedOperationResult result = new DefaultLocalizedOperationResult();
ValueStreamMapPresentationModel presentationModel = valueStreamMapService.getValueStreamMap("current", 1, Username.ANONYMOUS, result);
long timeTaken = (System.currentTimeMillis() - start) / 1000;
assertThat(String.format("VSM took %ds. Should have been generated in 30s.", timeTaken), timeTaken, Matchers.lessThan(30l));
assertThat(result.isSuccessful(), is(true));
assertThat(presentationModel.getNodesAtEachLevel().size(), is(14));
}
use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class MaterialUpdateServiceTest method shouldNotAllowConcurrentUpdatesForAutoUpdateMaterials_updateMaterial.
@Test
public void shouldNotAllowConcurrentUpdatesForAutoUpdateMaterials_updateMaterial() throws Exception {
ScmMaterial material = mock(ScmMaterial.class);
when(material.isAutoUpdate()).thenReturn(true);
MaterialUpdateMessage message = new MaterialUpdateMessage(material, 0);
doNothing().when(queue).post(message);
//prune inprogress queue to have this material in it
assertTrue(service.updateMaterial(material));
// immediately notify another check-in
assertFalse(service.updateMaterial(material));
verify(queue, times(1)).post(message);
verify(material).isAutoUpdate();
}
use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class MaterialUpdateServiceTest method shouldNotAllowConcurrentUpdatesForAutoUpdateConfigMaterials_updateMaterial.
@Test
public void shouldNotAllowConcurrentUpdatesForAutoUpdateConfigMaterials_updateMaterial() throws Exception {
ScmMaterial material = mock(ScmMaterial.class);
when(material.isAutoUpdate()).thenReturn(true);
when(material.getFingerprint()).thenReturn("fingerprint");
when(watchList.hasConfigRepoWithFingerprint("fingerprint")).thenReturn(true);
MaterialUpdateMessage message = new MaterialUpdateMessage(material, 0);
doNothing().when(configQueue).post(message);
//prune inprogress queue to have this material in it
assertTrue(service.updateMaterial(material));
// immediately notify another check-in
assertFalse(service.updateMaterial(material));
verify(configQueue, times(1)).post(message);
verify(material).isAutoUpdate();
}
use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class MaterialUpdateServiceTest method shouldAllowConcurrentUpdatesForNonAutoUpdateMaterials_updateMaterial.
@Test
public void shouldAllowConcurrentUpdatesForNonAutoUpdateMaterials_updateMaterial() throws Exception {
ScmMaterial material = mock(ScmMaterial.class);
when(material.isAutoUpdate()).thenReturn(false);
MaterialUpdateMessage message = new MaterialUpdateMessage(material, 0);
doNothing().when(queue).post(message);
//prune inprogress queue to have this material in it
assertTrue(service.updateMaterial(material));
// immediately notify another check-in
assertTrue(service.updateMaterial(material));
verify(queue, times(2)).post(message);
verify(material).isAutoUpdate();
}
Aggregations