From 9ee0deea24e04b5221edec74c74da922a2544a29 Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Wed, 4 Sep 2019 09:59:35 -0400 Subject: [PATCH] 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 --- .../targets/aws_codebuild/defaults/main.yml | 5 +++++ test/integration/targets/aws_codebuild/tasks/main.yml | 11 +++++------ .../targets/aws_codepipeline/defaults/main.yml | 6 +++++- .../targets/aws_codepipeline/tasks/main.yml | 7 +++---- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/test/integration/targets/aws_codebuild/defaults/main.yml b/test/integration/targets/aws_codebuild/defaults/main.yml index 36ac6f48a0d..9e1009a7fb5 100644 --- a/test/integration/targets/aws_codebuild/defaults/main.yml +++ b/test/integration/targets/aws_codebuild/defaults/main.yml @@ -1,2 +1,7 @@ --- # 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 +iam_role_name: "ansible-test-sts-{{ resource_prefix | regex_search('([0-9]+)$') }}-codebuild-service-role" diff --git a/test/integration/targets/aws_codebuild/tasks/main.yml b/test/integration/targets/aws_codebuild/tasks/main.yml index aeef503d899..953aaeaad81 100644 --- a/test/integration/targets/aws_codebuild/tasks/main.yml +++ b/test/integration/targets/aws_codebuild/tasks/main.yml @@ -18,17 +18,13 @@ - name: create IAM role needed for CodeBuild iam_role: - name: "ansible-test-sts-{{ resource_prefix }}-codebuild-service-role" + name: "{{ iam_role_name }}" description: Role with permissions for CodeBuild actions. assume_role_policy_document: "{{ lookup('file', 'codebuild_iam_trust_policy.json') }}" state: present <<: *aws_connection_info register: codebuild_iam_role - - name: Wait until IAM role is available - pause: - seconds: 10 - - name: Set variable with aws account id set_fact: aws_account_id: "{{ codebuild_iam_role.iam_role.arn.split(':')[4] }}" @@ -61,6 +57,9 @@ state: present <<: *aws_connection_info register: output + retries: 10 + delay: 5 + until: output is success - assert: that: @@ -115,6 +114,6 @@ - name: cleanup IAM role created for CodeBuild test iam_role: - name: "{{ resource_prefix }}-codebuild-service-role" + name: "{{ iam_role_name }}" state: absent <<: *aws_connection_info diff --git a/test/integration/targets/aws_codepipeline/defaults/main.yml b/test/integration/targets/aws_codepipeline/defaults/main.yml index b1e6dd29ab7..61db083dda1 100644 --- a/test/integration/targets/aws_codepipeline/defaults/main.yml +++ b/test/integration/targets/aws_codepipeline/defaults/main.yml @@ -2,4 +2,8 @@ # defaults file for aws_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 +codepipeline_service_role_name: "ansible-test-sts-{{ resource_prefix | regex_search('([0-9]+)$') }}-codebuild-service-role" diff --git a/test/integration/targets/aws_codepipeline/tasks/main.yml b/test/integration/targets/aws_codepipeline/tasks/main.yml index 0ac800faed7..f5fe7b4166c 100644 --- a/test/integration/targets/aws_codepipeline/tasks/main.yml +++ b/test/integration/targets/aws_codepipeline/tasks/main.yml @@ -25,10 +25,6 @@ <<: *aws_connection_info register: codepipeline_iam_role - - name: Pause a few seconds to ensure IAM role is available to next task - pause: - seconds: 10 - # ================== integration test ========================================== - name: create CodePipeline @@ -69,6 +65,9 @@ state: present <<: *aws_connection_info register: output + retries: 10 + delay: 5 + until: output is success - assert: that: