test: various fixes for integration tests (#193)

* test: update for new locations

* test(cert): fix issues with random name failing the test

The variable hcloud_dns_test_domain used the random function to generate
a number from 1-100. This number changed between every usage of the
variable, so the test that compared the domain name of the cert to the
variable kept failing, as different numbers were generated.

By generating the number once and saving it into a fact, this is fixed.

* test: fix issues with long resource names

Server and volume names have restricted length (63 and 64 respectivly).

This can cause issues when the `hcloud_prefix` is of certain length. By
applying truncate, we can be sure to not reach the limit.

This issue mainly happened in our internal ci, as the hcloud_prefix variable
contains the hostname where the tests were running, and our hostnames are
quite long.
This commit is contained in:
Julian Tölle 2023-02-13 10:48:26 +01:00 committed by GitHub
parent 292cdf2a05
commit e218306028
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 28 additions and 22 deletions

View file

@ -96,7 +96,7 @@
key: value
test: "val123"
register: result
- name: test update certificate with other labels
- name: test update certificate with other labels
assert:
that:
- result is changed
@ -122,6 +122,12 @@
that:
- result is success
- name: generate dns domain name
set_fact:
# hcloud_dns_test_domain uses random, which generates a new random number
# on every invocation, by saving it into a fact we generate the number once
hcloud_dns_test_domain: "{{ hcloud_dns_test_domain }}"
- name: test create managed certificate
hcloud_certificate:
name: "{{ hcloud_certificate_name }}"
@ -131,7 +137,7 @@
labels:
HC-Use-Staging-CA: "true"
register: result
- name: test rename certificate
- name: verify create managed certificate
assert:
that:
- result is changed
@ -143,7 +149,7 @@
id: "{{ result.hcloud_certificate.id }}"
state: absent
register: result
- name: verify absent server
- name: verify absent certificate
assert:
that:
- result is success

View file

@ -8,7 +8,7 @@
- name: verify test gather hcloud datacenter infos
assert:
that:
- hcloud_datacenters.hcloud_datacenter_info| list | count == 4
- hcloud_datacenters.hcloud_datacenter_info| list | count >= 5
- name: test gather hcloud datacenter infos in check mode
hcloud_datacenter_info:
@ -18,7 +18,7 @@
- name: verify test gather hcloud datacenter infos in check mode
assert:
that:
- hcloud_datacenters.hcloud_datacenter_info| list | count == 4
- hcloud_datacenters.hcloud_datacenter_info| list | count >= 5
- name: test gather hcloud datacenter infos with correct name
hcloud_datacenter_info:

View file

@ -3,4 +3,4 @@
---
hcloud_prefix: "tests"
hcloud_floating_ip_name: "{{hcloud_prefix}}-i"
hcloud_server_name: "{{hcloud_prefix}}-fip-t"
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-fip-t"

View file

@ -3,4 +3,4 @@
---
hcloud_prefix: "tests"
hcloud_load_balancer_name: "{{hcloud_prefix}}-i"
hcloud_server_name: "{{hcloud_prefix}}-lb-i"
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-lb-i"

View file

@ -2,6 +2,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
hcloud_prefix: "tests"
hcloud_server_name: "{{hcloud_prefix}}-lb-t"
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-lb-t"
hcloud_load_balancer_name: "{{hcloud_prefix}}-lb-target"
hcloud_testing_ip: "176.9.59.39"

View file

@ -8,7 +8,7 @@
- name: verify test gather hcloud location infos
assert:
that:
- hcloud_location.hcloud_location_info | list | count == 3
- hcloud_location.hcloud_location_info | list | count >= 5
- name: test gather hcloud location infos in check mode
hcloud_location_info:
@ -18,7 +18,7 @@
- name: verify test gather hcloud location infos in check mode
assert:
that:
- hcloud_location.hcloud_location_info | list | count == 3
- hcloud_location.hcloud_location_info | list | count >= 5
- name: test gather hcloud location infos with correct name
hcloud_location_info:

View file

@ -3,4 +3,4 @@
---
hcloud_prefix: "tests"
hcloud_placement_group_name: "{{hcloud_prefix}}-i"
hcloud_server_name: "{{hcloud_prefix}}-i"
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-i"

View file

@ -92,7 +92,7 @@
- name: test add server to placement group
hcloud_server:
name: "{{ hcloud_server_name }}"
placement_group: "{{ hcloud_server_name }}"
placement_group: "{{ hcloud_placement_group_name }}"
force: True
state: present
register: result
@ -106,7 +106,7 @@
- name: test add server to placement group idempotence
hcloud_server:
name: "{{ hcloud_server_name }}"
placement_group: "{{ hcloud_server_name }}"
placement_group: "{{ hcloud_placement_group_name }}"
force: True
state: present
register: result

View file

@ -3,4 +3,4 @@
---
hcloud_prefix: "tests"
hcloud_primary_ip_name: "{{hcloud_prefix}}-i"
hcloud_server_name: "{{hcloud_prefix}}-fip-t"
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-fip-t"

View file

@ -2,7 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
hcloud_prefix: "tests"
hcloud_server_name: "{{hcloud_prefix}}"
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}"
hcloud_floating_ip_name: "{{hcloud_prefix}}"
hcloud_primary_ip_name: "{{hcloud_prefix}}"
hcloud_load_balancer_name: "{{hcloud_prefix}}"

