]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/test_pidfile.sh
add stop-gap to fix compat with CPUs not supporting SSE 4.1
[ceph.git] / ceph / src / test / test_pidfile.sh
1 #!/usr/bin/env bash
2
3 #
4 # test pidfile here
5 #
6
7 # Includes
8 source $(dirname $0)/detect-build-env-vars.sh
9 source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
10
11 function run() {
12 local dir=$1
13 shift
14
15 export CEPH_MON="127.0.0.1:7124" # git grep '\<7124\>' : there must be only one
16 export CEPH_ARGS
17 CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
18 CEPH_ARGS+="--mon-host=$CEPH_MON "
19
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
23 done
24 }
25
26 function TEST_without_pidfile() {
27 local dir=$1
28 setup $dir
29 local data=$dir/osd1
30 local id=1
31 ceph-mon \
32 --id $id \
33 --mkfs \
34 --mon-data=$data \
35 --run-dir=$dir || return 1
36 expect_failure $dir "ignore empty --pid-file" ceph-mon \
37 -f \
38 --log-to-stderr \
39 --log_flush_on_exit \
40 --pid-file= \
41 --id $id \
42 --mon-data=$data \
43 --run-dir=$dir || return 1
44 teardown $dir
45 }
46
47 function TEST_pidfile() {
48 local dir=$1
49 setup $dir
50
51 # no daemon can use a pidfile that is owned by another daemon
52 run_mon $dir a || return 1
53 sleep 5
54 run_mon $dir a --log-to-stderr -f 2>&1 | grep "failed to lock pidfile" || return 1
55
56 run_osd $dir 0 || return 1
57 sleep 5
58 activate_osd $dir 0 --log-to-stderr -f 2>&1 | grep "failed to lock pidfile" || return 1
59
60 # when a daemon shutdown, it will not unlink a path different from
61 # the one it owns
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
66
67 # when a daemon starts, it re-uses the pid file if no other daemon
68 # has it locked
69 run_osd $dir 0 || return 1
70 ! cmp $dir/osd.0.pid $dir/osd.0.pid.old || return 1
71
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
74 # another daemon
75 mkdir $dir/old
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
80
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
85
86 teardown $dir || return 1
87 }
88
89 main pidfile "$@"
90