hcloud: Fix testsuite (#55076)

This commit is contained in:
Lukas Kämmerling 2019-04-10 15:16:10 +02:00 committed by René Moser
parent a971a0eb80
commit 3f579eb68f
21 changed files with 47 additions and 75 deletions

View file

@ -301,7 +301,7 @@ class AnsibleHcloudServer(Hcloud):
timeout = 100 timeout = 100
if self.module.params.get("upgrade_disk"): if self.module.params.get("upgrade_disk"):
timeout = ( timeout = (
500 1000
) # When we upgrade the disk too the resize progress takes some more time. ) # When we upgrade the disk too the resize progress takes some more time.
if not self.module.check_mode: if not self.module.check_mode:
self.hcloud_server.change_type( self.hcloud_server.change_type(

View file

@ -134,7 +134,7 @@ class AnsibleHcloudVolumeFacts(Hcloud):
self.module.params.get("name") self.module.params.get("name")
)] )]
elif self.module.params.get("label_selector") is not None: 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")) label_selector=self.module.params.get("label_selector"))
else: else:
self.hcloud_volume_facts = self.client.volumes.get_all() self.hcloud_volume_facts = self.client.volumes.get_all()

View file

@ -1,3 +1,2 @@
cloud/hcloud cloud/hcloud
shippable/hcloud/group1 shippable/hcloud/group1
disabled

View file

@ -1,51 +1,53 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de> # 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) # 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: 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: assert:
that: that:
- ansible_facts.hcloud_floating_ip_facts| list | count == 1 - 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: hcloud_floating_ip_facts:
check_mode: yes 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: assert:
that: that:
- ansible_facts.hcloud_floating_ip_facts| list | count == 1 - 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: hcloud_floating_ip_facts:
label_selector: "key=value" 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: assert:
that: that:
- ansible_facts.hcloud_floating_ip_facts|selectattr('description','equalto','{{ hcloud_test_floating_ip_name }}') | list | count == 1 - 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: hcloud_floating_ip_facts:
label_selector: "key!=value" 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: assert:
that: that:
- ansible_facts.hcloud_floating_ip_facts | list | count == 0 - 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: hcloud_floating_ip_facts:
id: "{{hcloud_test_floating_ip_id}}" 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: assert:
that: that:
- ansible_facts.hcloud_floating_ip_facts|selectattr('description','equalto','{{ hcloud_test_floating_ip_name }}') | list | count == 1 - 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: hcloud_floating_ip_facts:
id: "{{hcloud_test_floating_ip_id}}1" 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: assert:
that: that:
- ansible_facts.hcloud_floating_ip_facts | list | count == 0 - result is failed

View file

@ -1,3 +1,2 @@
cloud/hcloud cloud/hcloud
shippable/hcloud/group1 shippable/hcloud/group1
disabled

View file

@ -49,7 +49,9 @@
hcloud_image_facts: hcloud_image_facts:
id: "{{hcloud_test_image_id}}1" id: "{{hcloud_test_image_id}}1"
type: snapshot type: snapshot
ignore_errors: yes
register: result
- name: verify test gather hcloud image with wrong id - name: verify test gather hcloud image with wrong id
assert: assert:
that: that:
- ansible_facts.hcloud_image_facts | list | count == 0 - result is failed

View file

@ -1,3 +1,2 @@
cloud/hcloud cloud/hcloud
shippable/hcloud/group1 shippable/hcloud/group1
disabled

View file

@ -239,24 +239,26 @@
- name: test rebuild server - name: test rebuild server
hcloud_server: hcloud_server:
name: "{{ hcloud_server_name }}" name: "{{ hcloud_server_name }}"
image: ubuntu-18.04
state: rebuild state: rebuild
register: result_after_test register: result_after_test
- name: verify rebuild server - name: verify rebuild server
assert: assert:
that: that:
- result is changed - result_after_test is changed
- result.hcloud_server.id == result_after_test.hcloud_server.id - result.hcloud_server.id == result_after_test.hcloud_server.id
- name: test rebuild server with check mode - name: test rebuild server with check mode
hcloud_server: hcloud_server:
name: "{{ hcloud_server_name }}" name: "{{ hcloud_server_name }}"
image: ubuntu-18.04
state: rebuild state: rebuild
register: result_after_test register: result_after_test
check_mode: true check_mode: true
- name: verify rebuild server with check mode - name: verify rebuild server with check mode
assert: assert:
that: that:
- result is changed - result_after_test is changed
- name: absent server - name: absent server
hcloud_server: hcloud_server:

