Search in sources :

Example 71 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldPrefer_combinationThatBringsLatestPossibleRevisionsOfMostMaterials_whileComputingCompatibleRevisions.

@Test
public void shouldPrefer_combinationThatBringsLatestPossibleRevisionsOfMostMaterials_whileComputingCompatibleRevisions() throws Exception {
    /**
     *      +------ git ------+
     *      |        |        |
     *      |        |        |
     *      v        v        v
     *      P1      P2       P3
     *      |        |        |
     *      |        |        |
     *      +-----> P4 <------+
     */
    GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
    String[] git_revs = { "g1", "g2", "g3", "g4" };
    int i = 1;
    u.checkinInOrder(git, u.d(i++), git_revs);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(git));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(git));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(git));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(p2), u.m(p1), u.m(p3));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g1");
    String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g2", "g3");
    String p1_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g4");
    String p1_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g2");
    String p1_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g4");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g1");
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g2");
    String p2_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g3");
    String p2_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g4");
    // latest
    String p2_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g2");
    // Does this honour schedule order?
    String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g1");
    String p3_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g2");
    String p3_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g3");
    String p3_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g3");
    String p3_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g4");
    MaterialRevisions given = u.mrs(u.mr(p2, true, p2_5), u.mr(p1, true, p1_5), u.mr(p3, false, p3_5));
    MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_5), u.mr(p1, false, p1_4), u.mr(p3, false, p3_2));
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p4, cruiseConfig, given);
    assertThat(finalRevisions, is(expected));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 72 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldChooseTheRevisionFromSecondInAComplexSituation.

@Test
public void shouldChooseTheRevisionFromSecondInAComplexSituation() throws Exception {
    // hg -> First          git
    // |      \             |
    // |      Third  <- Second
    // |        |      /
    // |        |    /
    // +------> Last
    // 
    HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder1");
    String[] hg_revs = { "h1", "h2" };
    u.checkinInOrder(hg, hg_revs);
    GitMaterial git = u.wf(new GitMaterial("git"), "folder2");
    String[] git_revs = { "g1", "g2" };
    u.checkinInOrder(git, git_revs);
    ScheduleTestUtil.AddedPipeline first = u.saveConfigWith("first", u.m(hg));
    ScheduleTestUtil.AddedPipeline second = u.saveConfigWith("second", u.m(git));
    ScheduleTestUtil.AddedPipeline third = u.saveConfigWith("third", u.m(first), u.m(second));
    ScheduleTestUtil.AddedPipeline last = u.saveConfigWith("last", u.m(hg), u.m(second), u.m(third));
    String first_1 = u.runAndPass(first, "h1");
    String second_1 = u.runAndPass(second, "g1");
    String second_2 = u.runAndPass(second, "g1");
    String second_3 = u.runAndPass(second, "g2");
    String second_4 = u.runAndPass(second, "g2");
    String third_1 = u.runAndPass(third, first_1, second_2);
    String third_2 = u.runAndPass(third, first_1, second_2);
    String third_3 = u.runAndPass(third, first_1, second_2);
    MaterialRevisions given = u.mrs(u.mr(hg, true, hg_revs), u.mr(second, true, second_4), u.mr(third, true, third_3));
    MaterialRevisions expected = u.mrs(u.mr(hg, true, "h1"), u.mr(second, true, second_2), u.mr(third, true, third_3));
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("last"));
    assertThat(finalRevisions, is(expected));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 73 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldResolveTriangleDependency.

/* TRIANGLE TEST BEGIN */
@Test
public void shouldResolveTriangleDependency() throws Exception {
    GitMaterial git = new GitMaterial("git");
    String[] git_revs = { "g1" };
    u.checkinInOrder(git, git_revs);
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(git));
    ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p4));
    ScheduleTestUtil.AddedPipeline p6 = u.saveConfigWith("p6", u.m(p4), u.m(p5));
    String p4_1 = u.runAndPass(p4, "g1");
    String p4_2 = u.runAndPass(p4, "g1");
    String p5_1 = u.runAndPass(p5, p4_2);
    String p4_3 = u.runAndPass(p4, "g1");
    String p4_4 = u.runAndPass(p4, "g1");
    PipelineConfigDependencyGraph graph = new PipelineConfigDependencyGraph(p6.config, new PipelineConfigDependencyGraph(p5.config), new PipelineConfigDependencyGraph(p4.config));
    MaterialRevisions given = u.mrs(u.mr(p4, true, p4_4), u.mr(p5, true, p5_1));
    MaterialRevisions expected = u.mrs(u.mr(p4, true, p4_2), u.mr(p5, true, p5_1));
    assertThat(pipelineService.getRevisionsBasedOnDependencies(graph, given), is(expected));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 74 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class GitMultipleMaterialsTest method shouldIgnoreDestinationFolderWhenCloningMaterialWhenServerSide.

@Test
public void shouldIgnoreDestinationFolderWhenCloningMaterialWhenServerSide() throws Exception {
    GitMaterial material1 = repo.createMaterial("dest1");
    MaterialRevision materialRevision = new MaterialRevision(material1, material1.latestModification(pipelineDir, new TestSubprocessExecutionContext()));
    materialRevision.updateTo(pipelineDir, ProcessOutputStreamConsumer.inMemoryConsumer(), new TestSubprocessExecutionContext(true));
    assertThat(new File(pipelineDir, "dest1").exists(), is(false));
    assertThat(new File(pipelineDir, ".git").exists(), is(true));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) MaterialRevisionsMatchers.containsModifiedFile(com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile) File(java.io.File) Test(org.junit.Test)

Example 75 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class MaterialAgentFactoryTest method shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace.

@Test
public void shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace() throws IOException {
    String agentUuid = "uuid-01783738";
    File workingDirectory = temporaryFolder.newFolder();
    MaterialAgentFactory factory = new MaterialAgentFactory(new ProcessOutputStreamConsumer(new DevNull(), new DevNull()), workingDirectory, new AgentIdentifier("host", "1.1.1.1", agentUuid), packageRepositoryExtension, scmExtension);
    GitMaterial gitMaterial = new GitMaterial("http://foo", "master", "dest_folder");
    MaterialAgent agent = factory.createAgent(new MaterialRevision(gitMaterial));
    assertThat(agent, is(instanceOf(AbstractMaterialAgent.class)));
    SubprocessExecutionContext execCtx = (SubprocessExecutionContext) ReflectionUtil.getField(agent, "execCtx");
    assertThat(execCtx.getProcessNamespace("fingerprint"), is(CachedDigestUtils.sha256Hex(String.format("%s%s%s", "fingerprint", agentUuid, gitMaterial.workingdir(workingDirectory)))));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) DevNull(com.thoughtworks.go.util.command.DevNull) SubprocessExecutionContext(com.thoughtworks.go.config.materials.SubprocessExecutionContext) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) PluggableSCMMaterialAgent(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialAgent) PackageMaterialAgent(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialAgent) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) File(java.io.File) ProcessOutputStreamConsumer(com.thoughtworks.go.util.command.ProcessOutputStreamConsumer) Test(org.junit.Test)

Aggregations

GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)146 Test (org.junit.Test)137 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)70 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)55 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)31 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)20 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)13 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)11 Modification (com.thoughtworks.go.domain.materials.Modification)11 File (java.io.File)11 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)10 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)10 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)10 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)10 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)9 Material (com.thoughtworks.go.domain.materials.Material)8 Materials (com.thoughtworks.go.config.materials.Materials)7