summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/incidental_lvg/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/incidental_lvg/tasks')
-rw-r--r--test/integration/targets/incidental_lvg/tasks/main.yml15
-rw-r--r--test/integration/targets/incidental_lvg/tasks/setup.yml13
-rw-r--r--test/integration/targets/incidental_lvg/tasks/teardown.yml17
-rw-r--r--test/integration/targets/incidental_lvg/tasks/test_grow_reduce.yml33
-rw-r--r--test/integration/targets/incidental_lvg/tasks/test_indempotency.yml15
5 files changed, 93 insertions, 0 deletions
diff --git a/test/integration/targets/incidental_lvg/tasks/main.yml b/test/integration/targets/incidental_lvg/tasks/main.yml
new file mode 100644
index 00000000..a57f591b
--- /dev/null
+++ b/test/integration/targets/incidental_lvg/tasks/main.yml
@@ -0,0 +1,15 @@
+- name: Install required packages (Linux)
+ package:
+ name: lvm2
+ state: present
+ when: ansible_system == 'Linux'
+
+- name: Test lvg module
+ block:
+ - import_tasks: setup.yml
+
+ - import_tasks: test_indempotency.yml
+
+ - import_tasks: test_grow_reduce.yml
+ always:
+ - import_tasks: teardown.yml
diff --git a/test/integration/targets/incidental_lvg/tasks/setup.yml b/test/integration/targets/incidental_lvg/tasks/setup.yml
new file mode 100644
index 00000000..e63c2d64
--- /dev/null
+++ b/test/integration/targets/incidental_lvg/tasks/setup.yml
@@ -0,0 +1,13 @@
+- name: "Create files to use as a disk devices"
+ command: "dd if=/dev/zero of={{ remote_tmp_dir }}/img{{ item }} bs=1M count=10"
+ with_sequence: 'count=2'
+
+- name: "Create loop device for file"
+ command: "losetup --show -f {{ remote_tmp_dir }}/img{{ item }}"
+ with_sequence: 'count=2'
+ register: loop_devices
+
+- name: "Affect name on disk to work on"
+ set_fact:
+ loop_device1: "{{ loop_devices.results[0] }}"
+ loop_device2: "{{ loop_devices.results[1] }}"
diff --git a/test/integration/targets/incidental_lvg/tasks/teardown.yml b/test/integration/targets/incidental_lvg/tasks/teardown.yml
new file mode 100644
index 00000000..ed662f1e
--- /dev/null
+++ b/test/integration/targets/incidental_lvg/tasks/teardown.yml
@@ -0,0 +1,17 @@
+- name: Remove test volume group
+ lvg:
+ vg: testvg
+ state: absent
+
+- name: Detach loop device
+ command: "losetup -d {{ item.stdout }}"
+ loop: "{{ loop_devices.results|default([]) }}"
+ when:
+ - item.stdout is defined
+ - item.stdout is match("/dev/.*")
+
+- name: Remove device files
+ file:
+ path: "{{ remote_tmp_dir }}/img{{ item }}"
+ state: absent
+ with_sequence: 'count={{ loop_devices.results|length }}'
diff --git a/test/integration/targets/incidental_lvg/tasks/test_grow_reduce.yml b/test/integration/targets/incidental_lvg/tasks/test_grow_reduce.yml
new file mode 100644
index 00000000..1e988045
--- /dev/null
+++ b/test/integration/targets/incidental_lvg/tasks/test_grow_reduce.yml
@@ -0,0 +1,33 @@
+- name: "Create volume group on first disk"
+ lvg:
+ vg: testvg
+ pvs: "{{ loop_device1.stdout }}"
+
+- name: "get lvm facts"
+ setup:
+
+- debug: var=ansible_lvm
+
+- name: "Assert the testvg span only on first disk"
+ assert:
+ that:
+ - ansible_lvm.pvs[loop_device1.stdout].vg == "testvg"
+ - 'loop_device2.stdout not in ansible_lvm.pvs or
+ ansible_lvm.pvs[loop_device2.stdout].vg == ""'
+
+- name: "Extend to second disk AND reduce from the first disk"
+ lvg:
+ vg: testvg
+ pvs: "{{ loop_device2.stdout }}"
+
+- name: "get lvm facts"
+ setup:
+
+- debug: var=ansible_lvm
+
+- name: "Assert the testvg span only on first disk"
+ assert:
+ that:
+ - 'loop_device1.stdout not in ansible_lvm.pvs or
+ ansible_lvm.pvs[loop_device1.stdout].vg == ""'
+ - ansible_lvm.pvs[loop_device2.stdout].vg == "testvg"
diff --git a/test/integration/targets/incidental_lvg/tasks/test_indempotency.yml b/test/integration/targets/incidental_lvg/tasks/test_indempotency.yml
new file mode 100644
index 00000000..5007e56a
--- /dev/null
+++ b/test/integration/targets/incidental_lvg/tasks/test_indempotency.yml
@@ -0,0 +1,15 @@
+- name: Create volume group on disk device
+ lvg:
+ vg: testvg
+ pvs: "{{ loop_device1.stdout }}"
+
+- name: Create the volume group again to verify idempotence
+ lvg:
+ vg: testvg
+ pvs: "{{ loop_device1.stdout }}"
+ register: repeat_vg_create
+
+- name: Do all assertions to verify expected results
+ assert:
+ that:
+ - repeat_vg_create is not changed