diff mbox series

[2/2] fstest: btrfs/197: test for alien devices

Message ID 20191007094101.784-2-anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series [1/2] fstest: btrfs/196: test for alien btrfs-devices | expand

Commit Message

Anand Jain Oct. 7, 2019, 9:41 a.m. UTC
Test if btrfs.ko sucessfully identifies and reports the missing device,
if the missed device contians no btrfs magic string.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/btrfs/197     | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/197.out | 25 +++++++++++++++++
 tests/btrfs/group   |  1 +
 3 files changed, 105 insertions(+)
 create mode 100755 tests/btrfs/197
 create mode 100644 tests/btrfs/197.out

Comments

Eryu Guan Oct. 18, 2019, 9:13 a.m. UTC | #1
On Mon, Oct 07, 2019 at 05:41:01PM +0800, Anand Jain wrote:
> Test if btrfs.ko sucessfully identifies and reports the missing device,
> if the missed device contians no btrfs magic string.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  tests/btrfs/197     | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/197.out | 25 +++++++++++++++++
>  tests/btrfs/group   |  1 +
>  3 files changed, 105 insertions(+)
>  create mode 100755 tests/btrfs/197
>  create mode 100644 tests/btrfs/197.out
> 
> diff --git a/tests/btrfs/197 b/tests/btrfs/197
> new file mode 100755
> index 000000000000..82e1a299ca43
> --- /dev/null
> +++ b/tests/btrfs/197
> @@ -0,0 +1,79 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2019 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test 197
> +#
> +# Test stale and alien device in the fs devices list.
> +# Similar to the testcase btrfs/196 except that here the alien device no more
> +# contains the btrfs superblock.
> +#
> +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
> +. ./common/filter.btrfs
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# real QA test starts here
> +
> +# Modify as appropriate.
> +_supported_fs generic
> +_supported_os Linux
> +_require_command "$WIPEFS_PROG" wipefs
> +_require_scratch
> +_require_scratch_dev_pool 4
> +
> +workout()
> +{
> +	raid=$1
> +	device_nr=$2
> +
> +	echo $raid
> +	_scratch_dev_pool_get $device_nr
> +
> +	_scratch_pool_mkfs "-d$raid -m$raid" >> $seqres.full 2>&1 || \
> +							_fail "mkfs failed"
> +
> +	# Make device_1 an alien btrfs device for the raid created above by
> +	# adding it to the $TEST_DIR

Stale comments above.

Otherwise looks fine to me.

> +
> +	# don't test with the first device as auto fs check (_check_scratch_fs)
> +	# picks the first device
> +	device_1=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
> +	$WIPEFS_PROG -a $device_1 >> $seqres.full 2>&1

If creating a new btrfs works for btrfs/196, I wonder if we could merge
the two tests into one test, firstly create a new fs & degraded mount,
then wipefs & degraded mount.

Thanks,
Eryu

> +
> +	device_2=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
> +	_mount -o degraded $device_2 $SCRATCH_MNT
> +	# Check if missing device is reported as in the 196.out
> +	$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
> +						_filter_btrfs_filesystem_show
> +
> +	_scratch_unmount
> +	_scratch_dev_pool_put
> +}
> +
> +workout "raid1" "2"
> +workout "raid5" "3"
> +workout "raid6" "4"
> +workout "raid10" "4"
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/197.out b/tests/btrfs/197.out
> new file mode 100644
> index 000000000000..79237b854b5a
> --- /dev/null
> +++ b/tests/btrfs/197.out
> @@ -0,0 +1,25 @@
> +QA output created by 197
> +raid1
> +Label: none  uuid: <UUID>
> +	Total devices <NUM> FS bytes used <SIZE>
> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
> +	*** Some devices missing
> +
> +raid5
> +Label: none  uuid: <UUID>
> +	Total devices <NUM> FS bytes used <SIZE>
> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
> +	*** Some devices missing
> +
> +raid6
> +Label: none  uuid: <UUID>
> +	Total devices <NUM> FS bytes used <SIZE>
> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
> +	*** Some devices missing
> +
> +raid10
> +Label: none  uuid: <UUID>
> +	Total devices <NUM> FS bytes used <SIZE>
> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
> +	*** Some devices missing
> +
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index c86ea2516397..f2eac5c20712 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -199,3 +199,4 @@
>  194 auto volume
>  195 auto volume
>  196 auto quick volume
> +197 auto quick volume
> -- 
> 1.8.3.1
>
Anand Jain Oct. 22, 2019, 9:23 a.m. UTC | #2
On 10/18/19 5:13 PM, Eryu Guan wrote:
> On Mon, Oct 07, 2019 at 05:41:01PM +0800, Anand Jain wrote:
>> Test if btrfs.ko sucessfully identifies and reports the missing device,
>> if the missed device contians no btrfs magic string.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   tests/btrfs/197     | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   tests/btrfs/197.out | 25 +++++++++++++++++
>>   tests/btrfs/group   |  1 +
>>   3 files changed, 105 insertions(+)
>>   create mode 100755 tests/btrfs/197
>>   create mode 100644 tests/btrfs/197.out
>>
>> diff --git a/tests/btrfs/197 b/tests/btrfs/197
>> new file mode 100755
>> index 000000000000..82e1a299ca43
>> --- /dev/null
>> +++ b/tests/btrfs/197
>> @@ -0,0 +1,79 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2019 Oracle.  All Rights Reserved.
>> +#
>> +# FS QA Test 197
>> +#
>> +# Test stale and alien device in the fs devices list.
>> +# Similar to the testcase btrfs/196 except that here the alien device no more
>> +# contains the btrfs superblock.
>> +#
>> +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
>> +. ./common/filter.btrfs
>> +
>> +# remove previous $seqres.full before test
>> +rm -f $seqres.full
>> +
>> +# real QA test starts here
>> +
>> +# Modify as appropriate.
>> +_supported_fs generic
>> +_supported_os Linux
>> +_require_command "$WIPEFS_PROG" wipefs
>> +_require_scratch
>> +_require_scratch_dev_pool 4
>> +
>> +workout()
>> +{
>> +	raid=$1
>> +	device_nr=$2
>> +
>> +	echo $raid
>> +	_scratch_dev_pool_get $device_nr
>> +
>> +	_scratch_pool_mkfs "-d$raid -m$raid" >> $seqres.full 2>&1 || \
>> +							_fail "mkfs failed"
>> +
>> +	# Make device_1 an alien btrfs device for the raid created above by
>> +	# adding it to the $TEST_DIR
> 
> Stale comments above.

  updated in v2.

> Otherwise looks fine to me.
> 
>> +
>> +	# don't test with the first device as auto fs check (_check_scratch_fs)
>> +	# picks the first device
>> +	device_1=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
>> +	$WIPEFS_PROG -a $device_1 >> $seqres.full 2>&1
> 
> If creating a new btrfs works for btrfs/196, I wonder if we could merge
> the two tests into one test, firstly create a new fs & degraded mount,
> then wipefs & degraded mount.

  Its better if they are separate. The workout is already looping for
  different raids. Per experiences from btrfs/011 it gets harder to
  debug with testing different cases in one test case. Can I keep them
  separate?

  V2 is being sent out in a while.

Thanks, Anand

> Thanks,
> Eryu
> 
>> +
>> +	device_2=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
>> +	_mount -o degraded $device_2 $SCRATCH_MNT
>> +	# Check if missing device is reported as in the 196.out
>> +	$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
>> +						_filter_btrfs_filesystem_show
>> +
>> +	_scratch_unmount
>> +	_scratch_dev_pool_put
>> +}
>> +
>> +workout "raid1" "2"
>> +workout "raid5" "3"
>> +workout "raid6" "4"
>> +workout "raid10" "4"
>> +
>> +# success, all done
>> +status=0
>> +exit
>> diff --git a/tests/btrfs/197.out b/tests/btrfs/197.out
>> new file mode 100644
>> index 000000000000..79237b854b5a
>> --- /dev/null
>> +++ b/tests/btrfs/197.out
>> @@ -0,0 +1,25 @@
>> +QA output created by 197
>> +raid1
>> +Label: none  uuid: <UUID>
>> +	Total devices <NUM> FS bytes used <SIZE>
>> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
>> +	*** Some devices missing
>> +
>> +raid5
>> +Label: none  uuid: <UUID>
>> +	Total devices <NUM> FS bytes used <SIZE>
>> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
>> +	*** Some devices missing
>> +
>> +raid6
>> +Label: none  uuid: <UUID>
>> +	Total devices <NUM> FS bytes used <SIZE>
>> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
>> +	*** Some devices missing
>> +
>> +raid10
>> +Label: none  uuid: <UUID>
>> +	Total devices <NUM> FS bytes used <SIZE>
>> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
>> +	*** Some devices missing
>> +
>> diff --git a/tests/btrfs/group b/tests/btrfs/group
>> index c86ea2516397..f2eac5c20712 100644
>> --- a/tests/btrfs/group
>> +++ b/tests/btrfs/group
>> @@ -199,3 +199,4 @@
>>   194 auto volume
>>   195 auto volume
>>   196 auto quick volume
>> +197 auto quick volume
>> -- 
>> 1.8.3.1
>>
diff mbox series

