From 15e6d6bd54497536323489e11362c552f1657bdf Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Thu, 13 Aug 2020 21:53:29 +0200 Subject: [PATCH] Add test for volume/filesystem resize Based on @yizhanglinux's code in #139. Remove a disabled resize test from tests_lvm_errors where it does not belong anymore. --- tests/tests_lvm_errors.yml | 22 ------------- tests/tests_resize.yml | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 22 deletions(-) create mode 100644 tests/tests_resize.yml diff --git a/tests/tests_lvm_errors.yml b/tests/tests_lvm_errors.yml index 0a8ff726..d04eac4e 100644 --- a/tests/tests_lvm_errors.yml +++ b/tests/tests_lvm_errors.yml @@ -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 diff --git a/tests/tests_resize.yml b/tests/tests_resize.yml new file mode 100644 index 00000000..b58f76fd --- /dev/null +++ b/tests/tests_resize.yml @@ -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