Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop support of community.general for integration testing #361

Merged
merged 3 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- integration tests - remove dependency with collection ``community.general`` (https://github.com/ansible-collections/amazon.aws/pull/361).
8 changes: 4 additions & 4 deletions tests/integration/targets/ec2_eni/tasks/test_deletion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- result.changed
- result.interface is undefined
- '"network_interfaces" in eni_info'
- eni_id_1 not in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- eni_id_1 not in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )

- name: test removing the network interface by ID is idempotent
ec2_eni:
Expand Down Expand Up @@ -53,7 +53,7 @@
- result.changed
- result.interface is undefined
- '"network_interfaces" in eni_info'
- eni_id_2 not in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- eni_id_2 not in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )

- name: test removing the network interface by name is idempotent
ec2_eni:
Expand Down Expand Up @@ -88,5 +88,5 @@
assert:
that:
- '"network_interfaces" in eni_info'
- eni_id_1 not in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- eni_id_2 not in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- eni_id_1 not in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )
- eni_id_2 not in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
- _interface_0.private_ip_address == ip_1
- '"private_ip_addresses" in _interface_0'
- _interface_0.private_ip_addresses | length == 1
- ip_1 in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- ip_1 in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
- '"requester_id" in _interface_0'
- _interface_0.requester_id is string
- '"requester_managed" in _interface_0'
Expand Down Expand Up @@ -156,7 +156,7 @@
- _interface_0.private_ip_address == ip_5
- '"private_ip_addresses" in _interface_0'
- _interface_0.private_ip_addresses | length == 1
- ip_5 in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- ip_5 in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
- '"requester_id" in _interface_0'
- _interface_0.requester_id is string
- '"requester_managed" in _interface_0'
Expand All @@ -181,8 +181,8 @@
that:
- '"network_interfaces" in eni_info'
- eni_info.network_interfaces | length >= 2
- eni_id_1 in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- eni_id_2 in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- eni_id_1 in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )
- eni_id_2 in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )

# ============================================================
# Run some VPC filter based tests of ec2_eni_info
Expand All @@ -199,8 +199,8 @@
that:
- '"network_interfaces" in eni_info'
- eni_info.network_interfaces | length == 2
- eni_id_1 in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- eni_id_2 in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- eni_id_1 in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )
- eni_id_2 in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )

- name: Fetch ENI info with VPC filters - VPC
ec2_eni_info:
Expand All @@ -213,7 +213,7 @@
that:
- '"network_interfaces" in eni_info'
- eni_info.network_interfaces | length == 4
- eni_id_1 in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- eni_id_2 in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- ec2_ips[0] in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- ec2_ips[1] in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- eni_id_1 in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )
- eni_id_2 in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )
- ec2_ips[0] in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
- ec2_ips[1] in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- result.interface.id == eni_id_1
- result.interface.private_ip_addresses | length == 3
- _interface_0.private_ip_addresses | length == 3
- ip_1 in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- ip_1 in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
vars:
_interface_0: '{{ eni_info.network_interfaces[0] }}'

Expand All @@ -40,7 +40,7 @@
- result.interface.id == eni_id_1
- result.interface.private_ip_addresses | length == 3
- _interface_0.private_ip_addresses | length == 3
- ip_1 in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- ip_1 in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
vars:
_interface_0: '{{ eni_info.network_interfaces[0] }}'

Expand All @@ -64,7 +64,7 @@
- result.interface.id == eni_id_1
- result.interface.private_ip_addresses | length == 3
- _interface_0.private_ip_addresses | length == 3
- ip_1 in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- ip_1 in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
vars:
_interface_0: '{{ eni_info.network_interfaces[0] }}'

Expand Down Expand Up @@ -106,7 +106,7 @@
- new_secondary_ip in _private_ips
vars:
_interface_0: '{{ eni_info.network_interfaces[0] }}'
_private_ips: '{{ eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list }}'
_private_ips: "{{ eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list }}"

# ============================================================
- name: remove secondary address
Expand All @@ -128,7 +128,7 @@
- result.interface.id == eni_id_1
- result.interface.private_ip_addresses | length == 1
- _interface_0.private_ip_addresses | length == 1
- ip_1 in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- ip_1 in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
vars:
_interface_0: '{{ eni_info.network_interfaces[0] }}'

