ansible/test/integration/targets/docker_swarm_service/tasks/tests/resources.yml
Hannes Ljungberg 3d07e7241a docker_swarm_service: Documentation fixes (#53479)
* Document and validate mode choices

* Update examples

* Test cpu float values

* Test correct option

* Fix module return sample

* Add secrets and user to module return value

* Order options alphabetically

* Add changelog

* yaml indentation

* Revert "Order options alphabetically"

This reverts commit 51dabccda7930b707d5683670af7f89a68aeb577.

* Be consistent with choices type
2019-03-07 16:51:59 -06:00

230 lines
5.6 KiB
YAML

---
- name: Registering service name
set_fact:
service_name: "{{ name_prefix ~ '-resources' }}"
- name: Registering service name
set_fact:
service_names: "{{ service_names }} + [service_name]"
####################################################################
## limits.cpus #####################################################
####################################################################
- name: limits.cpus
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
limits:
cpus: 1
register: limit_cpu_1
- name: limits.cpus (idempotency)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
limits:
cpus: 1
register: limit_cpu_2
- name: limit_cpu (idempotency, old name)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
limit_cpu: 1
register: limit_cpu_2b
- name: limits.cpus (change)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
limits:
cpus: 0.5
register: limit_cpu_3
- name: cleanup
docker_swarm_service:
name: "{{ service_name }}"
state: absent
diff: no
- assert:
that:
- limit_cpu_1 is changed
- limit_cpu_2 is not changed
- limit_cpu_2b is not changed
- limit_cpu_3 is changed
###################################################################
## limits.memory ##################################################
###################################################################
- name: limits.memory
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
limits:
memory: 64M
register: limit_memory_1
- name: limits.memory (idempotency)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
limits:
memory: 64M
register: limit_memory_2
- name: limit_memory (idempotency, old name)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
limit_memory: "67108864"
register: limit_memory_2b
- name: limits.memory (change)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
limit_memory: 32M
register: limit_memory_3
- name: cleanup
docker_swarm_service:
name: "{{ service_name }}"
state: absent
diff: no
- assert:
that:
- limit_memory_1 is changed
- limit_memory_2 is not changed
- limit_memory_2b is not changed
- limit_memory_3 is changed
###################################################################
## reservations.cpus ##############################################
###################################################################
- name: reserve_cpu
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
reservations:
cpus: 1
register: reserve_cpu_1
- name: reserve_cpu (idempotency)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
reservations:
cpus: 1
register: reserve_cpu_2
- name: reserve_cpu (idempotency, old name)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
reserve_cpu: 1
register: reserve_cpu_2b
- name: reserve_cpu (change)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
reservations:
cpus: 0.5
register: reserve_cpu_3
- name: cleanup
docker_swarm_service:
name: "{{ service_name }}"
state: absent
diff: no
- assert:
that:
- reserve_cpu_1 is changed
- reserve_cpu_2 is not changed
- reserve_cpu_2b is not changed
- reserve_cpu_3 is changed
###################################################################
## reservations.memory ############################################
###################################################################
- name: reservations.memory
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
reservations:
memory: 64M
register: reserve_memory_1
- name: reservations.memory (idempotency)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
reserve_memory: 64M
register: reserve_memory_2
- name: reserve_memory (idempotency, old name)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
reserve_memory: "67108864"
register: reserve_memory_2b
- name: reservations.memory (change)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
resolve_image: no
command: '/bin/sh -v -c "sleep 10m"'
reserve_memory: 32M
register: reserve_memory_3
- name: cleanup
docker_swarm_service:
name: "{{ service_name }}"
state: absent
diff: no
- assert:
that:
- reserve_memory_1 is changed
- reserve_memory_2 is not changed
- reserve_memory_2b is not changed
- reserve_memory_3 is changed