3 # Copyright (C) 2017 Quantum Corp.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU Library Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Library Public License for more details.
15 source $
(dirname $0)/..
/detect-build-env-vars.sh
16 source $CEPH_ROOT/qa
/workunits
/ceph-helpers.sh
20 function port_forward
() {
24 socat TCP-LISTEN
:${source_port},fork
,reuseaddr TCP
:localhost
:${target_port} &
29 for p
in "${SOCAT_PIDS[@]}"; do
35 trap cleanup SIGTERM SIGKILL SIGQUIT SIGINT
41 export MON_IP
=127.0.0.1
42 export MONA_PUBLIC
=7132 # git grep '\<7132\>' ; there must be only one
43 export MONB_PUBLIC
=7133 # git grep '\<7133\>' ; there must be only one
44 export MONC_PUBLIC
=7134 # git grep '\<7134\>' ; there must be only one
45 export MONA_BIND
=7135 # git grep '\<7135\>' ; there must be only one
46 export MONB_BIND
=7136 # git grep '\<7136\>' ; there must be only one
47 export MONC_BIND
=7137 # git grep '\<7137\>' ; there must be only one
49 CEPH_ARGS
+="--fsid=$(uuidgen) --auth-supported=none "
51 local funcs
=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
52 for func
in $funcs ; do
53 setup
$dir ||
return 1
54 $func $dir && cleanup ||
{ cleanup
; return 1; }
59 function TEST_mon_client_connect_fails
() {
62 # start the mon with a public-bind-addr that is different
63 # from the public-addr.
64 CEPH_ARGS
+="--mon-initial-members=a "
65 CEPH_ARGS
+="--mon-host=${MON_IP}:${MONA_PUBLIC} "
66 run_mon_no_pool
$dir a
--mon-host=${MON_IP}:${MONA_PUBLIC} --public-bind-addr=${MON_IP}:${MONA_BIND} ||
return 1
68 # now attempt to ping it that should fail.
69 timeout
3 ceph
ping mon.a ||
return 0
73 function TEST_mon_client_connect
() {
76 # start the mon with a public-bind-addr that is different
77 # from the public-addr.
78 CEPH_ARGS
+="--mon-initial-members=a "
79 CEPH_ARGS
+="--mon-host=${MON_IP}:${MONA_PUBLIC} "
80 run_mon_no_pool
$dir a
--mon-host=${MON_IP}:${MONA_PUBLIC} --public-bind-addr=${MON_IP}:${MONA_BIND} ||
return 1
82 # now forward the public port to the bind port.
83 port_forward
${MONA_PUBLIC} ${MONA_BIND}
85 # attempt to connect. we expect that to work
86 ceph
ping mon.a ||
return 1
89 function TEST_mon_quorum
() {
92 # start the mon with a public-bind-addr that is different
93 # from the public-addr.
94 CEPH_ARGS
+="--mon-initial-members=a,b,c "
95 CEPH_ARGS
+="--mon-host=${MON_IP}:${MONA_PUBLIC},${MON_IP}:${MONB_PUBLIC},${MON_IP}:${MONC_PUBLIC} "
96 run_mon_no_pool
$dir a
--public-addr=${MON_IP}:${MONA_PUBLIC} --public-bind-addr=${MON_IP}:${MONA_BIND} ||
return 1
97 run_mon_no_pool
$dir b
--public-addr=${MON_IP}:${MONB_PUBLIC} --public-bind-addr=${MON_IP}:${MONB_BIND} ||
return 1
98 run_mon_no_pool
$dir c
--public-addr=${MON_IP}:${MONC_PUBLIC} --public-bind-addr=${MON_IP}:${MONC_BIND} ||
return 1
100 # now forward the public port to the bind port.
101 port_forward
${MONA_PUBLIC} ${MONA_BIND}
102 port_forward
${MONB_PUBLIC} ${MONB_BIND}
103 port_forward
${MONC_PUBLIC} ${MONC_BIND}
105 # expect monmap to contain 3 monitors (a, b, and c)
106 jqinput
="$(ceph mon_status --format=json 2>/dev/null)"
107 jq_success
"$jqinput" '.monmap.mons | length == 3' ||
return 1
110 wait_for_quorum
300 3 ||
return 1
111 # expect quorum to have all three monitors
112 jqfilter
='.quorum | length == 3'
113 jq_success
"$jqinput" "$jqfilter" ||
return 1
116 function TEST_put_get
() {
119 # start the mon with a public-bind-addr that is different
120 # from the public-addr.
121 CEPH_ARGS
+="--mon-initial-members=a,b,c "
122 CEPH_ARGS
+="--mon-host=${MON_IP}:${MONA_PUBLIC},${MON_IP}:${MONB_PUBLIC},${MON_IP}:${MONC_PUBLIC} "
123 run_mon_no_pool
$dir a
--public-addr=${MON_IP}:${MONA_PUBLIC} --public-bind-addr=${MON_IP}:${MONA_BIND} ||
return 1
124 run_mon_no_pool
$dir b
--public-addr=${MON_IP}:${MONB_PUBLIC} --public-bind-addr=${MON_IP}:${MONB_BIND} ||
return 1
125 run_mon_no_pool
$dir c
--public-addr=${MON_IP}:${MONC_PUBLIC} --public-bind-addr=${MON_IP}:${MONC_BIND} ||
return 1
127 # now forward the public port to the bind port.
128 port_forward
${MONA_PUBLIC} ${MONA_BIND}
129 port_forward
${MONB_PUBLIC} ${MONB_BIND}
130 port_forward
${MONC_PUBLIC} ${MONC_BIND}
133 wait_for_quorum
300 3 ||
return 1
135 run_mgr
$dir x ||
return 1
136 run_osd
$dir 0 ||
return 1
137 run_osd
$dir 1 ||
return 1
138 run_osd
$dir 2 ||
return 1
140 ceph osd pool create hello
8 ||
return 1
142 echo "hello world" > $dir/hello
143 rados
--pool hello put foo
$dir/hello ||
return 1
144 rados
--pool hello get foo
$dir/hello2 ||
return 1
145 diff $dir/hello
$dir/hello2 ||
return 1