storage icon indicating copy to clipboard operation
storage copied to clipboard

storage: test verify volume size will be failed if the resize equal to unused_disk_subfact.size

Open yizhanglinux opened this issue 5 years ago • 0 comments

playbook

# cat tests/testsresize.yml 
- hosts: all
  become: true
  vars:
    storage_safe_mode: false
    mount_location: '/opt/test1'
    volume_group_size: '10g'
    volume_size_before: '5g'
    unused_disk_subfact: '{{ ansible_devices[unused_disks[0]] }}'
    too_large_size: '{{ (unused_disk_subfact.sectors|int + 1) *
                        unused_disk_subfact.sectorsize|int }}'
    disk_size: '{{ unused_disk_subfact.sectors|int *
                   unused_disk_subfact.sectorsize|int }}'
    disk_size1: '{{ unused_disk_subfact.size }}'

  tasks:
    - include_role:
        name: storage

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

    # For ext4 FS

    - 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: debug size
      debug:
        var: disk_size

    - name: debug size1
      debug:
        var: disk_size1

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

    - include_tasks: verify-role-results.yml

ansible-playbook -i inventory tests/testsresize.yml -vvv

TASK [parse the actual size of the volume] *******************************************************************************************************************************************************************************************************************************
task path: /root/test/storage/tests/test-verify-volume-size.yml:3
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir /root/.ansible/tmp/ansible-tmp-1597993343.8844924-110335-1696759048704 && echo ansible-tmp-1597993343.8844924-110335-1696759048704="` echo /root/.ansible/tmp/ansible-tmp-1597993343.8844924-110335-1696759048704 `" ) && sleep 0'
Using module file /root/test/storage/library/bsize.py
<localhost> PUT /root/.ansible/tmp/ansible-local-108509iw3ko3a_/tmp9k12zv5k TO /root/.ansible/tmp/ansible-tmp-1597993343.8844924-110335-1696759048704/AnsiballZ_bsize.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1597993343.8844924-110335-1696759048704/ /root/.ansible/tmp/ansible-tmp-1597993343.8844924-110335-1696759048704/AnsiballZ_bsize.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1597993343.8844924-110335-1696759048704/AnsiballZ_bsize.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1597993343.8844924-110335-1696759048704/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => {
    "bytes": 111776523878,
    "changed": false,
    "invocation": {
        "module_args": {
            "size": "104.1G"
        }
    },
    "lvm": "104g",
    "parted": "104GiB",
    "size": "104 GiB"
}

TASK [parse the requested size of the volume] ****************************************************************************************************************************************************************************************************************************
task path: /root/test/storage/tests/test-verify-volume-size.yml:9
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir /root/.ansible/tmp/ansible-tmp-1597993344.362896-110350-102233425991250 && echo ansible-tmp-1597993344.362896-110350-102233425991250="` echo /root/.ansible/tmp/ansible-tmp-1597993344.362896-110350-102233425991250 `" ) && sleep 0'
Using module file /root/test/storage/library/bsize.py
<localhost> PUT /root/.ansible/tmp/ansible-local-108509iw3ko3a_/tmp3t3wfi91 TO /root/.ansible/tmp/ansible-tmp-1597993344.362896-110350-102233425991250/AnsiballZ_bsize.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1597993344.362896-110350-102233425991250/ /root/.ansible/tmp/ansible-tmp-1597993344.362896-110350-102233425991250/AnsiballZ_bsize.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1597993344.362896-110350-102233425991250/AnsiballZ_bsize.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1597993344.362896-110350-102233425991250/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => {
    "bytes": 111790000000,
    "changed": false,
    "invocation": {
        "module_args": {
            "size": "111.79 GB"
        }
    },
    "lvm": "104g",
    "parted": "104GiB",
    "size": "104 GiB"
}

TASK [debug] *************************************************************************************************************************************************************************************************************************************************************
task path: /root/test/storage/tests/test-verify-volume-size.yml:15
ok: [localhost] => {
    "storage_test_actual_size": {
        "bytes": 111776523878,
        "changed": false,
        "failed": false,
        "lvm": "104g",
        "parted": "104GiB",
        "size": "104 GiB"
    }
}

TASK [debug] *************************************************************************************************************************************************************************************************************************************************************
task path: /root/test/storage/tests/test-verify-volume-size.yml:18
ok: [localhost] => {
    "storage_test_requested_size": {
        "bytes": 111790000000,
        "changed": false,
        "failed": false,
        "lvm": "104g",
        "parted": "104GiB",
        "size": "104 GiB"
    }
}

TASK [assert] ************************************************************************************************************************************************************************************************************************************************************
task path: /root/test/storage/tests/test-verify-volume-size.yml:21
fatal: [localhost]: FAILED! => {
    "assertion": "storage_test_actual_size == storage_test_requested_size",
    "changed": false,
    "evaluated_to": false,
    "msg": "Volume test1 has unexpected size"
}

PLAY RECAP ***************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=192  changed=4    unreachable=0    failed=1    skipped=92   rescued=0    ignored=0  

yizhanglinux avatar Aug 21 '20 07:08 yizhanglinux