Skip to content

Commit

Permalink
Add test for volume/filesystem resize
Browse files Browse the repository at this point in the history
Based on @yizhanglinux's code in linux-system-roles#139.

Remove a disabled resize test from tests_lvm_errors where it does not belong
anymore.
  • Loading branch information
pcahyna authored and guazhang committed Aug 17, 2020
1 parent a34377c commit cc20e27
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 22 deletions.
22 changes: 0 additions & 22 deletions tests/tests_lvm_errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -341,28 +341,6 @@
not blivet_output.changed }}"
msg: "Unexpected behavior w/ existing data on specified disks"

- name: Test for correct handling of safe_mode with resize
block:
- name: Try to resize in safe mode
include_role:
name: storage
vars:
storage_pools:
- name: testpool1
type: lvm
disks: "{{ unused_disks }}"
volumes:
- name: testvol1
fs_type: 'ext4'
size: '2g'

- name: Verify the output
assert:
that: "{{ not blivet_output.failed and blivet_output.changed }}"
msg: "Unexpected behavior w/ existing data on specified disks"

when: false

- name: Test for correct handling of safe_mode with existing pool
block:
- name: Try to create LVM pool on disks that already belong to an existing pool
Expand Down
63 changes: 63 additions & 0 deletions tests/tests_resize.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
- hosts: all
vars:
mount_location: '/opt/test1'
volume_group_size: '10g'
volume_size_before: '5g'
volume_size_after: '9g'

tasks:
- include_role:
name: storage

- include_tasks: get_unused_disk.yml
vars:
min_size: "{{ volume_group_size }}"
max_return: 1

- name: Create one LVM logical volume with "{{ volume_size_before }}" under one volume group
include_role:
name: storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
type: lvm
volumes:
- name: test1
# resizing is currently supported only for ext2/3/4
fs_type: 'ext4'
size: "{{ volume_size_before }}"
mount_point: "{{ mount_location }}"

- include_tasks: verify-role-results.yml

- name: Change volume_size to "{{ volume_size_after }}"
include_role:
name: storage
vars:
storage_pools:
- name: foo
type: lvm
disks: "{{ unused_disks }}"
volumes:
- name: test1
fs_type: 'ext4'
size: "{{ volume_size_after }}"
mount_point: "{{ mount_location }}"

- include_tasks: verify-role-results.yml

- name: Clean up
include_role:
name: storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
state: absent
volumes:
- name: test1
size: "{{ volume_size_after }}"
mount_point: "{{ mount_location }}"

- include_tasks: verify-role-results.yml

0 comments on commit cc20e27

Please sign in to comment.