Skip to content

Commit 0f606ff

Browse files
authored
Merge pull request #51 from LBGarber/refactor-tests
Refactor integration tests
2 parents 45d0bd5 + af136a1 commit 0f606ff

File tree

11 files changed

+292
-275
lines changed

11 files changed

+292
-275
lines changed

tests/integration/targets/firewall/tasks/main.yaml renamed to tests/integration/targets/firewall_basic/tasks/main.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- name: Run Firewall integration tests
1+
- name: firewall_basic
22
block:
33
- name: Create a Linode Instance
44
linode.cloud.instance:
@@ -7,7 +7,6 @@
77
region: us-southeast
88
type: g6-standard-1
99
image: linode/alpine3.13
10-
wait: false
1110
state: present
1211
register: create_instance
1312

@@ -18,7 +17,6 @@
1817
region: us-southeast
1918
type: g6-standard-1
2019
image: linode/alpine3.13
21-
wait: false
2220
state: present
2321
register: create_instance_2
2422

@@ -134,7 +132,7 @@
134132
that:
135133
- update_devices_unchanged.changed == false
136134

137-
- name: Update a Linode Firewall rules
135+
- name: Update Linode Firewall rules
138136
linode.cloud.firewall:
139137
api_token: '{{ api_token }}'
140138
api_version: v4beta

tests/integration/targets/instance/tasks/main.yaml

Lines changed: 0 additions & 226 deletions
This file was deleted.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
- name: instance_basic
2+
block:
3+
- name: Create a Linode instance without a root password
4+
linode.cloud.instance:
5+
api_token: '{{ api_token }}'
6+
label: 'ansible-test-nopass-{{ ansible_date_time.epoch }}'
7+
region: us-east
8+
type: g6-standard-1
9+
image: linode/ubuntu20.04
10+
private_ip: true
11+
wait: false
12+
state: present
13+
register: create
14+
15+
- name: Assert instance created
16+
assert:
17+
that:
18+
- create.changed
19+
- create.instance.ipv4|length > 1
20+
21+
- name: Update the instance region and type (recreate disallowed)
22+
linode.cloud.instance:
23+
api_token: '{{ api_token }}'
24+
label: '{{ create.instance.label }}'
25+
region: us-southeast
26+
group: funny
27+
type: g6-standard-2
28+
image: linode/ubuntu20.04
29+
private_ip: true
30+
state: present
31+
register: invalid_update
32+
failed_when:
33+
- invalid_update.changed == true
34+
35+
- name: Update the instance
36+
linode.cloud.instance:
37+
api_token: '{{ api_token }}'
38+
label: '{{ create.instance.label }}'
39+
region: us-east
40+
group: funny
41+
type: g6-standard-1
42+
image: linode/ubuntu20.04
43+
private_ip: true
44+
state: present
45+
register: update
46+
47+
- name: Assert update
48+
assert:
49+
that:
50+
- update.instance.group == 'funny'
51+
52+
- name: Get info about the instance by id
53+
linode.cloud.instance_info:
54+
api_token: '{{ api_token }}'
55+
id: '{{ create.instance.id }}'
56+
register: info_id
57+
58+
- name: Assert instance info
59+
assert:
60+
that:
61+
- info_id.instance.ipv4|length > 1
62+
- info_id.instance.region == 'us-east'
63+
- info_id.configs|length == 1
64+
65+
- name: Get info about the instance by label
66+
linode.cloud.instance_info:
67+
api_token: '{{ api_token }}'
68+
label: '{{ create.instance.label }}'
69+
register: info_label
70+
71+
- name: Assert instance info
72+
assert:
73+
that:
74+
- info_label.instance.ipv4|length > 1
75+
- info_label.instance.region == 'us-east'
76+
- info_label.configs|length == 1
77+
78+
always:
79+
- ignore_errors: yes
80+
block:
81+
- name: Delete a Linode instance
82+
linode.cloud.instance:
83+
api_token: '{{ api_token }}'
84+
label: '{{ update.instance.label }}'
85+
state: absent
86+
register: delete_nopass
87+
88+
- name: Assert instance delete succeeded
89+
assert:
90+
that:
91+
- delete_nopass.changed
92+
- delete_nopass.instance.id == update.instance.id

0 commit comments

Comments
 (0)