]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/rbd/test_admin_socket.sh
4 TMPDIR
=/tmp
/rbd_test_admin_socket$$
6 trap "rm -fr $TMPDIR" 0
8 . $
(dirname $0)/..
/..
/standalone
/ceph-helpers.sh
10 function expect_false
()
13 if "$@"; then return 1; else return 0; fi
16 function rbd_watch_out_file
()
18 echo ${TMPDIR}/rbd_watch_
$1.out
21 function rbd_watch_pid_file
()
23 echo ${TMPDIR}/rbd_watch_
$1.pid
26 function rbd_watch_fifo
()
28 echo ${TMPDIR}/rbd_watch_
$1.fifo
31 function rbd_watch_asok
()
33 echo ${TMPDIR}/rbd_watch_
$1.asok
36 function rbd_get_perfcounter
()
42 name
=$
(ceph
--format xml
--admin-daemon $
(rbd_watch_asok
${image}) \
43 perf schema |
$XMLSTARLET el
-d3 |
44 grep "/librbd-.*-${image}/${counter}\$")
45 test -n "${name}" ||
return 1
47 ceph
--format xml
--admin-daemon $
(rbd_watch_asok
${image}) perf dump |
48 $XMLSTARLET sel
-t -m "${name}" -v .
51 function rbd_check_perfcounter
()
58 val
=$
(rbd_get_perfcounter
${image} ${counter})
60 test "${val}" -eq "${expected_val}"
63 function rbd_watch_start
()
66 local asok
=$
(rbd_watch_asok
${image})
68 mkfifo $
(rbd_watch_fifo
${image})
69 (cat $
(rbd_watch_fifo
${image}) |
70 rbd
--admin-socket ${asok} watch
${image} \
71 > $
(rbd_watch_out_file
${image}) 2>&1)&
73 # find pid of the started rbd watch process
76 pid
=$
(ps auxww |
awk "/[r]bd --admin.* watch ${image}/ {print \$2}")
77 test -n "${pid}" && break
81 echo ${pid} > $
(rbd_watch_pid_file
${image})
83 # find watcher admin socket
86 test -S "${asok}" && break
91 # configure debug level
92 ceph
--admin-daemon "${asok}" config
set debug_rbd
20
94 # check that watcher is registered
95 rbd status
${image} | expect_false
grep "Watchers: none"
98 function rbd_watch_end
()
103 # send 'enter' to watch to exit
104 echo > $
(rbd_watch_fifo
${image})
105 # just in case it is not terminated
106 kill $
(cat $
(rbd_watch_pid_file
${image})) ||
:
108 # output rbd watch out file for easier troubleshooting
109 cat $
(rbd_watch_out_file
${image})
112 rm -f $
(rbd_watch_fifo
${image}) $
(rbd_watch_pid_file
${image}) \
113 $
(rbd_watch_out_file
${image}) $
(rbd_watch_asok
${image})
118 ceph_admin
="ceph --admin-daemon $(rbd_watch_asok ${image})"
120 rbd create
--size 128 ${pool}/${image}
122 # check rbd cache commands are present in help output
123 rbd_cache_flush
="rbd cache flush ${pool}/${image}"
124 rbd_cache_invalidate
="rbd cache invalidate ${pool}/${image}"
126 rbd_watch_start
${image}
127 ${ceph_admin} help | fgrep
"${rbd_cache_flush}"
128 ${ceph_admin} help | fgrep
"${rbd_cache_invalidate}"
129 rbd_watch_end
${image}
131 # test rbd cache commands with disabled and enabled cache
132 for conf_rbd_cache
in false true
; do
134 rbd image-meta
set ${image} conf_rbd_cache
${conf_rbd_cache}
136 rbd_watch_start
${image}
138 rbd_check_perfcounter
${image} flush
0
139 ${ceph_admin} ${rbd_cache_flush}
140 # 'flush' counter should increase regardless if cache is enabled
141 rbd_check_perfcounter
${image} flush
1
143 rbd_check_perfcounter
${image} invalidate_cache
0
144 ${ceph_admin} ${rbd_cache_invalidate}
145 # 'invalidate_cache' counter should increase regardless if cache is enabled
146 rbd_check_perfcounter
${image} invalidate_cache
1
148 rbd_watch_end
${image}