Drop unused condition check
[pcp.git] / qa / 876
blob6d8560ef8ab07d37a241cd9231f431c8eab22413
1 #!/bin/sh
2 # PCP QA Test No. 876
3 # Exercise pmdaxfs quota metrics (project quota).
5 # Copyright (c) 2013 Red Hat.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
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"
19 $sudo modprobe xfs
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"
26 _cleanup()
28 cd $here
29 if [ -f $tmp.oprojects ]
30 then
31 $sudo mv $tmp.oprojects /etc/projects
32 elif [ -f $tmp.projects ]
33 then
34 $sudo rm /etc/projects
37 $sudo umount $tmp.xfsmount >/dev/null 2>&1
38 # dodge kernel race conditions (losetup -d)
39 for i in 1 2 3 4 5
41 loopcount=`$sudo losetup -a | wc -l`
42 [ $loopcount -eq 0 ] && break
43 ( $sudo losetup -d /dev/loop0 ) >/dev/null 2>&1
44 sync
45 sleep $i
46 done
47 rm -rf $tmp.*
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 | \
78 awk '\
79 $2 < 1 { print "'$metric' FAIL" } \
80 $2 > 0 { print "'$metric' PASS" } \
81 END {}'
82 done
83 echo "== project metrics:"
84 cat $tmp.out | grep quota.project
86 # success, all done
87 status=0
89 exit