3 # Exercise pmdaxfs quota metrics (project quota).
5 # Copyright (c) 2013 Red Hat.
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
16 which mkfs.xfs
>/dev
/null
2>&1 || _notrun
"XFS utilities not installed"
17 pmprobe
-I pmcd.agent.
type 2>&1 |
grep '"xfs"' >/dev
/null
18 test $?
-eq 0 || _notrun
"XFS PMDA metrics not available"
20 cat /proc
/filesystems |
awk '{ print $1 }' |
grep '^xfs$' >/dev
/null
21 test $?
-eq 0 || _notrun
"XFS kernel support unavailable"
22 # check for any loopback devices, cowardly abort this test if any exist
23 loopcount
=`$sudo losetup -a | wc -l`
24 [ $loopcount -eq 0 ] || _notrun
"System has loop devices already, bailing"
29 if [ -f $tmp.oprojects
]
31 $sudo mv $tmp.oprojects
/etc
/projects
32 elif [ -f $tmp.projects
]
34 $sudo rm /etc
/projects
37 $sudo umount
$tmp.xfsmount
>/dev
/null
2>&1
38 # dodge kernel race conditions (losetup -d)
41 loopcount
=`$sudo losetup -a | wc -l`
42 [ $loopcount -eq 0 ] && break
43 ( $sudo losetup
-d /dev
/loop0
) >/dev
/null
2>&1
50 status
=1 # failure is the default!
51 $sudo rm -rf $tmp.
* $seq.full
52 trap "_cleanup; exit \$status" 0 1 2 3 15
54 # real QA test starts here
55 echo "creating a filesystem"
56 mkfs.xfs
-dfile,size
=256m
,name
=$tmp.xfsfile
> /dev
/null ||
exit 1
58 echo "creating a mount point"
59 mkdir
-p $tmp.xfsmount ||
exit 1
61 echo "creating a project map"
62 test -f /etc
/projects
&& $sudo mv /etc
/projects
$tmp.oprojects
63 echo "0:$tmp.xfsmount" > $tmp.projects
64 $sudo cp $tmp.projects
/etc
/projects
66 echo "mounting xfs filesystem"
67 $sudo mount
-t xfs
-o loop
,prjquota
$tmp.xfsfile
$tmp.xfsmount
69 # stash a copy of metric values for debugging
70 pminfo
-f quota
2>&1 > $seq.full
72 echo "checking metric values"
73 pmprobe
-v quota
> $tmp.out
74 echo "== state metrics:"
75 for metric
in quota.state.project.accounting quota.state.project.enforcement
77 grep $metric $tmp.out | \
79 $2 < 1 { print "'$metric' FAIL" } \
80 $2 > 0 { print "'$metric' PASS" } \
83 echo "== project metrics:"
84 cat $tmp.out |
grep quota.project