]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/test_common.sh
6 # Common routines for tests
9 # Environment variables that affect tests:
10 # KEEP_TEMPDIR If set, the tempdir will not be deleted
11 # when the test is over.
14 # Clean up the temporary directory
16 if [ -n ${TEMPDIR} ]; then
21 # Create a temporary directory where test files will be stored.
24 if [ -z $KEEP_TEMPDIR ]; then
25 trap cleanup INT TERM EXIT
29 # Standard initialization function for tests
35 # Exit with an error message.
41 # Test that flag is set (the element is found in the list)
49 if [ "${flag}" = "${i}" ]; then
56 # Stop an OSD started by vstart
59 pidfile
="out/osd.$osd_index.pid"
60 if [ -e $pidfile ]; then
61 if kill `cat $pidfile` ; then
62 poll_cmd
"eval test -e $pidfile ; echo \$?" "1" 1 30
63 [ $?
-eq 1 ] && return 0
64 echo "ceph-osd process did not terminate correctly"
66 echo "kill `cat $pidfile` failed"
69 echo "ceph-osd process $osd_index is not running"
74 # Restart an OSD started by vstart
77 .
/ceph-osd
-i $osd_index -c ceph.conf
&
80 # Ask the user a yes/no question and get the response
86 y|Y|
yes|YES|Yes
) return 0 ;;
87 n|N|no|NO|No
) return 1 ;;
88 *) echo "Please type yes or no."
94 # Block until the user says "continue" or "c"
96 prompt
=${1:-"to go on"}
98 echo "Please type 'c' or 'continue' ${prompt}."
101 c|
continue) return 0 ;;
107 # Write a bunch of objects to rados
114 [ -d "${TEMPDIR}" ] || die
"must setup_tempdir"
115 for v
in `seq $start_ver $stop_ver`; do
116 chr
=`perl -e "print chr(48+$v)"`
117 head -c $obj_size /dev
/zero |
tr '\0' "$chr" > $TEMPDIR/ver
$v
118 for i
in `seq -w 1 $num_objs`; do
119 .
/rados
-c .
/ceph.conf
-p $pool put obj
$i $TEMPDIR/ver
$v || die
"radostool failed"
128 [ -d "${TEMPDIR}" ] || die
"must setup_tempdir"
129 chr
=`perl -e "print chr(48+$ver)"`
130 head -c $obj_size /dev
/zero |
tr '\0' "$chr" > $TEMPDIR/exemplar
131 for i
in `seq -w 1 $num_objs`; do
132 .
/rados
-c .
/ceph.conf
-p $pool get obj
$i $TEMPDIR/out
$i || die
"radostool failed"
133 cmp $TEMPDIR/out
$i $TEMPDIR/exemplar || die
"got back incorrect obj$i"
144 while [ $t -lt $total_time ]; do
145 $command |
grep "$search_str"
146 [ $?
-eq 0 ] && return 1
147 sleep $polling_interval
148 t
=$
(($t+$polling_interval))
156 echo "dumping osd store..."
157 find .
/dev
/osd
* -type f |
grep obj |
grep head$ |
sort |
while read file; do
167 while [ $osd -lt $CEPH_NUM_OSD ]; do
168 .
/ceph
-c .
/ceph.conf tell osd.
$osd debug kick_recovery_wq
0