mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-11-10 06:34:13 +00:00
test: use testing framework for server integration tests
This commit is contained in:
parent
1ae6769210
commit
4916673ccb
5 changed files with 127 additions and 88 deletions
|
@ -3,3 +3,35 @@
|
|||
hetzner.hcloud.ssh_key:
|
||||
name: "{{ hcloud_ssh_key_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Cleanup test_network
|
||||
hetzner.hcloud.network:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Cleanup test_primary_ipv4_1
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}v4-1"
|
||||
state: absent
|
||||
|
||||
- name: Cleanup test_primary_ipv4_2
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}v4-2"
|
||||
state: absent
|
||||
|
||||
- name: Cleanup test_primary_ipv6
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}v6"
|
||||
state: absent
|
||||
|
||||
- name: Cleanup test_firewall_1
|
||||
hetzner.hcloud.firewall:
|
||||
name: "{{ hcloud_firewall_name }}-1"
|
||||
force: true
|
||||
state: absent
|
||||
|
||||
- name: Cleanup test_firewall_2
|
||||
hetzner.hcloud.firewall:
|
||||
name: "{{ hcloud_firewall_name }}-2"
|
||||
force: true
|
||||
state: absent
|
||||
|
|
|
@ -4,3 +4,62 @@
|
|||
name: "{{ hcloud_ssh_key_name }}"
|
||||
public_key: "{{ test_ssh_keypair.public_key }}"
|
||||
register: test_ssh_key
|
||||
|
||||
- name: Create test_network
|
||||
hetzner.hcloud.network:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
ip_range: 10.0.0.0/16
|
||||
labels:
|
||||
key: value
|
||||
register: test_network
|
||||
|
||||
- name: Create test_subnetwork
|
||||
hetzner.hcloud.subnetwork:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
type: server
|
||||
network_zone: eu-central
|
||||
ip_range: 10.0.1.0/24
|
||||
register: test_subnetwork
|
||||
|
||||
- name: Create test_primary_ipv4_1
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}v4-1"
|
||||
type: ipv4
|
||||
datacenter: fsn1-dc14
|
||||
register: test_primary_ipv4_1
|
||||
|
||||
- name: Create test_primary_ipv4_2
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}v4-2"
|
||||
type: ipv4
|
||||
datacenter: fsn1-dc14
|
||||
register: test_primary_ipv4_2
|
||||
|
||||
- name: Create test_primary_ipv6
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}v6"
|
||||
type: ipv6
|
||||
datacenter: fsn1-dc14
|
||||
register: test_primary_ipv6
|
||||
|
||||
- name: Create test_firewall_1
|
||||
hetzner.hcloud.firewall:
|
||||
name: "{{ hcloud_firewall_name }}-1"
|
||||
rules:
|
||||
- direction: in
|
||||
protocol: icmp
|
||||
source_ips:
|
||||
- 0.0.0.0/0
|
||||
- ::/0
|
||||
register: test_firewall_1
|
||||
|
||||
- name: Create test_firewall_2
|
||||
hetzner.hcloud.firewall:
|
||||
name: "{{ hcloud_firewall_name }}-2"
|
||||
rules:
|
||||
- direction: in
|
||||
protocol: icmp
|
||||
source_ips:
|
||||
- 0.0.0.0/0
|
||||
- ::/0
|
||||
register: test_firewall_2
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Copyright: (c) 2022, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
#- ansible.builtin.include_tasks: test_validation.yml
|
||||
- ansible.builtin.include_tasks: test_validation.yml
|
||||
- ansible.builtin.include_tasks: test_basic.yml
|
||||
#- ansible.builtin.include_tasks: test_firewalls.yml
|
||||
- ansible.builtin.include_tasks: test_firewalls.yml
|
||||
- ansible.builtin.include_tasks: test_primary_ips.yml
|
||||
- ansible.builtin.include_tasks: test_private_network_only.yml
|
||||
|
|
|
@ -1,82 +1,36 @@
|
|||
# Copyright: (c) 2022, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: setup create primary ipv4
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}v4"
|
||||
type: ipv4
|
||||
datacenter: "fsn1-dc14"
|
||||
register: primaryIPv4
|
||||
|
||||
- name: setup create second primary ipv4
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}v42"
|
||||
type: ipv4
|
||||
datacenter: "fsn1-dc14"
|
||||
register: secondPrimaryIPv4
|
||||
|
||||
- name: setup create primary ipv6
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}v6"
|
||||
type: ipv6
|
||||
datacenter: "fsn1-dc14"
|
||||
register: primaryIPv6
|
||||
|
||||
- name: test create server with primary ips
|
||||
- name: Test create with primary ips
|
||||
hetzner.hcloud.server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: cpx11
|
||||
datacenter: "fsn1-dc14"
|
||||
image: "ubuntu-22.04"
|
||||
ipv4: "{{primaryIPv4.hcloud_primary_ip.id}}"
|
||||
ipv6: "{{primaryIPv6.hcloud_primary_ip.id}}"
|
||||
datacenter: fsn1-dc14
|
||||
image: ubuntu-22.04
|
||||
ipv4: "{{ test_primary_ipv4_1.hcloud_primary_ip.id }}"
|
||||
ipv6: "{{ test_primary_ipv6.hcloud_primary_ip.id }}"
|
||||
ssh_keys:
|
||||
- "{{ hcloud_ssh_key_name }}"
|
||||
state: stopped
|
||||
register: result
|
||||
- name: verify test create server with primary ips
|
||||
assert:
|
||||
- name: Verify create with primary ips
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test update server with primary ips
|
||||
- name: Test update with primary ips
|
||||
hetzner.hcloud.server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: cpx11
|
||||
datacenter: "fsn1-dc14"
|
||||
image: "ubuntu-22.04"
|
||||
ipv4: "{{secondPrimaryIPv4.hcloud_primary_ip.id}}"
|
||||
datacenter: fsn1-dc14
|
||||
image: ubuntu-22.04
|
||||
ipv4: "{{ test_primary_ipv4_2.hcloud_primary_ip.id }}"
|
||||
ipv6: ""
|
||||
enable_ipv6: false
|
||||
ssh_keys:
|
||||
- "{{ hcloud_ssh_key_name }}"
|
||||
state: stopped
|
||||
register: result
|
||||
- name: verify test create server with primary ips
|
||||
assert:
|
||||
- name: Verify update with primary ips
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: cleanup server with primary ips
|
||||
hetzner.hcloud.server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
|
||||
- name: cleanup test create primary ips
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_server_name }}v4"
|
||||
state: absent
|
||||
- name: cleanup test create primary ips
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_server_name }}v42"
|
||||
state: absent
|
||||
until: result is not failed
|
||||
retries: 5
|
||||
delay: 2
|
||||
- name: cleanup test create primary ips
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: "{{ hcloud_server_name }}v6"
|
||||
state: absent
|
||||
until: result is not failed
|
||||
retries: 5
|
||||
delay: 2
|
||||
|
|
|
@ -1,51 +1,45 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: setup
|
||||
- name: Test missing required parameters
|
||||
hetzner.hcloud.server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify setup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: test missing required parameters on create server
|
||||
hetzner.hcloud.server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
register: result
|
||||
state: present
|
||||
ignore_errors: true
|
||||
- name: verify fail test missing required parameters on create server
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify missing required parameters
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "missing required arguments: server_type, image"'
|
||||
- >-
|
||||
result.msg == "missing required arguments: server_type, image"
|
||||
|
||||
- name: test create server with not existing server type
|
||||
- name: Test create server with invalid server type
|
||||
hetzner.hcloud.server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: not-existing-server-type
|
||||
server_type: invalid-server-type
|
||||
image: ubuntu-22.04
|
||||
state: present
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify fail test create server with not existing server type
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify create server with invalid server type
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "server_type not-existing-server-type was not found"'
|
||||
- >-
|
||||
result.msg == "Invalid server type ID `invalid-server-type`: server_type invalid-server-type was not found"
|
||||
|
||||
- name: test create server with not existing image
|
||||
- name: Test create server with invalid image
|
||||
hetzner.hcloud.server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: cx11
|
||||
image: my-not-existing-image-20.04
|
||||
image: invalid-image
|
||||
state: present
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify fail test create server with not existing image
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify create server with invalid image
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "Image my-not-existing-image-20.04 was not found"'
|
||||
- >-
|
||||
result.msg == "image with ID 'invalid-image' not found: Image invalid-image was not found"
|
||||
|
|
Loading…
Reference in a new issue