Expand All @@ -152,7 +152,7 @@
- result.interface.private_ip_addresses | length == 1
- result.interface.private_ip_addresses | length == 1
- _interface_0.private_ip_addresses | length == 1
- ip_1 in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- ip_1 in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
vars:
_interface_0: '{{ eni_info.network_interfaces[0] }}'

Expand All @@ -177,8 +177,8 @@
- result.interface.id == eni_id_2
- result.interface.private_ip_addresses | length == 2
- _interface_0.private_ip_addresses | length == 2
- ip_5 in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- ip_4 in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- ip_5 in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
- ip_4 in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
vars:
_interface_0: '{{ eni_info.network_interfaces[0] }}'

Expand Down Expand Up @@ -262,6 +262,6 @@
that:
- result.changed
- _interface_0.private_ip_addresses | length == 1
- ip_1 in ( eni_info | community.general.json_query("network_interfaces[].private_ip_addresses[].private_ip_address") | list )
- ip_1 in ( eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list )
vars:
_interface_0: '{{ eni_info.network_interfaces[0] }}'
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
- not result.changed
- '"network_interfaces" in eni_info'
- eni_info.network_interfaces | length >= 1
- eni_id_1 not in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- eni_id_2 in ( eni_info | community.general.json_query("network_interfaces[].id") | list )
- eni_id_1 not in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )
- eni_id_2 in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )

# ============================================================

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/targets/ec2_snapshot/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
that:
- result is changed
- info_result.snapshots| length == 2
- '"{{ result.snapshot_id }}" in "{{ info_result| community.general.json_query("snapshots[].snapshot_id") }}"'
- result.snapshot_id in ( info_result.snapshots | map(attribute='snapshot_id') | list )

# JR: Check mode not supported
# - name: Take snapshot with a tag (check mode)
Expand Down Expand Up @@ -296,7 +296,7 @@
- assert:
that:
- info_result.snapshots| length == 7
- '"{{ tagged_snapshot_id }}" not in "{{ info_result| community.general.json_query("snapshots[].snapshot_id") }}"'
- tagged_snapshot_id not in ( info_result.snapshots | map(attribute='snapshot_id') | list )

- name: Delete snapshots
ec2_snapshot:
Expand Down
25 changes: 11 additions & 14 deletions tests/integration/targets/ec2_vpc_dhcp_option/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
security_token: "{{ security_token | default('') }}"
region: "{{ aws_region }}"

collections:
- community.general

block:

# DHCP option set can be attached to multiple VPCs, we don't want to use any that
Expand All @@ -26,7 +23,7 @@
register: result

- set_fact:
preexisting_option_sets: "{{ result | community.general.json_query('dhcp_options[*].dhcp_options_id') | list }}"
preexisting_option_sets: "{{ result.dhcp_options | map(attribute='dhcp_options_id') | list }}"

