hcloud: Fix testsuite (#55076)
This commit is contained in:
parent
a971a0eb80
commit
3f579eb68f
21 changed files with 47 additions and 75 deletions
|
@ -301,7 +301,7 @@ class AnsibleHcloudServer(Hcloud):
|
|||
timeout = 100
|
||||
if self.module.params.get("upgrade_disk"):
|
||||
timeout = (
|
||||
500
|
||||
1000
|
||||
) # When we upgrade the disk too the resize progress takes some more time.
|
||||
if not self.module.check_mode:
|
||||
self.hcloud_server.change_type(
|
||||
|
|
|
@ -134,7 +134,7 @@ class AnsibleHcloudVolumeFacts(Hcloud):
|
|||
self.module.params.get("name")
|
||||
)]
|
||||
elif self.module.params.get("label_selector") is not None:
|
||||
self.hcloud_volume_facts = self.client.servers.get_all(
|
||||
self.hcloud_volume_facts = self.client.volumes.get_all(
|
||||
label_selector=self.module.params.get("label_selector"))
|
||||
else:
|
||||
self.hcloud_volume_facts = self.client.volumes.get_all()
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group1
|
||||
disabled
|
||||
|
|
|
@ -1,51 +1,53 @@
|
|||
# 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: test gather hcloud image facts
|
||||
- name: test gather hcloud floating ip facts
|
||||
hcloud_floating_ip_facts:
|
||||
- name: verify test gather hcloud image facts in check mode
|
||||
- name: verify test gather hcloud floating ip facts in check mode
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_floating_ip_facts| list | count == 1
|
||||
|
||||
- name: test gather hcloud image facts in check mode
|
||||
- name: test gather hcloud floating ip facts in check mode
|
||||
hcloud_floating_ip_facts:
|
||||
check_mode: yes
|
||||
|
||||
- name: verify test gather hcloud image facts in check mode
|
||||
- name: verify test gather hcloud floating ip facts in check mode
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_floating_ip_facts| list | count == 1
|
||||
|
||||
|
||||
- name: test gather hcloud image facts with correct label selector
|
||||
- name: test gather hcloud floating ip facts with correct label selector
|
||||
hcloud_floating_ip_facts:
|
||||
label_selector: "key=value"
|
||||
- name: verify test gather hcloud image with correct label selector
|
||||
- name: verify test gather hcloud floating ip with correct label selector
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_floating_ip_facts|selectattr('description','equalto','{{ hcloud_test_floating_ip_name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud image facts with wrong label selector
|
||||
- name: test gather hcloud floating ip facts with wrong label selector
|
||||
hcloud_floating_ip_facts:
|
||||
label_selector: "key!=value"
|
||||
- name: verify test gather hcloud image with wrong label selector
|
||||
- name: verify test gather hcloud floating ip with wrong label selector
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_floating_ip_facts | list | count == 0
|
||||
|
||||
- name: test gather hcloud image facts with correct id
|
||||
- name: test gather hcloud floating ip facts with correct id
|
||||
hcloud_floating_ip_facts:
|
||||
id: "{{hcloud_test_floating_ip_id}}"
|
||||
- name: verify test gather hcloud image with correct id
|
||||
- name: verify test gather hcloud floating ip with correct id
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_floating_ip_facts|selectattr('description','equalto','{{ hcloud_test_floating_ip_name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud image facts with wrong id
|
||||
- name: test gather hcloud floating ip facts with wrong id
|
||||
hcloud_floating_ip_facts:
|
||||
id: "{{hcloud_test_floating_ip_id}}1"
|
||||
- name: verify test gather hcloud image with wrong id
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
- name: verify test gather hcloud floating ip with wrong id
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_floating_ip_facts | list | count == 0
|
||||
- result is failed
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group1
|
||||
disabled
|
||||
|
|
|
@ -49,7 +49,9 @@
|
|||
hcloud_image_facts:
|
||||
id: "{{hcloud_test_image_id}}1"
|
||||
type: snapshot
|
||||
ignore_errors: yes
|
||||
register: result
|
||||
- name: verify test gather hcloud image with wrong id
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_image_facts | list | count == 0
|
||||
- result is failed
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group1
|
||||
disabled
|
||||
|
|
|
@ -239,24 +239,26 @@
|
|||
- name: test rebuild server
|
||||
hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
image: ubuntu-18.04
|
||||
state: rebuild
|
||||
register: result_after_test
|
||||
- name: verify rebuild server
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result_after_test is changed
|
||||
- result.hcloud_server.id == result_after_test.hcloud_server.id
|
||||
|
||||
- name: test rebuild server with check mode
|
||||
hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
image: ubuntu-18.04
|
||||
state: rebuild
|
||||
register: result_after_test
|
||||
check_mode: true
|
||||
- name: verify rebuild server with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result_after_test is changed
|
||||
|
||||
- name: absent server
|
||||
hcloud_server:
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group1
|
||||
unstable # tests are unstable because they conflict when run concurrently
|
||||
|
|
|
@ -7,13 +7,6 @@
|
|||
state: absent
|
||||
register: result
|
||||
|
||||
- name: test gather hcloud server facts - empty resources
|
||||
hcloud_server_facts:
|
||||
- name: verify test gather hcloud server facts - empty resources
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_server_facts | count == 0
|
||||
|
||||
- name: create server
|
||||
hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group1
|
||||
disabled # conflicts with concurrent runs
|
||||
|
|
2
test/integration/targets/hcloud_ssh_key/meta/main.yml
Normal file
2
test/integration/targets/hcloud_ssh_key/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- setup_sshkey
|
|
@ -1,21 +1,12 @@
|
|||
# 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
|
||||
hcloud_ssh_key:
|
||||
fingerprint: "{{ hcloud_ssh_key_fingerprint }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify setup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
- name: test missing required parameters on create ssh_key
|
||||
hcloud_ssh_key:
|
||||
name: "{{ hcloud_ssh_key_name }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
- name: verify fail test missing required parameters on create server
|
||||
- name: verify fail test missing required parameters on create ssh_key
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
@ -24,7 +15,7 @@
|
|||
- name: test create ssh key with check mode
|
||||
hcloud_ssh_key:
|
||||
name: "{{ hcloud_ssh_key_name }}"
|
||||
public_key: "{{ hcloud_ssh_key_public_key }}"
|
||||
public_key: "{{ key_material }}"
|
||||
register: result
|
||||
check_mode: yes
|
||||
- name: test create ssh key with check mode
|
||||
|
@ -35,7 +26,7 @@
|
|||
- name: test create ssh key
|
||||
hcloud_ssh_key:
|
||||
name: "{{ hcloud_ssh_key_name }}"
|
||||
public_key: "{{ hcloud_ssh_key_public_key }}"
|
||||
public_key: "{{ key_material }}"
|
||||
labels:
|
||||
key: value
|
||||
my-label: label
|
||||
|
@ -45,14 +36,13 @@
|
|||
that:
|
||||
- sshKey is changed
|
||||
- sshKey.hcloud_ssh_key.name == "{{ hcloud_ssh_key_name }}"
|
||||
- sshKey.hcloud_ssh_key.public_key == "{{ hcloud_ssh_key_public_key }}"
|
||||
- sshKey.hcloud_ssh_key.fingerprint == "{{ hcloud_ssh_key_fingerprint }}"
|
||||
- sshKey.hcloud_ssh_key.public_key == "{{ key_material }}"
|
||||
- sshKey.hcloud_ssh_key.labels.key == "value"
|
||||
|
||||
- name: test create ssh key idempotence
|
||||
hcloud_ssh_key:
|
||||
name: "{{ hcloud_ssh_key_name }}"
|
||||
public_key: "{{ hcloud_ssh_key_public_key }}"
|
||||
public_key: "{{ key_material }}"
|
||||
register: result
|
||||
- name: verify create ssh key idempotence
|
||||
assert:
|
||||
|
@ -62,7 +52,7 @@
|
|||
- name: test update ssh key with check mode
|
||||
hcloud_ssh_key:
|
||||
id: "{{ sshKey.hcloud_ssh_key.id }}"
|
||||
name: "changed-ssh-key-name"
|
||||
name: "changed-{{ hcloud_ssh_key_name }}"
|
||||
register: result
|
||||
check_mode: yes
|
||||
- name: test create ssh key with check mode
|
||||
|
@ -73,7 +63,7 @@
|
|||
- name: test update ssh key
|
||||
hcloud_ssh_key:
|
||||
id: "{{ sshKey.hcloud_ssh_key.id }}"
|
||||
name: "changed-ssh-key-name"
|
||||
name: "changed-{{ hcloud_ssh_key_name }}"
|
||||
labels:
|
||||
key: value
|
||||
register: result
|
||||
|
@ -81,16 +71,16 @@
|
|||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.hcloud_ssh_key.name == "changed-ssh-key-name"
|
||||
- result.hcloud_ssh_key.name == "changed-{{ hcloud_ssh_key_name }}"
|
||||
|
||||
- name: test update ssh key with same labels
|
||||
hcloud_ssh_key:
|
||||
id: "{{ sshKey.hcloud_ssh_key.id }}"
|
||||
name: "changed-ssh-key-name"
|
||||
name: "changed-{{ hcloud_ssh_key_name }}"
|
||||
labels:
|
||||
key: value
|
||||
register: result
|
||||
- name: test update ssh key with same labels
|
||||
- name: test update ssh key with same labels
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
@ -98,7 +88,7 @@
|
|||
- name: test update ssh key with other labels
|
||||
hcloud_ssh_key:
|
||||
id: "{{ sshKey.hcloud_ssh_key.id }}"
|
||||
name: "changed-ssh-key-name"
|
||||
name: "changed-{{ hcloud_ssh_key_name }}"
|
||||
labels:
|
||||
key: value
|
||||
test: 123
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group1
|
||||
disabled
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# 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)
|
||||
---
|
||||
hcloud_ssh_key_name: "test_ssh_key"
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_ssh_key_name: "{{hcloud_prefix}}-ssh_key_facts"
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- setup_sshkey
|
|
@ -8,17 +8,10 @@
|
|||
state: absent
|
||||
register: result
|
||||
|
||||
- name: test gather hcloud ssh key facts - empty resources
|
||||
hcloud_ssh_key_facts:
|
||||
- name: verify test gather hcloud ssh key facts - empty resources
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_ssh_key_facts | count == 0
|
||||
|
||||
- name: setup test ssh_key
|
||||
hcloud_ssh_key:
|
||||
name: "{{hcloud_ssh_key_name}}"
|
||||
public_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGpl/tnk74nnQJxxLAtutUApUZMRJxryKh7VXkNbd4g9 john@example.com"
|
||||
public_key: "{{ key_material }}"
|
||||
labels:
|
||||
key: value
|
||||
register: result
|
||||
|
@ -26,7 +19,7 @@
|
|||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.hcloud_ssh_key.public_key == "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGpl/tnk74nnQJxxLAtutUApUZMRJxryKh7VXkNbd4g9 john@example.com"
|
||||
- result.hcloud_ssh_key.public_key == "{{ key_material }}"
|
||||
|
||||
- name: test gather hcloud ssh key facts in check mode
|
||||
hcloud_ssh_key_facts:
|
||||
|
@ -34,7 +27,7 @@
|
|||
- name: verify test gather hcloud ssh key facts in check mode
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_ssh_key_facts| list | count == 1
|
||||
- ansible_facts.hcloud_ssh_key_facts| list | count >= 1
|
||||
|
||||
- name: test gather hcloud ssh key facts
|
||||
hcloud_ssh_key_facts:
|
||||
|
@ -42,7 +35,7 @@
|
|||
- name: verify test gather hcloud ssh key facts
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_ssh_key_facts| list | count == 1
|
||||
- ansible_facts.hcloud_ssh_key_facts| list | count >= 1
|
||||
|
||||
- name: test gather hcloud ssh key facts with correct label selector
|
||||
hcloud_ssh_key_facts:
|
||||
|
@ -60,7 +53,6 @@
|
|||
that:
|
||||
- ansible_facts.hcloud_ssh_key_facts | list | count == 0
|
||||
|
||||
|
||||
- name: cleanup
|
||||
hcloud_ssh_key:
|
||||
name: "{{hcloud_ssh_key_name}}"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_volume_name: "{{hcloud_prefix}}-integ"
|
||||
hcloud_server_name: "{{hcloud_prefix}}-integ-server"
|
||||
hcloud_server_name: "{{hcloud_prefix}}-volume-server"
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group1
|
||||
disabled
|
||||
|
|
|
@ -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}}-integ"
|
||||
hcloud_volume_name: "{{hcloud_prefix}}-facts"
|
||||
|
|
|
@ -7,13 +7,6 @@
|
|||
state: absent
|
||||
register: result
|
||||
|
||||
- name: test gather hcloud volume facts - empty resources
|
||||
hcloud_volume_facts:
|
||||
- name: verify test gather hcloud volume facts - empty resources
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts.hcloud_volume_facts | count == 0
|
||||
|
||||
- name: setup volume
|
||||
hcloud_volume:
|
||||
name: "{{hcloud_volume_name}}"
|
||||
|
|
Loading…
Reference in a new issue