Search in sources :

Example 1 with ScmMaterial

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));
}
Also used : ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) PackageMaterialInstance(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialInstance) PluggableSCMMaterialInstance(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance) SvnMaterialInstance(com.thoughtworks.go.domain.materials.svn.SvnMaterialInstance) Test(org.junit.Test)

Example 2 with ScmMaterial

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));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) DefaultLocalizedOperationResult(com.thoughtworks.go.server.service.result.DefaultLocalizedOperationResult) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Example 3 with ScmMaterial

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();
}
Also used : MaterialUpdateMessageMatcher.matchMaterialUpdateMessage(com.thoughtworks.go.helper.MaterialUpdateMessageMatcher.matchMaterialUpdateMessage) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Test(org.junit.Test)

Example 4 with ScmMaterial

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();
}
Also used : MaterialUpdateMessageMatcher.matchMaterialUpdateMessage(com.thoughtworks.go.helper.MaterialUpdateMessageMatcher.matchMaterialUpdateMessage) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Test(org.junit.Test)

Example 5 with ScmMaterial

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();
}
Also used : MaterialUpdateMessageMatcher.matchMaterialUpdateMessage(com.thoughtworks.go.helper.MaterialUpdateMessageMatcher.matchMaterialUpdateMessage) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Test(org.junit.Test)

Aggregations

ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)26 Test (org.junit.Test)24 Modification (com.thoughtworks.go.domain.materials.Modification)6 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)5 MaterialUpdateMessageMatcher.matchMaterialUpdateMessage (com.thoughtworks.go.helper.MaterialUpdateMessageMatcher.matchMaterialUpdateMessage)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 PackageMaterialInstance (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialInstance)4 PluggableSCMMaterialInstance (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance)4 SvnMaterialInstance (com.thoughtworks.go.domain.materials.svn.SvnMaterialInstance)4 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)3 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 RunIf (com.googlecode.junit.ext.RunIf)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)2 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)2 PipelineLabel (com.thoughtworks.go.domain.label.PipelineLabel)2 Material (com.thoughtworks.go.domain.materials.Material)2 TransactionStatus (org.springframework.transaction.TransactionStatus)2 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)2