Patch

diff --git a/tests/btrfs/197 b/tests/btrfs/197
new file mode 100755
index 000000000000..82e1a299ca43
--- /dev/null
+++ b/tests/btrfs/197
@@ -0,0 +1,79 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Oracle.  All Rights Reserved.
+#
+# FS QA Test 197
+#
+# Test stale and alien device in the fs devices list.
+# Similar to the testcase btrfs/196 except that here the alien device no more
+# contains the btrfs superblock.
+#
+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
+. ./common/filter.btrfs
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+_require_command "$WIPEFS_PROG" wipefs
+_require_scratch
+_require_scratch_dev_pool 4
+
+workout()
+{
+	raid=$1
+	device_nr=$2
+
+	echo $raid
+	_scratch_dev_pool_get $device_nr
+
+	_scratch_pool_mkfs "-d$raid -m$raid" >> $seqres.full 2>&1 || \
+							_fail "mkfs failed"
+
+	# Make device_1 an alien btrfs device for the raid created above by
+	# adding it to the $TEST_DIR
+
+	# don't test with the first device as auto fs check (_check_scratch_fs)
+	# picks the first device
+	device_1=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
+	$WIPEFS_PROG -a $device_1 >> $seqres.full 2>&1
+
+	device_2=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
+	_mount -o degraded $device_2 $SCRATCH_MNT
+	# Check if missing device is reported as in the 196.out
+	$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
+						_filter_btrfs_filesystem_show
+
+	_scratch_unmount
+	_scratch_dev_pool_put
+}
+
+workout "raid1" "2"
+workout "raid5" "3"
+workout "raid6" "4"
+workout "raid10" "4"
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/197.out b/tests/btrfs/197.out
new file mode 100644
index 000000000000..79237b854b5a
--- /dev/null
+++ b/tests/btrfs/197.out
@@ -0,0 +1,25 @@ 
+QA output created by 197
+raid1
+Label: none  uuid: <UUID>
+	Total devices <NUM> FS bytes used <SIZE>
+	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+	*** Some devices missing
+
+raid5
+Label: none  uuid: <UUID>
+	Total devices <NUM> FS bytes used <SIZE>
+	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+	*** Some devices missing
+
+raid6
+Label: none  uuid: <UUID>
+	Total devices <NUM> FS bytes used <SIZE>
+	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+	*** Some devices missing
+
+raid10
+Label: none  uuid: <UUID>
+	Total devices <NUM> FS bytes used <SIZE>
+	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+	*** Some devices missing
+
diff --git a/tests/btrfs/group b/tests/btrfs/group
index c86ea2516397..f2eac5c20712 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -199,3 +199,4 @@ 
 194 auto volume
 195 auto volume
 196 auto quick volume
+197 auto quick volume