1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/docker_swarm_service/tasks/tests/resources.yml
Hannes Ljungberg 139abd0849 docker_swarm_service: Add option groups (#53213)
* Add logging option

* Add limits option

* Add reservations option

* Add restart_config option

* Add update_config option

* Add placement option and remove placement_preferences

* Yaml indentation

* Use correct PR number for change log

* Handle grouper fallbacks better

* Add removed_in_version to argument spec

* Fix broken suboption usage check

* Reduce duplicate deprecated option tests

* Clearer deprecation documentation

* Compare bytes with MiB

* Use correct test service suffix
2019-03-05 16:07:27 +00:00

214 lines
5.3 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
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
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
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
command: '/bin/sh -v -c "sleep 10m"'
limits:
cpus: 2
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
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
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
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
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
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
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
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
command: '/bin/sh -v -c "sleep 10m"'
reservations:
cpus: 2
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
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
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
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
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