Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 9, 2026. It is now read-only.

Commit 0eb7bd6

Browse filesBrowse files
authored
Merge pull request docker-java#663 from KostyaSha/fix24
Fix difference tests for 1.24 API
2 parents e8f82e8 + a520aaa commit 0eb7bd6
Copy full SHA for 0eb7bd6

15 files changed

+136-42Lines changed: 136 additions & 42 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,4 @@ do_install() {
310310

311311
# wrapped up in a function so that we have some protection against only getting
312312
# half the file during "curl | sh"
313-
do_install
313+
do_install
Collapse file

‎.travis/travis-before-install.sh‎

Copy file name to clipboardExpand all lines: .travis/travis-before-install.sh
+48-5Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
sudo apt-get install -y -q ca-certificates
55

6+
export HOST_PORT=2375
67
echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
78

89

@@ -21,7 +22,10 @@ sudo -E apt-get install -q -y wget
2122
sudo -E apt-get -q -y --purge remove docker-engine
2223
sudo -E apt-cache policy docker-engine
2324

24-
./get-docker-com.sh
25+
./.travis/get-docker-com.sh
26+
27+
sudo -E stop docker
28+
2529
#mkdir "${HOME}/.cache" || :
2630
#pushd "${HOME}/.cache"
2731
# wget -N "https://apt.dockerproject.org/repo/pool/main/d/docker-engine/docker-engine_${DOCKER_VERSION}_amd64.deb"
@@ -31,10 +35,49 @@ sudo -E apt-cache policy docker-engine
3135
#rm -f "src/test/resources/logback.xml"
3236
mv "src/test/resources/travis-logback.xml" "src/test/resources/logback.xml"
3337

34-
echo 'DOCKER_OPTS="-H=unix:///var/run/docker.sock -H=tcp://127.0.0.1:2375"' | sudo tee -a /etc/default/docker
35-
sudo -E restart docker
36-
sleep 10
37-
docker version
38+
# https://github.com/docker/docker/issues/18113
39+
sudo rm /var/lib/docker/network/files/local-kv.db
40+
41+
sudo cat /etc/default/docker
42+
43+
cat << EOF | sudo tee /etc/default/docker
44+
DOCKER_OPTS="\
45+
--dns 8.8.8.8 \
46+
--dns 8.8.4.4 \
47+
-D \
48+
-H=unix:///var/run/docker.sock \
49+
-H=tcp://0.0.0.0:${HOST_PORT} \
50+
"
51+
EOF
52+
53+
sudo cat /etc/default/docker
54+
sudo bash -c ':> /var/log/upstart/docker.log'
55+
56+
date
57+
sudo -E start docker
58+
59+
tries=20
60+
sleep=5
61+
for i in $(seq 1 $tries); do
62+
if sudo grep "API listen on" /var/log/upstart/docker.log ; then
63+
echo "Docker started. Delay $(($i * $sleep))"
64+
break
65+
elif [[ $i -ge $tries ]]; then
66+
echo "Docker didn't start. Exiting!"
67+
sudo cat /var/log/upstart/docker.log
68+
exit 1
69+
else
70+
echo "Docker didn't start, sleeping for 5 secs..."
71+
sleep $sleep
72+
fi
73+
done
74+
75+
76+
sudo ss -antpl
77+
78+
curl -V
79+
80+
docker version || sudo cat /var/log/upstart/docker.log
3881
docker info
3982

4083
set +u
Collapse file

‎src/main/java/com/github/dockerjava/api/DockerClient.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/github/dockerjava/api/DockerClient.java
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ public interface DockerClient extends Closeable {
170170
* @return created command
171171
* @see #copyArchiveFromContainerCmd(String, String)
172172
* @deprecated since docker API version 1.20, replaced by {@link #copyArchiveFromContainerCmd(String, String)}
173+
* since 1.24 fails.
173174
*/
174175
@Deprecated
175176
CopyFileFromContainerCmd copyFileFromContainerCmd(@Nonnull String containerId, @Nonnull String resource);
Collapse file

‎src/main/java/com/github/dockerjava/jaxrs/StartContainerCmdExec.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/github/dockerjava/jaxrs/StartContainerCmdExec.java
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.github.dockerjava.jaxrs;
22

3-
import static javax.ws.rs.client.Entity.entity;
4-
53
import javax.ws.rs.client.WebTarget;
64
import javax.ws.rs.core.MediaType;
75

@@ -22,11 +20,13 @@ public StartContainerCmdExec(WebTarget baseResource, DockerClientConfig dockerCl
2220

2321
@Override
2422
protected Void execute(StartContainerCmd command) {
25-
WebTarget webResource = getBaseResource().path("/containers/{id}/start").resolveTemplate("id",
26-
command.getContainerId());
23+
WebTarget webResource = getBaseResource().path("/containers/{id}/start")
24+
.resolveTemplate("id", command.getContainerId());
2725

2826
LOGGER.trace("POST: {}", webResource);
29-
webResource.request().accept(MediaType.APPLICATION_JSON).post(entity(command, MediaType.APPLICATION_JSON))
27+
webResource.request()
28+
.accept(MediaType.APPLICATION_JSON)
29+
.post(null)
3030
.close();
3131

3232
return null;
Collapse file

‎src/main/java/com/github/dockerjava/netty/exec/StartContainerCmdExec.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/github/dockerjava/netty/exec/StartContainerCmdExec.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ protected Void execute(StartContainerCmd command) {
2323
command.getContainerId());
2424

2525
LOGGER.trace("POST: {}", webResource);
26-
webResource.request().accept(MediaType.APPLICATION_JSON).post(command);
26+
webResource.request()
27+
.accept(MediaType.APPLICATION_JSON)
28+
.post(command);
2729

2830
return null;
2931
}
Collapse file

‎src/test/java/com/github/dockerjava/core/command/ConnectToNetworkCmdImplTest.java‎

Copy file name to clipboardExpand all lines: src/test/java/com/github/dockerjava/core/command/ConnectToNetworkCmdImplTest.java
+28-12Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.github.dockerjava.api.command.CreateContainerResponse;
44
import com.github.dockerjava.api.command.CreateNetworkResponse;
55
import com.github.dockerjava.api.command.InspectContainerResponse;
6+
import com.github.dockerjava.api.exception.DockerException;
67
import com.github.dockerjava.api.model.ContainerNetwork;
78
import com.github.dockerjava.api.model.Network;
89
import com.github.dockerjava.client.AbstractDockerClientTest;
@@ -16,6 +17,10 @@
1617
import java.lang.reflect.Method;
1718
import java.util.Collections;
1819

20+
import static org.hamcrest.Matchers.hasItem;
21+
import static org.hamcrest.core.Is.is;
22+
import static org.junit.Assert.assertThat;
23+
1924
@Test(groups = "integration")
2025
public class ConnectToNetworkCmdImplTest extends AbstractDockerClientTest {
2126

@@ -60,38 +65,49 @@ public void connectToNetwork() throws InterruptedException {
6065

6166
@Test
6267
public void connectToNetworkWithContainerNetwork() throws InterruptedException {
68+
final String NETWORK_SUBNET = "10.100.102.0/24";
69+
final String NETWORK_NAME = "jerseyTestNetwork";
70+
final String CONTAINER_IP = "10.100.102.100";
71+
72+
CreateContainerResponse container = dockerClient.createContainerCmd("busybox")
73+
.withCmd("sleep", "9999")
74+
.exec();
6375

64-
CreateContainerResponse container = dockerClient.createContainerCmd("busybox").withCmd("sleep", "9999").exec();
6576
dockerClient.startContainerCmd(container.getId()).exec();
6677

78+
try {
79+
dockerClient.removeNetworkCmd(NETWORK_NAME).exec();
80+
} catch (DockerException ignore) {
81+
}
82+
6783
CreateNetworkResponse network = dockerClient.createNetworkCmd()
68-
.withName("testNetwork")
84+
.withName(NETWORK_NAME)
6985
.withIpam(new Network.Ipam()
70-
.withConfig(new Network.Ipam.Config()
71-
.withSubnet("10.100.100.0/24")))
86+
.withConfig(new Network.Ipam.Config()
87+
.withSubnet(NETWORK_SUBNET)))
7288
.exec();
7389

7490
dockerClient.connectToNetworkCmd()
7591
.withNetworkId(network.getId())
7692
.withContainerId(container.getId())
7793
.withContainerNetwork(new ContainerNetwork()
78-
.withAliases("testing")
79-
.withIpamConfig(new ContainerNetwork.Ipam()
80-
.withIpv4Address("10.100.100.100")))
94+
.withAliases("aliasName")
95+
.withIpamConfig(new ContainerNetwork.Ipam()
96+
.withIpv4Address(CONTAINER_IP)))
8197
.exec();
8298

8399
Network updatedNetwork = dockerClient.inspectNetworkCmd().withNetworkId(network.getId()).exec();
84100

85101
Network.ContainerNetworkConfig containerNetworkConfig = updatedNetwork.getContainers().get(container.getId());
86102
assertNotNull(containerNetworkConfig);
87-
assertEquals(containerNetworkConfig.getIpv4Address(), "10.100.100.100/24");
103+
assertThat(containerNetworkConfig.getIpv4Address(), is(CONTAINER_IP + "/24"));
88104

89105
InspectContainerResponse inspectContainerResponse = dockerClient.inspectContainerCmd(container.getId()).exec();
90106

91-
ContainerNetwork testNetwork = inspectContainerResponse.getNetworkSettings().getNetworks().get("testNetwork");
107+
ContainerNetwork testNetwork = inspectContainerResponse.getNetworkSettings().getNetworks().get(NETWORK_NAME);
92108
assertNotNull(testNetwork);
93-
assertEquals(testNetwork.getAliases(), Collections.singletonList("testing"));
94-
assertEquals(testNetwork.getGateway(), "10.100.100.1");
95-
assertEquals(testNetwork.getIpAddress(), "10.100.100.100");
109+
assertThat(testNetwork.getAliases(), hasItem("aliasName"));
110+
assertEquals(testNetwork.getGateway(), "10.100.102.1");
111+
assertEquals(testNetwork.getIpAddress(), CONTAINER_IP);
96112
}
97113
}
Collapse file

‎src/test/java/com/github/dockerjava/core/command/CopyFileFromContainerCmdImplTest.java‎

Copy file name to clipboardExpand all lines: src/test/java/com/github/dockerjava/core/command/CopyFileFromContainerCmdImplTest.java
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package com.github.dockerjava.core.command;
22

3+
import static com.github.dockerjava.utils.TestUtils.getVersion;
34
import static org.hamcrest.MatcherAssert.assertThat;
45
import static org.hamcrest.Matchers.isEmptyOrNullString;
56
import static org.hamcrest.Matchers.not;
67

78
import java.io.InputStream;
89
import java.lang.reflect.Method;
910

11+
import com.github.dockerjava.core.RemoteApiVersion;
12+
import com.github.dockerjava.utils.TestUtils;
1013
import org.testng.ITestResult;
14+
import org.testng.SkipException;
1115
import org.testng.annotations.AfterMethod;
1216
import org.testng.annotations.AfterTest;
1317
import org.testng.annotations.BeforeMethod;
@@ -43,6 +47,10 @@ public void afterMethod(ITestResult result) {
4347

4448
@Test
4549
public void copyFromContainer() throws Exception {
50+
if (getVersion(dockerClient).isGreaterOrEqual(RemoteApiVersion.VERSION_1_24)) {
51+
throw new SkipException("Doesn't work since 1.24");
52+
}
53+
4654
// TODO extract this into a shared method
4755
CreateContainerResponse container = dockerClient.createContainerCmd("busybox")
4856
.withName("docker-java-itest-copyFromContainer").withCmd("touch", "/copyFromContainer").exec();
Collapse file

‎src/test/java/com/github/dockerjava/core/command/CreateContainerCmdImplTest.java‎

Copy file name to clipboardExpand all lines: src/test/java/com/github/dockerjava/core/command/CreateContainerCmdImplTest.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public void createContainerWithAlias() throws DockerException {
375375
.exec();
376376

377377
ContainerNetwork aliasNet = inspectContainerResponse.getNetworkSettings().getNetworks().get("aliasNet");
378-
assertEquals(aliasNet.getAliases(), Collections.singletonList("server"));
378+
assertThat(aliasNet.getAliases(), hasItem("server"));
379379
}
380380

381381
@Test
Collapse file

‎src/test/java/com/github/dockerjava/core/command/UnpauseCmdImplTest.java‎

Copy file name to clipboardExpand all lines: src/test/java/com/github/dockerjava/core/command/UnpauseCmdImplTest.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void unpausePausedContainer() {
5656

5757
ContainerUtils.pauseContainer(dockerClient, container);
5858

59-
ContainerUtils.unpaseContainer(dockerClient, container);
59+
ContainerUtils.unpauseContainer(dockerClient, container);
6060
}
6161

6262
@Test(expectedExceptions = InternalServerErrorException.class)
Collapse file

‎src/test/java/com/github/dockerjava/netty/exec/AttachContainerCmdExecTest.java‎

Copy file name to clipboardExpand all lines: src/test/java/com/github/dockerjava/netty/exec/AttachContainerCmdExecTest.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void attachContainerWithStdin() throws Exception {
9393

9494
dockerClient.startContainerCmd(container.getId()).exec();
9595

96-
Thread.sleep(SECONDS.toMillis(3)); //wait bash initialisation
96+
Thread.sleep(SECONDS.toMillis(10)); //wait bash initialisation
9797

9898
InspectContainerResponse inspectContainerResponse = dockerClient.inspectContainerCmd(container.getId()).exec();
9999

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.