From f8ec1451eae9a0bf3003a5d047144a43d3dee9e0 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 17 Mar 2015 13:31:54 -0700 Subject: [PATCH] Would help if I added these files in the right directory --- .../test_docker/tasks/docker-setup-debian.yml | 6 +++ .../roles/test_docker/tasks/docker-tests.yml | 41 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 test/integration/roles/test_docker/tasks/docker-setup-debian.yml create mode 100644 test/integration/roles/test_docker/tasks/docker-tests.yml diff --git a/test/integration/roles/test_docker/tasks/docker-setup-debian.yml b/test/integration/roles/test_docker/tasks/docker-setup-debian.yml new file mode 100644 index 0000000000..01a67eee6b --- /dev/null +++ b/test/integration/roles/test_docker/tasks/docker-setup-debian.yml @@ -0,0 +1,6 @@ +- name: Install docker packages (apt) + apt: + state: present + # Note: add docker-registry when available + name: docker.io,python-docker,netcat-openbsd + diff --git a/test/integration/roles/test_docker/tasks/docker-tests.yml b/test/integration/roles/test_docker/tasks/docker-tests.yml new file mode 100644 index 0000000000..e3ce04a56c --- /dev/null +++ b/test/integration/roles/test_docker/tasks/docker-tests.yml @@ -0,0 +1,41 @@ +- name: Start docker daemon + service: + name: docker + state: started + +- name: Download busybox image + docker: + image: busybox + state: present + pull: missing + +- name: Run a small script in busybox + docker: + image: busybox + state: reloaded + pull: always + command: "nc -l -p 2000 -e xargs -n1 echo hello" + detach: True + +- name: Get the docker container id + shell: "docker ps | grep busybox | awk '{ print $1 }'" + register: container_id + +- debug: var=container_id + +- name: Get the docker container ip + shell: "docker inspect {{ container_id.stdout_lines[0] }} | grep IPAddress | awk -F '\"' '{ print $4 }'" + register: container_ip + +- debug: var=container_ip + +- name: Try to access the server + shell: "echo 'world' | nc {{ container_ip.stdout_lines[0] }} 2000" + register: docker_output + +- debug: var=docker_output + +- name: check that the script ran + assert: + that: + - "'hello world' in docker_output.stdout_lines"