summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraiordache <anca.iordache@docker.com>2020-10-06 19:47:14 +0200
committeraiordache <anca.iordache@docker.com>2020-10-06 19:47:14 +0200
commit2c975c8f1121542c62313a7a4cfc7c2b73ff3e13 (patch)
tree7881b56270b52f3196cce8f2bd14d5733e7dfcc6
parentd6fe4bd064ec2d1a8675869752d575107259178a (diff)
downloaddocker-py-2c975c8f1121542c62313a7a4cfc7c2b73ff3e13.tar.gz
Update jenkins test pipeline
Signed-off-by: aiordache <anca.iordache@docker.com>
-rw-r--r--Dockerfile4
-rw-r--r--Jenkinsfile27
-rw-r--r--tests/Dockerfile7
-rw-r--r--tests/Dockerfile-ssh-dind6
4 files changed, 31 insertions, 13 deletions
diff --git a/Dockerfile b/Dockerfile
index 5918827..a8cae4e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,6 @@
ARG PYTHON_VERSION=2.7
+ARG SSH_DIND="ssh-dind:latest"
+FROM ${SSH_DIND} as sshdind
FROM python:${PYTHON_VERSION}
@@ -18,6 +20,6 @@ RUN pip install .
RUN apt-get install -y openssh-client
# Add the keys and set permissions
-COPY ./tests/ssh-keys /root/.ssh
+COPY --from=sshdind /root/.ssh /root/.ssh
RUN chmod 600 /root/.ssh/id_rsa && \
chmod 600 /root/.ssh/id_rsa.pub
diff --git a/Jenkinsfile b/Jenkinsfile
index 88c2159..93cf5ed 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -3,6 +3,7 @@
def imageNameBase = "dockerbuildbot/docker-py"
def imageNamePy2
def imageNamePy3
+def imageDindSSH
def images = [:]
def buildImage = { name, buildargs, pyTag ->
@@ -23,9 +24,12 @@ def buildImages = { ->
imageNamePy2 = "${imageNameBase}:py2-${gitCommit()}"
imageNamePy3 = "${imageNameBase}:py3-${gitCommit()}"
+ imageDindSSH = "ssh-dind:${gitCommit()}"
- buildImage(imageNamePy2, "-f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .", "py2.7")
- buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.7 .", "py3.7")
+ buildImage(imageDindSSH, "-f tests/Dockerfile-ssh-dind .", "ssh-dind")
+ buildImage(imageNamePy2, "-f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 --build-arg SSH_DIND=${imageDindSSH} .", "py2.7")
+ buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.7 --build-arg SSH_DIND=${imageDindSSH} .", "py3.7")
+
}
}
}
@@ -82,7 +86,7 @@ def runTests = { Map settings ->
try {
sh """docker network create ${testNetwork}"""
sh """docker run -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
- docker:${dockerVersion}-dind dockerd -H tcp://0.0.0.0:2375
+ ${imageDindSSH} dockerd -H tcp://0.0.0.0:2375
"""
sh """docker run \\
--name ${testContainerName} \\
@@ -91,7 +95,22 @@ def runTests = { Map settings ->
--network ${testNetwork} \\
--volumes-from ${dindContainerName} \\
${testImage} \\
- py.test -v -rxs --cov=docker tests/
+ py.test -v -rxs --cov=docker --ignore=tests/ssh tests/
+ """
+ // start DIND container with SSH
+ sh """docker stop ${dindContainerName}"""
+ sh """docker run -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
+ ${imageDindSSH} dockerd --experimental"""
+ sh """docker exec ${dindContainerName} sh -c "/usr/sbin/sshd -D -o ListenAddress=0.0.0.0 &"""
+ // run SSH tests only
+ sh """docker run \\
+ --name ${testContainerName} \\
+ -e "DOCKER_HOST=ssh://${dindContainerName}:22" \\
+ -e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
+ --network ${testNetwork} \\
+ --volumes-from ${dindContainerName} \\
+ ${testImage} \\
+ py.test -v -rxs --cov=docker tests/ssh
"""
} finally {
sh """
diff --git a/tests/Dockerfile b/tests/Dockerfile
index 3cdf18f..27494f2 100644
--- a/tests/Dockerfile
+++ b/tests/Dockerfile
@@ -1,4 +1,6 @@
ARG PYTHON_VERSION=3.7
+ARG SSH_DIND="ssh-dind:latest"
+FROM ${SSH_DIND} as sshdind
FROM python:${PYTHON_VERSION}
@@ -33,10 +35,7 @@ RUN pip install -r test-requirements.txt
COPY . /src
RUN pip install .
-# install SSHD
-RUN apt-get install -y openssh-client
-
# Add the keys and set permissions
-COPY tests/ssh-keys /root/.ssh
+COPY --from=sshdind /root/.ssh /root/.ssh
RUN chmod 600 /root/.ssh/id_rsa && \
chmod 600 /root/.ssh/id_rsa.pub
diff --git a/tests/Dockerfile-ssh-dind b/tests/Dockerfile-ssh-dind
index 60f8732..f5fb72f 100644
--- a/tests/Dockerfile-ssh-dind
+++ b/tests/Dockerfile-ssh-dind
@@ -11,7 +11,8 @@ RUN ssh-keygen -A
# copy the test SSH config
# Add the keys and set permissions
-COPY ./tests/ssh-keys/authorized_keys /root/.ssh/authorized_keys
+RUN ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa
+RUN cat /root/ssh/id_rsa.pub > /root/.ssh/authorized_keys
RUN chmod 600 /root/.ssh/authorized_keys
RUN echo "IgnoreUserKnownHosts yes" >> /etc/ssh/sshd_config && \
@@ -21,6 +22,3 @@ RUN echo "IgnoreUserKnownHosts yes" >> /etc/ssh/sshd_config && \
RUN echo "root:root" | chpasswd
RUN ln -s /usr/local/bin/docker /usr/bin/docker
EXPOSE 22
-
-# CMD /usr/sbin/sshd -D -o ListenAddress=0.0.0.0 & && \
-# dockerd --experimental