View file

@ -1,3 +1,2 @@
cloud/hcloud cloud/hcloud
shippable/hcloud/group1 shippable/hcloud/group1
unstable # tests are unstable because they conflict when run concurrently

View file

@ -7,13 +7,6 @@
state: absent state: absent
register: result 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 - name: create server
hcloud_server: hcloud_server:
name: "{{ hcloud_server_name }}" name: "{{ hcloud_server_name }}"

View file

@ -1,3 +1,2 @@
cloud/hcloud cloud/hcloud
shippable/hcloud/group1 shippable/hcloud/group1
disabled # conflicts with concurrent runs

View file

@ -0,0 +1,2 @@
dependencies:
- setup_sshkey

View file

@ -1,21 +1,12 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de> # 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) # 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 - name: test missing required parameters on create ssh_key
hcloud_ssh_key: hcloud_ssh_key:
name: "{{ hcloud_ssh_key_name }}" name: "{{ hcloud_ssh_key_name }}"
register: result register: result
ignore_errors: yes 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: assert:
that: that:
- result is failed - result is failed
@ -24,7 +15,7 @@
- name: test create ssh key with check mode - name: test create ssh key with check mode
hcloud_ssh_key: hcloud_ssh_key:
name: "{{ hcloud_ssh_key_name }}" name: "{{ hcloud_ssh_key_name }}"
public_key: "{{ hcloud_ssh_key_public_key }}" public_key: "{{ key_material }}"
register: result register: result
check_mode: yes check_mode: yes
- name: test create ssh key with check mode - name: test create ssh key with check mode
@ -35,7 +26,7 @@
- name: test create ssh key - name: test create ssh key
hcloud_ssh_key: hcloud_ssh_key:
name: "{{ hcloud_ssh_key_name }}" name: "{{ hcloud_ssh_key_name }}"
public_key: "{{ hcloud_ssh_key_public_key }}" public_key: "{{ key_material }}"
labels: labels:
key: value key: value
my-label: label my-label: label
@ -45,14 +36,13 @@
that: that:
- sshKey is changed - sshKey is changed
- sshKey.hcloud_ssh_key.name == "{{ hcloud_ssh_key_name }}" - sshKey.hcloud_ssh_key.name == "{{ hcloud_ssh_key_name }}"
- sshKey.hcloud_ssh_key.public_key == "{{ hcloud_ssh_key_public_key }}" - sshKey.hcloud_ssh_key.public_key == "{{ key_material }}"
- sshKey.hcloud_ssh_key.fingerprint == "{{ hcloud_ssh_key_fingerprint }}"
- sshKey.hcloud_ssh_key.labels.key == "value" - sshKey.hcloud_ssh_key.labels.key == "value"
- name: test create ssh key idempotence - name: test create ssh key idempotence
hcloud_ssh_key: hcloud_ssh_key:
name: "{{ hcloud_ssh_key_name }}" name: "{{ hcloud_ssh_key_name }}"
public_key: "{{ hcloud_ssh_key_public_key }}" public_key: "{{ key_material }}"
register: result register: result
- name: verify create ssh key idempotence - name: verify create ssh key idempotence
assert: assert:
@ -62,7 +52,7 @@
- name: test update ssh key with check mode - name: test update ssh key with check mode
hcloud_ssh_key: hcloud_ssh_key:
id: "{{ sshKey.hcloud_ssh_key.id }}" id: "{{ sshKey.hcloud_ssh_key.id }}"
name: "changed-ssh-key-name" name: "changed-{{ hcloud_ssh_key_name }}"
register: result register: result
check_mode: yes check_mode: yes
- name: test create ssh key with check mode - name: test create ssh key with check mode
@ -73,7 +63,7 @@
- name: test update ssh key - name: test update ssh key
hcloud_ssh_key: hcloud_ssh_key:
id: "{{ sshKey.hcloud_ssh_key.id }}" id: "{{ sshKey.hcloud_ssh_key.id }}"
name: "changed-ssh-key-name" name: "changed-{{ hcloud_ssh_key_name }}"
labels: labels:
key: value key: value
register: result register: result
@ -81,12 +71,12 @@
assert: assert:
that: that:
- result is changed - 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 - name: test update ssh key with same labels
hcloud_ssh_key: hcloud_ssh_key:
id: "{{ sshKey.hcloud_ssh_key.id }}" id: "{{ sshKey.hcloud_ssh_key.id }}"
name: "changed-ssh-key-name" name: "changed-{{ hcloud_ssh_key_name }}"
labels: labels:
key: value key: value
register: result register: result
@ -98,7 +88,7 @@
- name: test update ssh key with other labels - name: test update ssh key with other labels
hcloud_ssh_key: hcloud_ssh_key:
id: "{{ sshKey.hcloud_ssh_key.id }}" id: "{{ sshKey.hcloud_ssh_key.id }}"
name: "changed-ssh-key-name" name: "changed-{{ hcloud_ssh_key_name }}"
labels: labels:
key: value key: value
test: 123 test: 123

