Skip to content

Commit

Permalink
test: use shared variable for server type, image and location (ansibl…
Browse files Browse the repository at this point in the history
…e-collections#522)

##### SUMMARY

Use shared variables to store information about which server type, image
or location to use for our integrations tests.

- The location was changed from FSN to HEL.
- The image was changed from ubuntu-22.04 to debian-12.
  • Loading branch information
jooola authored Jun 26, 2024
1 parent 069b866 commit f3d697c
Show file tree
Hide file tree
Showing 64 changed files with 645 additions and 150 deletions.
15 changes: 15 additions & 0 deletions tests/integration/common/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,18 @@ hcloud_prefix: "tests"
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
hcloud_role_ns: "{{ role_name | split('_') | map('batch', 2) | map('first') | flatten() | join() }}"
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"

# Used to easily update the server types and images across all our tests.
hcloud_server_type_name: cax11
hcloud_server_type_id: 45

hcloud_server_type_upgrade_name: cax21
hcloud_server_type_upgrade_id: 93

hcloud_image_name: debian-12
hcloud_image_id: 114690389 # architecture=arm

hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3
15 changes: 15 additions & 0 deletions tests/integration/targets/certificate/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ hcloud_prefix: "tests"
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
hcloud_role_ns: "{{ role_name | split('_') | map('batch', 2) | map('first') | flatten() | join() }}"
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"

# Used to easily update the server types and images across all our tests.
hcloud_server_type_name: cax11
hcloud_server_type_id: 45

hcloud_server_type_upgrade_name: cax21
hcloud_server_type_upgrade_id: 93

hcloud_image_name: debian-12
hcloud_image_id: 114690389 # architecture=arm

hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ hcloud_prefix: "tests"
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
hcloud_role_ns: "{{ role_name | split('_') | map('batch', 2) | map('first') | flatten() | join() }}"
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"

# Used to easily update the server types and images across all our tests.
hcloud_server_type_name: cax11
hcloud_server_type_id: 45

hcloud_server_type_upgrade_name: cax21
hcloud_server_type_upgrade_id: 93

hcloud_image_name: debian-12
hcloud_image_id: 114690389 # architecture=arm

hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3
15 changes: 15 additions & 0 deletions tests/integration/targets/datacenter_info/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ hcloud_prefix: "tests"
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
hcloud_role_ns: "{{ role_name | split('_') | map('batch', 2) | map('first') | flatten() | join() }}"
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"

# Used to easily update the server types and images across all our tests.
hcloud_server_type_name: cax11
hcloud_server_type_id: 45

hcloud_server_type_upgrade_name: cax21
hcloud_server_type_upgrade_id: 93

hcloud_image_name: debian-12
hcloud_image_id: 114690389 # architecture=arm

hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3

This file was deleted.

15 changes: 15 additions & 0 deletions tests/integration/targets/firewall/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ hcloud_prefix: "tests"
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
hcloud_role_ns: "{{ role_name | split('_') | map('batch', 2) | map('first') | flatten() | join() }}"
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"

# Used to easily update the server types and images across all our tests.
hcloud_server_type_name: cax11
hcloud_server_type_id: 45

hcloud_server_type_upgrade_name: cax21
hcloud_server_type_upgrade_id: 93

hcloud_image_name: debian-12
hcloud_image_id: 114690389 # architecture=arm

hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3
4 changes: 2 additions & 2 deletions tests/integration/targets/firewall/tasks/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Create test_server
hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cax11
image: ubuntu-22.04
server_type: "{{ hcloud_server_type_name }}"
image: "{{ hcloud_image_name }}"
state: stopped
register: test_server
15 changes: 15 additions & 0 deletions tests/integration/targets/firewall_info/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ hcloud_prefix: "tests"
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
hcloud_role_ns: "{{ role_name | split('_') | map('batch', 2) | map('first') | flatten() | join() }}"
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"

# Used to easily update the server types and images across all our tests.
hcloud_server_type_name: cax11
hcloud_server_type_id: 45

hcloud_server_type_upgrade_name: cax21
hcloud_server_type_upgrade_id: 93

hcloud_image_name: debian-12
hcloud_image_id: 114690389 # architecture=arm

hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3
4 changes: 2 additions & 2 deletions tests/integration/targets/firewall_info/tasks/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
- name: Create test_server
hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cax11
image: ubuntu-22.04
server_type: "{{ hcloud_server_type_name }}"
image: "{{ hcloud_image_name }}"
labels:
firewall: "{{ hcloud_firewall_name }}"
state: stopped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ hcloud_prefix: "tests"
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
hcloud_role_ns: "{{ role_name | split('_') | map('batch', 2) | map('first') | flatten() | join() }}"
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"

# Used to easily update the server types and images across all our tests.
hcloud_server_type_name: cax11
hcloud_server_type_id: 45

hcloud_server_type_upgrade_name: cax21
hcloud_server_type_upgrade_id: 93

hcloud_image_name: debian-12
hcloud_image_id: 114690389 # architecture=arm

hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3
4 changes: 2 additions & 2 deletions tests/integration/targets/firewall_resource/tasks/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
- name: Create test_server
hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cax11
image: ubuntu-22.04
server_type: "{{ hcloud_server_type_name }}"
image: "{{ hcloud_image_name }}"
labels:
key: value
state: stopped
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/targets/floating_ip/defaults/main/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ hcloud_prefix: "tests"
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
hcloud_role_ns: "{{ role_name | split('_') | map('batch', 2) | map('first') | flatten() | join() }}"
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"

# Used to easily update the server types and images across all our tests.
hcloud_server_type_name: cax11
hcloud_server_type_id: 45

hcloud_server_type_upgrade_name: cax21
hcloud_server_type_upgrade_id: 93

hcloud_image_name: debian-12
hcloud_image_id: 114690389 # architecture=arm

hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3
42 changes: 21 additions & 21 deletions tests/integration/targets/floating_ip/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
- name: setup server
hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cax11
image: ubuntu-22.04
server_type: "{{ hcloud_server_type_name }}"
image: "{{ hcloud_image_name }}"
state: stopped
location: "fsn1"
location: "{{ hcloud_location_name }}"
register: main_server
- name: verify setup server
assert:
Expand All @@ -32,8 +32,8 @@
- name: setup another server
hetzner.hcloud.server:
name: "{{ hcloud_server_name }}2"
server_type: cax11
image: ubuntu-22.04
server_type: "{{ hcloud_server_type_name }}"
image: "{{ hcloud_image_name }}"
state: stopped
register: main_server2
- name: verify setup another server
Expand Down Expand Up @@ -67,7 +67,7 @@
- name: test missing type parameter on delete Floating IP
hetzner.hcloud.floating_ip:
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
state: "absent"
register: result
ignore_errors: true
Expand All @@ -81,7 +81,7 @@
hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv5
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
register: result
ignore_errors: true
- name: verify invalid type
Expand Down Expand Up @@ -109,7 +109,7 @@
name: "{{ hcloud_floating_ip_name }}"
description: "Web Server"
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
register: floatingIP
check_mode: true
- name: verify test create Floating IP with check mode
Expand All @@ -122,22 +122,22 @@
name: "{{ hcloud_floating_ip_name }}"
description: "Web Server"
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
register: floatingIP
- name: verify test create Floating IP
assert:
that:
- floatingIP is changed
- floatingIP.hcloud_floating_ip.name ==hcloud_floating_ip_name
- floatingIP.hcloud_floating_ip.description == "Web Server"
- floatingIP.hcloud_floating_ip.home_location == "fsn1"
- floatingIP.hcloud_floating_ip.home_location == hcloud_location_name

- name: test create Floating IP idempotency
hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
description: "Web Server"
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
register: floatingIP
- name: verify test create Floating IP idempotency
assert:
Expand All @@ -149,7 +149,7 @@
name: "{{ hcloud_floating_ip_name }}"
description: "changed-description"
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
check_mode: true
register: floatingIP
- name: verify test create Floating IP with check mode
Expand All @@ -163,7 +163,7 @@
name: "{{ hcloud_floating_ip_name }}"
description: "changed-description"
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
labels:
key: value
register: floatingIP
Expand All @@ -178,7 +178,7 @@
name: "{{ hcloud_floating_ip_name }}"
description: "changed-description"
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
labels:
key: value
register: floatingIP
Expand All @@ -191,7 +191,7 @@
hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
labels:
key: value
register: floatingIP
Expand All @@ -204,7 +204,7 @@
hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
labels:
key: value
other: label
Expand All @@ -218,7 +218,7 @@
hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
labels:
other: label
key: value
Expand Down Expand Up @@ -271,7 +271,7 @@
hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
register: floatingIP
- name: verify test unassign Floating IP
assert:
Expand All @@ -283,7 +283,7 @@
hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
register: floatingIP
- name: verify test unassign Floating IPidempotency
assert:
Expand Down Expand Up @@ -401,7 +401,7 @@
hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv6
home_location: "fsn1"
home_location: "{{ hcloud_location_name }}"
state: "present"
register: result
- name: verify test create ipv6 floating ip
Expand Down Expand Up @@ -442,7 +442,7 @@
hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: fsn1
home_location: "{{ hcloud_location_name }}"
delete_protection: true
register: floatingIP
- name: verify create Floating IP with delete protection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ hcloud_prefix: "tests"
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
hcloud_role_ns: "{{ role_name | split('_') | map('batch', 2) | map('first') | flatten() | join() }}"
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"

# Used to easily update the server types and images across all our tests.
hcloud_server_type_name: cax11
hcloud_server_type_id: 45

hcloud_server_type_upgrade_name: cax21
hcloud_server_type_upgrade_id: 93

hcloud_image_name: debian-12
hcloud_image_id: 114690389 # architecture=arm

hcloud_location_name: hel1
hcloud_location_id: 3
hcloud_datacenter_name: hel1-dc2
hcloud_datacenter_id: 3
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Create test_floating_ip
hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
home_location: fsn1
home_location: "{{ hcloud_location_name }}"
type: ipv4
labels:
key: value
Expand Down
Loading

0 comments on commit f3d697c

Please sign in to comment.