Skip to content

Commit

Permalink
improve docker_* test speed (ansible#53417)
Browse files Browse the repository at this point in the history
* docker_swarm_service tests: use 'resolve_image: no' to avoid registry lookup if image is up-to-date.

* Improve docker_node performance: don't sleep after last try.
  • Loading branch information
felixfontein authored and mattclay committed Mar 6, 2019
1 parent 00ba452 commit a904bc7
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/ansible/module_utils/docker/swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ def check_if_swarm_node_is_down(self, node_id=None, repeat_check=1):
node_id = self.get_swarm_node_id()

for retry in range(0, repeat_check):
if retry > 0:
sleep(5)
node_info = self.get_node_inspect(node_id=node_id)
if node_info['Status']['State'] == 'down':
return True
sleep(5)
return False

def get_node_inspect(self, node_id=None, skip_missing=False):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
logging:
driver: json-file
Expand All @@ -25,6 +26,7 @@
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
logging:
driver: json-file
Expand All @@ -34,6 +36,7 @@
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
log_driver: json-file
register: logging_driver_2b
Expand All @@ -42,6 +45,7 @@
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
logging:
driver: syslog
Expand All @@ -68,6 +72,7 @@
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
logging:
driver: json-file
Expand All @@ -80,6 +85,7 @@
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
logging:
driver: json-file
Expand All @@ -92,6 +98,7 @@
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
log_driver: json-file
log_driver_options:
Expand All @@ -103,6 +110,7 @@
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
logging:
driver: json-file
Expand All @@ -116,6 +124,7 @@
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
logging:
driver: json-file
Expand All @@ -126,6 +135,7 @@
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
logging:
driver: json-file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
name: test_service
endpoint_mode: dnsrr
image: busybox
resolve_image: no
args:
- sleep
- "3600"
Expand All @@ -43,6 +44,7 @@
docker_swarm_service:
name: test_service
image: busybox
resolve_image: no
args:
- sleep
- "1800"
Expand All @@ -57,6 +59,7 @@
docker_swarm_service:
name: test_service
image: busybox
resolve_image: no
endpoint_mode: vip
mode: global
args:
Expand All @@ -73,6 +76,7 @@
docker_swarm_service:
name: test_service
image: busybox
resolve_image: no
mode: global
args:
- sleep
Expand Down
Loading

0 comments on commit a904bc7

Please sign in to comment.