From d2f3d97b05d133fd889a2b960dfd7509a823aac2 Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Tue, 15 Oct 2019 13:59:54 +0200 Subject: [PATCH] Remove last instance of ignore_errors: yes and check for errors properly. Verify again that data have not been lost. Do not use a pool type of partition, seems to be unimplemented. Create one volume in the pool, the role does not cope with empty pools. Note that even with those changes the role application fails - apparently it refuses to create a VG when there is already a filesystem, even with safe mode off. --- tests/tests_disk_errors.yml | 75 ++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/tests/tests_disk_errors.yml b/tests/tests_disk_errors.yml index e0309879..71fcf0b2 100644 --- a/tests/tests_disk_errors.yml +++ b/tests/tests_disk_errors.yml @@ -124,36 +124,59 @@ disks: "{{ unused_disks }}" type: partition - - 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: UNREACH + fail: + msg: "this should be unreachable" - - name: Create a partition pool on the disk already containing a file system w/o safe_mode - include_role: - name: storage + 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: - storage_safe_mode: false - storage_pools: - - name: foo - disks: "{{ unused_disks }}" - type: partition + # Ugh! needed to expand ansible_failed_task + storage_provider: blivet - 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" + 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: Clean up - include_role: - name: storage - vars: - storage_volumes: - - name: test1 - type: disk - disks: "{{ unused_disks }}" - present: false + - name: stat the file + stat: + path: "{{ testfile }}" + register: stat_r + + - name: assert file presence + assert: + that: + stat_r.stat.isreg is defined and stat_r.stat.isreg + msg: "data lost!" + + - name: Create a LVM pool on the disk already containing a file system w/o safe_mode + include_role: + name: storage + vars: + storage_safe_mode: false + storage_pools: + - name: foo + disks: "{{ unused_disks }}" + type: partition - ignore_errors: yes + - name: Verify the output + assert: + that: not blivet_output.failed + msg: "failed to create LVM pool over existing file system using default value of safe_mode" + + - name: Clean up + include_role: + name: storage + vars: + storage_volumes: + - name: test1 + type: disk + disks: "{{ unused_disks }}" + present: false