Skip to content

Commit

Permalink
aws_az_info tests don't need anything beyond what we normally support
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Aug 5, 2021
1 parent a751b16 commit 6cb8497
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 209 deletions.
209 changes: 183 additions & 26 deletions tests/integration/targets/aws_az_info/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,183 @@
- set_fact:
virtualenv: "{{ remote_tmp_dir }}/virtualenv"
virtualenv_command: "{{ ansible_python_interpreter }} -m virtualenv"

- set_fact:
virtualenv_interpreter: "{{ virtualenv }}/bin/python"

- pip:
name: virtualenv

- pip:
name:
- 'botocore>=1.13.0'
- boto3
- coverage<5
virtualenv: "{{ virtualenv }}"
virtualenv_command: "{{ virtualenv_command }}"
virtualenv_site_packages: no

- include_tasks: tests.yml
vars:
ansible_python_interpreter: "{{ virtualenv_interpreter }}"

- file:
path: "{{ virtualenv }}"
state: absent
---
- module_defaults:
group/aws:
aws_access_key: '{{ aws_access_key | default(omit) }}'
aws_secret_key: '{{ aws_secret_key | default(omit) }}'
security_token: '{{ security_token | default(omit) }}'
region: '{{ aws_region | default(omit) }}'

block:
- name: 'List available AZs in current Region'
aws_az_info:
register: region_azs

- name: check task return attributes
vars:
first_az: '{{ region_azs.availability_zones[0] }}'
assert:
that:
- region_azs is successful
- '"availability_zones" in region_azs'
- '"group_name" in first_az'
- '"messages" in first_az'
- '"network_border_group" in first_az'
- '"opt_in_status" in first_az'
- '"region_name" in first_az'
- '"state" in first_az'
- '"zone_id" in first_az'
- '"zone_name" in first_az'
- '"zone_type" in first_az'

- name: 'List available AZs in current Region - check_mode'
aws_az_info:
check_mode: yes
register: check_azs

- name: check task return attributes
vars:
first_az: '{{ check_azs.availability_zones[0] }}'
assert:
that:
- check_azs is successful
- '"availability_zones" in check_azs'
- '"group_name" in first_az'
- '"messages" in first_az'
- '"network_border_group" in first_az'
- '"opt_in_status" in first_az'
- '"region_name" in first_az'
- '"state" in first_az'
- '"zone_id" in first_az'
- '"zone_name" in first_az'
- '"zone_type" in first_az'


# Be specific - aws_region isn't guaranteed to be any specific value
- name: 'List Available AZs in us-east-1'
aws_az_info:
region: 'us-east-1'
register: us_east_1

- name: 'Check that an AZ from us-east-1 has valid looking attributes'
vars:
first_az: '{{ us_east_1.availability_zones[0] }}'
assert:
that:
- us_east_1 is successful
- '"availability_zones" in us_east_1'
- '"group_name" in first_az'
- '"messages" in first_az'
- '"network_border_group" in first_az'
- '"opt_in_status" in first_az'
- '"region_name" in first_az'
- '"state" in first_az'
- '"zone_id" in first_az'
- '"zone_name" in first_az'
- '"zone_type" in first_az'
- first_az.group_name.startswith('us-east-1')
- first_az.network_border_group.startswith('us-east-1')
- first_az.region_name == 'us-east-1'
- first_az.zone_id.startswith('use1-az')
- not first_az.zone_id == "use1-az"
- first_az.zone_name.startswith('us-east-1')
- not first_az.zone_name == 'us-east-1'
- first_az.zone_type == 'availability-zone'

- name: 'Filter Available AZs in us-west-2 using - ("zone-name")'
aws_az_info:
region: 'us-west-2'
filters:
zone-name: 'us-west-2c'
register: us_west_2

- name: 'Check that an AZ from us-west-2 has attributes we expect'
vars:
first_az: '{{ us_west_2.availability_zones[0] }}'
assert:
that:
- us_west_2 is successful
- '"availability_zones" in us_west_2'
- us_west_2.availability_zones | length == 1
- '"group_name" in first_az'
- '"messages" in first_az'
- '"network_border_group" in first_az'
- '"opt_in_status" in first_az'
- '"region_name" in first_az'
- '"state" in first_az'
- '"zone_id" in first_az'
- '"zone_name" in first_az'
- '"zone_type" in first_az'
- first_az.group_name == 'us-west-2'
- first_az.network_border_group == 'us-west-2'
- first_az.region_name == 'us-west-2'
# AZs are mapped to the 'real' AZs on a per-account basis
- first_az.zone_id.startswith('usw2-az')
- not first_az.zone_id == 'usw2-az'
- first_az.zone_name == 'us-west-2c'
- first_az.zone_type == 'availability-zone'

- name: 'Filter Available AZs in eu-central-1 using _ ("zone_name")'
aws_az_info:
region: 'eu-central-1'
filters:
zone_name: 'eu-central-1b'
register: eu_central_1

- name: 'Check that eu-central-1b has the attributes we expect'
vars:
first_az: '{{ eu_central_1.availability_zones[0] }}'
assert:
that:
- eu_central_1 is successful
- '"availability_zones" in eu_central_1'
- eu_central_1.availability_zones | length == 1
- '"group_name" in first_az'
- '"messages" in first_az'
- '"network_border_group" in first_az'
- '"opt_in_status" in first_az'
- '"region_name" in first_az'
- '"state" in first_az'
- '"zone_id" in first_az'
- '"zone_name" in first_az'
- '"zone_type" in first_az'
- first_az.group_name == 'eu-central-1'
- first_az.network_border_group == 'eu-central-1'
- first_az.region_name == 'eu-central-1'
# AZs are mapped to the 'real' AZs on a per-account basis
- first_az.zone_id.startswith('euc1-az')
- not first_az.zone_id == "euc1-az"
- first_az.zone_name == 'eu-central-1b'
- first_az.zone_type == 'availability-zone'

- name: 'Filter Available AZs in eu-west-2 using _ and - ("zone_name" and "zone-name") : _ wins '
aws_az_info:
region: 'eu-west-2'
filters:
zone-name: 'eu-west-2a'
zone_name: 'eu-west-2c'
register: eu_west_2

- name: 'Check that we get the AZ specified by zone_name rather than zone-name'
vars:
first_az: '{{ eu_west_2.availability_zones[0] }}'
assert:
that:
- eu_west_2 is successful
- '"availability_zones" in eu_west_2'
- eu_west_2.availability_zones | length == 1
- '"group_name" in first_az'
- '"messages" in first_az'
- '"network_border_group" in first_az'
- '"opt_in_status" in first_az'
- '"region_name" in first_az'
- '"state" in first_az'
- '"zone_id" in first_az'
- '"zone_name" in first_az'
- '"zone_type" in first_az'
- first_az.group_name == 'eu-west-2'
- first_az.network_border_group == 'eu-west-2'
- first_az.region_name == 'eu-west-2'
# AZs are mapped to the 'real' AZs on a per-account basis
- first_az.zone_id.startswith('euw2-az')
- not first_az.zone_id == "euw2-az"
- first_az.zone_name == 'eu-west-2c'
- first_az.zone_type == 'availability-zone'
183 changes: 0 additions & 183 deletions tests/integration/targets/aws_az_info/tasks/tests.yml

This file was deleted.

0 comments on commit 6cb8497

Please sign in to comment.