View file

@ -2,7 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
hcloud_prefix: "tests"
hcloud_server_name: "{{hcloud_prefix}}-i"
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-i"
hcloud_firewall_name: "{{hcloud_prefix}}-i"
hcloud_primary_ip_name: "{{hcloud_prefix}}-i"
hcloud_network_name: "{{hcloud_prefix}}-i"

View file

@ -2,4 +2,4 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
hcloud_prefix: "tests"
hcloud_server_name: "{{hcloud_prefix}}-ii"
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-ii"

View file

@ -3,4 +3,4 @@
---
hcloud_prefix: "tests"
hcloud_network_name: "{{hcloud_prefix}}-sn"
hcloud_server_name: "{{hcloud_prefix}}-sn"
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-sn"

View file

@ -2,7 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
hcloud_prefix: "tests"
hcloud_server_name: "{{hcloud_prefix}}"
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}"
hcloud_ssh_key_name: "{{hcloud_prefix}}"
hcloud_ssh_key_public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDnaTPfKaX1QKcRLOfr34buVLh5FhJAThI9NYB0xNdXsMd4Y0zLyyCQzHbx4eWCVZxym/s6csWSeLaAhO1GOHeAw3hQFMqf1oTBx6Y8g0pKpeotKPa/PDSUzdZF9Lc+DadtpQd8kFVHAu1Kd3zoEUnk1u6kP7I4qu4Z/6F9qBDF+M3aobiPVxdS7GwaVRW3nZu+FcQDLiBiNOjuRDyjHcDfEUkoh2SOu25RrFtGPzFu5mGmBJwotKpWAocLGfHzyn/fAHxgw3jKZVH/t+XWQFnl82Ie8yE3Z1EZ7oDkNRqFQT9AdXEQOLycTTYTQMJZpgeFTv3sAo6lPRCusiFmmLcf ci@ansible.hetzner.cloud"
hcloud_ssh_key_fingerprint: "56:89:c4:d6:a7:4a:79:82:f4:c2:58:9c:e1:d2:2d:4e"

View file

@ -2,5 +2,5 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
hcloud_prefix: "tests"
hcloud_volume_name: "{{hcloud_prefix}}-i"
hcloud_server_name: "{{hcloud_prefix}}-vs"
hcloud_volume_name: "{{ hcloud_prefix | truncate(60, True, '', 0) }}-i"
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-vs"

View file

@ -2,4 +2,4 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
hcloud_prefix: "tests"
hcloud_volume_name: "{{hcloud_prefix}}-i"
hcloud_volume_name: "{{ hcloud_prefix | truncate(60, True, '', 0) }}-i"