]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/test_pidfile.sh
8 source $
(dirname $0)/detect-build-env-vars.sh
9 source $CEPH_ROOT/qa
/standalone
/ceph-helpers.sh
15 export CEPH_MON
="127.0.0.1:7124" # git grep '\<7124\>' : there must be only one
17 CEPH_ARGS
+="--fsid=$(uuidgen) --auth-supported=none "
18 CEPH_ARGS
+="--mon-host=$CEPH_MON "
20 local funcs
=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
21 for func
in $funcs ; do
22 $func $dir ||
return 1
26 function TEST_without_pidfile
() {
35 --run-dir=$dir ||
return 1
36 expect_failure
$dir "ignore empty --pid-file" ceph-mon \
43 --run-dir=$dir ||
return 1
47 function TEST_pidfile
() {
51 # no daemon can use a pidfile that is owned by another daemon
52 run_mon
$dir a ||
return 1
54 run_mon
$dir a
--log-to-stderr -f 2>&1 |
grep "failed to lock pidfile" ||
return 1
56 run_osd
$dir 0 ||
return 1
58 activate_osd
$dir 0 --log-to-stderr -f 2>&1 |
grep "failed to lock pidfile" ||
return 1
60 # when a daemon shutdown, it will not unlink a path different from
62 mv $dir/osd
.0.pid
$dir/osd
.0.pid.old ||
return 1
63 cp $dir/osd
.0.pid.old
$dir/osd
.0.pid ||
return 1
64 kill_daemons
$dir TERM osd
.0 ||
return 1
65 test -f $dir/osd
.0.pid ||
return 1
67 # when a daemon starts, it re-uses the pid file if no other daemon
69 run_osd
$dir 0 ||
return 1
70 ! cmp $dir/osd
.0.pid
$dir/osd
.0.pid.old ||
return 1
72 # if the pid in the file is different from the pid of the daemon
73 # the file is not removed because it is assumed to be owned by
76 cp $dir/osd
.0.pid
$dir/old
/osd
.0.pid
# so that kill_daemon finds the pid
77 echo 123 > $dir/osd
.0.pid
78 kill_daemons
$dir/old TERM osd
.0 ||
return 1
79 test -f $dir/osd
.0.pid ||
return 1
81 # when the daemon shutdown, it removes its own pid file
82 test -f $dir/mon.a.pid ||
return 1
83 kill_daemons
$dir TERM mon.a ||
return 1
84 ! test -f $dir/mon.a.pid ||
return 1
86 teardown
$dir ||
return 1