]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: helper to create an OSD for functional tests
authorLoic Dachary <loic@dachary.org>
Sun, 2 Mar 2014 16:48:25 +0000 (17:48 +0100)
committerLoic Dachary <loic@dachary.org>
Mon, 3 Mar 2014 08:28:55 +0000 (09:28 +0100)
Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/Makefile.am
src/test/osd/osd-test-helpers.sh [new file with mode: 0644]

index 083a8ffc0ba01dfa183c7b83e6a0b038ffb7dba0..7d2b4eb4e38ff337e0d161d4669c4af6f6e62b7e 100644 (file)
@@ -242,7 +242,8 @@ check_SCRIPTS += \
        test/vstart_wrapped_tests.sh
 
 EXTRA_DIST += \
-       $(srcdir)/test/mon/mon-test-helpers.sh
+       $(srcdir)/test/mon/mon-test-helpers.sh \
+       $(srcdir)/test/osd/osd-test-helpers.sh
 
 # target to build but not run the unit tests
 unittests:: $(check_PROGRAMS)
diff --git a/src/test/osd/osd-test-helpers.sh b/src/test/osd/osd-test-helpers.sh
new file mode 100644 (file)
index 0000000..341c171
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash
+#
+# Copyright (C) 2014 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.
+#
+
+function run_osd() {
+    local dir=$1
+    shift
+    local id=$1
+    shift
+    local osd_data=$dir/$id
+
+    local ceph_disk_args
+    ceph_disk_args+=" --statedir=$dir"
+    ceph_disk_args+=" --sysconfdir=$dir"
+    ceph_disk_args+=" --prepend-to-path="
+    ceph_disk_args+=" --verbose"
+
+    touch $dir/ceph.conf
+
+    ./ceph-disk $ceph_disk_args \
+        prepare $osd_data || return 1
+
+    local ceph_args="$CEPH_ARGS"
+    ceph_args+=" --osd-journal-size=100"
+    ceph_args+=" --osd-data=$osd_data"
+    ceph_args+=" --chdir="
+    ceph_args+=" --run-dir=$dir"
+    ceph_args+=" --log-file=$dir/osd-\$id.log"
+    ceph_args+=" --pid-file=$dir/osd-\$id.pidfile"
+    ceph_args+=" "
+    ceph_args+="$@"
+    CEPH_ARGS="$ceph_args" ./ceph-disk $ceph_disk_args \
+        activate \
+        --mark-init=none \
+        $osd_data || return 1
+
+    [ "$id" = "$(cat $osd_data/whoami)" ] || return 1
+
+    ./ceph osd crush create-or-move "$id" 1 root=default host=localhost
+}