Skip to content

Commit 63ff3ba

Browse files
pcahynadwlehman
authored andcommitted
More test fixes
- Check for errors properly in LVM error test, part 1 Remove ignore_errors in non-safe-mode tests and instead catch errors. Comment out the currently broken tests. - Check safe_mode properly in the LVM tests Do not use ignore_errors, catch the error instead. - Disable the resizing test, resizing does not seem to work at all currently. - Remove the explicit setting of storage_safe_mode to true True should be the default. - Safe mode should now be the default, account for this - Check that safe mode works even when the filesystem is unmounted. - Verify that replacing a fs by a LVM pool fails in safe mode - Cleanup properly.
1 parent 7682373 commit 63ff3ba

File tree

2 files changed

+311
-66
lines changed

2 files changed

+311
-66
lines changed

tests/tests_disk_errors.yml

Lines changed: 92 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
include_role:
7474
name: storage
7575
vars:
76-
storage_safe_mode: true
7776
storage_volumes:
7877
- name: test1
7978
type: disk
@@ -101,6 +100,61 @@
101100
not blivet_output.changed"
102101
msg: "Unexpected behavior w/ existing data on specified disks"
103102

103+
- name: Unmount file system
104+
include_role:
105+
name: storage
106+
vars:
107+
storage_volumes:
108+
- name: test1
109+
type: disk
110+
fs_type: 'ext4'
111+
disks: "{{ unused_disks }}"
112+
mount_point: none
113+
114+
- name: Test for correct handling of safe_mode with unmounted filesystem
115+
block:
116+
- name: Try to replace the file system on disk in safe mode
117+
include_role:
118+
name: storage
119+
vars:
120+
storage_volumes:
121+
- name: test1
122+
type: disk
123+
fs_type: 'ext3'
124+
disks: "{{ unused_disks }}"
125+
126+
- name: UNREACH
127+
fail:
128+
msg: "this should be unreachable"
129+
130+
rescue:
131+
- name: Check that we failed in the role
132+
assert:
133+
that:
134+
- ansible_failed_task.name != 'UNREACH'
135+
msg: "Role has not failed when it should have"
136+
vars:
137+
# Ugh! needed to expand ansible_failed_task
138+
storage_provider: blivet
139+
140+
- name: Verify the output
141+
assert:
142+
that: "blivet_output.failed and
143+
blivet_output.msg|regex_search('cannot remove existing formatting on volume.*in safe mode') and
144+
not blivet_output.changed"
145+
msg: "Unexpected behavior w/ existing data on specified disks"
146+
147+
- name: Remount file system
148+
include_role:
149+
name: storage
150+
vars:
151+
storage_volumes:
152+
- name: test1
153+
type: disk
154+
fs_type: 'ext4'
155+
disks: "{{ unused_disks }}"
156+
mount_point: "{{ mount_location }}"
157+
104158
- name: stat the file
105159
stat:
106160
path: "{{ testfile }}"
@@ -118,7 +172,6 @@
118172
include_role:
119173
name: storage
120174
vars:
121-
storage_safe_mode: true
122175
storage_pools:
123176
- name: foo
124177
disks: "{{ unused_disks }}"
@@ -145,6 +198,38 @@
145198
not blivet_output.changed"
146199
msg: "Unexpected behavior w/ existing data on specified disks"
147200

201+
- name: Test for correct handling of safe_mode with existing filesystem
202+
block:
203+
- name: Try to create LVM pool on disk that already belongs to an existing filesystem
204+
include_role:
205+
name: storage
206+
vars:
207+
storage_pools:
208+
- name: foo
209+
disks: "{{ unused_disks }}"
210+
type: lvm
211+
212+
- name: UNREACH
213+
fail:
214+
msg: "this should be unreachable"
215+
216+
rescue:
217+
- name: Check that we failed in the role
218+
assert:
219+
that:
220+
- ansible_failed_task.name != 'UNREACH'
221+
msg: "Role has not failed when it should have"
222+
vars:
223+
# Ugh! needed to expand ansible_failed_task
224+
storage_provider: blivet
225+
226+
- name: Verify the output
227+
assert:
228+
that: "{{ blivet_output.failed and
229+
blivet_output.msg|regex_search('cannot remove existing formatting and/or devices on disk.*in safe mode') and
230+
not blivet_output.changed }}"
231+
msg: "Unexpected behavior w/ existing data on specified disks"
232+
148233
- name: stat the file
149234
stat:
150235
path: "{{ testfile }}"
@@ -169,15 +254,15 @@
169254
- name: Verify the output
170255
assert:
171256
that: not blivet_output.failed
172-
msg: "failed to create partition pool over existing file system using default value of safe_mode"
257+
msg: "failed to create partition pool over existing file system w/o safe_mode"
173258

174259
- name: Clean up
175260
include_role:
176261
name: storage
177262
vars:
178263
storage_safe_mode: false
179-
storage_volumes:
180-
- name: test1
181-
type: disk
264+
storage_pools:
265+
- name: foo
266+
type: partition
182267
disks: "{{ unused_disks }}"
183-
present: false
268+
state: absent

0 commit comments

Comments
 (0)