-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: use testing framework for server integration tests
- Loading branch information
Showing
5 changed files
with
127 additions
and
88 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
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
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,8 +1,8 @@ | ||
# Copyright: (c) 2022, Hetzner Cloud GmbH <[email protected]> | ||
# 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 |
72 changes: 13 additions & 59 deletions
72
tests/integration/targets/server/tasks/test_primary_ips.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,82 +1,36 @@ | ||
# Copyright: (c) 2022, 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 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 |
48 changes: 21 additions & 27 deletions
48
tests/integration/targets/server/tasks/test_validation.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,51 +1,45 @@ | ||
# 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 | ||
- 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" |