action #117211
Updated by JERiveraMoya about 2 years ago
### Observation #### Motivation First problem The snapper_cleanup_timeline test fails with the message that the [free disk space is more than 20%](https://openqa.suse.de/tests/9565286#step/snapper_cleanup_timeline/50). The root cause of this problem, is that the test module first performs a `dd` command and immediately after that it does a `df -h` to determine the used disk space. The problem is, that `dd` is using kernel buffers that will then transfered to disk **after** `dd` is finished. If `df -h` is performed immediately after `dd` then we are still in the phase of transfering buffers to the disk and therefore we get a lower disk usage. The solution for this is calling `sync` after the `dd` command which ensures that all bufffers are indeed written to disk. I made a PoC that looks like this: ~~~ assert_script_run("dd if=/dev/urandom of=/tmp/blob bs=10M count=$block_number", timeout => 1500, fail_message => "Failed to fill up disk space"); assert_script_run("sync", timeout => 60, fail_message => "Failed to sync"); $used_disk = convert2numeric(get_used_partition_space("/")); ~~~ #### Second problem The [convert2numeric](https://github.com/os-autoinst/os-autoinst-distri-opensuse/blob/afff37a3fc28da190070e15f8f481b0baf2c665b/tests/console/snapper_cleanup_timeline.pm#L29) subroutine is completely agnostic to size units. In the actual run this means: - `$disk_size = 38` (Gigabytes). - `$group_space =16.88` (Megabytes) - `$space_limit = 0.2` (20 %) So luckily with this numbers the test in [line 44](https://github.com/os-autoinst/os-autoinst-distri-opensuse/blob/afff37a3fc28da190070e15f8f481b0baf2c665b/tests/console/snapper_cleanup_timeline.pm#L44) results in `false`. To fix this the Units that are returned from `df -h` in the `filesystem_utils` package need to be evaluated as well, otherwise we compare Megabytes with Gigabytes which is obviously obviousy wrong. However you do this, keep an eye on where the values are used, because this might affect the `$block_number` variable used in the `dd` command. #### ### Scope YaST review ### Acceptance criteria **AC1:** The `sync` is implemented after the `dd` command and the correct amount of used space is reported. **AC2:** Problems in `convert2numeric` are fixed ### Additional info We could also discuss, if the test in [line 44](https://github.com/os-autoinst/os-autoinst-distri-opensuse/blob/afff37a3fc28da190070e15f8f481b0baf2c665b/tests/console/snapper_cleanup_timeline.pm#L44) is really needed in this test module. Current disk usages by snapshots is 16.88 Megabyts compared to 38 Gigabytes of disk size. This test module is only used in the `snapper_cleanup_timeline` test suite which is chained directly after `create_hdd_textmode`, so the chances are low that we run into a situation where snapshots occupy more than 50% of the disk space.