forked from ansible-collections/hetzner.hcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improve
load_balancer_network
integration using new framework (…
…ansible-collections#545) ##### SUMMARY Use the new testing framework for the load_balancer_network integration tests.
- Loading branch information
Showing
4 changed files
with
89 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
tests/integration/targets/load_balancer_network/tasks/cleanup.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: Cleanup test_load_balancer | ||
hetzner.hcloud.load_balancer: | ||
name: "{{ hcloud_load_balancer_name }}" | ||
state: absent | ||
|
||
- name: Cleanup test_network | ||
hetzner.hcloud.network: | ||
name: "{{ hcloud_network_name }}" | ||
state: absent |
21 changes: 21 additions & 0 deletions
21
tests/integration/targets/load_balancer_network/tasks/prepare.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Create test_network | ||
hetzner.hcloud.network: | ||
name: "{{ hcloud_network_name }}" | ||
ip_range: 10.0.0.0/16 | ||
register: test_network | ||
|
||
- name: Create test_subnetwork | ||
hetzner.hcloud.subnetwork: | ||
network: "{{ hcloud_network_name }}" | ||
network_zone: "{{ hcloud_network_zone_name }}" | ||
type: cloud | ||
ip_range: 10.0.1.0/24 | ||
register: test_subnetwork | ||
|
||
- name: Create test_load_balancer | ||
hetzner.hcloud.load_balancer: | ||
name: "{{ hcloud_load_balancer_name }}" | ||
load_balancer_type: lb11 | ||
location: "{{ hcloud_location_name }}" | ||
register: test_load_balancer |
184 changes: 58 additions & 126 deletions
184
tests/integration/targets/load_balancer_network/tasks/test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,181 +1,113 @@ | ||
# Copyright: (c) 2019, Hetzner Cloud GmbH <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
--- | ||
- name: setup network | ||
hetzner.hcloud.network: | ||
name: "{{ hcloud_network_name }}" | ||
ip_range: "10.0.0.0/8" | ||
state: present | ||
register: network | ||
- name: verify setup network | ||
assert: | ||
that: | ||
- network is success | ||
|
||
- name: setup subnetwork | ||
hetzner.hcloud.subnetwork: | ||
network: "{{ hcloud_network_name }}" | ||
ip_range: "10.0.0.0/16" | ||
type: "cloud" | ||
network_zone: "{{ hcloud_network_zone_name }}" | ||
state: present | ||
register: subnetwork | ||
- name: verify subnetwork | ||
assert: | ||
that: | ||
- subnetwork is success | ||
|
||
- name: setup load_balancer | ||
hetzner.hcloud.load_balancer: | ||
name: "{{hcloud_load_balancer_name}}" | ||
load_balancer_type: lb11 | ||
state: present | ||
location: "{{ hcloud_location_name }}" | ||
register: load_balancer | ||
- name: verify setup load_balancer | ||
assert: | ||
that: | ||
- load_balancer is success | ||
|
||
- name: test missing required parameters on create load_balancer network | ||
- name: Test missing required parameters | ||
hetzner.hcloud.load_balancer_network: | ||
state: present | ||
register: result | ||
ignore_errors: true | ||
- name: verify fail test missing required parameters on create load_balancer network | ||
assert: | ||
register: result | ||
- name: Verify missing required parameters | ||
ansible.builtin.assert: | ||
that: | ||
- result is failed | ||
- '"missing required arguments:" in result.msg' | ||
- 'result.msg == "missing required arguments: load_balancer, network"' | ||
|
||
- name: test fail load balancer does not exist | ||
- name: Test create with checkmode | ||
hetzner.hcloud.load_balancer_network: | ||
load_balancer: "{{ hcloud_load_balancer_name }}" | ||
network: "{{ hcloud_network_name }}" | ||
load_balancer: does-not-exist | ||
state: present | ||
check_mode: true | ||
register: result | ||
ignore_errors: true | ||
- name: verify test fail load_balancer does not exist | ||
assert: | ||
- name: Verify create with checkmode | ||
ansible.builtin.assert: | ||
that: | ||
- result is failed | ||
- "result.msg == 'resource (load_balancer) does not exist: does-not-exist'" | ||
- result is changed | ||
|
||
- name: test fail network does not exist | ||
- name: Test create | ||
hetzner.hcloud.load_balancer_network: | ||
network: does-not-exist | ||
load_balancer: "{{ hcloud_load_balancer_name }}" | ||
network: "{{ hcloud_network_name }}" | ||
state: present | ||
register: result | ||
ignore_errors: true | ||
- name: verify test fail network does not exist | ||
assert: | ||
- name: Verify create | ||
ansible.builtin.assert: | ||
that: | ||
- result is failed | ||
- "result.msg == 'resource (network) does not exist: does-not-exist'" | ||
- result is changed | ||
- result.hcloud_load_balancer_network.load_balancer == hcloud_load_balancer_name | ||
- result.hcloud_load_balancer_network.network == hcloud_load_balancer_name | ||
|
||
- name: test create load_balancer network with checkmode | ||
- name: Test create idempotency | ||
hetzner.hcloud.load_balancer_network: | ||
load_balancer: "{{ hcloud_load_balancer_name }}" | ||
network: "{{ hcloud_network_name }}" | ||
load_balancer: "{{hcloud_load_balancer_name}}" | ||
state: present | ||
register: result | ||
check_mode: true | ||
- name: verify test create load_balancer network with checkmode | ||
assert: | ||
- name: Verify create idempotency | ||
ansible.builtin.assert: | ||
that: | ||
- result is changed | ||
- result is not changed | ||
|
||
- name: test create load_balancer network | ||
- name: Test create with not existing load_balancer | ||
hetzner.hcloud.load_balancer_network: | ||
load_balancer: not-existing | ||
network: "{{ hcloud_network_name }}" | ||
load_balancer: "{{hcloud_load_balancer_name}}" | ||
state: present | ||
register: load_balancerNetwork | ||
- name: verify create load_balancer network | ||
assert: | ||
ignore_errors: true | ||
register: result | ||
- name: Verify create with not existing load_balancer | ||
ansible.builtin.assert: | ||
that: | ||
- load_balancerNetwork is changed | ||
- load_balancerNetwork.hcloud_load_balancer_network.network == hcloud_network_name | ||
- load_balancerNetwork.hcloud_load_balancer_network.load_balancer == hcloud_load_balancer_name | ||
- result is failed | ||
- 'result.msg == "resource (load_balancer) does not exist: not-existing"' | ||
|
||
- name: test create load_balancer network idempotency | ||
- name: Test create with not existing network | ||
hetzner.hcloud.load_balancer_network: | ||
network: "{{ hcloud_network_name }}" | ||
load_balancer: "{{hcloud_load_balancer_name}}" | ||
load_balancer: "{{ hcloud_load_balancer_name }}" | ||
network: not-existing | ||
state: present | ||
register: load_balancerNetwork | ||
- name: verify create load_balancer network idempotency | ||
assert: | ||
ignore_errors: true | ||
register: result | ||
- name: Verify create with not existing network | ||
ansible.builtin.assert: | ||
that: | ||
- load_balancerNetwork is not changed | ||
- result is failed | ||
- 'result.msg == "resource (network) does not exist: not-existing"' | ||
|
||
- name: test absent load_balancer network | ||
- name: Test delete | ||
hetzner.hcloud.load_balancer_network: | ||
load_balancer: "{{ hcloud_load_balancer_name }}" | ||
network: "{{ hcloud_network_name }}" | ||
load_balancer: "{{hcloud_load_balancer_name}}" | ||
state: absent | ||
register: result | ||
- name: verify test absent load_balancer network | ||
assert: | ||
- name: Verify delete | ||
ansible.builtin.assert: | ||
that: | ||
- result is changed | ||
|
||
- name: test create load_balancer network with specified ip | ||
- name: Test create with ip | ||
hetzner.hcloud.load_balancer_network: | ||
load_balancer: "{{ hcloud_load_balancer_name }}" | ||
network: "{{ hcloud_network_name }}" | ||
load_balancer: "{{hcloud_load_balancer_name}}" | ||
ip: "10.0.0.2" | ||
ip: 10.0.1.2 | ||
state: present | ||
register: load_balancerNetwork | ||
- name: verify create load_balancer network with specified ip | ||
assert: | ||
that: | ||
- load_balancerNetwork is changed | ||
- load_balancerNetwork.hcloud_load_balancer_network.network == hcloud_network_name | ||
- load_balancerNetwork.hcloud_load_balancer_network.load_balancer == hcloud_load_balancer_name | ||
- load_balancerNetwork.hcloud_load_balancer_network.ip == "10.0.0.2" | ||
|
||
- name: cleanup create load_balancer network with specified ip | ||
hetzner.hcloud.load_balancer_network: | ||
network: "{{ hcloud_network_name }}" | ||
load_balancer: "{{hcloud_load_balancer_name}}" | ||
state: absent | ||
register: result | ||
- name: verify cleanup create load_balancer network with specified ip | ||
assert: | ||
- name: Verify create with ip | ||
ansible.builtin.assert: | ||
that: | ||
- result is changed | ||
- result.hcloud_load_balancer_network.load_balancer == hcloud_load_balancer_name | ||
- result.hcloud_load_balancer_network.network == hcloud_load_balancer_name | ||
- result.hcloud_load_balancer_network.ip == "10.0.1.2" | ||
|
||
- name: cleanup load_balancer | ||
hetzner.hcloud.load_balancer: | ||
name: "{{ hcloud_load_balancer_name }}" | ||
state: absent | ||
register: result | ||
- name: verify cleanup load_balancer | ||
assert: | ||
that: | ||
- result is success | ||
|
||
- name: cleanup subnetwork | ||
hetzner.hcloud.subnetwork: | ||
- name: Test delete with ip | ||
hetzner.hcloud.load_balancer_network: | ||
load_balancer: "{{ hcloud_load_balancer_name }}" | ||
network: "{{ hcloud_network_name }}" | ||
ip_range: "10.0.0.0/16" | ||
type: "cloud" | ||
network_zone: "{{ hcloud_network_zone_name }}" | ||
ip: 10.0.1.2 | ||
state: absent | ||
register: result | ||
- name: verify cleanup subnetwork | ||
assert: | ||
- name: Verify delete with ip | ||
ansible.builtin.assert: | ||
that: | ||
- result is changed | ||
|
||
- name: cleanup | ||
hetzner.hcloud.network: | ||
name: "{{hcloud_network_name}}" | ||
state: absent | ||
register: result | ||
- name: verify cleanup | ||
assert: | ||
that: | ||
- result is success |