Skip to content

Commit 3f3ca7e

Browse files
committed
Use networks instead of legacy links for test setup
Signed-off-by: Joffrey F <[email protected]>
1 parent ffdc048 commit 3f3ca7e

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

Jenkinsfile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ def imageNamePy2
55
def imageNamePy3
66
def images = [:]
77

8-
def dockerVersions = ["17.06.2-ce", "17.12.0-ce", "18.01.0-ce"]
8+
def dockerVersions = [
9+
"17.06.2-ce", // Latest EE
10+
"17.12.1-ce", // Latest CE stable
11+
"18.02.0-ce", // Latest CE edge
12+
"18.03.0-ce-rc4" // Latest CE RC
13+
]
914

1015
def buildImage = { name, buildargs, pyTag ->
1116
img = docker.image(name)
@@ -59,22 +64,26 @@ def runTests = { Map settings ->
5964
checkout(scm)
6065
def dindContainerName = "dpy-dind-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
6166
def testContainerName = "dpy-tests-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
67+
def testNetwork = "dpy-testnet-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
6268
try {
63-
sh """docker run -d --name ${dindContainerName} -v /tmp --privileged \\
69+
sh """docker network create ${testNetwork}"""
70+
sh """docker run -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
6471
dockerswarm/dind:${dockerVersion} dockerd -H tcp://0.0.0.0:2375
6572
"""
6673
sh """docker run \\
67-
--name ${testContainerName} --volumes-from ${dindContainerName} \\
68-
-e 'DOCKER_HOST=tcp://docker:2375' \\
74+
--name ${testContainerName} \\
75+
-e "DOCKER_HOST=tcp://${dindContainerName}:2375" \\
6976
-e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
70-
--link=${dindContainerName}:docker \\
77+
--network ${testNetwork} \\
78+
--volumes-from ${dindContainerName} \\
7179
${testImage} \\
7280
py.test -v -rxs tests/integration
7381
"""
7482
} finally {
7583
sh """
7684
docker stop ${dindContainerName} ${testContainerName}
7785
docker rm -vf ${dindContainerName} ${testContainerName}
86+
docker network rm ${testNetwork}
7887
"""
7988
}
8089
}

Makefile

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ all: test
33

44
.PHONY: clean
55
clean:
6-
-docker rm -f dpy-dind-py2 dpy-dind-py3
6+
-docker rm -f dpy-dind-py2 dpy-dind-py3 dpy-dind-certs dpy-dind-ssl
77
find -name "__pycache__" | xargs rm -rf
88

99
.PHONY: build
@@ -44,41 +44,47 @@ integration-test-py3: build-py3
4444
TEST_API_VERSION ?= 1.35
4545
TEST_ENGINE_VERSION ?= 17.12.0-ce
4646

47+
.PHONY: setup-network
48+
setup-network:
49+
docker network inspect dpy-tests || docker network create dpy-tests
50+
4751
.PHONY: integration-dind
4852
integration-dind: integration-dind-py2 integration-dind-py3
4953

5054
.PHONY: integration-dind-py2
51-
integration-dind-py2: build
55+
integration-dind-py2: build setup-network
5256
docker rm -vf dpy-dind-py2 || :
53-
docker run -d --name dpy-dind-py2 --privileged dockerswarm/dind:${TEST_ENGINE_VERSION} dockerd\
54-
-H tcp://0.0.0.0:2375 --experimental
55-
docker run -t --rm --env="DOCKER_HOST=tcp://docker:2375" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
56-
--link=dpy-dind-py2:docker docker-sdk-python py.test tests/integration
57+
docker run -d --network dpy-tests --name dpy-dind-py2 --privileged\
58+
dockerswarm/dind:${TEST_ENGINE_VERSION} dockerd -H tcp://0.0.0.0:2375 --experimental
59+
docker run -t --rm --env="DOCKER_HOST=tcp://dpy-dind-py2:2375" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
60+
--network dpy-tests docker-sdk-python py.test tests/integration
5761
docker rm -vf dpy-dind-py2
5862

5963
.PHONY: integration-dind-py3
60-
integration-dind-py3: build-py3
64+
integration-dind-py3: build-py3 setup-network
6165
docker rm -vf dpy-dind-py3 || :
62-
docker run -d --name dpy-dind-py3 --privileged dockerswarm/dind:${TEST_ENGINE_VERSION} dockerd\
63-
-H tcp://0.0.0.0:2375 --experimental
64-
docker run -t --rm --env="DOCKER_HOST=tcp://docker:2375" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
65-
--link=dpy-dind-py3:docker docker-sdk-python3 py.test tests/integration
66+
docker run -d --network dpy-tests --name dpy-dind-py3 --privileged\
67+
dockerswarm/dind:${TEST_ENGINE_VERSION} dockerd -H tcp://0.0.0.0:2375 --experimental
68+
docker run -t --rm --env="DOCKER_HOST=tcp://dpy-dind-py3:2375" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
69+
--network dpy-tests docker-sdk-python3 py.test tests/integration
6670
docker rm -vf dpy-dind-py3
6771

6872
.PHONY: integration-dind-ssl
6973
integration-dind-ssl: build-dind-certs build build-py3
74+
docker rm -vf dpy-dind-certs dpy-dind-ssl || :
7075
docker run -d --name dpy-dind-certs dpy-dind-certs
7176
docker run -d --env="DOCKER_HOST=tcp://localhost:2375" --env="DOCKER_TLS_VERIFY=1"\
7277
--env="DOCKER_CERT_PATH=/certs" --volumes-from dpy-dind-certs --name dpy-dind-ssl\
73-
-v /tmp --privileged dockerswarm/dind:${TEST_ENGINE_VERSION} dockerd --tlsverify\
74-
--tlscacert=/certs/ca.pem --tlscert=/certs/server-cert.pem\
78+
--network dpy-tests --network-alias docker -v /tmp --privileged\
79+
dockerswarm/dind:${TEST_ENGINE_VERSION}\
80+
dockerd --tlsverify --tlscacert=/certs/ca.pem --tlscert=/certs/server-cert.pem\
7581
--tlskey=/certs/server-key.pem -H tcp://0.0.0.0:2375 --experimental
7682
docker run -t --rm --volumes-from dpy-dind-ssl --env="DOCKER_HOST=tcp://docker:2375"\
7783
--env="DOCKER_TLS_VERIFY=1" --env="DOCKER_CERT_PATH=/certs" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
78-
--link=dpy-dind-ssl:docker docker-sdk-python py.test tests/integration
84+
--network dpy-tests docker-sdk-python py.test tests/integration
7985
docker run -t --rm --volumes-from dpy-dind-ssl --env="DOCKER_HOST=tcp://docker:2375"\
8086
--env="DOCKER_TLS_VERIFY=1" --env="DOCKER_CERT_PATH=/certs" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
81-
--link=dpy-dind-ssl:docker docker-sdk-python3 py.test tests/integration
87+
--network dpy-tests docker-sdk-python3 py.test tests/integration
8288
docker rm -vf dpy-dind-ssl dpy-dind-certs
8389

8490
.PHONY: flake8

0 commit comments

Comments
 (0)