[stable-2.9] aws_codebuild tests - add retries and delay instead of a pause task (#61731) (#61771)

* [stable-2.9] aws_codebuild tests - add retries and delay instead of a pause task (#61731)

- Add retries instead of a pause task
- Shorten the IAM role name length
- Put the IAM role name in defaults/main.yml instead
- Fix the aws_codepipeline tests too
(cherry picked from commit 9ee0deea24)

Co-authored-by: Sloane Hertel <shertel@redhat.com>

* codebuild/codepipeline - fix regex for shippable resource_prefix (#61783)

* Fix bad assumption about shippable resource_prefix for codebuild and codepipeline tests
* Update test/integration/targets/aws_codepipeline/defaults/main.yml

(cherry picked from commit d5c8d325e4)
pull/61885/head
Sam Doran 5 years ago committed by Toshio Kuratomi
parent 682c3674b8
commit 187f85f4d2

@ -1,2 +1,10 @@
--- ---
# defaults file for aws_codebuild # defaults file for aws_codebuild
# IAM role names have to be less than 64 characters
# The 8 digit identifier at the end of resource_prefix helps determine during
# which test something was created and allows tests to be run in parallel
# Shippable resource_prefixes are in the format shippable-123456-123, so in those cases
# we need both sets of digits to keep the resource name unique
unique_id: "{{ resource_prefix | regex_search('(\\d+-?)(\\d+)$') }}"
iam_role_name: "ansible-test-sts-{{ unique_id }}-codebuild-service-role"

@ -18,17 +18,13 @@
- name: create IAM role needed for CodeBuild - name: create IAM role needed for CodeBuild
iam_role: iam_role:
name: "ansible-test-sts-{{ resource_prefix }}-codebuild-service-role" name: "{{ iam_role_name }}"
description: Role with permissions for CodeBuild actions. description: Role with permissions for CodeBuild actions.
assume_role_policy_document: "{{ lookup('file', 'codebuild_iam_trust_policy.json') }}" assume_role_policy_document: "{{ lookup('file', 'codebuild_iam_trust_policy.json') }}"
state: present state: present
<<: *aws_connection_info <<: *aws_connection_info
register: codebuild_iam_role register: codebuild_iam_role
- name: Wait until IAM role is available
pause:
seconds: 10
- name: Set variable with aws account id - name: Set variable with aws account id
set_fact: set_fact:
aws_account_id: "{{ codebuild_iam_role.iam_role.arn.split(':')[4] }}" aws_account_id: "{{ codebuild_iam_role.iam_role.arn.split(':')[4] }}"
@ -61,6 +57,9 @@
state: present state: present
<<: *aws_connection_info <<: *aws_connection_info
register: output register: output
retries: 10
delay: 5
until: output is success
- assert: - assert:
that: that:
@ -115,6 +114,6 @@
- name: cleanup IAM role created for CodeBuild test - name: cleanup IAM role created for CodeBuild test
iam_role: iam_role:
name: "{{ resource_prefix }}-codebuild-service-role" name: "{{ iam_role_name }}"
state: absent state: absent
<<: *aws_connection_info <<: *aws_connection_info

@ -2,4 +2,11 @@
# defaults file for aws_codepipeline # defaults file for aws_codepipeline
codepipeline_name: "{{ resource_prefix }}-test-codepipeline" codepipeline_name: "{{ resource_prefix }}-test-codepipeline"
codepipeline_service_role_name: "ansible-test-sts-{{ resource_prefix }}-codepipeline-role"
# IAM role names have to be less than 64 characters
# The 8 digit identifier at the end of resource_prefix helps determine during
# which test something was created and allows tests to be run in parallel
# Shippable resource_prefixes are in the format shippable-123456-123, so in those cases
# we need both sets of digits to keep the resource name unique
unique_id: "{{ resource_prefix | regex_search('(\\d+-?)(\\d+)$') }}"
codepipeline_service_role_name: "ansible-test-sts-{{ unique_id }}-codepipeline-role"

@ -25,10 +25,6 @@
<<: *aws_connection_info <<: *aws_connection_info
register: codepipeline_iam_role register: codepipeline_iam_role
- name: Pause a few seconds to ensure IAM role is available to next task
pause:
seconds: 10
# ================== integration test ========================================== # ================== integration test ==========================================
- name: create CodePipeline - name: create CodePipeline
@ -69,6 +65,9 @@
state: present state: present
<<: *aws_connection_info <<: *aws_connection_info
register: output register: output
retries: 10
delay: 5
until: output is success
- assert: - assert:
that: that:

Loading…
Cancel
Save