Skip to content

Commit

Permalink
test: refactor all integration tests for consistency (#490)
Browse files Browse the repository at this point in the history
* refactor all integration tests for consistency and fix some intermittent failures

* missed couple

* update gitsubmodule
  • Loading branch information
ykim-akamai authored Apr 4, 2024
1 parent 6e81059 commit 7767904
Show file tree
Hide file tree
Showing 63 changed files with 461 additions and 271 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
- name: account_availability_info
block:
- name: Get info about the current account availability
- name: GET account_availability_info request
linode.cloud.account_availability_info:
region: us-east
register: account_availability

- assert:
- name: Assert GET account_availability_info response
assert:
that:
- account_availability.account_availability.region == "us-east"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
- name: account_availability_list
block:
- linode.cloud.account_availability_list:
- name: GET account_availability_list request w no filter
linode.cloud.account_availability_list:
count: 5
register: no_filter

- assert:
- name: Assert GET account_availability_list response w no filter
assert:
that:
- no_filter.account_availabilities | length == 5

Expand Down
29 changes: 19 additions & 10 deletions tests/integration/targets/api_request_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
- name: api_request_baisc
- name: api_request_basic
block:
- set_fact:
r: "{{ 1000000000 | random }}"

- linode.cloud.api_request:
- name: GET api_request request
linode.cloud.api_request:
# Arbitrary authorized endpoint
path: lke/versions
method: GET
register: response_get

- assert:
- name: Assert GET api_request response
assert:
that:
- response_get.status == 200
- response_get.changed == False

- linode.cloud.api_request:
- name: POST api_request request
linode.cloud.api_request:
path: domains
method: POST
body:
Expand All @@ -23,38 +26,44 @@
soa_email: [email protected]
register: response_post

- assert:
- name: Assert POST api_request response
assert:
that:
- response_post.status == 200
- response_post.changed == True

- linode.cloud.api_request:
- name: PUT api_request request
linode.cloud.api_request:
path: 'domains/{{ response_post.body.id }}'
method: PUT
body:
description: cool
register: response_put

- assert:
- name: Assert PUT api_request response
assert:
that:
- response_put.status == 200
- response_put.changed == True
- response_put.body.description == 'cool'

- linode.cloud.api_request:
- name: PUT api_request request (negative case)
linode.cloud.api_request:
path: 'reallycoolfakepath'
method: PUT
register: response_failed
failed_when: response_failed.failed == False
always:
- ignore_errors: yes
block:
- linode.cloud.api_request:
- name: DELETE api_request request
linode.cloud.api_request:
path: 'domains/{{ response_post.body.id }}'
method: DELETE
register: response_delete

- assert:
- name: Assert DELETE api_request response
assert:
that:
- response_delete.status == 200
- response_delete.changed == True
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/targets/api_request_extra/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
- set_fact:
r: "{{ 1000000000 | random }}"

- name: List all available Linode regions
- name: GET region_list request
linode.cloud.region_list:
register: regions

- name: Create a volume by the api_request module
- name: POST volume request
linode.cloud.api_request:
path: "/volumes"
method: POST
Expand All @@ -29,7 +29,7 @@
always:
- ignore_errors: true
block:
- name: Delete the volume
- name: DELETE volume request
linode.cloud.volume:
label: '{{ response.body.label }}'
state: absent
Expand All @@ -38,7 +38,7 @@
retries: 5
delay: 10

- name: Assert the volume was deleted
- name: Assert volume deleted
assert:
that:
- delete_volume.changed
Expand Down
10 changes: 6 additions & 4 deletions tests/integration/targets/database_engine_list/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
- name: database_engine_list
block:
- name: List database engines with no filter
- name: List database_engine_list with no filter
linode.cloud.database_engine_list:
register: no_filter

- assert:
- name: Assert database_engine_list with no filter
assert:
that:
- no_filter.database_engines | length >= 1

- name: List database engines with filter on engine
- name: List database_engine_list with filter on engine
linode.cloud.database_engine_list:
filters:
- name: engine
values: mysql
register: filter

- assert:
- name: Assert List database_engine_list with filter on engine
assert:
that:
- filter.database_engines | length >= 1
- filter.database_engines[0].engine == 'mysql'
Expand Down
19 changes: 11 additions & 8 deletions tests/integration/targets/domain_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- set_fact:
r: "{{ 1000000000 | random }}"

- name: Create a domain
- name: Create domain
linode.cloud.domain:
description: 'really cool domain'
domain: 'ansible-test-domain-{{ r }}.com'
Expand All @@ -19,7 +19,8 @@
state: present
register: create

- assert:
- name: Assert domain is created
assert:
that:
- create.domain.description == 'really cool domain'
- create.domain.expire_sec == 300
Expand All @@ -31,7 +32,7 @@
- create.domain.ttl_sec == 14400
- create.domain.type == 'master'

- name: Update a domain
- name: Update domain label
linode.cloud.domain:
description: 'really cool'
domain: '{{ create.domain.domain }}'
Expand All @@ -47,7 +48,8 @@
state: present
register: update

- assert:
- name: Assert domain is updated
assert:
that:
- update.domain.description == 'really cool'
- update.domain.expire_sec == 14400
Expand All @@ -59,12 +61,13 @@
- update.domain.ttl_sec == 604800
- update.domain.type == 'slave'

- name: Get domain info
- name: Get domain_info
linode.cloud.domain_info:
domain: '{{ create.domain.domain }}'
register: info

- assert:
- name: Assert domain_info response
assert:
that:
- info.domain.description == 'really cool'
- info.domain.expire_sec == 14400
Expand All @@ -79,13 +82,13 @@
always:
- ignore_errors: yes
block:
- name: Delete the domain
- name: Delete domain
linode.cloud.domain:
domain: '{{ create.domain.domain }}'
state: absent
register: delete

- name: Assert domain delete succeeded
- name: Assert domain is deleted
assert:
that:
- delete.changed
Expand Down
18 changes: 10 additions & 8 deletions tests/integration/targets/domain_list/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- set_fact:
r: "{{ 1000000000 | random }}"

- name: Create a domain
- name: Create domain
linode.cloud.domain:
description: 'really cool domain'
domain: 'ansible-test-domain-{{ r }}.com'
Expand All @@ -19,7 +19,7 @@
state: present
register: create

- name: Assert domain created
- name: Assert domain is created
assert:
that:
- create.domain.description == 'really cool domain'
Expand All @@ -32,15 +32,16 @@
- create.domain.ttl_sec == 14400
- create.domain.type == 'master'

- name: List domains with no filter
- name: List domain_list with no filter
linode.cloud.domain_list:
register: no_filter

- assert:
- name: Assert domain_list with no filter
assert:
that:
- no_filter.domains | length >= 1

- name: List domains with filter on domain
- name: List domain_list with filter on domain
linode.cloud.domain_list:
order_by: created
order: desc
Expand All @@ -49,20 +50,21 @@
values: ansible-test-domain-{{ r }}.com
register: filter

- assert:
- name: Assert domain_list with filter on domain
assert:
that:
- filter.domains | length >= 1
- filter.domains[0].domain == 'ansible-test-domain-{{ r }}.com'
always:
- ignore_errors: yes
block:
- name: Delete the domain
- name: Delete domain
linode.cloud.domain:
domain: '{{ create.domain.domain }}'
state: absent
register: delete

- name: Assert domain delete succeeded
- name: Assert domain is deleted
assert:
that:
- delete.changed
Expand Down
Loading

0 comments on commit 7767904

Please sign in to comment.