Skip to content

Commit

Permalink
Check for errors properly in LVM error test, part 1
Browse files Browse the repository at this point in the history
Remove ignore_errors in non-safe-mode tests and instead catch errors. Comment
out the currently broken tests.
  • Loading branch information
pcahyna committed Oct 21, 2019
1 parent dd695e8 commit 368d145
Showing 1 changed file with 125 additions and 36 deletions.
161 changes: 125 additions & 36 deletions tests/tests_lvm_errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,32 @@
size: "{{ volume1_size }}"
mount_point: "{{ mount_location1 }}"

- name: Verify the output
- name: UNREACH
fail:
msg: "this should be unreachable"

rescue:
- name: Check that we failed in the role
assert:
that: "{{ blivet_output.failed and
blivet_output.msg|regex_search('unable to resolve.+disk')|length>0 and
not blivet_output.changed }}"
msg: "Unexpected behavior w/ non-existent pool disk"
ignore_errors: yes
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

# the following does not work properly
# - debug:
# msg: "{{ 'failed: ' + blivet_output.failed | string +
# 'msg: ' + blivet_output.msg +
# 'changed: ' + blivet_output.changed | string }}"

# - name: Verify the output
# assert:
# that: "{{ blivet_output.failed and
# blivet_output.msg|regex_search('unable to resolve.+disk')|length>0 and
# not blivet_output.changed }}"
# msg: "Unexpected behavior w/ non-existent pool disk"

- name: Test for correct handling of invalid size specification.
block:
Expand All @@ -55,13 +74,27 @@
size: "{{ invalid_size }}"
mount_point: "{{ mount_location1 }}"

- name: Verify the output
- name: UNREACH
fail:
msg: "this should be unreachable"

rescue:
- name: Check that we failed in the role
assert:
that: "{{ blivet_output.failed and
blivet_output.msg|regex_search('invalid size.+for volume') and
not blivet_output.changed }}"
msg: "Unexpected behavior w/ invalid volume size"
ignore_errors: yes
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

# the following does not work properly
# - name: Verify the output
# assert:
# that: "{{ blivet_output.failed and
# blivet_output.msg|regex_search('invalid size.+for volume') and
# not blivet_output.changed }}"
# msg: "Unexpected behavior w/ invalid volume size"

- name: Test for correct handling of too-large volume size.
block:
Expand All @@ -77,13 +110,27 @@
size: "{{ too_large_size }}"
mount_point: "{{ mount_location1 }}"

- name: Verify the output
- name: UNREACH
fail:
msg: "this should be unreachable"

rescue:
- name: Check that we failed in the role
assert:
that: "{{ blivet_output.failed and
blivet_output.msg|regex_search('size.+exceeds.+space in pool') and
not blivet_output.changed }}"
msg: "Unexpected behavior w/ too-large volume size"
ignore_errors: yes
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

# the following does not work properly
# - name: Verify the output
# assert:
# that: "{{ blivet_output.failed and
# blivet_output.msg|regex_search('size.+exceeds.+space in pool') and
# not blivet_output.changed }}"
# msg: "Unexpected behavior w/ too-large volume size"

- name: Test for correct handling of non-list disk specification.
block:
Expand All @@ -99,13 +146,27 @@
size: "{{ too_large_size }}"
mount_point: "{{ mount_location1 }}"

- name: Verify the output
- name: UNREACH
fail:
msg: "this should be unreachable"

rescue:
- name: Check that we failed in the role
assert:
that: "{{ blivet_output.failed and
blivet_output.msg|regex_search('disk.+list') and
not blivet_output.changed }}"
msg: "Unexpected behavior w/ disks not in list form"
ignore_errors: yes
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

# the following does not work properly
# - name: Verify the output
# assert:
# that: "{{ blivet_output.failed and
# blivet_output.msg|regex_search('disk.+list') and
# not blivet_output.changed }}"
# msg: "Unexpected behavior w/ disks not in list form"

- name: Test for correct handling of missing disk specification.
block:
Expand All @@ -121,13 +182,27 @@
size: "{{ too_large_size }}"
mount_point: "{{ mount_location1 }}"

- name: Verify the output
- name: UNREACH
fail:
msg: "this should be unreachable"

rescue:
- name: Check that we failed in the role
assert:
that: "{{ blivet_output.failed and
blivet_output.msg|regex_search('no disks.+pool') and
not blivet_output.changed }}"
msg: "Unexpected behavior w/ no disks specified"
ignore_errors: yes
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

# the following does not work properly
# - name: Verify the output
# assert:
# that: "{{ blivet_output.failed and
# blivet_output.msg|regex_search('no disks.+pool') and
# not blivet_output.changed }}"
# msg: "Unexpected behavior w/ no disks specified"

- name: Test for correct handling of LVM volume not defined within a pool.
block:
Expand All @@ -142,13 +217,27 @@
size: "{{ volume1_size }}"
mount_point: "{{ mount_location1 }}"

- name: Verify the output
- name: UNREACH
fail:
msg: "this should be unreachable"

rescue:
- name: Check that we failed in the role
assert:
that: "{{ blivet_output.failed and
blivet_output.msg|regex_search('failed to find pool .+ for volume') and
not blivet_output.changed }}"
msg: "Unexpected behavior w/ LVM volume defined outside of any pool"
ignore_errors: yes
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

# the following does not work properly
# - name: Verify the output
# assert:
# that: "{{ blivet_output.failed and
# blivet_output.msg|regex_search('failed to find pool .+ for volume') and
# not blivet_output.changed }}"
# msg: "Unexpected behavior w/ LVM volume defined outside of any pool"

- name: Test for correct handling of safe_mode
block:
Expand Down

0 comments on commit 368d145

Please sign in to comment.