Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
d439b737
Commit
d439b737
authored
Jan 09, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use docker-java 3.0.x for launch script integration tests
parent
c373c0e8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
49 deletions
+30
-49
README.adoc
...gration-tests/spring-boot-launch-script-tests/README.adoc
+10
-26
pom.xml
...integration-tests/spring-boot-launch-script-tests/pom.xml
+2
-2
SysVinitLaunchScriptIT.java
...ngframework/boot/launchscript/SysVinitLaunchScriptIT.java
+18
-19
logback.xml
...g-boot-launch-script-tests/src/test/resources/logback.xml
+0
-2
No files found.
spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/README.adoc
View file @
d439b737
...
...
@@ -4,16 +4,20 @@ This module contains integration tests for the default launch script that is use
to make a jar file fully executable on Linux. The tests use Docker to verify the
functionality in a variety of Linux distributions.
== Setting up Docker
The setup that's required varies depending on your operating system.
=== Docker on OS X
The latest version of Docker runs as a native Mac application but isn't supported by
docker-java. This means that you should use Docker Toolbox. See the
https://docs.docker.com/engine/installation/mac/[OS X installation instructions] for
details.
Install Docker for Mac. See the https://docs.docker.com/docker-for-mac/install/[macOS
installation instructions] for details.
=== Docker on Linux
...
...
@@ -30,29 +34,7 @@ $ sudo usermod -a -G docker awilkinson
You may need to log out and back in again for this change to take affect and for your
user to be able to connect to the daemon.
== Preparing to run the tests
Before running the tests, you must prepare your environment according to your operating
system.
=== Preparation on OS X
The tests must be run in an environment where various environment variables including
`DOCKER_HOST` and `DOCKER_CERT_PATH` have been set:
----
$ eval $(docker-machine env default)
----
=== Preparation on Linux
Docker Daemon's default configuration on Linux uses a Unix socket for communication.
However, Docker's Java client uses HTTP by default. Docker Java's client can be configured
to use the Unix socket via the `DOCKER_URL` environment variable:
----
$ export DOCKER_URL=unix:///var/run/docker.sock
----
== Running the tests
...
...
@@ -69,6 +51,8 @@ connection. Subsequent runs will be faster as the images are cached locally. You
`docker images` to see a list of the cached images. Images created by these tests will be
tagged with `spring-boot-it` prefix to easily distinguish them.
== Cleaning up
If you want to reclaim the disk space used by the cached images (at the expense of having
...
...
spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/pom.xml
View file @
d439b737
...
...
@@ -12,7 +12,7 @@
<description>
Spring Boot Launch Script Integration Tests
</description>
<properties>
<main.basedir>
${basedir}/../../..
</main.basedir>
<jersey.version>
2.
1
1
</jersey.version>
<jersey.version>
2.
23.
1
</jersey.version>
</properties>
<dependencies>
<dependency>
...
...
@@ -32,7 +32,7 @@
<dependency>
<groupId>
com.github.docker-java
</groupId>
<artifactId>
docker-java
</artifactId>
<version>
2.2.3
</version>
<version>
3.0.14
</version>
<scope>
test
</scope>
</dependency>
<dependency>
...
...
spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java
View file @
d439b737
...
...
@@ -22,6 +22,7 @@ import java.io.InputStream;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.regex.Pattern
;
...
...
@@ -30,17 +31,19 @@ import javax.ws.rs.client.Entity;
import
javax.ws.rs.client.WebTarget
;
import
com.github.dockerjava.api.DockerClient
;
import
com.github.dockerjava.api.DockerClientException
;
import
com.github.dockerjava.api.command.DockerCmd
;
import
com.github.dockerjava.api.exception.DockerClientException
;
import
com.github.dockerjava.api.model.BuildResponseItem
;
import
com.github.dockerjava.api.model.Frame
;
import
com.github.dockerjava.core.
CompressArchiveUtil
;
import
com.github.dockerjava.core.
DefaultDockerClientConfig
;
import
com.github.dockerjava.core.DockerClientBuilder
;
import
com.github.dockerjava.core.DockerClientConfig
;
import
com.github.dockerjava.core.command.AttachContainerResultCallback
;
import
com.github.dockerjava.core.command.BuildImageResultCallback
;
import
com.github.dockerjava.core.command.WaitContainerResultCallback
;
import
com.github.dockerjava.core.util.CompressArchiveUtil
;
import
com.github.dockerjava.jaxrs.AbstrSyncDockerCmdExec
;
import
com.github.dockerjava.jaxrs.
DockerCmdExecFactoryImpl
;
import
com.github.dockerjava.jaxrs.
JerseyDockerCmdExecFactory
;
import
org.assertj.core.api.Condition
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -253,8 +256,10 @@ public class SysVinitLaunchScriptIT {
}
});
resultCallback
.
awaitCompletion
(
60
,
TimeUnit
.
SECONDS
).
close
();
docker
.
waitContainerCmd
(
container
).
exec
();
resultCallback
.
awaitCompletion
(
60
,
TimeUnit
.
SECONDS
);
WaitContainerResultCallback
waitContainerCallback
=
new
WaitContainerResultCallback
();
docker
.
waitContainerCmd
(
container
).
exec
(
waitContainerCallback
);
waitContainerCallback
.
awaitCompletion
(
60
,
TimeUnit
.
SECONDS
);
return
output
.
toString
();
}
finally
{
...
...
@@ -268,11 +273,10 @@ public class SysVinitLaunchScriptIT {
}
private
DockerClient
createClient
()
{
DockerClientConfig
config
=
DockerClientConfig
.
createDefaultConfigBuilder
()
.
withVersion
(
"1.19"
).
build
();
DockerClient
docker
=
DockerClientBuilder
.
getInstance
(
config
)
DockerClientConfig
config
=
D
efaultD
ockerClientConfig
.
createDefaultConfigBuilder
()
.
with
Api
Version
(
"1.19"
).
build
();
return
DockerClientBuilder
.
getInstance
(
config
)
.
withDockerCmdExecFactory
(
this
.
commandExecFactory
).
build
();
return
docker
;
}
private
String
buildImage
(
DockerClient
docker
)
{
...
...
@@ -328,7 +332,8 @@ public class SysVinitLaunchScriptIT {
}
};
docker
.
buildImageCmd
(
new
File
(
dockerfile
)).
withTag
(
tag
).
exec
(
resultCallback
);
docker
.
buildImageCmd
(
new
File
(
dockerfile
))
.
withTags
(
new
HashSet
<>(
Arrays
.
asList
(
tag
))).
exec
(
resultCallback
);
String
imageId
=
resultCallback
.
awaitImageId
();
return
imageId
;
}
...
...
@@ -403,8 +408,8 @@ public class SysVinitLaunchScriptIT {
@Override
protected
Void
execute
(
CopyToContainerCmd
command
)
{
try
(
InputStream
streamToUpload
=
new
FileInputStream
(
CompressArchiveUtil
.
archiveTARFiles
(
command
.
getFile
().
getParentFile
(),
try
(
InputStream
streamToUpload
=
new
FileInputStream
(
CompressArchiveUtil
.
archiveTARFiles
(
command
.
getFile
().
getParentFile
(),
Arrays
.
asList
(
command
.
getFile
()),
command
.
getFile
().
getName
())))
{
WebTarget
webResource
=
getBaseResource
().
path
(
"/containers/{id}/archive"
)
...
...
@@ -448,13 +453,7 @@ public class SysVinitLaunchScriptIT {
}
private
static
final
class
SpringBootDockerCmdExecFactory
extends
DockerCmdExecFactoryImpl
{
private
SpringBootDockerCmdExecFactory
()
{
withClientRequestFilters
((
requestContext
)
->
// Workaround for https://go-review.googlesource.com/#/c/3821/
requestContext
.
getHeaders
().
add
(
"Connection"
,
"close"
));
}
extends
JerseyDockerCmdExecFactory
{
private
CopyToContainerCmdExec
createCopyToContainerCmdExec
()
{
return
new
CopyToContainerCmdExec
(
getBaseResource
(),
getDockerClientConfig
());
...
...
spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/logback.xml
View file @
d439b737
...
...
@@ -6,8 +6,6 @@
</encoder>
</appender>
<logger
name=
"com.github.dockerjava.core.command"
level=
"DEBUG"
/>
<root
level=
"INFO"
>
<appender-ref
ref=
"STDOUT"
/>
</root>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment