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