Test-1: Tests for PR # 175#177
Conversation
f130c29 to
2b59f02
Compare
|
@shishir-a412ed can we put some description in commit, explaining what this test is testing. |
| test_status=0 | ||
| fi | ||
|
|
||
| $DSSBIN --reset >> $LOGS 2>&1 |
There was a problem hiding this comment.
I think docker storage reset should be a separate test. First test should just test if DOCKER_ROOT_VOLUME works fine or not.
There was a problem hiding this comment.
I think we already have test for devmapper and overlay cleanup. We probably should write one for docker-root-volume cleanup as well.
There was a problem hiding this comment.
Yeah I saw those tests (devmapper and overlay cleanup) while developing this one.
After running this test, we would still need to unmount and remove DOCKER_ROOT_VOLUME.
I felt if I use docker-storage-setup --reset, it would test the reset functionality and do the cleanup at the same time. Otherwise it would be duplicating the effort.
| DEVS="$devs" | ||
| VG=$vg_name | ||
| DOCKER_ROOT_VOLUME=yes | ||
| DOCKER_ROOT_VOLUME_SIZE=40%FREE |
There was a problem hiding this comment.
we should not have to specify size. Let it be default. Want this test to take default path where users will simply specify DOCKER_ROOT_VOLUME=yes.
There was a problem hiding this comment.
Initially I did not specify DOCKER_ROOT_VOLUME_SIZE=40%FREE in the test. I was expecting docker-storage-setup to pick up the default value from /usr/lib/docker-storage-setup/docker-storage-seutp. However the CI started failing. I believe it was because CI version of that file did not have these new storage options DOCKER_ROOT_VOLUME and DOCKER_ROOT_VOLUME_SIZE.
| # Make sure $DOCKER_ROOT_VOLUME {docker-root-lv} got created | ||
| # successfully. | ||
| if lv_exists "$docker_root_lv_name"; then | ||
| test_status=0 |
There was a problem hiding this comment.
Don't set test_status=0 yet. As test will be successful only when you have done mountpoint check as well. You can instead check if lv exists or not and if not, then do the cleanup and return.
| local lv lv_name="$1" | ||
|
|
||
| for lv in $(lvs --noheadings -o lv_name); do | ||
| if [ "$lv" == "$lv_name" ]; then |
There was a problem hiding this comment.
Do we really have to search for lv name in output. Can we just pass the expected lv to lvs and that should tell us if it exists or not?
lvs docker-vg/docker-root-lv ?
There was a problem hiding this comment.
I used existing logic and structure of vg_exists() while developing lv_exists(). I wanted to keep lv_exists() as close as possible to existing code style. Does this work for you ? or should we change both (vg_exists, lv_exists) to incorporate this logic ?
There was a problem hiding this comment.
shishir, now you have code in extra_volume_exists(), in docker-storage-setup.sh. It should be much simpler to use that.
486390f to
9df560b
Compare
|
@rhvgoyal PTAL. |
| local mnt | ||
| mnt=$(findmnt -n -o TARGET --first-only --source /dev/${vg_name}/${docker_root_lv_name}) | ||
| if [ "$mnt" == "/var/lib/docker" ];then | ||
| test_status=0 |
There was a problem hiding this comment.
I think test_status should be set to 0 only once when we have done all the checks.
| $DSSBIN --reset >> $LOGS 2>&1 | ||
| # Test failed. | ||
| if [ $? -eq 0 ]; then | ||
| if [ ! -e /etc/sysconfig/docker-storage ]; then |
There was a problem hiding this comment.
I don't think we need to check for presence of this file. here. We should write a separate test which tests the reset functionality. And then we should make sure logical volume went away, var-lib-docker.mount file went away and
/etc/sysconfig/docker-storage went away.
| # Test failed. | ||
| if [ $? -eq 0 ]; then | ||
| if [ ! -e /etc/sysconfig/docker-storage ]; then | ||
| test_status=0 |
There was a problem hiding this comment.
Ok, how about following. Write two tests.
- First tests to test volume creation funcitonality
- second test to test reset funcitonality.
In first test you can still use --reset to cleanup but don't use its return code to determine test status. This will be something like cleanup $vg_name. It can fail too but we don't determine success/failure of tests based on cleanup.
So first test will ignore the --reset results. It will PASS/FAIL based on whether volume creation was successful or not.
Second test will fail if reset did not work properly.
There was a problem hiding this comment.
Based on our discussion on irc, I am not using --reset for volume creation tests. I am writing a manual methods for doing cleanups.
9df560b to
077640b
Compare
|
@rhvgoyal PTAL. |
077640b to
e5f3588
Compare
| wipe_signatures "$devs" | ||
| } | ||
|
|
||
| cleanup_container_root_volume() { |
There was a problem hiding this comment.
This function feels very specific. It probably is better in the test itself and not part of library.
Or, break this down into smaller pieces. That is have a helper function to cleanup mount unit file in libtest.sh and logic to remove lvm keep it in test itself.
ab842a2 to
ecae40d
Compare
|
@rhvgoyal PTAL. |
|
@shishir-a412ed On my local machine, once in a while test is failing. It says mkfs failed as device or resource is busy. mkfs.xfs: cannot open /dev/dss-test-foo/docker-root-lv: Device or resource busy |
|
I introduced "udevadm settle" after lvcreate and before mkfs and that seems to have fixed the issue. So looks like udev is keeping device busy. I will open another PR to fix it. |
| lvchange -an $vg_name/${lv_name} >> $LOGS 2>&1 | ||
| lvremove $vg_name/${lv_name} >> $LOGS 2>&1 | ||
|
|
||
| cleanup_mount_file $mountpath |
There was a problem hiding this comment.
This should be $mount_path and not $mountpath. As a result, right now /etc/systemd/system/var-lib-docker.mount is not being cleaned up on the system after the tests.
|
I used |
This test tests docker-storage-setup options DOCKER_ROOT_VOLUME and DOCKER_ROOT_VOLUME_SIZE. This test will check if DOCKER_ROOT_VOLUME option is set to `yes`, docker-storage-setup would create a separate logical volume named `docker-root-lv` and mount it to default docker root location (/var/lib/docker). Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
ecae40d to
4f2ce20
Compare
|
@rhvgoyal PTAL. |
|
LGTM |
|
📌 Commit 4f2ce20 has been approved by |
|
☀️ Test successful - status-redhatci |
Signed-off-by: Shishir Mahajan shishir.mahajan@redhat.com