Search in sources :

Example 6 with PluggableArtifactConfig

use of com.thoughtworks.go.config.PluggableArtifactConfig in project gocd by gocd.

the class ArtifactPlanTest method shouldConvertPluggableArtifactConfigToArtifactPlans.

@Test
public void shouldConvertPluggableArtifactConfigToArtifactPlans() {
    final PluggableArtifactConfig artifactConfig = new PluggableArtifactConfig("ID", "StoreID", create("Foo", true, "Bar"), create("Baz", false, "Car"));
    final ArtifactPlan artifactPlan = new ArtifactPlan(artifactConfig);
    assertThat(artifactPlan.getArtifactType(), is(ArtifactType.plugin));
    assertThat(artifactPlan.getPluggableArtifactConfiguration().size(), is(3));
    assertThat(artifactPlan.getPluggableArtifactConfiguration(), hasEntry("id", "ID"));
    assertThat(artifactPlan.getPluggableArtifactConfiguration(), hasEntry("storeId", "StoreID"));
    final Map<String, String> configuration = (Map<String, String>) artifactPlan.getPluggableArtifactConfiguration().get("configuration");
    assertThat(configuration.size(), is(2));
    assertThat(configuration, hasEntry("Foo", "Bar"));
    assertThat(configuration, hasEntry("Baz", "Car"));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) Map(java.util.Map) Test(org.junit.Test)

Example 7 with PluggableArtifactConfig

use of com.thoughtworks.go.config.PluggableArtifactConfig in project gocd by gocd.

the class ArtifactsPublisherTest method shouldErrorOutWhenFailedToCreateFolderToWritePluggableArtifactMetadata.

@Test
public void shouldErrorOutWhenFailedToCreateFolderToWritePluggableArtifactMetadata() {
    assumeFalse("Do not run on windows.", IS_WINDOWS);
    final ArtifactStore artifactStore = new ArtifactStore("s3", "cd.go.s3", create("Foo", false, "Bar"));
    final ArtifactStores artifactStores = new ArtifactStores(artifactStore);
    final ArtifactPlan artifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString())).thenReturn(new PublishArtifactResponse(Collections.singletonMap("Foo", "Bar")));
    thrown.expect(RuntimeException.class);
    thrown.expectMessage("[go] Could not create pluggable artifact metadata folder");
    workingFolder.setWritable(false);
    new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(artifactPlan));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) PublishArtifactResponse(com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse) Test(org.junit.Test)

Example 8 with PluggableArtifactConfig

use of com.thoughtworks.go.config.PluggableArtifactConfig in project gocd by gocd.

the class ArtifactsPublisherTest method shouldNotUploadMetadataFileWhenPublishPluggableArtifactIsUnsuccessful.

@Test
public void shouldNotUploadMetadataFileWhenPublishPluggableArtifactIsUnsuccessful() {
    final ArtifactStore artifactStore = new ArtifactStore("s3", "cd.go.s3", create("Foo", false, "Bar"));
    final ArtifactStores artifactStores = new ArtifactStores(artifactStore);
    final ArtifactPlan artifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString())).thenThrow(new RuntimeException("something"));
    try {
        new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(artifactPlan));
        fail("Should throw error for pluggable artifact [installers].");
    } catch (Exception e) {
        assertThat(publisher.publishedFiles().size(), is(0));
        assertThat(e.getMessage(), containsString("[go] Uploading finished. Failed to upload [installers]."));
    }
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) ExpectedException(org.junit.rules.ExpectedException) IOException(java.io.IOException) Test(org.junit.Test)

Example 9 with PluggableArtifactConfig

use of com.thoughtworks.go.config.PluggableArtifactConfig in project gocd by gocd.

the class ArtifactsPublisherTest method shouldPublishPluggableArtifactsAndUploadMetadataFileToServer.

@Test
public void shouldPublishPluggableArtifactsAndUploadMetadataFileToServer() throws IOException {
    final ArtifactStore s3ArtifactStore = new ArtifactStore("s3", "cd.go.s3", create("access_key", false, "some-key"));
    final ArtifactStore dockerArtifactStore = new ArtifactStore("docker", "cd.go.docker", create("registry-url", false, "docker.io"));
    final ArtifactStores artifactStores = new ArtifactStores(s3ArtifactStore, dockerArtifactStore);
    final ArtifactPlan s3ArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
    final ArtifactPlan dockerArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("test-reports", "docker", create("junit", false, "junit.xml")));
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(s3ArtifactPlan), eq(s3ArtifactStore), anyString())).thenReturn(new PublishArtifactResponse(Collections.singletonMap("src", "s3://dist")));
    when(artifactExtension.publishArtifact(eq("cd.go.docker"), eq(dockerArtifactPlan), eq(dockerArtifactStore), anyString())).thenReturn(new PublishArtifactResponse(Collections.singletonMap("image", "alpine")));
    new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(s3ArtifactPlan, dockerArtifactPlan));
    assertThat(uploadedPluggableMetadataFiles(publisher.publishedFiles()), containsInAnyOrder("cd.go.s3.json", "cd.go.docker.json"));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) PublishArtifactResponse(com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse) Test(org.junit.Test)

Example 10 with PluggableArtifactConfig

use of com.thoughtworks.go.config.PluggableArtifactConfig in project gocd by gocd.

the class ArtifactsPublisherTest method shouldRegisterAndDeRegisterArtifactRequestProcessBeforeAndAfterPublishingPluggableArtifact.

@Test
public void shouldRegisterAndDeRegisterArtifactRequestProcessBeforeAndAfterPublishingPluggableArtifact() {
    final ArtifactStore s3ArtifactStore = new ArtifactStore("s3", "cd.go.s3", create("access_key", false, "some-key"));
    final ArtifactStores artifactStores = new ArtifactStores(s3ArtifactStore);
    final ArtifactPlan s3ArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(s3ArtifactPlan), eq(s3ArtifactStore), anyString())).thenReturn(new PublishArtifactResponse(Collections.singletonMap("src", "s3://dist")));
    new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(s3ArtifactPlan));
    InOrder inOrder = inOrder(registry, artifactExtension);
    inOrder.verify(registry, times(1)).registerProcessorFor(eq(CONSOLE_LOG.requestName()), any(ArtifactRequestProcessor.class));
    inOrder.verify(artifactExtension, times(1)).publishArtifact("cd.go.s3", s3ArtifactPlan, s3ArtifactStore, workingFolder.getAbsolutePath());
    inOrder.verify(registry, times(1)).removeProcessorFor(CONSOLE_LOG.requestName());
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) InOrder(org.mockito.InOrder) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) PublishArtifactResponse(com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse) Test(org.junit.Test)

Aggregations

PluggableArtifactConfig (com.thoughtworks.go.config.PluggableArtifactConfig)14 Test (org.junit.Test)14 ArtifactStore (com.thoughtworks.go.config.ArtifactStore)8 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)7 PublishArtifactResponse (com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse)6 ArtifactConfigs (com.thoughtworks.go.config.ArtifactConfigs)5 ArtifactConfig (com.thoughtworks.go.config.ArtifactConfig)3 TestArtifactConfig (com.thoughtworks.go.config.TestArtifactConfig)3 GoPublisher (com.thoughtworks.go.work.GoPublisher)2 IOException (java.io.IOException)2 ExpectedException (org.junit.rules.ExpectedException)2 InOrder (org.mockito.InOrder)2 ArtifactPlan (com.thoughtworks.go.domain.ArtifactPlan)1 Map (java.util.Map)1