From 09972bf4dfa6e9fd540fa1e56852507b70a98170 Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Mon, 21 Oct 2019 20:23:50 +0200 Subject: [PATCH 1/4] Safe mode should now be the default, account for this --- tests/tests_disk_errors.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/tests_disk_errors.yml b/tests/tests_disk_errors.yml index fab86937..e0d7df1e 100644 --- a/tests/tests_disk_errors.yml +++ b/tests/tests_disk_errors.yml @@ -73,7 +73,6 @@ include_role: name: storage vars: - storage_safe_mode: true storage_volumes: - name: test1 type: disk @@ -118,7 +117,6 @@ include_role: name: storage vars: - storage_safe_mode: true storage_pools: - name: foo disks: "{{ unused_disks }}" @@ -169,7 +167,7 @@ - name: Verify the output assert: that: not blivet_output.failed - msg: "failed to create partition pool over existing file system using default value of safe_mode" + msg: "failed to create partition pool over existing file system w/o safe_mode" - name: Clean up include_role: From 7f021399910e8ebaf788385b8314a26090d4b4a1 Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Mon, 21 Oct 2019 20:24:48 +0200 Subject: [PATCH 2/4] Check that safe mode works even when the filesystem is unmounted. --- tests/tests_disk_errors.yml | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/tests_disk_errors.yml b/tests/tests_disk_errors.yml index e0d7df1e..5d93a4d1 100644 --- a/tests/tests_disk_errors.yml +++ b/tests/tests_disk_errors.yml @@ -100,6 +100,61 @@ not blivet_output.changed" msg: "Unexpected behavior w/ existing data on specified disks" + - name: Unmount file system + include_role: + name: storage + vars: + storage_volumes: + - name: test1 + type: disk + fs_type: 'ext4' + disks: "{{ unused_disks }}" + mount_point: none + + - name: Test for correct handling of safe_mode with unmounted filesystem + block: + - name: Try to replace the file system on disk in safe mode + include_role: + name: storage + vars: + storage_volumes: + - name: test1 + type: disk + fs_type: 'ext3' + disks: "{{ unused_disks }}" + + - name: UNREACH + fail: + msg: "this should be unreachable" + + rescue: + - name: Check that we failed in the role + assert: + that: + - ansible_failed_task.name != 'UNREACH' + msg: "Role has not failed when it should have" + vars: + # Ugh! needed to expand ansible_failed_task + storage_provider: blivet + + - name: Verify the output + assert: + that: "blivet_output.failed and + blivet_output.msg|regex_search('cannot remove existing formatting on volume.*in safe mode') and + not blivet_output.changed" + msg: "Unexpected behavior w/ existing data on specified disks" + + - name: Remount file system + include_role: + name: storage + vars: + storage_volumes: + - name: test1 + type: disk + fs_type: 'ext4' + disks: "{{ unused_disks }}" + mount_point: "{{ mount_location }}" + - name: stat the file stat: path: "{{ testfile }}" From 9a25938b6fbf00ce5cf876d0b4e7f2bc373dcd59 Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Mon, 21 Oct 2019 20:25:33 +0200 Subject: [PATCH 3/4] Verify that replacing a fs by a LVM pool fails in safe mode --- tests/tests_disk_errors.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/tests_disk_errors.yml b/tests/tests_disk_errors.yml index 5d93a4d1..34b03d97 100644 --- a/tests/tests_disk_errors.yml +++ b/tests/tests_disk_errors.yml @@ -198,6 +198,38 @@ not blivet_output.changed" msg: "Unexpected behavior w/ existing data on specified disks" + - name: Test for correct handling of safe_mode with existing filesystem + block: + - name: Try to create LVM pool on disk that already belongs to an existing filesystem + include_role: + name: storage + vars: + storage_pools: + - name: foo + disks: "{{ unused_disks }}" + type: lvm + + - name: UNREACH + fail: + msg: "this should be unreachable" + + rescue: + - name: Check that we failed in the role + assert: + that: + - ansible_failed_task.name != 'UNREACH' + msg: "Role has not failed when it should have" + vars: + # Ugh! needed to expand ansible_failed_task + storage_provider: blivet + + - name: Verify the output + assert: + that: "{{ blivet_output.failed and + blivet_output.msg|regex_search('cannot remove existing formatting and/or devices on disk.*in safe mode') and + not blivet_output.changed }}" + msg: "Unexpected behavior w/ existing data on specified disks" + - name: stat the file stat: path: "{{ testfile }}" From da350a9816351be09d010bf21ade80596a2317db Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Tue, 22 Oct 2019 16:53:19 +0200 Subject: [PATCH 4/4] Cleanup properly. --- tests/tests_disk_errors.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tests_disk_errors.yml b/tests/tests_disk_errors.yml index 34b03d97..7112f6ed 100644 --- a/tests/tests_disk_errors.yml +++ b/tests/tests_disk_errors.yml @@ -261,8 +261,8 @@ name: storage vars: storage_safe_mode: false - storage_volumes: - - name: test1 - type: disk + storage_pools: + - name: foo + type: partition disks: "{{ unused_disks }}" - present: false + state: absent