Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hcloud testsuite #55076

Merged
merged 6 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ansible/modules/cloud/hcloud/hcloud_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def _update_server(self):
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(
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/modules/cloud/hcloud/hcloud_volume_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def get_volumes(self):
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()
Expand Down
1 change: 0 additions & 1 deletion test/integration/targets/hcloud_floating_ip_facts/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
cloud/hcloud
shippable/hcloud/group1
disabled
28 changes: 15 additions & 13 deletions test/integration/targets/hcloud_floating_ip_facts/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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 change: 0 additions & 1 deletion test/integration/targets/hcloud_image_facts/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
cloud/hcloud
shippable/hcloud/group1
disabled
4 changes: 3 additions & 1 deletion test/integration/targets/hcloud_image_facts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 0 additions & 1 deletion test/integration/targets/hcloud_server/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
cloud/hcloud
shippable/hcloud/group1
disabled
6 changes: 4 additions & 2 deletions test/integration/targets/hcloud_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion test/integration/targets/hcloud_server_facts/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
cloud/hcloud
shippable/hcloud/group1
unstable # tests are unstable because they conflict when run concurrently
7 changes: 0 additions & 7 deletions test/integration/targets/hcloud_server_facts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
1 change: 0 additions & 1 deletion test/integration/targets/hcloud_ssh_key/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
cloud/hcloud
shippable/hcloud/group1
disabled # conflicts with concurrent runs
2 changes: 2 additions & 0 deletions test/integration/targets/hcloud_ssh_key/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- setup_sshkey
32 changes: 11 additions & 21 deletions test/integration/targets/hcloud_ssh_key/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -73,32 +63,32 @@
- 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
- name: test update ssh key
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

- 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
Expand Down
1 change: 0 additions & 1 deletion test/integration/targets/hcloud_ssh_key_facts/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
cloud/hcloud
shippable/hcloud/group1
disabled
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions test/integration/targets/hcloud_ssh_key_facts/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- setup_sshkey
16 changes: 4 additions & 12 deletions test/integration/targets/hcloud_ssh_key_facts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,34 @@
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
- name: verify create test ssh_key
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:
check_mode: yes
- 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:
check_mode: yes
- 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:
Expand All @@ -60,7 +53,6 @@
that:
- ansible_facts.hcloud_ssh_key_facts | list | count == 0


- name: cleanup
hcloud_ssh_key:
name: "{{hcloud_ssh_key_name}}"
Expand Down
2 changes: 1 addition & 1 deletion test/integration/targets/hcloud_volume/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 0 additions & 1 deletion test/integration/targets/hcloud_volume_facts/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
cloud/hcloud
shippable/hcloud/group1
disabled
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 0 additions & 7 deletions test/integration/targets/hcloud_volume_facts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
Expand Down