Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes: #13422 Signed-off-by: shun song <song.shun3@zte.com.cn>
- Loading branch information
Showing
2 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#!/bin/bash -e | ||
|
||
# | ||
# test pidfile here | ||
# | ||
|
||
# Includes | ||
source ../qa/workunits/ceph-helpers.sh | ||
|
||
function run() { | ||
local dir=$1 | ||
shift | ||
|
||
export CEPH_MON="127.0.0.1:17108" | ||
export CEPH_ARGS | ||
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none " | ||
CEPH_ARGS+="--mon-host=$CEPH_MON " | ||
|
||
local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')} | ||
for func in $funcs ; do | ||
$func $dir || return 1 | ||
done | ||
} | ||
|
||
|
||
function TEST_normal() { | ||
local dir=$1 | ||
setup $dir | ||
run_mon $dir a | ||
run_osd $dir 0 | ||
teardown $dir | ||
} | ||
|
||
function TEST_without_pidfile() { | ||
local dir=$1 | ||
setup $dir | ||
local RUNID=`uuidgen` | ||
run_mon $dir a --pid-file= --daemonize=$RUNID || { teardown_unexist_pidfile $dir; return 1; } | ||
run_osd $dir 0 --pid-file= --daemonize=$RUNID || { teardown_unexist_pidfile $dir; return 1; } | ||
teardown_unexist_pidfile $dir $RUNID || return 1 | ||
} | ||
|
||
function teardown_unexist_pidfile() { | ||
local dir=$1 | ||
shift | ||
local RUNID=$1 | ||
shift | ||
local delays=('0' '1' '3' '5' '10' '10' '20' '60') | ||
local pids=$(ps aux|awk "/cep[h].*$RUNID.*/ {print \$2}") | ||
for i in $pids ; do | ||
local kill_complete="0" | ||
local count=0 | ||
while [ $kill_complete -eq "0" ] ; do | ||
if kill -9 $i 2> /dev/null ; then | ||
kill_complete="0" | ||
count=$((count+1)) | ||
sleep ${delays[$count]} | ||
else | ||
kill_complete="1" | ||
fi | ||
done | ||
done | ||
if [ $(stat -f -c '%T' .) == "btrfs" ]; then | ||
__teardown_btrfs $dir | ||
fi | ||
rm -fr $dir | ||
if [ $kill_complete -eq "0" ] ;then | ||
return 1 | ||
else | ||
return 0 | ||
fi | ||
} | ||
|
||
|
||
function run_osd_again() { | ||
local dir=$1 | ||
shift | ||
local id=$1 | ||
shift | ||
ceph-osd \ | ||
--cluster=ceph \ | ||
--id=$id \ | ||
--osd-data=$dir/$id \ | ||
--osd-journal=$dir/$id/journal \ | ||
--pid-file $dir/osd.0.pid 2>&1 | grep "failed to lock pidfile" | ||
} | ||
|
||
function run_mon_again() { | ||
|
||
local dir=$1 | ||
shift | ||
local id=$1 | ||
shift | ||
ceph-mon \ | ||
--id $id \ | ||
--mon-data=$dir \ | ||
--log-file=$dir/mon.$id.log \ | ||
--mon-cluster-log-file=$dir/log \ | ||
--run-dir=$dir \ | ||
--pid-file=$dir/mon.$id.pid 2>&1 | grep "failed to lock pidfile" | ||
} | ||
|
||
function TEST_contend_pidfile() { | ||
local dir=$1 | ||
setup $dir | ||
|
||
run_mon $dir a | ||
run_mon_again $dir a || return 1 | ||
|
||
run_osd $dir 0 | ||
run_osd_again $dir 0 || return 1 | ||
teardown $dir || return 1 | ||
} | ||
|
||
main pidfile |