btrfs: make all btrfs tests that exercise balance use _run_btrfs_balance_start()
[xfstests-dev.git] / tests / btrfs / 195
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test btrfs/195
6 #
7 # Test raid profile conversion. It's sufficient to test all dest profiles as
8 # source profiles just rely on being able to read the data and metadata.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # real QA test starts here
33
34 # Modify as appropriate.
35 _supported_fs btrfs
36 _supported_os Linux
37 _require_scratch_dev_pool 4
38
39
40 declare -a TEST_VECTORS=(
41 # $nr_dev_min:$data:$metadata:$data_convert:$metadata_convert
42 "4:single:raid1"
43 "4:single:raid0"
44 "4:single:raid10"
45 "4:single:dup"
46 "4:single:raid5"
47 "4:single:raid6"
48 "2:raid1:single"
49 )
50
51 run_testcase() {
52         IFS=':' read -ra args <<< $1
53         num_disks=${args[0]}
54         src_type=${args[1]}
55         dst_type=${args[2]}
56
57         _scratch_dev_pool_get $num_disks
58
59         echo "=== Running test: $1 ===" >> $seqres.full
60
61         _scratch_pool_mkfs -d$src_type >> $seqres.full 2>&1
62         _scratch_mount
63
64         # Create random filesystem with 20k write ops
65         $FSSTRESS_PROG -d $SCRATCH_MNT -w -n 10000 $FSSTRESS_AVOID >>$seqres.full 2>&1
66
67         _run_btrfs_balance_start -f -dconvert=$dst_type $SCRATCH_MNT >> $seqres.full
68         [ $? -eq 0 ] || echo "$1: Failed convert"
69
70         $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
71         [ $? -eq 0 ] || echo "$1: Scrub failed"
72
73         _scratch_unmount
74         _check_btrfs_filesystem $SCRATCH_DEV
75         _scratch_dev_pool_put
76 }
77
78 for i in "${TEST_VECTORS[@]}"; do
79         run_testcase $i
80 done
81
82 echo "Silence is golden"
83 status=0
84 exit