]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: verify it is possible to reuse an OSD id 6882/head
authorLoic Dachary <ldachary@redhat.com>
Thu, 10 Dec 2015 14:20:32 +0000 (15:20 +0100)
committerLoic Dachary <ldachary@redhat.com>
Mon, 11 Jan 2016 15:58:55 +0000 (16:58 +0100)
When an OSD id is removed via ceph osd rm, it will be reused by the next
ceph osd create command. Verify that and OSD reusing such an id
successfully comes up.

http://tracker.ceph.com/issues/13988 Refs: #13988

Signed-off-by: Loic Dachary <loic@dachary.org>
(cherry picked from commit 7324615bdb829f77928fa10d4e988c6422945937)

qa/workunits/ceph-helpers.sh
src/test/Makefile.am
src/test/osd/osd-reuse-id.sh [new file with mode: 0755]

index 5ee290962c30a582b592217d7916306514116f44..3c942bb6f2085e8761a443725e4108ebe047cb21 100755 (executable)
@@ -438,6 +438,42 @@ function test_run_osd() {
 
 #######################################################################
 
+##
+# Shutdown and remove all traces of the osd by the name osd.**id**.
+#
+# The OSD is shutdown with the TERM signal. It is then removed from
+# the auth list, crush map, osd map etc and the files associated with
+# it are also removed.
+#
+# @param dir path name of the environment
+# @param id osd identifier
+# @return 0 on success, 1 on error
+#
+function destroy_osd() {
+    local dir=$1
+    local id=$2
+
+    kill_daemons $dir TERM osd.$id || return 1
+    ceph osd out osd.$id || return 1
+    ceph auth del osd.$id || return 1
+    ceph osd crush remove osd.$id || return 1
+    ceph osd rm $id || return 1
+    rm -fr $dir/$id
+}
+
+function test_destroy_osd() {
+    local dir=$1
+
+    setup $dir || return 1
+    run_mon $dir a || return 1
+    run_osd $dir 0 || return 1
+    destroy_osd $dir 0 || return 1
+    ! ceph osd dump | grep "osd.$id " || return 1
+    teardown $dir || return 1
+}
+
+#######################################################################
+
 ##
 # Run (activate) an osd by the name osd.**id** with data in
 # **dir**/**id**.  The logs can be found in **dir**/osd.**id**.log,
@@ -1135,10 +1171,42 @@ function test_erasure_code_plugin_exists() {
 
 #######################################################################
 
+##
+# Display all log files from **dir** on stdout.
+#
+# @param dir directory in which all data is stored
+#
+
+function display_logs() {
+    local dir=$1
+
+    find $dir -maxdepth 1 -name '*.log' | \
+        while read file ; do
+            echo "======================= $file"
+            cat $file
+        done
+}
+
+function test_display_logs() {
+    local dir=$1
+
+    setup $dir || return 1
+    run_mon $dir a || return 1
+    kill_daemons $dir || return 1
+    display_logs $dir > $dir/log.out
+    grep --quiet mon.a.log $dir/log.out || return 1
+    teardown $dir || return 1
+}
+
+#######################################################################
+
 ##
 # Call the **run** function (which must be defined by the caller) with
 # the **dir** argument followed by the caller argument list.
 #
+# If the **run** function returns on error, all logs found in **dir**
+# are displayed for diagnostic purposes.
+#
 # **teardown** function is called when the **run** function returns
 # (on success or on error), to cleanup leftovers. The CEPH_CONF is set
 # to /dev/null and CEPH_ARGS is unset so that the tests are protected from
@@ -1171,6 +1239,7 @@ function main() {
     if run $dir "$@" ; then
         code=0
     else
+        display_logs $dir
         code=1
     fi
     teardown $dir || return 1
index 89fc7dfa7603a783f21e75a50e1ca9cee9b8d396..fa813bab08aacafa6f7e59394d087fd0bf852bda 100644 (file)
@@ -80,6 +80,7 @@ check_SCRIPTS += \
        test/mon/mon-scrub.sh \
        test/osd/osd-scrub-repair.sh \
        test/osd/osd-config.sh \
+       test/osd/osd-reuse-id.sh \
        test/osd/osd-bench.sh \
        test/osd/osd-copy-from.sh \
        test/mon/mon-handle-forward.sh \
diff --git a/src/test/osd/osd-reuse-id.sh b/src/test/osd/osd-reuse-id.sh
new file mode 100755 (executable)
index 0000000..8efdf5c
--- /dev/null
@@ -0,0 +1,51 @@
+#! /bin/bash
+#
+# Copyright (C) 2015 Red Hat <contact@redhat.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 ../qa/workunits/ceph-helpers.sh
+
+function run() {
+    local dir=$1
+    shift
+
+    export CEPH_MON="127.0.0.1:7123" # git grep '\<7123\>' : there must be only one
+    export CEPH_ARGS
+    CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
+    CEPH_ARGS+="--mon-host=$CEPH_MON "
+
+    local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
+    for func in $funcs ; do
+        $func $dir || return 1
+    done
+}
+
+function TEST_reuse_id() {
+    local dir=$1
+
+    setup $dir || return 1
+    run_mon $dir a --osd_pool_default_size=1 || return 1
+    run_osd $dir 0 || return 1
+    run_osd $dir 1 || return 1
+    wait_for_clean || return 1
+    destroy_osd $dir 1 || return 1
+    run_osd $dir 1 || return 1
+}
+
+main osd-reuse-id "$@"
+
+# Local Variables:
+# compile-command: "cd ../.. ; make -j4 && test/osd/osd-reuse-id.sh"
+# End:
+