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 _begin_fstest auto quick health
12 # Import common functions.
16 # real QA test starts here
18 _require_scratch_nocheck
20 _require_xfs_spaceman_command "health"
22 _scratch_mkfs > $seqres.full 2>&1
24 _scratch_cycle_mount # make sure we haven't run quotacheck on this mount
26 # Haven't checked anything, it should tell us to run scrub
27 $XFS_SPACEMAN_PROG -c "health" $SCRATCH_MNT
29 # Run scrub to collect health info.
30 _scratch_scrub -n >> $seqres.full
33 $XFS_SPACEMAN_PROG -c "$@" $SCRATCH_MNT | tee -a $seqres.full
37 query "$@" | grep -q ": ok$"
41 query "$@" | grep -q ": unhealthy$"
44 # Let's see if we get at least one healthy rating for each health reporting
46 query_health "health -f" || \
47 echo "Didn't see a single healthy fs metadata?"
49 query_health "health -a 0" || \
50 echo "Didn't see a single healthy ag metadata?"
52 query_health "health $SCRATCH_MNT" || \
53 echo "Didn't see a single healthy file metadata?"
55 # Unmount, corrupt filesystem
57 _scratch_xfs_db -x -c 'sb 1' -c 'fuzz -d magicnum random' >> $seqres.full
59 # Now let's see what the AG report says
61 _scratch_scrub -n >> $seqres.full 2>&1
62 query_sick "health -a 1" || \
63 echo "Didn't see the expected unhealthy metadata?"