]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: test for MForward messages 1003/head
authorLoic Dachary <loic@dachary.org>
Fri, 27 Dec 2013 10:18:59 +0000 (11:18 +0100)
committerLoic Dachary <loic@dachary.org>
Sun, 26 Jan 2014 12:40:53 +0000 (13:40 +0100)
Creates two mons, send a mon command to the peon and check that the
command is forwarded to the leader.

Add a test to check that the connection features of the client are
preserved when the message reaches the leader.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/Makefile.am
src/test/mon/mon-handle-forward.sh [new file with mode: 0755]

index 8f4c25a6468e3d2f73ffe1ac3352c887579da8e5..fe5f4c782e44a1aba92bbf042cc65a8f54baf5d6 100644 (file)
@@ -246,6 +246,7 @@ check_SCRIPTS += \
        test/mon/osd-pool-create.sh \
        test/mon/mkfs.sh \
        test/ceph-disk.sh \
+       test/mon/mon-handle-forward.sh \
        test/vstart_wrapped_tests.sh
 
 # target to build but not run the unit tests
diff --git a/src/test/mon/mon-handle-forward.sh b/src/test/mon/mon-handle-forward.sh
new file mode 100755 (executable)
index 0000000..6f3ea67
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
+#
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library Public License for more details.
+#
+source test/mon/mon-test-helpers.sh
+
+function run() {
+    local dir=$1
+
+    PORT=7451
+    MONA=127.0.0.1:$PORT
+    MONB=127.0.0.1:$(($PORT + 1))
+    (
+        FSID=$(uuidgen) 
+        export CEPH_ARGS
+        CEPH_ARGS+="--fsid=$FSID --auth-supported=none "
+        CEPH_ARGS+="--mon-initial-members=a,b --mon-host=$MONA,$MONB "
+        run_mon $dir a --public-addr $MONA
+        run_mon $dir b --public-addr $MONB
+    )
+
+    timeout 10 ./ceph --mon-host $MONA mon stat || return 1
+    # check that MONB is indeed a peon
+    ./ceph --admin-daemon $dir/b/ceph-mon.b.asok mon_status | 
+       grep '"peon"' || return 1
+    # when the leader ( MONA ) is used, there is no message forwarding
+    ./ceph --mon-host $MONA osd pool create POOL1 12 
+    grep 'mon_command(.*"POOL1"' $dir/a/log 
+    grep 'mon_command(.*"POOL1"' $dir/b/log && return 1
+    # when the peon ( MONB ) is used, the message is forwarded to the leader
+    ./ceph --mon-host $MONB osd pool create POOL2 12 
+    grep 'forward_request.*mon_command(.*"POOL2"' $dir/b/log
+    grep ' forward(mon_command(.*"POOL2"' $dir/a/log 
+    # forwarded messages must retain features from the original connection
+    features=$(sed -n -e 's|.*127.0.0.1:0.*accept features \([0-9][0-9]*\)|\1|p' < \
+        $dir/b/log)
+    grep ' forward(mon_command(.*"POOL2".*con_features '$features $dir/a/log
+}
+
+main mon-handle-forward
+
+# Local Variables:
+# compile-command: "cd ../.. ; make TESTS=test/mon/mon-handle-forward.sh check"
+# End: