Skip to content
Permalink
Browse files

Merge branch 'master' into JENKINS-50591

  • Loading branch information...
carlossg committed Apr 6, 2018
2 parents dd963e3 + fb9698c commit 4392c8caa313e01b197a7abbc76cc428bb4eb921
26 pom.xml
@@ -18,7 +18,7 @@
<jenkins-core.version>2.115-20180402.200252-1</jenkins-core.version> <!-- TODO https://github.com/jenkinsci/jenkins/pull/3302 -->
<jenkins-war.version>2.115-20180402.200314-1</jenkins-war.version>
<java.level>8</java.level>
<workflow-api-plugin.version>2.27-20180402.200639-11</workflow-api-plugin.version> <!-- TODO https://github.com/jenkinsci/workflow-api-plugin/pull/67 -->
<workflow-api-plugin.version>2.27-20180404.204940-13</workflow-api-plugin.version> <!-- TODO https://github.com/jenkinsci/workflow-api-plugin/pull/67 -->
<useBeta>true</useBeta>
</properties>

@@ -111,6 +111,30 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.test</groupId>
<artifactId>docker-fixtures</artifactId>
<version>1.7</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ssh-slaves</artifactId>
<version>1.26</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jdk-tool</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
@@ -59,6 +59,7 @@ public static void live() {
assumeTrue(S3_BUCKET + " bucket does not exist", builder.build().doesBucketExistV2(S3_BUCKET));
assumeThat("can get credentials from environment", builder.getCredentials().getCredentials(), notNullValue());
} catch (SdkClientException x) {
x.printStackTrace();
assumeNoException("failed to connect to S3 with current credentials", x);
}
}
@@ -24,6 +24,8 @@

package io.jenkins.plugins.artifact_manager_s3;

import com.amazonaws.SdkClientException;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

@@ -37,7 +39,6 @@
import org.apache.commons.io.output.NullOutputStream;
import org.jclouds.rest.internal.InvokeHttpMethod;
import org.jenkinsci.plugins.workflow.ArtifactManagerTest;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -53,12 +54,17 @@
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Run;
import hudson.plugins.sshslaves.SSHLauncher;
import hudson.remoting.Which;
import hudson.slaves.DumbSlave;
import hudson.tasks.ArtifactArchiver;
import jenkins.model.ArtifactManager;
import jenkins.model.ArtifactManagerConfiguration;
import jenkins.model.ArtifactManagerFactory;
import jenkins.model.Jenkins;
import jenkins.security.MasterToSlaveCallable;
import org.jenkinsci.test.acceptance.docker.DockerImage;
import org.jenkinsci.test.acceptance.docker.fixtures.JavaContainer;

public class JCloudsArtifactManagerTest {

@@ -69,6 +75,13 @@ public static void live() {
JCloudsAbstractTest.live();
}

private static DockerImage image;

@BeforeClass
public static void doPrepareImage() throws Exception {
image = ArtifactManagerTest.prepareImage();
}

@Rule
public JenkinsRule j = new JenkinsRule();

@@ -106,8 +119,29 @@ protected ArtifactManagerFactory getArtifactManagerFactory() {

@Test
public void smokes() throws Exception {
if (image != null) {
System.err.println("verifying that while the master can connect to S3, a Dockerized agent cannot");
try (JavaContainer container = image.start(JavaContainer.class).start()) {
DumbSlave agent = new DumbSlave("assumptions", "/home/test/slave", new SSHLauncher(container.ipBound(22), container.port(22), "test", "test", "", ""));
Jenkins.get().addNode(agent);
j.waitOnline(agent);
try {
agent.getChannel().call(new LoadS3Credentials());
fail("did not expect to be able to connect to S3 from a Dockerized agent"); // or AssumptionViolatedException?
} catch (SdkClientException x) {
System.err.println("a Dockerized agent was unable to connect to S3, as expected: " + x);
}
}
}
// To demo class loading performance: loggerRule.record(SlaveComputer.class, Level.FINEST);
ArtifactManagerTest.run(j, getArtifactManagerFactory(), /* TODO S3BlobStore.list does not seem to handle weird characters */false);
ArtifactManagerTest.run(j, getArtifactManagerFactory(), /* TODO S3BlobStore.list does not seem to handle weird characters */false, image);
}
private static final class LoadS3Credentials extends MasterToSlaveCallable<Void, RuntimeException> {
@Override
public Void call() {
AmazonS3ClientBuilder.standard().build();
return null;
}
}

@Test

0 comments on commit 4392c8c

Please sign in to comment.
You can’t perform that action at this time.