Skip to content

Commit

Permalink
Add tests for safe mode with LUKS on partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
pcahyna committed Sep 22, 2020
1 parent a887f83 commit 06cc7da
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions tests/tests_luks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,46 @@

- include_tasks: verify-role-results.yml

- import_tasks: create-test-file.yml

- name: Test for correct handling of safe_mode
block:
- name: Remove the encryption layer
include_role:
name: linux-system-roles.storage
vars:
storage_pools:
- name: foo
type: partition
disks: "{{ unused_disks }}"
volumes:
- name: test1
type: partition
mount_point: "{{ mount_location }}"
size: 4g
encryption: false
encryption_password: 'yabbadabbadoo'
- name: unreachable task
fail:
msg: UNREACH
rescue:
- name: Check that we failed in the role
assert:
that:
- ansible_failed_result.msg != 'UNREACH'
msg: "Role has not failed when it should have"

- name: Verify the output of the safe_mode test
assert:
that: "blivet_output.failed and
blivet_output.msg
|regex_search('cannot remove existing
formatting.*in safe mode due to encryption removal')
and not blivet_output.changed"
msg: "Unexpected behavior w/ existing filesystem in safe mode"

- import_tasks: verify-data-preservation.yml

- name: Remove the encryption layer
include_role:
name: linux-system-roles.storage
Expand All @@ -244,6 +284,48 @@

- include_tasks: verify-role-results.yml

- import_tasks: create-test-file.yml

- name: Test for correct handling of safe_mode
block:
- name: Add encryption to the volume
include_role:
name: linux-system-roles.storage
vars:
storage_pools:
- name: foo
type: partition
disks: "{{ unused_disks }}"
volumes:
- name: test1
type: partition
mount_point: "{{ mount_location }}"
size: 4g
encryption: true
encryption_password: 'yabbadabbadoo'

- name: unreachable task
fail:
msg: UNREACH

rescue:
- name: Check that we failed in the role
assert:
that:
- ansible_failed_result.msg != 'UNREACH'
msg: "Role has not failed when it should have"

- name: Verify the output of the safe_mode test
assert:
that: "blivet_output.failed and
blivet_output.msg
|regex_search('cannot remove existing
formatting.*in safe mode due to adding encryption')
and not blivet_output.changed"
msg: "Unexpected behavior w/ existing volume in safe mode"

- import_tasks: verify-data-preservation.yml

- name: Test key file handling
block:
- name: Create a key file
Expand Down

0 comments on commit 06cc7da

Please sign in to comment.