- name: create a VPC with a default DHCP option set to test inheritance and delete_old
ec2_vpc_net:
Expand Down Expand Up @@ -183,8 +180,8 @@
- dhcp_options.new_options['domain-name'] == ['{{ aws_domain_name }}']
- dhcp_options.new_options['domain-name-servers'] == ['AmazonProvidedDNS']
# We return the list of dicts that boto gives us, in addition to the user-friendly config dict
- dhcp_options_config['ntp-servers'] | community.general.json_query('[*].value') | list | sort == ['10.0.0.2', '10.0.1.2']
- dhcp_options_config['netbios-name-servers'] | community.general.json_query('[*].value') | list | sort == ['10.0.0.1', '10.0.1.1']
- dhcp_options_config['ntp-servers'] | map(attribute='value') | list | sort == ['10.0.0.2', '10.0.1.2']
- dhcp_options_config['netbios-name-servers'] | map(attribute='value') | list | sort == ['10.0.0.1', '10.0.1.1']
- dhcp_options_config['netbios-node-type'][0]['value'] == '2'
- dhcp_options_config['domain-name'][0]['value'] == '{{ aws_domain_name }}'
- dhcp_options_config['domain-name-servers'][0]['value'] == 'AmazonProvidedDNS'
Expand All @@ -206,8 +203,8 @@
- new_config.keys() | list | sort == ['domain-name', 'domain-name-servers', 'netbios-name-servers', 'netbios-node-type', 'ntp-servers']
- new_config['domain-name'][0]['value'] == '{{ aws_domain_name }}'
- new_config['domain-name-servers'][0]['value'] == 'AmazonProvidedDNS'
- new_config['ntp-servers'] | community.general.json_query('[*].value') | list | sort == ['10.0.0.2', '10.0.1.2']
- new_config['netbios-name-servers'] | community.general.json_query('[*].value') | list | sort == ['10.0.0.1', '10.0.1.1']
- new_config['ntp-servers'] | map(attribute='value') | list | sort == ['10.0.0.2', '10.0.1.2']
- new_config['netbios-name-servers'] | map(attribute='value') | list | sort == ['10.0.0.1', '10.0.1.1']
- new_config['netbios-node-type'][0]['value'] == '2'
# We return the list of dicts that boto gives us, in addition to the user-friendly config dict
- new_dhcp_options.dhcp_config[0]['ntp-servers'] | sort == ['10.0.0.2', '10.0.1.2']
Expand Down Expand Up @@ -305,8 +302,8 @@
- assert:
that:
- new_config.keys() | list | sort == ['netbios-name-servers', 'netbios-node-type', 'ntp-servers']
- new_config['ntp-servers'] | community.general.json_query('[*].value') | list | sort == ['10.0.0.2', '10.0.1.2']
- new_config['netbios-name-servers'] | community.general.json_query('[*].value') | list | sort == ['10.0.0.1', '10.0.1.1']
- new_config['ntp-servers'] | map(attribute='value') | list | sort == ['10.0.0.2', '10.0.1.2']
- new_config['netbios-name-servers'] | map(attribute='value') | list | sort == ['10.0.0.1', '10.0.1.1']
- new_config['netbios-node-type'][0]['value'] == '2'

- name: disassociate the new DHCP option set so it can be deleted
Expand Down Expand Up @@ -384,8 +381,8 @@
that:
- new_config.keys() | list | sort == ['domain-name', 'domain-name-servers', 'netbios-name-servers', 'netbios-node-type', 'ntp-servers']
- new_config['domain-name'][0]['value'] == '{{ aws_domain_name }}'
- new_config['ntp-servers'] | community.general.json_query('[*].value') | list | sort == ['10.0.0.2', '10.0.1.2']
- new_config['netbios-name-servers'] | community.general.json_query('[*].value') | list | sort == ['10.0.0.1', '10.0.1.1']
- new_config['ntp-servers'] | map(attribute='value') | list | sort == ['10.0.0.2', '10.0.1.2']
- new_config['netbios-name-servers'] | map(attribute='value') | list | sort == ['10.0.0.1', '10.0.1.1']
- new_config['netbios-node-type'][0]['value'] == '1'

- name: verify the original set was deleted
Expand Down Expand Up @@ -533,8 +530,8 @@
- dhcp_options.new_options['netbios-name-servers'] | sort == ['10.0.0.1', '10.0.1.1']
- original_dhcp_options_id != dhcp_options.dhcp_options_id
# We return the list of dicts that boto gives us, in addition to the user-friendly config dict
- dhcp_options_config['ntp-servers'] | community.general.json_query('[*].value') | list | sort == ['10.0.0.2', '10.0.1.2']
- dhcp_options_config['netbios-name-servers'] | community.general.json_query('[*].value') | list | sort == ['10.0.0.1', '10.0.1.1']
- dhcp_options_config['ntp-servers'] | map(attribute='value') | list | sort == ['10.0.0.2', '10.0.1.2']
- dhcp_options_config['netbios-name-servers'] | map(attribute='value') | list | sort == ['10.0.0.1', '10.0.1.1']
- dhcp_options.dhcp_options.tags.keys() | length == 2
- dhcp_options.dhcp_options.tags['CreatedBy'] == 'ansible-test'
- dhcp_options.dhcp_options.tags['Collection'] == 'amazon.aws'
Expand Down
Loading