Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / standalone / mon / mon-handle-forward.sh
1 #!/bin/bash
2 #
3 # Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
4 # Copyright (C) 2014,2015 Red Hat <contact@redhat.com>
5 #
6 # Author: Loic Dachary <loic@dachary.org>
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU Library Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU Library Public License for more details.
17 #
18 source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
19
20 function run() {
21     local dir=$1
22
23     setup $dir || return 1
24
25     MONA=127.0.0.1:7300
26     MONB=127.0.0.1:7301
27     (
28         FSID=$(uuidgen)
29         export CEPH_ARGS
30         CEPH_ARGS+="--fsid=$FSID --auth-supported=none "
31         CEPH_ARGS+="--mon-initial-members=a,b --mon-host=$MONA,$MONB "
32         run_mon $dir a --public-addr $MONA || return 1
33         run_mon $dir b --public-addr $MONB || return 1
34     )
35
36     timeout 360 ceph --mon-host $MONA mon stat || return 1
37     # check that MONB is indeed a peon
38     ceph --admin-daemon $(get_asok_path mon.b) mon_status |
39        grep '"peon"' || return 1
40     # when the leader ( MONA ) is used, there is no message forwarding
41     ceph --mon-host $MONA osd pool create POOL1 12
42     CEPH_ARGS='' ceph --admin-daemon $(get_asok_path mon.a) log flush || return 1
43     grep 'mon_command(.*"POOL1"' $dir/a/mon.a.log
44     CEPH_ARGS='' ceph --admin-daemon $(get_asok_path mon.b) log flush || return 1
45     grep 'mon_command(.*"POOL1"' $dir/mon.b.log && return 1
46     # when the peon ( MONB ) is used, the message is forwarded to the leader
47     ceph --mon-host $MONB osd pool create POOL2 12
48     CEPH_ARGS='' ceph --admin-daemon $(get_asok_path mon.b) log flush || return 1
49     grep 'forward_request.*mon_command(.*"POOL2"' $dir/mon.b.log
50     CEPH_ARGS='' ceph --admin-daemon $(get_asok_path mon.a) log flush || return 1
51     grep ' forward(mon_command(.*"POOL2"' $dir/mon.a.log
52     # forwarded messages must retain features from the original connection
53     features=$(sed -n -e 's|.*127.0.0.1:0.*accept features \([0-9][0-9]*\)|\1|p' < \
54         $dir/mon.b.log)
55     grep ' forward(mon_command(.*"POOL2".*con_features '$features $dir/mon.a.log
56
57     teardown $dir || return 1
58 }
59
60 main mon-handle-forward "$@"
61
62 # Local Variables:
63 # compile-command: "cd ../.. ; make -j4 TESTS=test/mon/mon-handle-forward.sh check"
64 # End: