Skip to content

Commit

Permalink
Merge remote-tracking branch 'pcahyna/non-destructive-test-disk-impro…
Browse files Browse the repository at this point in the history
…vements' into non-destructive
  • Loading branch information
dwlehman committed Oct 23, 2019
2 parents 901dfd8 + da350a9 commit db1adcc
Showing 1 changed file with 92 additions and 7 deletions.
99 changes: 92 additions & 7 deletions tests/tests_disk_errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
include_role:
name: storage
vars:
storage_safe_mode: true
storage_volumes:
- name: test1
type: disk
Expand Down Expand Up @@ -101,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 }}"
Expand All @@ -118,7 +172,6 @@
include_role:
name: storage
vars:
storage_safe_mode: true
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
Expand All @@ -145,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 }}"
Expand All @@ -169,15 +254,15 @@
- 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:
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

0 comments on commit db1adcc

Please sign in to comment.