예제 #1
0
  @Test
  public void shouldCollectOriginErrorsFromMaterialConfigs_InMergedConfig() {
    BasicCruiseConfig mainCruiseConfig = new BasicCruiseConfig(pipelines);
    PartialConfig partialConfig = PartialConfigMother.withPipelineInGroup("pipe2", "g2");
    partialConfig.getGroups().get(0).get(0).setOrigin(new RepoConfigOrigin());
    cruiseConfig = new BasicCruiseConfig(mainCruiseConfig, partialConfig);
    PipelineConfig pipeline1 =
        goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
    PipelineConfig pipeline2 =
        PipelineConfigMother.createPipelineConfigWithStage("pipeline2", "stage");
    pipeline2.setOrigin(new RepoConfigOrigin());
    partialConfig.getGroups().addPipeline("g2", pipeline2);

    goConfigMother.setDependencyOn(cruiseConfig, pipeline1, "pipeline2", "stage");

    List<ConfigErrors> allErrors = cruiseConfig.validateAfterPreprocess();
    assertThat(allErrors.size(), is(1));
    assertNotNull(allErrors.get(0).on("origin"));
  }
예제 #2
0
 @Test
 public void
     shouldGenerateAMapOfAllPipelinesAndTheirParentDependencies_WhenAllPipelinesInMapAreLocal() {
   /*
    *    -----+ p2 --> p4
    *  p1
    *    -----+ p3
    *
    * */
   PipelineConfig p1 = createPipelineConfig("p1", "s1", "j1");
   PipelineConfig p2 = createPipelineConfig("p2", "s2", "j1");
   p2.addMaterialConfig(
       new DependencyMaterialConfig(
           new CaseInsensitiveString("p1"), new CaseInsensitiveString("s1")));
   PipelineConfig p3 = createPipelineConfig("p3", "s3", "j1");
   p3.addMaterialConfig(
       new DependencyMaterialConfig(
           new CaseInsensitiveString("p1"), new CaseInsensitiveString("s1")));
   PipelineConfig p4 = createPipelineConfig("p4", "s4", "j1");
   p4.addMaterialConfig(
       new DependencyMaterialConfig(
           new CaseInsensitiveString("p2"), new CaseInsensitiveString("s2")));
   pipelines.addAll(Arrays.asList(p4, p2, p1, p3));
   Map<String, List<PipelineConfig>> expectedPipelines =
       cruiseConfig.generatePipelineVsDownstreamMap();
   assertThat(expectedPipelines.size(), is(5));
   assertThat(expectedPipelines.get("p1"), hasItems(p2, p3));
   assertThat(expectedPipelines.get("p2"), hasItems(p4));
   assertThat(expectedPipelines.get("p3").isEmpty(), is(true));
   assertThat(expectedPipelines.get("p4").isEmpty(), is(true));
   assertThat(expectedPipelines.get("remote-pipe-1").isEmpty(), is(true));
 }
예제 #3
0
  @Test
  public void
      shouldGenerateAMapOfAllPipelinesAndTheirParentDependencies_WhenThereAreRemotePipelinesInMap() {
    /*
     *    -----+ p2 --> p4
     *  p1
     *    -----+ p3 --> remote-pipe-1
     *
     * */
    PipelineConfig p1 = createPipelineConfig("p1", "s1", "j1");
    PipelineConfig p2 = createPipelineConfig("p2", "s2", "j1");
    p2.addMaterialConfig(
        new DependencyMaterialConfig(
            new CaseInsensitiveString("p1"), new CaseInsensitiveString("s1")));
    PipelineConfig p3 = createPipelineConfig("p3", "s3", "j1");
    p3.addMaterialConfig(
        new DependencyMaterialConfig(
            new CaseInsensitiveString("p1"), new CaseInsensitiveString("s1")));
    PipelineConfig p4 = createPipelineConfig("p4", "s4", "j1");
    p4.addMaterialConfig(
        new DependencyMaterialConfig(
            new CaseInsensitiveString("p2"), new CaseInsensitiveString("s2")));
    pipelines.addAll(Arrays.asList(p4, p2, p1, p3));

    PipelineConfig remotePipe1 = createPipelineConfig("remote-pipe-1", "s5", "j1");
    remotePipe1.addMaterialConfig(
        new DependencyMaterialConfig(
            new CaseInsensitiveString("p3"), new CaseInsensitiveString("s3")));
    PartialConfig part = new PartialConfig();
    part.getGroups().addPipeline("remoteGroup", remotePipe1);
    cruiseConfig = new BasicCruiseConfig(new BasicCruiseConfig(pipelines), part);
    Map<String, List<PipelineConfig>> expectedPipelines =
        cruiseConfig.generatePipelineVsDownstreamMap();
    assertThat(expectedPipelines.size(), is(5));
    assertThat(expectedPipelines.get("p1"), hasItems(p2, p3));
    assertThat(expectedPipelines.get("p2"), hasItems(p4));
    assertThat(expectedPipelines.get("p3"), hasItems(remotePipe1));
    assertThat(expectedPipelines.get("remote-pipe-1").isEmpty(), is(true));
    assertThat(expectedPipelines.get("p4").isEmpty(), is(true));
  }