diff --git a/tests/integration/targets/rds_instance/defaults/main.yml b/tests/integration/targets/rds_instance/defaults/main.yml deleted file mode 100644 index a2d215ba8af..00000000000 --- a/tests/integration/targets/rds_instance/defaults/main.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -instance_id: "{{ resource_prefix }}" -modified_instance_id: "{{ resource_prefix }}-updated" -username: test -password: test12345678 -db_instance_class: db.t2.micro -storage_encrypted_db_instance_class: db.t2.small -modified_db_instance_class: db.t2.medium -allocated_storage: 20 -modified_allocated_storage: 30 - -# For aurora tests -cluster_id: "{{ resource_prefix }}-cluster" -aurora_db_instance_class: db.t2.medium - -# For oracle tests -oracle_ee_db_instance_class: db.r3.xlarge -processor_features: - coreCount: 1 - threadsPerCore: 1 -modified_processor_features: - coreCount: 2 - threadsPerCore: 2 diff --git a/tests/integration/targets/rds_instance/inventory b/tests/integration/targets/rds_instance/inventory new file mode 100644 index 00000000000..8ae740d0181 --- /dev/null +++ b/tests/integration/targets/rds_instance/inventory @@ -0,0 +1,21 @@ +[tests] +credentials +states +tags +modification +bad_options +processor_features +encryption +final_snapshot +read_replica +vpc_security_groups +restore_instance +snapshot + +# TODO: uncomment after adding rds_cluster module +# aurora + + +[all:vars] +ansible_connection=local +ansible_python_interpreter="{{ ansible_playbook_python }}" diff --git a/tests/integration/targets/rds_instance/main.yml b/tests/integration/targets/rds_instance/main.yml new file mode 100644 index 00000000000..fc2c909ec11 --- /dev/null +++ b/tests/integration/targets/rds_instance/main.yml @@ -0,0 +1,11 @@ +--- +# Beware: most of our tests here are run in parallel. +# To add new tests you'll need to add a new host to the inventory and a matching +# '{{ inventory_hostname }}'.yml file in roles/rds_instance/tasks/ + +- hosts: all + gather_facts: no + strategy: free + serial: 5 + roles: + - rds_instance diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/defaults/main.yml b/tests/integration/targets/rds_instance/roles/rds_instance/defaults/main.yml new file mode 100644 index 00000000000..33760c64660 --- /dev/null +++ b/tests/integration/targets/rds_instance/roles/rds_instance/defaults/main.yml @@ -0,0 +1,28 @@ +--- +instance_id: "{{ resource_prefix }}-{{ inventory_hostname | replace('_','-') }}" +modified_instance_id: "{{ resource_prefix }}-updated" +username: test +password: test12345678 +db_instance_class: db.t3.micro +storage_encrypted_db_instance_class: db.t3.small +modified_db_instance_class: db.t3.medium +allocated_storage: 20 +modified_allocated_storage: 30 + +# For aurora tests +cluster_id: "{{ resource_prefix }}-cluster" +aurora_db_instance_class: db.t3.medium + +# For oracle tests +# Smallest instance that permits modification of the coreCount +oracle_ee_db_instance_class: db.r5.2xlarge +processor_features: + coreCount: 2 + threadsPerCore: 1 +modified_processor_features: + coreCount: 4 + threadsPerCore: 2 + +# For mariadb tests +mariadb_engine_version: 10.3.20 +mariadb_engine_version_2: 10.4.8 diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/main.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/main.yml new file mode 100644 index 00000000000..9131b872fa2 --- /dev/null +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/main.yml @@ -0,0 +1,14 @@ +--- +- name: 'rds_instance integration tests' + collections: + - amazon.aws + - community.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: + - include: './test_{{ inventory_hostname }}.yml' + #- include: ./test_restore_instance.yml # TODO: snapshot, s3 diff --git a/tests/integration/targets/rds_instance/tasks/test_aurora.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_aurora.yml similarity index 100% rename from tests/integration/targets/rds_instance/tasks/test_aurora.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_aurora.yml diff --git a/tests/integration/targets/rds_instance/tasks/test_bad_options.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_bad_options.yml similarity index 100% rename from tests/integration/targets/rds_instance/tasks/test_bad_options.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_bad_options.yml diff --git a/tests/integration/targets/rds_instance/tasks/credential_tests.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_credentials.yml similarity index 100% rename from tests/integration/targets/rds_instance/tasks/credential_tests.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_credentials.yml diff --git a/tests/integration/targets/rds_instance/tasks/test_encryption.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_encryption.yml similarity index 100% rename from tests/integration/targets/rds_instance/tasks/test_encryption.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_encryption.yml diff --git a/tests/integration/targets/rds_instance/tasks/test_final_snapshot.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_final_snapshot.yml similarity index 97% rename from tests/integration/targets/rds_instance/tasks/test_final_snapshot.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_final_snapshot.yml index 9ad56360932..922a008c353 100644 --- a/tests/integration/targets/rds_instance/tasks/test_final_snapshot.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_final_snapshot.yml @@ -58,4 +58,4 @@ id: "{{ instance_id }}" state: absent skip_final_snapshot: True - ignore_errors: yes + ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/tasks/test_modification.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modification.yml similarity index 93% rename from tests/integration/targets/rds_instance/tasks/test_modification.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modification.yml index fab7647af3e..03e49967cae 100644 --- a/tests/integration/targets/rds_instance/tasks/test_modification.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modification.yml @@ -1,4 +1,5 @@ --- + #TODO: test availability_zone and multi_az - block: - name: Ensure the resource doesn't exist @@ -18,7 +19,7 @@ id: "{{ instance_id }}" state: present engine: mariadb - engine_version: "10.1.26" + engine_version: "{{ mariadb_engine_version }}" username: "{{ username }}" password: "{{ password }}" db_instance_class: "{{ db_instance_class }}" @@ -108,7 +109,7 @@ backup_retention_period: 2 preferred_backup_window: "05:00-06:00" preferred_maintenance_window: "mon:06:20-mon:06:50" - engine_version: "10.2.21" + engine_version: "{{ mariadb_engine_version_2 }}" allow_major_version_upgrade: true auto_minor_version_upgrade: false port: 1150 @@ -122,8 +123,8 @@ - '"allocated_storage" in result.pending_modified_values or result.allocated_storage == 30' - '"max_allocated_storage" in result.pending_modified_values or result.max_allocated_storage == 100' - '"port" in result.pending_modified_values or result.endpoint.port == 1150' - - '"db_instance_class" in result.pending_modified_values or result.db_instance_class == "db.t2.medium"' - - '"engine_version" in result.pending_modified_values or result.engine_version == "10.2.21"' + - '"db_instance_class" in result.pending_modified_values or result.db_instance_class == modified_db_instance_class' + - '"engine_version" in result.pending_modified_values or result.engine_version == mariadb_engine_version_2' - name: Idempotence modifying several pending attributes rds_instance: @@ -134,7 +135,7 @@ backup_retention_period: 2 preferred_backup_window: "05:00-06:00" preferred_maintenance_window: "mon:06:20-mon:06:50" - engine_version: "10.2.21" + engine_version: "{{ mariadb_engine_version_2 }}" allow_major_version_upgrade: true auto_minor_version_upgrade: false port: 1150 @@ -150,8 +151,8 @@ - '"allocated_storage" in result.pending_modified_values or result.allocated_storage == 30' - '"max_allocated_storage" in result.pending_modified_values or result.max_allocated_storage == 100' - '"port" in result.pending_modified_values or result.endpoint.port == 1150' - - '"db_instance_class" in result.pending_modified_values or result.db_instance_class == "db.t2.medium"' - - '"engine_version" in result.pending_modified_values or result.engine_version == "10.2.21"' + - '"db_instance_class" in result.pending_modified_values or result.db_instance_class == modified_db_instance_class' + - '"engine_version" in result.pending_modified_values or result.engine_version == mariadb_engine_version_2' - name: Idempotence modifying several pending attributes - preferred_maintenance_window not lowercase rds_instance: diff --git a/tests/integration/targets/rds_instance/tasks/test_processor_features.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_processor_features.yml similarity index 100% rename from tests/integration/targets/rds_instance/tasks/test_processor_features.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_processor_features.yml diff --git a/tests/integration/targets/rds_instance/tasks/test_read_replica.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_read_replica.yml similarity index 99% rename from tests/integration/targets/rds_instance/tasks/test_read_replica.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_read_replica.yml index 01f15b8b3ca..20c3c74690b 100644 --- a/tests/integration/targets/rds_instance/tasks/test_read_replica.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_read_replica.yml @@ -55,6 +55,7 @@ tags: Name: "{{ instance_id }}" Created_by: Ansible rds_instance tests + wait: yes register: result - assert: diff --git a/tests/integration/targets/rds_instance/tasks/test_restore_instance.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_restore_instance.yml similarity index 98% rename from tests/integration/targets/rds_instance/tasks/test_restore_instance.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_restore_instance.yml index 8ca114fbcee..64a948211c3 100644 --- a/tests/integration/targets/rds_instance/tasks/test_restore_instance.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_restore_instance.yml @@ -1,5 +1,6 @@ --- - block: + # TODO: snapshot, s3 - name: Ensure the resource doesn't exist rds_instance: diff --git a/tests/integration/targets/rds_instance/tasks/test_snapshot.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_snapshot.yml similarity index 84% rename from tests/integration/targets/rds_instance/tasks/test_snapshot.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_snapshot.yml index de4c3edcc10..131f9753e88 100644 --- a/tests/integration/targets/rds_instance/tasks/test_snapshot.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_snapshot.yml @@ -69,4 +69,15 @@ that: - result.changed - # TODO ideally we test with an actual shared snapshot - but we'd need a second account - making tests fairly complicated? + # TODO ideally we test with an actual shared snapshot - but we'd need a second account - making tests fairly complicated? + + always: + + - name: Delete the instance + rds_instance: + id: "{{ item }}" + state: absent + skip_final_snapshot: True + loop: + - "{{ instance_id }}" + ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/tasks/test_states.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_states.yml similarity index 100% rename from tests/integration/targets/rds_instance/tasks/test_states.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_states.yml diff --git a/tests/integration/targets/rds_instance/tasks/test_tags.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_tags.yml similarity index 100% rename from tests/integration/targets/rds_instance/tasks/test_tags.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_tags.yml diff --git a/tests/integration/targets/rds_instance/tasks/test_vpc_security_groups.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_vpc_security_groups.yml similarity index 100% rename from tests/integration/targets/rds_instance/tasks/test_vpc_security_groups.yml rename to tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_vpc_security_groups.yml diff --git a/tests/integration/targets/rds_instance/runme.sh b/tests/integration/targets/rds_instance/runme.sh new file mode 100755 index 00000000000..aa324772bbe --- /dev/null +++ b/tests/integration/targets/rds_instance/runme.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# +# Beware: most of our tests here are run in parallel. +# To add new tests you'll need to add a new host to the inventory and a matching +# '{{ inventory_hostname }}'.yml file in roles/ec2_instance/tasks/ + + +set -eux + +export ANSIBLE_ROLES_PATH=../ + +ansible-playbook main.yml -i inventory "$@" diff --git a/tests/integration/targets/rds_instance/tasks/main.yml b/tests/integration/targets/rds_instance/tasks/main.yml deleted file mode 100644 index e56dc896478..00000000000 --- a/tests/integration/targets/rds_instance/tasks/main.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- name: 'rds_instance integration 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: - - include: ./credential_tests.yml - tags: credentials - - include: ./test_states.yml - tags: states - - include: ./test_tags.yml - tags: tags - - include: ./test_modification.yml # TODO: test availability_zone and multi_az - tags: modification - - include: ./test_bad_options.yml - tags: bad_options - - include: ./test_processor_features.yml - tags: processor_features - - include: ./test_encryption.yml - tags: encryption - - include: ./test_final_snapshot.yml - tags: final_snapshot - - include: ./test_read_replica.yml - tags: read_replica - - include: ./test_vpc_security_groups.yml - tags: vpc_security_groups - - include: ./test_restore_instance.yml # TODO: snapshot, s3 - tags: restore - - include: ./test_snapshot.yml - tags: snapshot - # TODO: uncomment after adding rds_cluster module - #- include: ./test_aurora.yml