Search in sources :

Example 6 with ArtifactStore

use of com.thoughtworks.go.config.ArtifactStore 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 7 with ArtifactStore

use of com.thoughtworks.go.config.ArtifactStore 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 8 with ArtifactStore

use of com.thoughtworks.go.config.ArtifactStore 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 9 with ArtifactStore

use of com.thoughtworks.go.config.ArtifactStore 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)

Example 10 with ArtifactStore

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

the class FetchPluggableArtifactBuilderTest method setUp.

@Before
public void setUp() throws Exception {
    publisher = mock(DefaultGoPublisher.class);
    artifactExtension = mock(ArtifactExtension.class);
    checksumFileHandler = mock(ChecksumFileHandler.class);
    registry = mock(PluginRequestProcessorRegistry.class);
    metadataDest = new File(temporaryFolder.newFolder("dest"), "cd.go.s3.json");
    FileUtils.writeStringToFile(metadataDest, "{\"artifactId\":{}}", StandardCharsets.UTF_8);
    jobIdentifier = new JobIdentifier("cruise", -10, "1", "dev", "1", "windows", 1L);
    artifactStore = new ArtifactStore("s3", "cd.go.s3", ConfigurationPropertyMother.create("ACCESS_KEY", true, "hksjdfhsksdfh"));
    fetchPluggableArtifactTask = new FetchPluggableArtifactTask(new CaseInsensitiveString("dev"), new CaseInsensitiveString("windows"), "artifactId", ConfigurationPropertyMother.create("Destination", false, "build/"));
    sourceOnServer = format("%s/%s", PLUGGABLE_ARTIFACT_METADATA_FOLDER, "cd.go.s3.json");
    when(checksumFileHandler.handleResult(SC_OK, publisher)).thenReturn(true);
}
Also used : DefaultGoPublisher(com.thoughtworks.go.work.DefaultGoPublisher) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) ArtifactExtension(com.thoughtworks.go.plugin.access.artifact.ArtifactExtension) PluginRequestProcessorRegistry(com.thoughtworks.go.plugin.infra.PluginRequestProcessorRegistry) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) ChecksumFileHandler(com.thoughtworks.go.domain.ChecksumFileHandler) File(java.io.File) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Before(org.junit.Before)

Aggregations

ArtifactStore (com.thoughtworks.go.config.ArtifactStore)13 Test (org.junit.Test)11 PluggableArtifactConfig (com.thoughtworks.go.config.PluggableArtifactConfig)8 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)7 PublishArtifactResponse (com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse)7 FetchPluggableArtifactTask (com.thoughtworks.go.config.FetchPluggableArtifactTask)3 ArtifactPlan (com.thoughtworks.go.domain.ArtifactPlan)3 GoPluginApiRequest (com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)2 GoPublisher (com.thoughtworks.go.work.GoPublisher)2 IOException (java.io.IOException)2 ExpectedException (org.junit.rules.ExpectedException)2 InOrder (org.mockito.InOrder)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 ChecksumFileHandler (com.thoughtworks.go.domain.ChecksumFileHandler)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 ArtifactExtension (com.thoughtworks.go.plugin.access.artifact.ArtifactExtension)1 PluginRequestProcessorRegistry (com.thoughtworks.go.plugin.infra.PluginRequestProcessorRegistry)1 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)1 File (java.io.File)1 HashMap (java.util.HashMap)1