View file

@ -1,3 +1,2 @@
cloud/hcloud cloud/hcloud
shippable/hcloud/group1 shippable/hcloud/group1
disabled

View file

@ -1,4 +1,5 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de> # 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) # 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"

View file

@ -0,0 +1,2 @@
dependencies:
- setup_sshkey

View file

@ -8,17 +8,10 @@
state: absent state: absent
register: result 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 - name: setup test ssh_key
hcloud_ssh_key: hcloud_ssh_key:
name: "{{hcloud_ssh_key_name}}" name: "{{hcloud_ssh_key_name}}"
public_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGpl/tnk74nnQJxxLAtutUApUZMRJxryKh7VXkNbd4g9 john@example.com" public_key: "{{ key_material }}"
labels: labels:
key: value key: value
register: result register: result
@ -26,7 +19,7 @@
assert: assert:
that: that:
- result is changed - 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 - name: test gather hcloud ssh key facts in check mode
hcloud_ssh_key_facts: hcloud_ssh_key_facts:
@ -34,7 +27,7 @@
- name: verify test gather hcloud ssh key facts in check mode - name: verify test gather hcloud ssh key facts in check mode
assert: assert:
that: 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 - name: test gather hcloud ssh key facts
hcloud_ssh_key_facts: hcloud_ssh_key_facts:
@ -42,7 +35,7 @@
- name: verify test gather hcloud ssh key facts - name: verify test gather hcloud ssh key facts
assert: assert:
that: 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 - name: test gather hcloud ssh key facts with correct label selector
hcloud_ssh_key_facts: hcloud_ssh_key_facts:
@ -60,7 +53,6 @@
that: that:
- ansible_facts.hcloud_ssh_key_facts | list | count == 0 - ansible_facts.hcloud_ssh_key_facts | list | count == 0
- name: cleanup - name: cleanup
hcloud_ssh_key: hcloud_ssh_key:
name: "{{hcloud_ssh_key_name}}" name: "{{hcloud_ssh_key_name}}"

View file

@ -3,4 +3,4 @@
--- ---
hcloud_prefix: "tests" hcloud_prefix: "tests"
hcloud_volume_name: "{{hcloud_prefix}}-integ" hcloud_volume_name: "{{hcloud_prefix}}-integ"
hcloud_server_name: "{{hcloud_prefix}}-integ-server" hcloud_server_name: "{{hcloud_prefix}}-volume-server"

View file

@ -1,3 +1,2 @@
cloud/hcloud cloud/hcloud
shippable/hcloud/group1 shippable/hcloud/group1
disabled

View file

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

View file

@ -7,13 +7,6 @@
state: absent state: absent
register: result 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 - name: setup volume
hcloud_volume: hcloud_volume:
name: "{{hcloud_volume_name}}" name: "{{hcloud_volume_name}}"