Fixing up docker integration tests a bit

This commit is contained in:
James Cammarata 2015-12-10 13:10:17 -05:00
parent bd9582d072
commit c402325085
2 changed files with 8 additions and 34 deletions

View file

@ -8,7 +8,6 @@
image: busybox image: busybox
state: present state: present
pull: missing pull: missing
docker_api_version: "1.14"
- name: Run a small script in busybox - name: Run a small script in busybox
docker: docker:
@ -17,22 +16,12 @@
pull: always pull: always
command: "nc -l -p 2000 -e xargs -n1 echo hello" command: "nc -l -p 2000 -e xargs -n1 echo hello"
detach: True detach: True
docker_api_version: "1.14"
- name: Get the docker container id
shell: "docker ps | grep busybox | awk '{ print $1 }'"
register: container_id
- name: Get the docker container ip - name: Get the docker container ip
shell: "docker inspect {{ container_id.stdout_lines[0] }} | grep IPAddress | awk -F '\"' '{ print $4 }'" set_fact: container_ip="{{docker_containers[0].NetworkSettings.IPAddress}}"
register: container_ip
- name: Pause a few moments because docker is not reliable
pause:
seconds: 40
- name: Try to access the server - name: Try to access the server
shell: "echo 'world' | nc {{ container_ip.stdout_lines[0] }} 2000" shell: "echo 'world' | nc {{ container_ip }} 2000"
register: docker_output register: docker_output
- name: check that the script ran - name: check that the script ran
@ -49,22 +38,12 @@
TEST: hello TEST: hello
command: '/bin/sh -c "nc -l -p 2000 -e xargs -n1 echo $TEST"' command: '/bin/sh -c "nc -l -p 2000 -e xargs -n1 echo $TEST"'
detach: True detach: True
docker_api_version: "1.14"
- name: Get the docker container id
shell: "docker ps | grep busybox | awk '{ print $1 }'"
register: container_id
- name: Get the docker container ip - name: Get the docker container ip
shell: "docker inspect {{ container_id.stdout_lines[0] }} | grep IPAddress | awk -F '\"' '{ print $4 }'" set_fact: container_ip="{{docker_containers[0].NetworkSettings.IPAddress}}"
register: container_ip
- name: Pause a few moments because docker is not reliable
pause:
seconds: 40
- name: Try to access the server - name: Try to access the server
shell: "echo 'world' | nc {{ container_ip.stdout_lines[0] }} 2000" shell: "echo 'world' | nc {{ container_ip }} 2000"
register: docker_output register: docker_output
- name: check that the script ran - name: check that the script ran
@ -73,7 +52,7 @@
- "'hello world' in docker_output.stdout_lines" - "'hello world' in docker_output.stdout_lines"
- name: Remove containers - name: Remove containers
shell: "docker rm $(docker ps -aq)" shell: "docker rm -f $(docker ps -aq)"
- name: Remove all images from the local docker - name: Remove all images from the local docker
shell: "docker rmi -f $(docker images -q)" shell: "docker rmi -f $(docker images -q)"

View file

@ -19,11 +19,8 @@
- name: Push docker image into the private registry - name: Push docker image into the private registry
command: "docker push localhost:5000/mine" command: "docker push localhost:5000/mine"
- name: Remove containers
shell: "docker rm $(docker ps -aq)"
- name: Remove all images from the local docker - name: Remove all images from the local docker
shell: "docker rmi -f $(docker images -q)" shell: "docker rmi -f {{image_id.stdout_lines[0]}}"
- name: Get number of images in docker - name: Get number of images in docker
command: "docker images" command: "docker images"
@ -41,7 +38,6 @@
state: present state: present
pull: missing pull: missing
insecure_registry: True insecure_registry: True
docker_api_version: "1.14"
- name: Run a small script in the new image - name: Run a small script in the new image
docker: docker:
@ -51,7 +47,6 @@
command: "nc -l -p 2000 -e xargs -n1 echo hello" command: "nc -l -p 2000 -e xargs -n1 echo hello"
detach: True detach: True
insecure_registry: True insecure_registry: True
docker_api_version: "1.14"
- name: Get the docker container id - name: Get the docker container id
shell: "docker ps | grep mine | awk '{ print $1 }'" shell: "docker ps | grep mine | awk '{ print $1 }'"
@ -76,8 +71,9 @@
- name: Remove containers - name: Remove containers
shell: "docker rm $(docker ps -aq)" shell: "docker rm -f $(docker ps -aq)"
- shell: docker images -q
- name: Remove all images from the local docker - name: Remove all images from the local docker
shell: "docker rmi -f $(docker images -q)" shell: "docker rmi -f $(docker images -q)"
@ -157,7 +153,6 @@
state: running state: running
command: "nc -l -p 2000 -e xargs -n1 echo hello" command: "nc -l -p 2000 -e xargs -n1 echo hello"
detach: True detach: True
docker_api_version: "1.14"
- name: Get the docker container id - name: Get the docker container id
shell: "docker ps | grep mine | awk '{ print $1 }'" shell: "docker ps | grep mine | awk '{ print $1 }'"