Improve paused test and behavior. (#48056)

(cherry picked from commit 569ec812e7)
This commit is contained in:
Felix Fontein 2018-11-05 12:34:23 +01:00 committed by Toshio Kuratomi
parent 0742f00c29
commit 49de1f1c7c
2 changed files with 9 additions and 20 deletions

View file

@ -1870,6 +1870,7 @@ class ContainerManager(DockerBaseClass):
self.fail("Error %s container %s: %s" % ( self.fail("Error %s container %s: %s" % (
"pausing" if self.parameters.paused else "unpausing", container.Id, str(exc) "pausing" if self.parameters.paused else "unpausing", container.Id, str(exc)
)) ))
container = self._get_container(container.Id)
self.results['changed'] = True self.results['changed'] = True
self.results['actions'].append(dict(set_paused=self.parameters.paused)) self.results['actions'].append(dict(set_paused=self.parameters.paused))

View file

@ -2238,24 +2238,21 @@
- name: paused - name: paused
docker_container: docker_container:
image: alpine:3.8 image: alpine:3.8
command: "/bin/sh -c 'sleep 1s ; yes'" command: "/bin/sh -c 'sleep 10m'"
name: "{{ cname }}" name: "{{ cname }}"
state: started state: started
paused: yes paused: yes
stop_timeout: 1 stop_timeout: 1
register: paused_1 register: paused_1
- pause: - name: inspect paused
seconds: 2 command: "docker inspect -f {% raw %}'{{.State.Status}} {{.State.Paused}}'{% endraw %} {{ cname }}"
- name: paused (logs)
command: docker logs --tail=20 "{{ cname }}"
register: paused_2 register: paused_2
- name: paused (idempotent) - name: paused (idempotent)
docker_container: docker_container:
image: alpine:3.8 image: alpine:3.8
command: "/bin/sh -c 'sleep 1s ; yes'" command: "/bin/sh -c 'sleep 10m'"
name: "{{ cname }}" name: "{{ cname }}"
state: started state: started
paused: yes paused: yes
@ -2272,17 +2269,8 @@
stop_timeout: 1 stop_timeout: 1
register: paused_4 register: paused_4
- pause: - name: inspect paused
seconds: 2 command: "docker inspect -f {% raw %}'{{.State.Status}} {{.State.Paused}}'{% endraw %} {{ cname }}"
- name: paused (stop)
docker_container:
name: "{{ cname }}"
state: stopped
stop_timeout: 1
- name: paused (logs)
command: docker logs --tail=20 "{{ cname }}"
register: paused_5 register: paused_5
- name: cleanup - name: cleanup
@ -2294,10 +2282,10 @@
- assert: - assert:
that: that:
- paused_1 is changed - paused_1 is changed
- paused_2.stdout_lines | length == 0 - 'paused_2.stdout == "paused true"'
- paused_3 is not changed - paused_3 is not changed
- paused_4 is changed - paused_4 is changed
- paused_5.stdout_lines | length > 0 - 'paused_5.stdout == "running false"'
#################################################################### ####################################################################
## pid_mode ######################################################## ## pid_mode ########################################################