Add tests using a docker private registry
This commit is contained in:
parent
fe6a2d644d
commit
2cfeec3683
2 changed files with 69 additions and 2 deletions
|
@ -14,5 +14,10 @@
|
|||
# Add other distributions as the proper packages become available
|
||||
when: ansible_distribution in ['Fedora']
|
||||
|
||||
- include: docker-tests.yml
|
||||
when: ansible_distribution in ['RedHat', 'CentOS'] and ansible_lsb.major_release|int == 6
|
||||
#- include: docker-tests.yml
|
||||
# when: ansible_distribution in ['RedHat', 'CentOS'] and ansible_lsb.major_release|int == 6
|
||||
|
||||
- include: registry-tests.yml
|
||||
# Add other distributions as the proper packages become available
|
||||
when: ansible_distribution in ['Fedora']
|
||||
|
||||
|
|
62
test/integration/roles/test_docker/tasks/registry-tests.yml
Normal file
62
test/integration/roles/test_docker/tasks/registry-tests.yml
Normal file
|
@ -0,0 +1,62 @@
|
|||
- name: Configure a private docker registry
|
||||
service:
|
||||
name: docker-registry
|
||||
state: started
|
||||
|
||||
- name: Get busybox image id
|
||||
shell: "docker images | grep busybox | awk '{ print $3 }'"
|
||||
register: image_id
|
||||
|
||||
- name: Tag docker image into the local repository
|
||||
shell: "docker tag {{ image_id.stdout_lines[0] }} localhost:5000/mine"
|
||||
|
||||
- name: Push docker image into the local repository
|
||||
shell: "docker push localhost:5000/mine"
|
||||
|
||||
- name: Remove the busybox image from the local docker
|
||||
shell: "docker rmi -f {{ image_id.stdout_lines[0] }}"
|
||||
|
||||
- name: Remove the new image from the local docker
|
||||
shell: "docker rmi -f localhost:5000/mine"
|
||||
|
||||
- name: Get number of images in docker
|
||||
shell: "docker images |wc -l"
|
||||
register: docker_output
|
||||
|
||||
- name: Check that there are no images in docker
|
||||
assert:
|
||||
that:
|
||||
- "'1' in docker_output.stdout_lines"
|
||||
|
||||
- name: Retrieve the image from private docker server
|
||||
docker:
|
||||
image: "localhost:5000/mine"
|
||||
state: present
|
||||
pull: missing
|
||||
insecure_registry: True
|
||||
|
||||
- name: Run a small script in the new image
|
||||
docker:
|
||||
image: "localhost:5000/mine"
|
||||
state: reloaded
|
||||
pull: always
|
||||
command: "nc -l -p 2000 -e xargs -n1 echo hello"
|
||||
detach: True
|
||||
insecure_registry: True
|
||||
|
||||
- name: Get the docker container id
|
||||
shell: "docker ps | grep mine | awk '{ print $1 }'"
|
||||
register: 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
|
||||
|
||||
- name: Try to access the server
|
||||
shell: "echo 'world' | nc {{ container_ip.stdout_lines[0] }} 2000"
|
||||
register: docker_output
|
||||
|
||||
- name: check that the script ran
|
||||
assert:
|
||||
that:
|
||||
- "'hello world' in docker_output.stdout_lines"
|
Loading…
Reference in a new issue