Skip to content

Commit

Permalink
Merge pull request #51 from LBGarber/refactor-tests
Browse files Browse the repository at this point in the history
Refactor integration tests
  • Loading branch information
0xch4z authored Jun 25, 2021
2 parents 45d0bd5 + af136a1 commit 0f606ff
Show file tree
Hide file tree
Showing 11 changed files with 292 additions and 275 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- name: Run Firewall integration tests
- name: firewall_basic
block:
- name: Create a Linode Instance
linode.cloud.instance:
Expand All @@ -7,7 +7,6 @@
region: us-southeast
type: g6-standard-1
image: linode/alpine3.13
wait: false
state: present
register: create_instance

Expand All @@ -18,7 +17,6 @@
region: us-southeast
type: g6-standard-1
image: linode/alpine3.13
wait: false
state: present
register: create_instance_2

Expand Down Expand Up @@ -134,7 +132,7 @@
that:
- update_devices_unchanged.changed == false

- name: Update a Linode Firewall rules
- name: Update Linode Firewall rules
linode.cloud.firewall:
api_token: '{{ api_token }}'
api_version: v4beta
Expand Down
226 changes: 0 additions & 226 deletions tests/integration/targets/instance/tasks/main.yaml

This file was deleted.

92 changes: 92 additions & 0 deletions tests/integration/targets/instance_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
- name: instance_basic
block:
- name: Create a Linode instance without a root password
linode.cloud.instance:
api_token: '{{ api_token }}'
label: 'ansible-test-nopass-{{ ansible_date_time.epoch }}'
region: us-east
type: g6-standard-1
image: linode/ubuntu20.04
private_ip: true
wait: false
state: present
register: create

- name: Assert instance created
assert:
that:
- create.changed
- create.instance.ipv4|length > 1

- name: Update the instance region and type (recreate disallowed)
linode.cloud.instance:
api_token: '{{ api_token }}'
label: '{{ create.instance.label }}'
region: us-southeast
group: funny
type: g6-standard-2
image: linode/ubuntu20.04
private_ip: true
state: present
register: invalid_update
failed_when:
- invalid_update.changed == true

- name: Update the instance
linode.cloud.instance:
api_token: '{{ api_token }}'
label: '{{ create.instance.label }}'
region: us-east
group: funny
type: g6-standard-1
image: linode/ubuntu20.04
private_ip: true
state: present
register: update

- name: Assert update
assert:
that:
- update.instance.group == 'funny'

- name: Get info about the instance by id
linode.cloud.instance_info:
api_token: '{{ api_token }}'
id: '{{ create.instance.id }}'
register: info_id

- name: Assert instance info
assert:
that:
- info_id.instance.ipv4|length > 1
- info_id.instance.region == 'us-east'
- info_id.configs|length == 1

- name: Get info about the instance by label
linode.cloud.instance_info:
api_token: '{{ api_token }}'
label: '{{ create.instance.label }}'
register: info_label

- name: Assert instance info
assert:
that:
- info_label.instance.ipv4|length > 1
- info_label.instance.region == 'us-east'
- info_label.configs|length == 1

always:
- ignore_errors: yes
block:
- name: Delete a Linode instance
linode.cloud.instance:
api_token: '{{ api_token }}'
label: '{{ update.instance.label }}'
state: absent
register: delete_nopass

- name: Assert instance delete succeeded
assert:
that:
- delete_nopass.changed
- delete_nopass.instance.id == update.instance.id
Loading

0 comments on commit 0f606ff

Please sign in to comment.