ansible/test/integration/targets/aws_api_gateway/tasks/main.yml
Matt Martz 4fe08441be Deprecate tests used as filters (#32361)
* Warn on tests used as filters

* Update docs, add aliases for tests that fit more gramatically with test syntax

* Fix rst formatting

* Add successful filter, alias of success

* Remove renamed_deprecation, it was overkill

* Make directory alias for is_dir

* Update tests to use proper jinja test syntax

* Update additional documentation, living outside of YAML files, to reflect proper jinja test syntax

* Add conversion script, porting guide updates, and changelog updates

* Update newly added uses of tests as filters

* No underscore variable

* Convert recent tests as filter changes to win_stat

* Fix some changes related to rebasing a few integration tests

* Make tests_as_filters_warning explicitly accept the name of the test, instead of inferring the name

* Add test for tests_as_filters_warning

* Update tests as filters in newly added/modified tests

* Address recent changes to several integration tests

* Address recent changes in cs_vpc
2017-11-27 17:58:08 -05:00

182 lines
6 KiB
YAML

- block:
# ============================================================
- name: test with no parameters
aws_api_gateway:
register: result
ignore_errors: true
- name: assert failure when called with no parameters
assert:
that:
- 'result.failed'
- 'result.msg.startswith("The aws_api_gateway module requires a region")'
# ============================================================
- name: test with minimal parameters but no region
aws_api_gateway:
api_id: 'fake-api-doesnt-exist'
register: result
ignore_errors: true
- name: assert failure when called with with minimal parameters but no region
assert:
that:
- 'result.failed'
- 'result.msg.startswith("The aws_api_gateway module requires a region")'
# ============================================================
- name: test disallow multiple swagger sources
aws_api_gateway:
api_id: 'fake-api-doesnt-exist'
region: 'fake_region'
swagger_file: foo.yml
swagger_text: "this is not really an API"
register: result
ignore_errors: true
- name: assert failure when called with with minimal parameters but no region
assert:
that:
- 'result.failed'
- 'result.msg.startswith("parameters are mutually exclusive")'
# This fails with
# msg": "There is an issue in the code of the module. You must
# specify either both, resource or client to the conn_type
# parameter in the boto3_conn function call"
# even though the call appears to include conn_type='client'
# # ============================================================
# - name: test invalid region parameter
# aws_api_gateway:
# api_id: 'fake-api-doesnt-exist'
# region: 'asdf querty 1234'
# register: result
# ignore_errors: true
# - name: assert invalid region parameter
# assert:
# that:
# - 'result.failed'
# - 'result.msg.startswith("Region asdf querty 1234 does not seem to be available ")'
# ============================================================
- name: build API file
template:
src: minimal-swagger-api.yml.j2
dest: "{{output_dir}}/minimal-swagger-api.yml"
tags: new_api,api,api_file
- name: deploy new API
aws_api_gateway:
api_file: "{{output_dir}}/minimal-swagger-api.yml"
stage: "minimal"
region: '{{ec2_region}}'
aws_access_key: '{{ec2_access_key}}'
aws_secret_key: '{{ec2_secret_key}}'
security_token: '{{security_token}}'
register: create_result
- name: assert deploy new API worked
assert:
that:
- 'create_result.changed == True'
- '"api_id" in create_result'
# - '"created_response.created_date" in create_result'
# - '"deploy_response.created_date" in create_result'
- name: check API works
uri: url="https://{{create_result.api_id}}.execute-api.{{ec2_region}}.amazonaws.com/minimal"
register: uri_result
- name: assert API works success
assert:
that:
- 'uri_result'
- name: check nonexistent endpoints cause errors
uri: url="https://{{create_result.api_id}}.execute-api.{{ec2_region}}.amazonaws.com/nominal"
register: bad_uri_result
ignore_errors: true
- name: assert
assert:
that:
- bad_uri_result is failed
# ============================================================
- name: deploy first API
aws_api_gateway:
api_file: "{{output_dir}}/minimal-swagger-api.yml"
stage: "minimal"
region: '{{ec2_region}}'
aws_access_key: '{{ec2_access_key}}'
aws_secret_key: '{{ec2_secret_key}}'
security_token: '{{security_token}}'
register: create_result_1
- name: deploy second API rapidly after first
aws_api_gateway:
api_file: "{{output_dir}}/minimal-swagger-api.yml"
stage: "minimal"
region: '{{ec2_region}}'
aws_access_key: '{{ec2_access_key}}'
aws_secret_key: '{{ec2_secret_key}}'
security_token: '{{security_token}}'
register: create_result_2
- name: assert both APIs deployed successfully
assert:
that:
- 'create_result_1.changed == True'
- 'create_result_2.changed == True'
- '"api_id" in create_result_1'
- '"api_id" in create_result_1'
# - '"created_response.created_date" in create_result'
# - '"deploy_response.created_date" in create_result'
- name: destroy first API
aws_api_gateway:
state: absent
api_id: '{{create_result_1.api_id}}'
region: '{{ec2_region}}'
aws_access_key: '{{ec2_access_key}}'
aws_secret_key: '{{ec2_secret_key}}'
security_token: '{{security_token}}'
register: destroy_result_1
- name: destroy second API rapidly after first
aws_api_gateway:
state: absent
api_id: '{{create_result_2.api_id}}'
region: '{{ec2_region}}'
aws_access_key: '{{ec2_access_key}}'
aws_secret_key: '{{ec2_secret_key}}'
security_token: '{{security_token}}'
register: destroy_result_2
- name: assert both APIs deployed successfully
assert:
that:
- 'destroy_result_1.changed == True'
- 'destroy_result_2.changed == True'
# - '"created_response.created_date" in create_result'
# - '"deploy_response.created_date" in create_result'
always:
# ============================================================
- name: test state=absent (expect changed=false)
aws_api_gateway:
state: absent
api_id: '{{create_result.api_id}}'
ec2_region: '{{ec2_region}}'
aws_access_key: '{{ec2_access_key}}'
aws_secret_key: '{{ec2_secret_key}}'
security_token: '{{security_token}}'
register: destroy_result