Skip to content

Commit

Permalink
test: use shared network zone variable (ansible-collections#543)
Browse files Browse the repository at this point in the history
##### SUMMARY

Allow to easily update the network zone when changing the location, for
testing.
  • Loading branch information
jooola authored Aug 6, 2024
1 parent c6d7121 commit 87ad95a
Show file tree
Hide file tree
Showing 43 changed files with 90 additions and 21 deletions.
2 changes: 2 additions & 0 deletions tests/integration/common/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 2 additions & 0 deletions tests/integration/targets/firewall/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 2 additions & 0 deletions tests/integration/targets/image_info/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 2 additions & 0 deletions tests/integration/targets/iso_info/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
6 changes: 3 additions & 3 deletions tests/integration/targets/load_balancer/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
hetzner.hcloud.load_balancer:
name: "{{ hcloud_load_balancer_name }}"
load_balancer_type: lb11
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
state: present
check_mode: true
register: result
Expand All @@ -30,7 +30,7 @@
hetzner.hcloud.load_balancer:
name: "{{ hcloud_load_balancer_name }}"
load_balancer_type: lb11
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
labels:
key: value
label: value123
Expand All @@ -51,7 +51,7 @@
hetzner.hcloud.load_balancer:
name: "{{ hcloud_load_balancer_name }}"
load_balancer_type: lb11
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
state: present
register: result
- name: Verify create idempotency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
hetzner.hcloud.load_balancer:
name: "{{ hcloud_load_balancer_name }}"
load_balancer_type: lb11
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
labels:
key: value
register: test_load_balancer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
network: "{{ hcloud_network_name }}"
ip_range: "10.0.0.0/16"
type: "cloud"
network_zone: "eu-central"
network_zone: "{{ hcloud_network_zone_name }}"
state: present
register: subnetwork
- name: verify subnetwork
Expand Down Expand Up @@ -162,7 +162,7 @@
network: "{{ hcloud_network_name }}"
ip_range: "10.0.0.0/16"
type: "cloud"
network_zone: "eu-central"
network_zone: "{{ hcloud_network_zone_name }}"
state: absent
register: result
- name: verify cleanup subnetwork
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 2 additions & 0 deletions tests/integration/targets/network/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 1 addition & 1 deletion tests/integration/targets/network_info/tasks/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
type: server
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
ip_range: 10.0.1.0/24
register: test_subnetwork

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 2 additions & 0 deletions tests/integration/targets/primary_ip/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 2 additions & 0 deletions tests/integration/targets/rdns/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 1 addition & 1 deletion tests/integration/targets/rdns/tasks/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
hetzner.hcloud.load_balancer:
name: "{{ hcloud_load_balancer_name }}"
load_balancer_type: lb11
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
state: present
register: test_load_balancer
2 changes: 2 additions & 0 deletions tests/integration/targets/route/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 2 additions & 0 deletions tests/integration/targets/server/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
1 change: 1 addition & 0 deletions tests/integration/targets/server/tasks/test_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@
assert:
that:
- result is success

- name: test create server with labels
hetzner.hcloud.server:
name: "{{ hcloud_server_name}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}-1"
ip_range: 192.168.0.0/24
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
type: cloud
state: present

- name: setup create network subnet 2
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}-1"
ip_range: 192.168.1.0/24
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
type: cloud
state: present

Expand All @@ -48,15 +48,15 @@
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}-2"
ip_range: 192.168.2.0/24
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
type: cloud
state: present

- name: setup create secondary network subnet 2
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}-2"
ip_range: 192.168.3.0/24
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
type: cloud
state: present

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 1 addition & 1 deletion tests/integration/targets/server_network/tasks/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
type: server
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
ip_range: 10.0.1.0/24
register: test_subnetwork

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 2 additions & 0 deletions tests/integration/targets/ssh_key/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
2 changes: 2 additions & 0 deletions tests/integration/targets/subnetwork/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
16 changes: 8 additions & 8 deletions tests/integration/targets/subnetwork/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- name: Test create with checkmode
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
type: cloud
ip_range: 10.0.0.0/24
state: present
Expand All @@ -30,7 +30,7 @@
- name: Test create
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
type: cloud
ip_range: 10.0.0.0/24
state: present
Expand All @@ -40,14 +40,14 @@
that:
- result is changed
- result.hcloud_subnetwork.network == hcloud_network_name
- result.hcloud_subnetwork.network_zone == "eu-central"
- result.hcloud_subnetwork.network_zone == hcloud_network_zone_name
- result.hcloud_subnetwork.type == "cloud"
- result.hcloud_subnetwork.ip_range == "10.0.0.0/24"

- name: Test create idempotency
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
type: cloud
ip_range: 10.0.0.0/24
state: present
Expand All @@ -60,7 +60,7 @@
- name: Test delete
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
type: cloud
ip_range: 10.0.0.0/24
state: absent
Expand All @@ -73,7 +73,7 @@
- name: Test create with vswitch
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
type: vswitch
ip_range: 10.0.1.0/24
vswitch_id: "{{ test_vswitch_id }}"
Expand All @@ -84,15 +84,15 @@
that:
- result is changed
- result.hcloud_subnetwork.network == hcloud_network_name
- result.hcloud_subnetwork.network_zone == "eu-central"
- result.hcloud_subnetwork.network_zone == hcloud_network_zone_name
- result.hcloud_subnetwork.type == "vswitch"
- result.hcloud_subnetwork.ip_range == "10.0.1.0/24"
- result.hcloud_subnetwork.vswitch_id | string == test_vswitch_id

- name: Test delete with vswitch
hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
network_zone: eu-central
network_zone: "{{ hcloud_network_zone_name }}"
type: vswitch
ip_range: 10.0.1.0/24
state: absent
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/targets/volume/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

hcloud_network_zone_name: eu-central

0 comments on commit 87ad95a

Please sign in to comment.