Skip to content

Commit

Permalink
test: fix sector-based disk size calculation from ansible_devices
Browse files Browse the repository at this point in the history
Device sizes specified in sectors are in general in 512 sectors
regardless of the actual device physical sector size. Example of
ansible_devices facts for a 4k sector size drive:

...
  "sectors": "41943040",
  "sectorsize": "4096",
  "size": "20.00 GB"
...

Resolves: RHEL-30959

Signed-off-by: Vojtech Trefny <[email protected]>
  • Loading branch information
vojtechtrefny authored and richm committed Apr 4, 2024
1 parent 6db3ef8 commit bb1eb23
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions tests/tests_create_lv_size_equal_to_vg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
volume_group_size: '10g'
lv_size: '10g'
unused_disk_subfact: '{{ ansible_devices[unused_disks[0]] }}'
disk_size: '{{ unused_disk_subfact.sectors | int *
unused_disk_subfact.sectorsize | int }}'
disk_size: '{{ unused_disk_subfact.sectors | int * 512 }}'
tags:
- tests::lvm

Expand Down
3 changes: 1 addition & 2 deletions tests/tests_misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
volume_group_size: "5g"
volume1_size: "4g"
unused_disk_subfact: "{{ ansible_devices[unused_disks[0]] }}"
too_large_size: "{{ (unused_disk_subfact.sectors | int * 1.2) *
unused_disk_subfact.sectorsize | int }}"
too_large_size: "{{ (unused_disk_subfact.sectors | int * 1.2) * 512 }}"
tags:
- tests::lvm
tasks:
Expand Down
6 changes: 2 additions & 4 deletions tests/tests_resize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
invalid_size1: xyz GiB
invalid_size2: none
unused_disk_subfact: '{{ ansible_devices[unused_disks[0]] }}'
too_large_size: '{{ unused_disk_subfact.sectors | int * 1.2 *
unused_disk_subfact.sectorsize | int }}'
disk_size: '{{ unused_disk_subfact.sectors | int *
unused_disk_subfact.sectorsize | int }}'
too_large_size: '{{ unused_disk_subfact.sectors | int * 1.2 * 512 }}'
disk_size: '{{ unused_disk_subfact.sectors | int * 512 }}'
tags:
- tests::lvm
tasks:
Expand Down

0 comments on commit bb1eb23

Please sign in to comment.