summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/hcloud_volume
diff options
context:
space:
mode:
authorChristopher Schmitt <47825810+cschmitt-hcloud@users.noreply.github.com>2019-03-26 19:24:10 +0100
committerRené Moser <mail@renemoser.net>2019-03-26 19:24:10 +0100
commitfe0765eb2b538fbe1cfe61f80c5913feca86b5ff (patch)
treeb35d4bdb468e26d3b3cdf1d33f5f1e813907741a /test/integration/targets/hcloud_volume
parentcs_volume: fix unit tests cleanup (#54397) (diff)
downloadansible-fe0765eb2b538fbe1cfe61f80c5913feca86b5ff.tar.xz
ansible-fe0765eb2b538fbe1cfe61f80c5913feca86b5ff.zip
Add hcloud_volume module (#53745)
Diffstat (limited to 'test/integration/targets/hcloud_volume')
-rw-r--r--test/integration/targets/hcloud_volume/aliases2
-rw-r--r--test/integration/targets/hcloud_volume/defaults/main.yml6
-rw-r--r--test/integration/targets/hcloud_volume/tasks/main.yml177
3 files changed, 185 insertions, 0 deletions
diff --git a/test/integration/targets/hcloud_volume/aliases b/test/integration/targets/hcloud_volume/aliases
new file mode 100644
index 0000000000..51742ee23f
--- /dev/null
+++ b/test/integration/targets/hcloud_volume/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+unsupported
diff --git a/test/integration/targets/hcloud_volume/defaults/main.yml b/test/integration/targets/hcloud_volume/defaults/main.yml
new file mode 100644
index 0000000000..ad7469fb29
--- /dev/null
+++ b/test/integration/targets/hcloud_volume/defaults/main.yml
@@ -0,0 +1,6 @@
+# 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_prefix: "tests"
+hcloud_volume_name: "{{hcloud_prefix}}-integ"
+hcloud_server_name: "{{hcloud_prefix}}-integ-server"
diff --git a/test/integration/targets/hcloud_volume/tasks/main.yml b/test/integration/targets/hcloud_volume/tasks/main.yml
new file mode 100644
index 0000000000..ba59af06b1
--- /dev/null
+++ b/test/integration/targets/hcloud_volume/tasks/main.yml
@@ -0,0 +1,177 @@
+# 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 server
+ hcloud_server:
+ name: "{{hcloud_server_name}}"
+ server_type: cx11
+ image: ubuntu-18.04
+ state: started
+ location: "fsn1"
+ register: main_server
+- name: verify setup server
+ assert:
+ that:
+ - main_server is changed
+
+- name: test missing size parameter on create Volume
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ server: "{{hcloud_server_name}}"
+ register: result
+ ignore_errors: yes
+- name: verify fail test missing size parameter on create Volume
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "missing required arguments: size"'
+
+- name: test create volume with check mode
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ size: 10
+ location: "fsn1"
+ register: result
+ check_mode: yes
+- name: verify create volume with check mode result
+ assert:
+ that:
+ - result is changed
+
+- name: test create volume
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ size: 10
+ location: "fsn1"
+ register: volume
+- name: verify test create volume
+ assert:
+ that:
+ - volume is changed
+ - volume.hcloud_volume.name == "{{hcloud_volume_name}}"
+ - volume.hcloud_volume.location == "fsn1"
+ - volume.hcloud_volume.size == 10
+ - volume.hcloud_volume.server != "{{hcloud_server_name}}"
+
+- name: test create volume idempotence
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ size: 10
+ location: "fsn1"
+ register: volume
+- name: verify test create volume
+ assert:
+ that:
+ - volume is not changed
+
+- name: test attach volume with checkmode
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ server: "{{hcloud_server_name}}"
+ check_mode: yes
+ register: volume
+- name: verify test attach volume with checkmode
+ assert:
+ that:
+ - volume is changed
+ - volume.hcloud_volume.server != "{{hcloud_server_name}}"
+
+- name: test attach volume
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ server: "{{hcloud_server_name}}"
+ register: volume
+- name: verify attach volume
+ assert:
+ that:
+ - volume is changed
+ - volume.hcloud_volume.server == "{{hcloud_server_name}}"
+ - main_server is changed
+
+- name: test detach volume with checkmode
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ check_mode: yes
+ register: volume
+- name: verify detach volume with checkmode
+ assert:
+ that:
+ - volume is changed
+ - volume.hcloud_volume.server == "{{hcloud_server_name}}"
+
+- name: test detach volume
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ register: volume
+- name: verify detach volume
+ assert:
+ that:
+ - volume is changed
+ - volume.hcloud_volume.location == "fsn1"
+ - volume.hcloud_volume.server != "{{hcloud_server_name}}"
+ - main_server is changed
+
+- name: test update volume label
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ labels:
+ key: value
+ register: volume
+- name: verify test update volume lable
+ assert:
+ that:
+ - volume is changed
+ - volume.hcloud_volume.labels.key == "value"
+
+- name: test update volume label with the same label
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ labels:
+ key: value
+ register: volume
+- name: verify test update volume lable with the same label
+ assert:
+ that:
+ - volume is not changed
+
+- name: test increase volume size
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ size: 11
+ register: volume
+- name: verify test increase volume size
+ assert:
+ that:
+ - volume is changed
+ - volume.hcloud_volume.size == 11
+
+- name: test decreace volume size
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ size: 10
+ register: volume
+- name: verify test decreace volume size
+ assert:
+ that:
+ - volume is not changed
+ - volume.hcloud_volume.size == 11
+
+- name: test delete volume
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ state: absent
+ register: result
+- name: verify delete volume
+ assert:
+ that:
+ - result is success
+
+- name: cleanup
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success