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/sqs_queue/tasks/main.yml

116 lines
3.5 KiB
YAML
Raw Normal View History

---
- name: set up aws connection info
set_fact:
aws_connection_info: &aws_connection_info
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
security_token: "{{ security_token }}"
region: "{{ aws_region }}"
no_log: yes
- block:
- name: Test creating SQS queue
sqs_queue:
name: "{{ resource_prefix }}{{ 1000 | random }}"
<<: *aws_connection_info
register: create_result
- name: Assert SQS queue created
assert:
that:
- create_result.changed
- create_result.region == "{{ aws_region }}"
always:
- name: Test deleting SQS queue
sqs_queue:
name: "{{ create_result.name }}"
state: absent
<<: *aws_connection_info
register: delete_result
retries: 3
delay: 3
until: delete_result.changed
- name: Assert SQS queue deleted
assert:
that:
- delete_result.changed
- name: Test delete SQS queue that doesn't exist
sqs_queue:
name: "{{ resource_prefix }}{{ 1000 | random }}"
state: absent
<<: *aws_connection_info
register: delete_result
- name: Assert delete non-existant queue returns cleanly
assert:
that:
- delete_result.changed == False
- name: Test queue features
block:
- name: Test create queue with attributes
sqs_queue:
name: "{{ resource_prefix }}{{ 1000 | random }}"
default_visibility_timeout: 900
delivery_delay: 900
maximum_message_size: 9009
message_retention_period: 900
receive_message_wait_time: 10
policy:
Version: "2012-10-17"
Statement:
Effect: Allow
Action: "*"
<<: *aws_connection_info
register: create_result
- name: Assert queue created with configuration
assert:
that:
- create_result.changed
- create_result.default_visibility_timeout == "900"
- create_result.delivery_delay == "900"
- create_result.maximum_message_size == "9009"
- create_result.message_retention_period == "900"
- create_result.receive_message_wait_time == "10"
- create_result.policy.Version == "2012-10-17"
- create_result.policy.Statement.Effect == "Allow"
- create_result.policy.Statement.Action == "*"
always:
- name: Cleaning up queue
echo: "{{ create_result.name }}"
sqs_queue:
name: "{{ create_result.name }}"
state: absent
<<: *aws_connection_info
register: delete_result
retries: 3
delay: 3
until: delete_result.changed
- name: Test queue with redrive
block:
- name: Creating dead letter queue
sqs_queue:
name: "{{ resource_prefix }}{{ 1000 | random }}"
<<: *aws_connection_info
register: dead_letter_queue
- name: Test create queue with redrive_policy
sqs_queue:
name: "{{ resource_prefix }}{{ 1000 | random }}"
redrive_policy:
maxReceiveCount: 5
deadLetterTargetArn: "{{ dead_letter_queue.queue_arn }}"
<<: *aws_connection_info
register: create_result
- name: Assert queue created with configuration
assert:
that:
- create_result.changed
always:
- name: Cleaning up queue
sqs_queue:
name: "{{ item.name }}"
state: absent
<<: *aws_connection_info
register: delete_result
retries: 3
delay: 3
with_items:
- { name: "{{ create_result.name }}" }
- { name: "{{ dead_letter_queue.name }}" }