2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019, Oracle and/or its affiliates. All Rights Reserved.
7 # Basic tests of the xfs_spaceman health command.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
29 # real QA test starts here
31 _require_scratch_nocheck
33 _require_xfs_spaceman_command "health"
37 _scratch_mkfs > $seqres.full 2>&1
39 _scratch_cycle_mount # make sure we haven't run quotacheck on this mount
41 # Haven't checked anything, it should tell us to run scrub
42 $XFS_SPACEMAN_PROG -c "health" $SCRATCH_MNT
44 # Run scrub to collect health info.
45 _scratch_scrub -n >> $seqres.full
48 $XFS_SPACEMAN_PROG -c "$@" $SCRATCH_MNT | tee -a $seqres.full
52 query "$@" | grep -q ": ok$"
56 query "$@" | grep -q ": unhealthy$"
59 # Let's see if we get at least one healthy rating for each health reporting
61 query_health "health -f" || \
62 echo "Didn't see a single healthy fs metadata?"
64 query_health "health -a 0" || \
65 echo "Didn't see a single healthy ag metadata?"
67 query_health "health $SCRATCH_MNT" || \
68 echo "Didn't see a single healthy file metadata?"
70 # Unmount, corrupt filesystem
72 _scratch_xfs_db -x -c 'sb 1' -c 'fuzz -d magicnum random' >> $seqres.full
74 # Now let's see what the AG report says
76 _scratch_scrub -n >> $seqres.full 2>&1
77 query_sick "health -a 1" || \
78 echo "Didn't see the expected unhealthy metadata?"