action #117211
Updated by JERiveraMoya about 2 years ago
#### Motivation
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("/"));
~~~
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 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.
#### Acceptance criteria
**AC1:** The `sync` is implemented after the `dd` command and the correct amount of used space is reported.
#### Additional information
`status=progress` option might help because it doesn't return until finished, instead of `sync` command.