File: 876

package info (click to toggle)
pcp 7.0.5-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,916 kB
  • sloc: ansic: 1,478,844; sh: 177,285; xml: 160,462; cpp: 83,809; python: 24,349; perl: 18,303; yacc: 6,877; lex: 2,864; makefile: 2,694; awk: 165; fortran: 60; java: 52
file content (97 lines) | stat: -rwxr-xr-x 2,685 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
# PCP QA Test No. 876
# Exercise pmdaxfs quota metrics (project quota).
#
# Copyright (c) 2013 Red Hat.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

which mkfs.xfs >/dev/null 2>&1 || _notrun "XFS utilities not installed"
pmprobe -I pmcd.agent.type 2>&1 | grep '"xfs"' >/dev/null
test $? -eq 0 || _notrun "XFS PMDA metrics not available"
$sudo modprobe xfs >/dev/null 2>&1
cat /proc/filesystems | awk '{ print $1 }' | grep '^xfs$' >/dev/null
test $? -eq 0 || _notrun "XFS kernel support unavailable"
which xfs_quota >/dev/null || _notrun "xfs_quota not installed"
# punting here ... know version 5.0.0 is OK and know version 3.1.9 is not
# good
version=`xfs_quota -V | sed -e 's/.* //'`
version_maj=`echo $version | sed -e 's/\..*//'`
[ "$version_maj" -ge 4 ] || _notrun "Need at least version 4.0.0 (not $version) for xfs_quota"
# check for any loopback devices, cowardly abort this test if any exist
loopcount=`$sudo losetup -a | wc -l`
[ $loopcount -eq 0 ] || _notrun "System has loop devices already, bailing"

_cleanup()
{
    cd $here
    if [ -f $tmp.oprojects ]
    then
	$sudo mv $tmp.oprojects /etc/projects
    elif [ -f $tmp.projects ]
    then
	$sudo rm /etc/projects
    fi

    $sudo umount $tmp.xfsmount >/dev/null 2>&1
    # dodge kernel race conditions (losetup -d)
    for i in 1 2 3 4 5
    do
	loopcount=`$sudo losetup -a | wc -l`
	[ $loopcount -eq 0 ] && break
	( $sudo losetup -d /dev/loop0 ) >/dev/null 2>&1
	sync
	sleep $i
    done
    rm -rf $tmp.*
}

status=1	# failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

# real QA test starts here
echo "creating a filesystem"
mkfs.xfs -dfile,size=350m,name=$tmp.xfsfile > /dev/null || exit 1

echo "creating a mount point"
mkdir -p $tmp.xfsmount || exit 1

echo "creating a project map"
test -f /etc/projects && $sudo mv /etc/projects $tmp.oprojects
echo "0:$tmp.xfsmount" > $tmp.projects
$sudo cp $tmp.projects /etc/projects

echo "mounting xfs filesystem"
$sudo mount -t xfs -o loop,prjquota $tmp.xfsfile $tmp.xfsmount

# stash a copy of metric values for debugging
pminfo -f quota 2>&1 > $seq_full
# ditto for xfs_quota
echo "" >>$seq_full
xfs_quota -c print $tmp.xfsmount >>$seq_full

echo "checking metric values"
pmprobe -v quota > $tmp.out
echo "== state metrics:"
for metric in quota.state.project.accounting quota.state.project.enforcement
do
    grep $metric $tmp.out | \
    awk '\
	$2 < 1 { print "'$metric' FAIL" } \
	$2 > 0 { print "'$metric' PASS" } \
	END {}'
done
echo "== project metrics:"
cat $tmp.out | grep quota.project

# success, all done
status=0

exit