btrfs: test balance profile convert functionality
authorNikolay Borisov <nborisov@suse.com>
Tue, 1 Oct 2019 09:04:19 +0000 (12:04 +0300)
committerEryu Guan <guaneryu@gmail.com>
Sun, 6 Oct 2019 14:36:45 +0000 (22:36 +0800)
Add basic test to ensure btrfs conversion functionality is tested.
This test exercies conversion to all possible types of the data
portion. This is sufficient since from the POV of relocation we are
only moving blockgroups.

v5.3 and later kernel needs the following patch to pass the test

btrfs: Fix a regression which we can't convert to SINGLE profile

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/btrfs/195 [new file with mode: 0755]
tests/btrfs/195.out [new file with mode: 0644]
tests/btrfs/group

diff --git a/tests/btrfs/195 b/tests/btrfs/195
new file mode 100755 (executable)
index 0000000..e40edb9
--- /dev/null
@@ -0,0 +1,84 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 SUSE Linux Products GmbH. All Rights Reserved.
+#
+# FS QA Test btrfs/195
+#
+# Test raid profile conversion. It's sufficient to test all dest profiles as
+# source profiles just rely on being able to read the data and metadata.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch_dev_pool 4
+
+
+declare -a TEST_VECTORS=(
+# $nr_dev_min:$data:$metadata:$data_convert:$metadata_convert
+"4:single:raid1"
+"4:single:raid0"
+"4:single:raid10"
+"4:single:dup"
+"4:single:raid5"
+"4:single:raid6"
+"2:raid1:single"
+)
+
+run_testcase() {
+       IFS=':' read -ra args <<< $1
+       num_disks=${args[0]}
+       src_type=${args[1]}
+       dst_type=${args[2]}
+
+       _scratch_dev_pool_get $num_disks
+
+       echo "=== Running test: $1 ===" >> $seqres.full
+
+       _scratch_pool_mkfs -d$src_type >> $seqres.full 2>&1
+       _scratch_mount
+
+       # Create random filesystem with 20k write ops
+       $FSSTRESS_PROG -d $SCRATCH_MNT -w -n 10000 $FSSTRESS_AVOID >>$seqres.full 2>&1
+
+       $BTRFS_UTIL_PROG balance start -f -dconvert=$dst_type $SCRATCH_MNT >> $seqres.full 2>&1
+       [ $? -eq 0 ] || echo "$1: Failed convert"
+
+       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+       [ $? -eq 0 ] || echo "$1: Scrub failed"
+
+       _scratch_unmount
+       _check_btrfs_filesystem $SCRATCH_DEV
+       _scratch_dev_pool_put
+}
+
+for i in "${TEST_VECTORS[@]}"; do
+       run_testcase $i
+done
+
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/195.out b/tests/btrfs/195.out
new file mode 100644 (file)
index 0000000..172c246
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 195
+Silence is golden
index d8aafe2..3ce6fa4 100644 (file)
 192 auto replay snapshot stress
 193 auto quick qgroup enospc limit
 194 auto volume
+195 auto volume