Search in sources :

Example 96 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class AutoBuildCauseTest method shouldReturnPeggedRevisionsForUpstreamMaterialWhenFirstOrderDependencyMaterialIsChanged.

@Test
public void shouldReturnPeggedRevisionsForUpstreamMaterialWhenFirstOrderDependencyMaterialIsChanged() throws Exception {
    HgMaterialConfig hg = MaterialConfigsMother.hgMaterialConfig();
    PipelineConfig third = PipelineConfigMother.pipelineConfig("third", MaterialConfigsMother.dependencyMaterialConfig("second", "mingle"), new JobConfigs());
    PipelineConfig second = PipelineConfigMother.pipelineConfig("second", MaterialConfigsMother.dependencyMaterialConfig("first", "mingle"), new JobConfigs());
    PipelineConfig first = PipelineConfigMother.pipelineConfig("first", hg, new JobConfigs());
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(third, new PipelineConfigDependencyGraph(second, new PipelineConfigDependencyGraph(first)), new PipelineConfigDependencyGraph(first));
    MaterialRevisions revisions = new MaterialRevisions();
    MaterialRevision firstRev = dependencyMaterialRevision("first", 10, "label", "mingle", 1, new Date());
    firstRev.markAsNotChanged();
    MaterialRevision secondRev = dependencyMaterialRevision("second", 1, "label", "mingle", 1, new Date());
    secondRev.markAsChanged();
    revisions.addRevision(secondRev);
    revisions.addRevision(firstRev);
    when(goConfigService.upstreamDependencyGraphOf("third", cruiseConfig)).thenReturn(dependencyGraph);
    MaterialRevisions expectedRevisions = new MaterialRevisions();
    when(pipelineService.getRevisionsBasedOnDependencies(eq(revisions), eq(cruiseConfig), eq(dependencyGraph.getCurrent().name()))).thenReturn(expectedRevisions);
    assertThat(new AutoBuild(goConfigService, pipelineService, "third", new SystemEnvironment(), materialChecker, serverHealthService).onModifications(revisions, false, null).getMaterialRevisions(), sameInstance(expectedRevisions));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 97 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class AutoBuildCauseTest method shouldReturnCorrectRevisionsIfFirstOrderMaterialIsChanged.

@Test
public void shouldReturnCorrectRevisionsIfFirstOrderMaterialIsChanged() throws Exception {
    PipelineConfigDependencyGraph dependencyGraph = dependencyGraphOfDepthOne(MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
    String targetPipeline = dependencyGraph.getCurrent().name().toLower();
    MaterialRevisions revisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
    MaterialRevisions firstOrderRevision = createSvnMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
    MaterialRevision dependencyRevision = dependencyMaterialRevision("upstream", 1, "label", "first", 1, new Date());
    revisions.addAll(firstOrderRevision);
    revisions.addRevision(dependencyRevision);
    dependencyRevision.markAsNotChanged();
    firstOrderRevision.getMaterialRevision(0).markAsChanged();
    revisions.getMaterialRevision(0).markAsChanged();
    MaterialRevisions expectedRevisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("1"));
    expectedRevisions.addRevision(dependencyRevision);
    when(goConfigService.upstreamDependencyGraphOf(targetPipeline, cruiseConfig)).thenReturn(dependencyGraph);
    when(pipelineService.getRevisionsBasedOnDependencies(eq(revisions), eq(cruiseConfig), eq(dependencyGraph.getCurrent().name()))).thenReturn(expectedRevisions);
    assertThat(new AutoBuild(goConfigService, pipelineService, targetPipeline, new SystemEnvironment(), materialChecker, serverHealthService).onModifications(revisions, false, null).getMaterialRevisions(), is(expectedRevisions));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) 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 98 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class AutoBuildCauseTest method shouldUpdateRecomputedMaterialRevisionsChangedStatus.

@Test
public void shouldUpdateRecomputedMaterialRevisionsChangedStatus() throws Exception {
    PipelineConfigDependencyGraph dependencyGraph = dependencyGraphOfDepthOne(MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
    String targetPipeline = dependencyGraph.getCurrent().name().toLower();
    MaterialRevisions revisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"), oneModifiedFile("1"));
    MaterialRevisions revisionsForMaterial2 = multipleRevisions(MaterialsMother.svnMaterial(), 10, oneModifiedFile("svn2"));
    MaterialRevision dependencyRevision = dependencyMaterialRevision("upstream", 1, "label", "first", 1, new Date());
    revisions.addRevision(dependencyRevision);
    revisions.addAll(revisionsForMaterial2);
    for (MaterialRevision revision : revisions) {
        revision.markAsChanged();
    }
    MaterialRevisions expectedRevisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("1"));
    expectedRevisions.getMaterialRevision(0).markAsChanged();
    MaterialRevisions expectedForMaterial2 = multipleRevisions(MaterialsMother.svnMaterial(), 10, oneModifiedFile("svn1"));
    expectedForMaterial2.getMaterialRevision(0).markAsNotChanged();
    expectedRevisions.addRevision(dependencyRevision);
    expectedRevisions.addAll(expectedForMaterial2);
    when(goConfigService.upstreamDependencyGraphOf(targetPipeline, cruiseConfig)).thenReturn(dependencyGraph);
    when(pipelineService.getRevisionsBasedOnDependencies(eq(revisions), eq(cruiseConfig), eq(dependencyGraph.getCurrent().name()))).thenReturn(expectedRevisions);
    BuildCause buildCause = new AutoBuild(goConfigService, pipelineService, targetPipeline, new SystemEnvironment(), materialChecker, serverHealthService).onModifications(revisions, false, null);
    MaterialRevisions finalRevisions = buildCause.getMaterialRevisions();
    assertThat(finalRevisions.numberOfRevisions(), is(expectedRevisions.numberOfRevisions()));
    for (int i = 0; i < expectedRevisions.numberOfRevisions(); i++) {
        MaterialRevision finalRev = finalRevisions.getMaterialRevision(i);
        MaterialRevision expectedRev = expectedRevisions.getMaterialRevision(i);
        assertThat(finalRev, is(expectedRev));
        assertThat(finalRev.isChanged(), is(expectedRev.isChanged()));
    }
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 99 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class DiskSpaceFullCheckerTest method tearDown.

@After
public void tearDown() throws Exception {
    new SystemEnvironment().clearProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT);
    verifyNoMoreInteractions(sender);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) After(org.junit.After)

Example 100 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class DiskSpaceFullCheckerTest method simulateFullDisk.

private CruiseConfig simulateFullDisk() {
    new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT, "1200009M");
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig(".", new SecurityConfig()));
    return cruiseConfig;
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerConfig(com.thoughtworks.go.config.ServerConfig) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig)

Aggregations

SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)158 Test (org.junit.Test)82 Before (org.junit.Before)38 File (java.io.File)35 AgentInstance (com.thoughtworks.go.domain.AgentInstance)26 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)15 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)14 ArrayList (java.util.ArrayList)12 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)10 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)8 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)8 ZipUtil (com.thoughtworks.go.util.ZipUtil)8 Date (java.util.Date)8 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)7 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)7 AgentConfig (com.thoughtworks.go.config.AgentConfig)6 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)6 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)5