From 17e85772ef4dda92aa003364c6201b85dd475dba Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Tue, 10 Aug 2021 10:01:02 +0200 Subject: [PATCH] Remove integration tests testing for old (unsupported) versions of botocore --- .../playbooks/full_test.yml | 6 - .../targets/cloudformation_stack_set/runme.sh | 8 - .../ecs_cluster/tasks/network_fail.yml | 194 ------------------ .../targets/efs/playbooks/full_test.yml | 9 - .../targets/efs/playbooks/version_fail.yml | 32 --- tests/integration/targets/efs/runme.sh | 15 -- .../{playbooks/roles/efs => }/tasks/main.yml | 8 +- .../targets/elb_target/defaults/main.yml | 15 ++ .../files/ansible_lambda_target.py | 0 .../files/assume-role.json | 0 .../elb_target/playbooks/full_test.yml | 7 - .../roles/elb_lambda_target/defaults/main.yml | 5 - .../roles/elb_target/defaults/main.yml | 10 - .../elb_target/playbooks/version_fail.yml | 41 ---- tests/integration/targets/elb_target/runme.sh | 13 -- .../tasks/main.yml => tasks/ec2_target.yml} | 13 +- .../main.yml => tasks/lambda_target.yml} | 22 +- .../targets/elb_target/tasks/main.yml | 13 ++ 18 files changed, 48 insertions(+), 363 deletions(-) delete mode 100644 tests/integration/targets/cloudformation_stack_set/playbooks/full_test.yml delete mode 100755 tests/integration/targets/cloudformation_stack_set/runme.sh delete mode 100644 tests/integration/targets/ecs_cluster/tasks/network_fail.yml delete mode 100644 tests/integration/targets/efs/playbooks/full_test.yml delete mode 100644 tests/integration/targets/efs/playbooks/version_fail.yml delete mode 100755 tests/integration/targets/efs/runme.sh rename tests/integration/targets/efs/{playbooks/roles/efs => }/tasks/main.yml (99%) create mode 100644 tests/integration/targets/elb_target/defaults/main.yml rename tests/integration/targets/elb_target/{playbooks/roles/elb_lambda_target => }/files/ansible_lambda_target.py (100%) rename tests/integration/targets/elb_target/{playbooks/roles/elb_lambda_target => }/files/assume-role.json (100%) delete mode 100644 tests/integration/targets/elb_target/playbooks/full_test.yml delete mode 100644 tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/defaults/main.yml delete mode 100644 tests/integration/targets/elb_target/playbooks/roles/elb_target/defaults/main.yml delete mode 100644 tests/integration/targets/elb_target/playbooks/version_fail.yml delete mode 100755 tests/integration/targets/elb_target/runme.sh rename tests/integration/targets/elb_target/{playbooks/roles/elb_target/tasks/main.yml => tasks/ec2_target.yml} (97%) rename tests/integration/targets/elb_target/{playbooks/roles/elb_lambda_target/tasks/main.yml => tasks/lambda_target.yml} (92%) create mode 100644 tests/integration/targets/elb_target/tasks/main.yml diff --git a/tests/integration/targets/cloudformation_stack_set/playbooks/full_test.yml b/tests/integration/targets/cloudformation_stack_set/playbooks/full_test.yml deleted file mode 100644 index 257e1e48a51..00000000000 --- a/tests/integration/targets/cloudformation_stack_set/playbooks/full_test.yml +++ /dev/null @@ -1,6 +0,0 @@ -- hosts: localhost - connection: local - environment: "{{ ansible_test.environment }}" - - roles: - - ../../cloudformation_stack_set diff --git a/tests/integration/targets/cloudformation_stack_set/runme.sh b/tests/integration/targets/cloudformation_stack_set/runme.sh deleted file mode 100755 index d499c679b26..00000000000 --- a/tests/integration/targets/cloudformation_stack_set/runme.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -# Run full test suite -source virtualenv.sh -pip install 'botocore>1.10.26' boto3 -ansible-playbook -i ../../inventory -v playbooks/full_test.yml "$@" diff --git a/tests/integration/targets/ecs_cluster/tasks/network_fail.yml b/tests/integration/targets/ecs_cluster/tasks/network_fail.yml deleted file mode 100644 index d21eba22a0b..00000000000 --- a/tests/integration/targets/ecs_cluster/tasks/network_fail.yml +++ /dev/null @@ -1,194 +0,0 @@ ---- -- block: - - name: create ecs cluster - ecs_cluster: - name: "{{ resource_prefix }}" - state: present - - - name: create ecs_taskdefinition with bridged network - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}" - state: present - network_mode: bridge - register: ecs_taskdefinition_creation - - - name: create ecs_taskdefinition with awsvpc network - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}-vpc" - state: present - network_mode: awsvpc - register: ecs_taskdefinition_creation_vpc - - - name: create ecs_taskdefinition and execution_role_arn (expected to fail) - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}-vpc" - execution_role_arn: not_a_real_arn - state: present - network_mode: awsvpc - ignore_errors: yes - register: ecs_taskdefinition_arn - - - name: check that graceful failure message is returned from ecs_taskdefinition_arn - assert: - that: - - ecs_taskdefinition_arn.failed - - 'ecs_taskdefinition_arn.msg == "botocore needs to be version 1.10.44 or higher to use execution_role_arn"' - - - name: ecs_taskdefinition works fine even when older botocore is used - assert: - that: - - ecs_taskdefinition_creation_vpc.changed - - - name: create ecs_service using bridged network - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 1 - state: present - register: ecs_service_creation - - - name: create ecs_service using awsvpc network_configuration - ecs_service: - name: "{{ resource_prefix }}-vpc" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}-vpc" - desired_count: 1 - network_configuration: - subnets: - - subnet-abcd1234 - security_groups: - - sg-abcd1234 - state: present - register: ecs_service_creation_vpc - ignore_errors: yes - - - name: check that graceful failure message is returned from ecs_service - assert: - that: - - ecs_service_creation_vpc.failed - - 'ecs_service_creation_vpc.msg == "botocore needs to be version 1.7.44 or higher to use network configuration"' - - - name: create ecs_service using awsvpc network_configuration and launch_type - ecs_service: - name: "{{ resource_prefix }}-vpc" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}-vpc" - desired_count: 1 - network_configuration: - subnets: - - subnet-abcd1234 - security_groups: - - sg-abcd1234 - launch_type: FARGATE - state: present - register: ecs_service_creation_vpc_launchtype - ignore_errors: yes - - - name: check that graceful failure message is returned from ecs_service - assert: - that: - - ecs_service_creation_vpc_launchtype.failed - - 'ecs_service_creation_vpc_launchtype.msg == "botocore needs to be version 1.7.44 or higher to use network configuration"' - - - name: create ecs_service with launchtype and missing network_configuration - ecs_service: - name: "{{ resource_prefix }}-vpc" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}-vpc" - desired_count: 1 - launch_type: FARGATE - state: present - register: ecs_service_creation_vpc_launchtype_nonet - ignore_errors: yes - - - name: check that graceful failure message is returned from ecs_service - assert: - that: - - ecs_service_creation_vpc_launchtype_nonet.failed - - 'ecs_service_creation_vpc_launchtype_nonet.msg == "launch_type is FARGATE but all of the following are missing: network_configuration"' - - - name: create ecs_task using awsvpc network_configuration - ecs_task: - cluster: "{{ resource_prefix }}-vpc" - task_definition: "{{ resource_prefix }}" - operation: run - count: 1 - started_by: me - network_configuration: - subnets: - - subnet-abcd1234 - security_groups: - - sg-abcd1234 - register: ecs_task_creation_vpc - ignore_errors: yes - - - name: check that graceful failure message is returned from ecs_task - assert: - that: - - ecs_task_creation_vpc.failed - - 'ecs_task_creation_vpc.msg == "botocore needs to be version 1.7.44 or higher to use network configuration"' - - - always: - - name: scale down ecs service - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 0 - state: present - ignore_errors: yes - - - name: pause to wait for scale down - pause: - seconds: 30 - - - name: remove ecs service - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 1 - state: absent - ignore_errors: yes - - - name: remove ecs task definition - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}" - revision: "{{ ecs_taskdefinition_creation.taskdefinition.revision }}" - state: absent - ignore_errors: yes - - - name: remove ecs task definition vpc - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}-vpc" - revision: "{{ ecs_taskdefinition_creation_vpc.taskdefinition.revision }}" - state: absent - ignore_errors: yes - - - name: remove ecs cluster - ecs_cluster: - name: "{{ resource_prefix }}" - state: absent - ignore_errors: yes diff --git a/tests/integration/targets/efs/playbooks/full_test.yml b/tests/integration/targets/efs/playbooks/full_test.yml deleted file mode 100644 index e15e5aa4e90..00000000000 --- a/tests/integration/targets/efs/playbooks/full_test.yml +++ /dev/null @@ -1,9 +0,0 @@ -- hosts: localhost - connection: local -# environment: "{{ ansible_test.environment }}" - - vars: - resource_prefix: 'ansible-testing' - - roles: - - efs diff --git a/tests/integration/targets/efs/playbooks/version_fail.yml b/tests/integration/targets/efs/playbooks/version_fail.yml deleted file mode 100644 index 6d73b75867e..00000000000 --- a/tests/integration/targets/efs/playbooks/version_fail.yml +++ /dev/null @@ -1,32 +0,0 @@ -- hosts: localhost - connection: local - environment: "{{ ansible_test.environment }}" - vars: - resource_prefix: 'ansible-testing' - - tasks: - - name: 'efs graceful failure tests' - collections: - - amazon.aws - module_defaults: - group/aws: - aws_access_key: '{{ aws_access_key }}' - aws_secret_key: '{{ aws_secret_key }}' - security_token: '{{ security_token | default(omit) }}' - region: '{{ aws_region }}' - block: - - - name: create efs with provisioned_throughput options (fails gracefully) - efs: - state: present - name: "{{ resource_prefix }}-efs" - throughput_mode: 'provisioned' - provisioned_throughput_in_mibps: 8.0 - register: efs_provisioned_throughput_creation - ignore_errors: yes - - - name: check that graceful error message is returned when creation with throughput_mode and old botocore - assert: - that: - - efs_provisioned_throughput_creation.failed - - 'efs_provisioned_throughput_creation.msg == "throughput_mode parameter requires botocore >= 1.10.57"' diff --git a/tests/integration/targets/efs/runme.sh b/tests/integration/targets/efs/runme.sh deleted file mode 100755 index e4f214b8e85..00000000000 --- a/tests/integration/targets/efs/runme.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -export ANSIBLE_ROLES_PATH=../ - -# Test graceful failure for older versions of botocore -source virtualenv.sh -pip install 'botocore<1.10.57' boto3 -ansible-playbook -i ../../inventory -v playbooks/version_fail.yml "$@" - -# Run full test suite -source virtualenv.sh -pip install 'botocore>=1.10.57' boto3 -ansible-playbook -i ../../inventory -v playbooks/full_test.yml "$@" diff --git a/tests/integration/targets/efs/playbooks/roles/efs/tasks/main.yml b/tests/integration/targets/efs/tasks/main.yml similarity index 99% rename from tests/integration/targets/efs/playbooks/roles/efs/tasks/main.yml rename to tests/integration/targets/efs/tasks/main.yml index 094ac782628..93071a2becd 100644 --- a/tests/integration/targets/efs/playbooks/roles/efs/tasks/main.yml +++ b/tests/integration/targets/efs/tasks/main.yml @@ -168,8 +168,8 @@ provisioned_throughput_in_mibps: 5.0 register: efs_result - - assert: - that: + - assert: + that: - efs_result is changed # ============================================================ @@ -186,9 +186,9 @@ throughput_mode: 'provisioned' provisioned_throughput_in_mibps: 5.0 register: efs_result - + - assert: - that: + that: - efs_result is not changed - efs_result.efs["throughput_mode"] == "provisioned" - efs_result.efs["provisioned_throughput_in_mibps"] == 5.0 diff --git a/tests/integration/targets/elb_target/defaults/main.yml b/tests/integration/targets/elb_target/defaults/main.yml new file mode 100644 index 00000000000..14068f1e5c0 --- /dev/null +++ b/tests/integration/targets/elb_target/defaults/main.yml @@ -0,0 +1,15 @@ +unique_id: "ansible-test-{{ tiny_prefix }}" + +# Defaults used by the lambda based test + +lambda_role_name: '{{ unique_id }}-elb-target' +lambda_name: '{{ unique_id }}-elb-target' +elb_target_group_name: "{{ unique_id }}-elb-tg" + +# Defaults used by the EC2 based test +ec2_ami_name: 'amzn2-ami-hvm-2.0.20190612-x86_64-gp2' +tg_name: "{{ unique_id }}-tg" +tg_tcpudp_name: "{{ unique_id }}-tgtcpudp" +lb_name: "{{ unique_id }}-lb" +healthy_state: + state: 'healthy' diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/files/ansible_lambda_target.py b/tests/integration/targets/elb_target/files/ansible_lambda_target.py similarity index 100% rename from tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/files/ansible_lambda_target.py rename to tests/integration/targets/elb_target/files/ansible_lambda_target.py diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/files/assume-role.json b/tests/integration/targets/elb_target/files/assume-role.json similarity index 100% rename from tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/files/assume-role.json rename to tests/integration/targets/elb_target/files/assume-role.json diff --git a/tests/integration/targets/elb_target/playbooks/full_test.yml b/tests/integration/targets/elb_target/playbooks/full_test.yml deleted file mode 100644 index ac95c66f3de..00000000000 --- a/tests/integration/targets/elb_target/playbooks/full_test.yml +++ /dev/null @@ -1,7 +0,0 @@ -- hosts: localhost - connection: local -# environment: "{{ ansible_test.environment }}" - - roles: - - elb_lambda_target - - elb_target diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/defaults/main.yml b/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/defaults/main.yml deleted file mode 100644 index 911e2080e8b..00000000000 --- a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/defaults/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -unique_id: "ansible-test-{{ resource_prefix | hash('md5') }}" -lambda_role_name: '{{ unique_id }}-elb-target' -#lambda_role_name: '{{ resource_prefix }}-elb-target' -lambda_name: '{{ unique_id }}-elb-target' -elb_target_group_name: "{{ unique_id | truncate(8, True, '') }}-elb-tg" diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_target/defaults/main.yml b/tests/integration/targets/elb_target/playbooks/roles/elb_target/defaults/main.yml deleted file mode 100644 index 75204ee0b02..00000000000 --- a/tests/integration/targets/elb_target/playbooks/roles/elb_target/defaults/main.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -ec2_ami_name: 'amzn2-ami-hvm-2.0.20190612-x86_64-gp2' - -unique_id: "ansible-test-{{ resource_prefix | hash('md5') | truncate(8, True, '') }}" -tg_name: "{{ unique_id }}-tg" -tg_tcpudp_name: "{{ unique_id }}-tgtcpudp" -lb_name: "{{ unique_id }}-lb" - -healthy_state: - state: 'healthy' diff --git a/tests/integration/targets/elb_target/playbooks/version_fail.yml b/tests/integration/targets/elb_target/playbooks/version_fail.yml deleted file mode 100644 index 9149f593048..00000000000 --- a/tests/integration/targets/elb_target/playbooks/version_fail.yml +++ /dev/null @@ -1,41 +0,0 @@ -- hosts: localhost - connection: local - environment: "{{ ansible_test.environment }}" - - tasks: - - name: set up aws connection info - module_defaults: - group/aws: - aws_access_key: "{{ aws_access_key }}" - aws_secret_key: "{{ aws_secret_key }}" - security_token: "{{ security_token | default(omit) }}" - region: "{{ aws_region }}" - block: - - name: set up testing target group (type=ip) - elb_target_group: - state: present - #name: "{{ unique_id }}-tg" - name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-tg" - health_check_port: 80 - protocol: http - port: 80 - vpc_id: 'vpc-abcd1234' - target_type: ip - tags: - Description: "Created by {{ resource_prefix }}" - register: elb_target_group_type_ip - ignore_errors: yes - - - name: check that setting up target group with type=ip fails with friendly message - assert: - that: - - elb_target_group_type_ip is failed - - "'msg' in elb_target_group_type_ip" - - # In the off-chance that this went (partially) through when it shouldn't... - always: - - name: Remove testing target group (type=ip) - elb_target_group: - state: absent - #name: "{{ unique_id }}-tg" - name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-tg" diff --git a/tests/integration/targets/elb_target/runme.sh b/tests/integration/targets/elb_target/runme.sh deleted file mode 100755 index fe0850e46c9..00000000000 --- a/tests/integration/targets/elb_target/runme.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -# Test graceful failure for older versions of botocore -source virtualenv.sh -pip install 'botocore<=1.7.1' boto3 -ansible-playbook -i ../../inventory -v playbooks/version_fail.yml "$@" - -# Run full test suite -source virtualenv.sh -pip install 'botocore' 'boto3>=1.16.57' -ansible-playbook -i ../../inventory -v playbooks/full_test.yml "$@" diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_target/tasks/main.yml b/tests/integration/targets/elb_target/tasks/ec2_target.yml similarity index 97% rename from tests/integration/targets/elb_target/playbooks/roles/elb_target/tasks/main.yml rename to tests/integration/targets/elb_target/tasks/ec2_target.yml index 30a67cef93c..108ffa4d30b 100644 --- a/tests/integration/targets/elb_target/playbooks/roles/elb_target/tasks/main.yml +++ b/tests/integration/targets/elb_target/tasks/ec2_target.yml @@ -1,20 +1,11 @@ --- - - name: set up elb_target test prerequisites - module_defaults: - group/aws: - aws_access_key: "{{ aws_access_key }}" - aws_secret_key: "{{ aws_secret_key }}" - security_token: "{{ security_token | default(omit) }}" - region: "{{ aws_region }}" - collections: - - amazon.aws - + - name: set up ec2 based test prerequisites block: # ============================================================ - name: - debug: msg="********** Setting up elb_target test dependencies **********" + debug: msg="********** Setting up elb_target EC2 test dependencies **********" # ============================================================ - name: Find AMI to use diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/tasks/main.yml b/tests/integration/targets/elb_target/tasks/lambda_target.yml similarity index 92% rename from tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/tasks/main.yml rename to tests/integration/targets/elb_target/tasks/lambda_target.yml index fb310b848c5..8b7955ddbe3 100644 --- a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/tasks/main.yml +++ b/tests/integration/targets/elb_target/tasks/lambda_target.yml @@ -1,13 +1,6 @@ - name: set up lambda as elb_target - module_defaults: - group/aws: - aws_access_key: '{{ aws_access_key }}' - aws_secret_key: '{{ aws_secret_key }}' - security_token: '{{ security_token | default(omit) }}' - region: '{{ aws_region }}' - collections: - - community.general block: + - name: create zip to deploy lambda code archive: path: '{{ role_path }}/files/ansible_lambda_target.py' @@ -23,6 +16,7 @@ - name: when it is too fast, the role is not usable. pause: seconds: 10 + - name: deploy lambda.zip to ansible_lambda_target function lambda: name: '{{ lambda_name }}' @@ -36,6 +30,7 @@ retries: 3 delay: 15 until: lambda_function.changed + - name: create empty target group elb_target_group: name: '{{ elb_target_group_name }}' @@ -43,10 +38,12 @@ state: present modify_targets: false register: elb_target_group + - name: tg is created, state must be changed assert: that: - elb_target_group.changed + - name: allow elb to invoke the lambda function lambda_policy: state: present @@ -56,6 +53,7 @@ action: lambda:InvokeFunction principal: elasticloadbalancing.amazonaws.com source_arn: '{{ elb_target_group.target_group_arn }}' + - name: add lambda to elb target elb_target_group: name: '{{ elb_target_group_name }}' @@ -64,10 +62,12 @@ targets: - Id: '{{ lambda_function.configuration.function_arn }}' register: elb_target_group + - name: target is updated, state must be changed assert: that: - elb_target_group.changed + - name: re-add lambda to elb target (idempotency) elb_target_group: name: '{{ elb_target_group_name }}' @@ -76,10 +76,12 @@ targets: - Id: '{{ lambda_function.configuration.function_arn }}' register: elb_target_group + - name: target is still the same, state must not be changed (idempotency) assert: that: - not elb_target_group.changed + - name: remove lambda target from target group elb_target_group: name: '{{ elb_target_group_name }}' @@ -87,10 +89,12 @@ state: absent targets: [] register: elb_target_group + - name: target is still the same, state must not be changed (idempotency) assert: that: - elb_target_group.changed + always: - name: remove elb target group elb_target_group: @@ -98,11 +102,13 @@ target_type: lambda state: absent ignore_errors: true + - name: remove lambda function lambda: name: '{{ lambda_name }}' state: absent ignore_errors: true + - name: remove iam role for lambda iam_role: name: '{{ lambda_role_name }}' diff --git a/tests/integration/targets/elb_target/tasks/main.yml b/tests/integration/targets/elb_target/tasks/main.yml new file mode 100644 index 00000000000..e6c62f922d3 --- /dev/null +++ b/tests/integration/targets/elb_target/tasks/main.yml @@ -0,0 +1,13 @@ +--- +- name: set up elb_target test prerequisites + module_defaults: + group/aws: + aws_access_key: "{{ aws_access_key }}" + aws_secret_key: "{{ aws_secret_key }}" + security_token: "{{ security_token | default(omit) }}" + region: "{{ aws_region }}" + collections: + - amazon.aws + block: + - include_tasks: lambda_target.yml + - include_tasks: ec2_target.yml