Skip to content

Commit

Permalink
refactor test case
Browse files Browse the repository at this point in the history
  • Loading branch information
yec-akamai committed Sep 24, 2024
1 parent 7769e33 commit e64e1ee
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/integration/targets/image_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
- set_fact:
r: "{{ 1000000000 | random }}"

- name: List regions
linode.cloud.region_list: {}
register: all_regions

- set_fact:
capable_regions: '{{ (all_regions.regions | selectattr("capabilities", "search", "Object Storage") | selectattr("site_type", "equalto", "core") | map(attribute="id") | list) }}'

- name: Create an instance to image
linode.cloud.instance:
label: 'ansible-test-{{ r }}'
region: us-east
region: '{{ capable_regions[1] }}'
type: g6-standard-1
image: linode/alpine3.19
state: present
Expand Down Expand Up @@ -83,8 +90,8 @@
tags:
- 'test'
replica_regions:
- 'us-east'
- 'eu-west'
- '{{ capable_regions[0] }}'
- '{{ capable_regions[1] }}'
wait_for_replications: yes
wait_timeout: 1200
state: present
Expand All @@ -96,7 +103,8 @@
- image_replicate.changed
- image_replicate.image.id == image_create.image.id
- image_replicate.image.regions | length == 2
- image_replicate.image.regions[0].region == 'us-east'
- image_replicate.image.regions[0].region == capable_regions[1]
- image_replicate.image.regions[1].region == capable_regions[0]
- image_replicate.image.regions[0].status == 'available'
- image_replicate.image.regions[1].status == 'available'

Expand All @@ -108,7 +116,7 @@
tags:
- 'test'
replica_regions:
- 'eu-west'
- '{{ capable_regions[0] }}'
wait_for_replications: yes
wait_timeout: 1200
state: present
Expand All @@ -119,7 +127,7 @@
that:
- image_replicate.changed
- image_replicate.image.regions | length == 1
- image_replicate.image.regions[0].region == 'eu-west'
- image_replicate.image.regions[0].region == capable_regions[0]
- image_replicate.image.regions[0].status == 'available'

- name: Overwrite the image
Expand Down

0 comments on commit e64e1ee

Please sign in to comment.