Skip to content

Commit

Permalink
Merge pull request #138 from MarkEWaite/octopus
Browse files Browse the repository at this point in the history
Do not require docker socket access in test
  • Loading branch information
jglick authored Jul 8, 2023
2 parents ab0407e + ef57773 commit 3dc5357
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.68</version>
<version>4.70</version>
<relativePath/>
</parent>

Expand Down Expand Up @@ -62,7 +62,6 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>authentication-tokens</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
Expand Down Expand Up @@ -156,7 +155,7 @@
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.387.x</artifactId>
<version>2163.v2d916d90c305</version>
<version>2230.v0cb_4040cde55</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ private FilePath downloadDocker(DumbSlave slave, FilePath toolDir, String versio
ByteArrayOutputStream baos = new ByteArrayOutputStream();
TeeOutputStream tee = new TeeOutputStream(baos, new PlainTextConsoleOutputStream(System.err));
TaskListener l = new StreamTaskListener(tee);
ByteArrayOutputStream errStream = new ByteArrayOutputStream();

FilePath exe = toolDir.child(version+"/bin/docker");
// Download for first time:
Expand All @@ -124,9 +125,14 @@ private FilePath downloadDocker(DumbSlave slave, FilePath toolDir, String versio
assertThat(baos.toString(), not(containsString(Messages.DockerToolInstaller_downloading_docker_client_(version))));
// Version check:
baos.reset();
assertEquals(0, slave.createLauncher(l).launch().cmds(exe.getRemote(), "version", "--format", "{{.Client.Version}}").quiet(true).stdout(tee).stderr(System.err).join());
if (!version.equals("latest")) {
assertEquals(version, baos.toString().trim());
if (slave.createLauncher(l).launch().cmds(exe.getRemote(), "version", "--format", "{{.Client.Version}}").quiet(true).stdout(tee).stderr(errStream).join() != 0) {
/* Failure message should mention /var/run/docker.sock */
assertThat(errStream.toString(), containsString("/var/run/docker.sock"));
} else {
/* Successful output should either be `latest` or include the docker version */
if (!version.equals("latest")) {
assertEquals(version, baos.toString().trim());
}
}
return exe;
}
Expand Down

0 comments on commit 3dc5357

Please sign in to comment.