From 12055eace673c88acffa7db5a14ec55562517e04 Mon Sep 17 00:00:00 2001 From: Jordon Phillips Date: Wed, 16 May 2018 17:34:31 -0400 Subject: [PATCH] Add integration tests for sqs_queue module (#40110) --- test/integration/targets/sqs_queue/aliases | 2 + .../targets/sqs_queue/defaults/main.yml | 1 + .../targets/sqs_queue/tasks/main.yml | 115 ++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 test/integration/targets/sqs_queue/aliases create mode 100644 test/integration/targets/sqs_queue/defaults/main.yml create mode 100644 test/integration/targets/sqs_queue/tasks/main.yml diff --git a/test/integration/targets/sqs_queue/aliases b/test/integration/targets/sqs_queue/aliases new file mode 100644 index 0000000000..d6ae2f116b --- /dev/null +++ b/test/integration/targets/sqs_queue/aliases @@ -0,0 +1,2 @@ +cloud/aws +posix/ci/cloud/group4/aws diff --git a/test/integration/targets/sqs_queue/defaults/main.yml b/test/integration/targets/sqs_queue/defaults/main.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/test/integration/targets/sqs_queue/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/test/integration/targets/sqs_queue/tasks/main.yml b/test/integration/targets/sqs_queue/tasks/main.yml new file mode 100644 index 0000000000..bef751c5ea --- /dev/null +++ b/test/integration/targets/sqs_queue/tasks/main.yml @@ -0,0 +1,115 @@ +--- +- 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 }}" }