]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: run ceph-disk tests via tox
authorLoic Dachary <ldachary@redhat.com>
Fri, 1 Jan 2016 21:09:00 +0000 (22:09 +0100)
committerLoic Dachary <ldachary@redhat.com>
Thu, 4 Feb 2016 07:36:37 +0000 (14:36 +0700)
Signed-off-by: Loic Dachary <loic@dachary.org>
src/ceph-disk/run-tox.sh [changed mode: 0644->0755]
src/ceph-disk/tests/ceph-disk.sh [new file with mode: 0644]
src/ceph-disk/tox.ini
src/test/Makefile.am
src/test/ceph-disk.sh [deleted file]
src/test/test_btrfs_common.sh [deleted file]

old mode 100644 (file)
new mode 100755 (executable)
diff --git a/src/ceph-disk/tests/ceph-disk.sh b/src/ceph-disk/tests/ceph-disk.sh
new file mode 100644 (file)
index 0000000..7732a73
--- /dev/null
@@ -0,0 +1,379 @@
+#!/bin/bash
+#
+# Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
+# Copyright (C) 2014, 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.
+#
+
+#
+# Removes btrfs subvolumes under the given directory param
+#
+function teardown_btrfs() {
+    local btrfs_base_dir=$1
+
+    btrfs_dirs=`ls -l $btrfs_base_dir | egrep '^d' | awk '{print $9}'`
+    for btrfs_dir in $btrfs_dirs
+    do
+        btrfs_subdirs=`ls -l $btrfs_base_dir/$btrfs_dir | egrep '^d' | awk '{print $9}'` 
+        for btrfs_subdir in $btrfs_subdirs
+        do
+           btrfs subvolume delete $btrfs_base_dir/$btrfs_dir/$btrfs_subdir
+        done
+    done
+}
+
+PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}:  '
+
+export PATH=..:.:$PATH # make sure program from sources are prefered
+DIR=test-ceph-disk
+if virtualenv virtualenv-$DIR && test -d ceph-detect-init ; then
+    . virtualenv-$DIR/bin/activate
+    (
+       # older versions of pip will not install wrap_console scripts
+       # when using wheel packages
+       pip install --upgrade 'pip >= 6.1'
+       if test -d ceph-detect-init/wheelhouse ; then
+            wheelhouse="--no-index --use-wheel --find-links=ceph-detect-init/wheelhouse"
+       fi
+       pip --log virtualenv-$DIR/log.txt install $wheelhouse --editable ceph-detect-init
+    )
+fi
+: ${CEPH_DISK:=ceph-disk}
+OSD_DATA=$DIR/osd
+MON_ID=a
+MONA=127.0.0.1:7451
+TEST_POOL=rbd
+FSID=$(uuidgen)
+export CEPH_CONF=$DIR/ceph.conf
+export CEPH_ARGS="--fsid $FSID"
+CEPH_ARGS+=" --chdir="
+CEPH_ARGS+=" --journal-dio=false"
+CEPH_ARGS+=" --run-dir=$DIR"
+CEPH_ARGS+=" --osd-failsafe-full-ratio=.99"
+CEPH_ARGS+=" --mon-host=$MONA"
+CEPH_ARGS+=" --log-file=$DIR/\$name.log"
+CEPH_ARGS+=" --pid-file=$DIR/\$name.pidfile"
+if test -d ../.libs ; then
+    CEPH_ARGS+=" --erasure-code-dir=../.libs"
+    CEPH_ARGS+=" --compression-dir=../.libs"
+fi
+CEPH_ARGS+=" --auth-supported=none"
+CEPH_ARGS+=" --osd-journal-size=100"
+CEPH_DISK_ARGS=
+CEPH_DISK_ARGS+=" --statedir=$DIR"
+CEPH_DISK_ARGS+=" --sysconfdir=$DIR"
+CEPH_DISK_ARGS+=" --prepend-to-path="
+CEPH_DISK_ARGS+=" --verbose"
+TIMEOUT=360
+
+cat=$(which cat)
+timeout=$(which timeout)
+diff=$(which diff)
+mkdir=$(which mkdir)
+rm=$(which rm)
+uuidgen=$(which uuidgen)
+
+function setup() {
+    teardown
+    mkdir $DIR
+    mkdir $OSD_DATA
+    touch $DIR/ceph.conf # so ceph-disk think ceph is the cluster
+}
+
+function teardown() {
+    kill_daemons
+    if [ $(stat -f -c '%T' .) == "btrfs" ]; then
+        rm -fr $DIR/*/*db
+        teardown_btrfs $DIR
+    fi
+    grep " $(pwd)/$DIR/" < /proc/mounts | while read mounted rest ; do
+        umount $mounted
+    done
+    rm -fr $DIR
+}
+
+function run_mon() {
+    local mon_dir=$DIR/$MON_ID
+
+    ceph-mon \
+        --id $MON_ID \
+        --mkfs \
+        --mon-data=$mon_dir \
+        --mon-initial-members=$MON_ID \
+        "$@"
+
+    ceph-mon \
+        --id $MON_ID \
+        --mon-data=$mon_dir \
+        --mon-osd-full-ratio=.99 \
+        --mon-data-avail-crit=1 \
+        --mon-cluster-log-file=$mon_dir/log \
+        --public-addr $MONA \
+        "$@"
+}
+
+function kill_daemons() {
+    if ! test -e $DIR ; then
+        return
+    fi
+    for pidfile in $(find $DIR | grep pidfile) ; do
+        pid=$(cat $pidfile)
+        for try in 0 1 1 1 2 3 ; do
+            kill $pid 2>/dev/null || break
+            sleep $try
+        done
+    done
+}
+
+function command_fixture() {
+    local command=$1
+
+    [ $(which $command) = ../$command ] || [ $(which $command) = `readlink -f $(pwd)/$command` ] || return 1
+
+    cat > $DIR/$command <<EOF
+#!/bin/bash
+touch $DIR/used-$command
+exec ../$command "\$@"
+EOF
+    chmod +x $DIR/$command
+}
+
+function tweak_path() {
+    local tweaker=$1
+
+    setup
+
+    command_fixture ceph-conf || return 1
+    command_fixture ceph-osd || return 1
+
+    test_activate_dir
+
+    [ ! -f $DIR/used-ceph-conf ] || return 1
+    [ ! -f $DIR/used-ceph-osd ] || return 1
+
+    teardown
+
+    setup
+
+    command_fixture ceph-conf || return 1
+    command_fixture ceph-osd || return 1
+
+    $tweaker test_activate_dir || return 1
+
+    [ -f $DIR/used-ceph-osd ] || return 1
+
+    teardown
+}
+
+function use_prepend_to_path() {
+    local ceph_disk_args
+    ceph_disk_args+=" --statedir=$DIR"
+    ceph_disk_args+=" --sysconfdir=$DIR"
+    ceph_disk_args+=" --prepend-to-path=$DIR"
+    ceph_disk_args+=" --verbose"
+    CEPH_DISK_ARGS="$ceph_disk_args" \
+        "$@" || return 1
+}
+
+function test_prepend_to_path() {
+    tweak_path use_prepend_to_path || return 1
+}
+
+function use_path() {
+    PATH="$DIR:$PATH" \
+        "$@" || return 1
+}
+
+function test_path() {
+    tweak_path use_path || return 1
+}
+
+function test_no_path() {
+    ( export PATH=..:${VIRTUAL_ENV}/bin:/usr/bin:/bin ; test_activate_dir ) || return 1
+}
+
+function test_mark_init() {
+    run_mon
+
+    local osd_data=$(pwd)/$DIR/dir
+    $mkdir -p $osd_data
+
+    local osd_uuid=$($uuidgen)
+
+    $mkdir -p $OSD_DATA
+
+    ${CEPH_DISK} $CEPH_DISK_ARGS \
+        prepare --osd-uuid $osd_uuid $osd_data || return 1
+
+    $timeout $TIMEOUT ${CEPH_DISK} $CEPH_DISK_ARGS \
+        --verbose \
+        activate \
+        --mark-init=auto \
+        --no-start-daemon \
+        $osd_data || return 1
+
+    test -f $osd_data/$(ceph-detect-init) || return 1
+
+    if test systemd = $(ceph-detect-init) ; then
+        expected=sysvinit
+    else
+        expected=systemd
+    fi
+    $timeout $TIMEOUT ${CEPH_DISK} $CEPH_DISK_ARGS \
+        --verbose \
+        activate \
+        --mark-init=$expected \
+        --no-start-daemon \
+        $osd_data || return 1
+
+    ! test -f $osd_data/$(ceph-detect-init) || return 1
+    test -f $osd_data/$expected || return 1
+
+    $rm -fr $osd_data
+}
+
+function test_zap() {
+    local osd_data=$DIR/dir
+    $mkdir -p $osd_data
+
+    ${CEPH_DISK} $CEPH_DISK_ARGS zap $osd_data 2>&1 | grep -q 'not full block device' || return 1
+
+    $rm -fr $osd_data
+}
+
+# ceph-disk prepare returns immediately on success if the magic file
+# exists in the --osd-data directory.
+function test_activate_dir_magic() {
+    local uuid=$($uuidgen)
+    local osd_data=$DIR/osd
+
+    echo a failure to create the fsid file implies the magic file is not created
+
+    mkdir -p $osd_data/fsid
+    CEPH_ARGS="--fsid $uuid" \
+     ${CEPH_DISK} $CEPH_DISK_ARGS prepare $osd_data > $DIR/out 2>&1
+    grep --quiet 'Is a directory' $DIR/out || return 1
+    ! [ -f $osd_data/magic ] || return 1
+    rmdir $osd_data/fsid
+
+    echo successfully prepare the OSD
+
+    CEPH_ARGS="--fsid $uuid" \
+     ${CEPH_DISK} $CEPH_DISK_ARGS prepare $osd_data 2>&1 | tee $DIR/out
+    grep --quiet 'Preparing osd data dir' $DIR/out || return 1
+    grep --quiet $uuid $osd_data/ceph_fsid || return 1
+    [ -f $osd_data/magic ] || return 1
+
+    echo will not override an existing OSD
+
+    CEPH_ARGS="--fsid $($uuidgen)" \
+     ${CEPH_DISK} $CEPH_DISK_ARGS prepare $osd_data 2>&1 | tee $DIR/out
+    grep --quiet 'Data dir .* already exists' $DIR/out || return 1
+    grep --quiet $uuid $osd_data/ceph_fsid || return 1
+}
+
+function test_pool_read_write() {
+    local osd_uuid=$1
+
+    $timeout $TIMEOUT ceph osd pool set $TEST_POOL size 1 || return 1
+
+    local id=$(ceph osd create $osd_uuid)
+    local weight=1
+    ceph osd crush add osd.$id $weight root=default host=localhost || return 1
+    echo FOO > $DIR/BAR
+    $timeout $TIMEOUT rados --pool $TEST_POOL put BAR $DIR/BAR || return 1
+    $timeout $TIMEOUT rados --pool $TEST_POOL get BAR $DIR/BAR.copy || return 1
+    $diff $DIR/BAR $DIR/BAR.copy || return 1
+}
+
+function test_activate() {
+    local to_prepare=$1
+    local to_activate=$2
+    local journal=$3
+    local osd_uuid=$($uuidgen)
+
+    $mkdir -p $OSD_DATA
+
+    ${CEPH_DISK} $CEPH_DISK_ARGS \
+        prepare --osd-uuid $osd_uuid $to_prepare $journal || return 1
+
+    $timeout $TIMEOUT ${CEPH_DISK} $CEPH_DISK_ARGS \
+        activate \
+        --mark-init=none \
+        $to_activate || return 1
+
+    test_pool_read_write $osd_uuid || return 1
+}
+
+function test_activate_dir() {
+    run_mon
+
+    local osd_data=$DIR/dir
+    $mkdir -p $osd_data
+    test_activate $osd_data $osd_data || return 1
+    $rm -fr $osd_data
+}
+
+function test_find_cluster_by_uuid() {
+    setup
+    test_activate_dir 2>&1 | tee $DIR/test_find
+    ! grep "No cluster conf found in $DIR" $DIR/test_find || return 1
+    teardown
+
+    setup
+    rm $DIR/ceph.conf
+    test_activate_dir > $DIR/test_find 2>&1 
+    grep --quiet "No cluster conf found in $DIR" $DIR/test_find || return 1
+    teardown
+}
+
+# http://tracker.ceph.com/issues/9653
+function test_keyring_path() {
+    test_activate_dir 2>&1 | tee $DIR/test_keyring
+    grep --quiet "keyring $DIR/bootstrap-osd/ceph.keyring" $DIR/test_keyring || return 1
+}
+
+function run() {
+    local default_actions
+    default_actions+="test_path "
+    default_actions+="test_no_path "
+    default_actions+="test_find_cluster_by_uuid "
+    default_actions+="test_prepend_to_path "
+    default_actions+="test_activate_dir_magic "
+    default_actions+="test_activate_dir "
+    default_actions+="test_keyring_path "
+    default_actions+="test_mark_init "
+    default_actions+="test_zap "
+    local actions=${@:-$default_actions}
+    local status
+    for action in $actions  ; do
+        setup
+        set -x
+        $action
+        status=$?
+        set +x
+        teardown
+        if test $status != 0 ; then
+            break
+        fi
+    done
+    rm -fr virtualenv-$DIR
+    return $status
+}
+
+run $@
+
+# Local Variables:
+# compile-command: "cd .. ; test/ceph-disk.sh # test_activate_dir"
+# End:
index 3592f14458bab5e20811543488a82e34fab3a805..1a1729478a5bec6d44463bce2a1a052913c41b07 100644 (file)
@@ -1,12 +1,10 @@
 [tox]
-envlist = pep8,py27
-skip_missing_interpreters = True
+envlist = py27
 
 [testenv]
-basepython =
-    py27: python2.7
-    py3: python3
-setenv = VIRTUAL_ENV={envdir}
+setenv =
+       VIRTUAL_ENV={envdir}
+       CEPH_DISK={envbindir}/coverage run --append --source=ceph_disk -- {envbindir}/ceph-disk
 usedevelop = true
 deps =
   {env:NO_INDEX:}
@@ -14,18 +12,8 @@ deps =
   --find-links=file://{toxinidir}/wheelhouse
   -r{toxinidir}/requirements.txt
   -r{toxinidir}/test-requirements.txt
+  ../ceph-detect-init
 
 commands = coverage run --source=ceph_disk {envbindir}/py.test -v tests
+           bash -x tests/ceph-disk.sh
            coverage report --omit=*test*,*tox* --show-missing
-
-[testenv:pep8]
-basepython = python2
-commands = flake8 ceph_disk tests
-
-[testenv:integration]
-basepython = python2
-setenv = VIRTUAL_ENV={envdir}
-deps = -r{toxinidir}/requirements.txt
-  -r{toxinidir}/test-requirements.txt
-
-commands = {envbindir}/py.test -v integration/test_main.py
index a4419a259a5435978c28af311b884aa2315f3c08..7fa8366192af5fdc20f67f8e267088657e854fff 100644 (file)
@@ -92,12 +92,7 @@ check_SCRIPTS += \
        test/test_objectstore_memstore.sh \
         test/test_pidfile.sh
 
-check_SCRIPTS += test/ceph-disk.sh
-
 EXTRA_DIST += \
-       $(srcdir)/test/python/ceph-disk/setup.py \
-       $(srcdir)/test/python/ceph-disk/tox.ini \
-       $(srcdir)/test/python/ceph-disk/tests/test_ceph_disk.py \
        $(srcdir)/test/python/brag-client/setup.py \
        $(srcdir)/test/python/brag-client/tox.ini \
        $(srcdir)/test/python/brag-client/tests/test_ceph_brag.py \
diff --git a/src/test/ceph-disk.sh b/src/test/ceph-disk.sh
deleted file mode 100755 (executable)
index 4eaebc8..0000000
+++ /dev/null
@@ -1,362 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
-# Copyright (C) 2014, 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 test/test_btrfs_common.sh
-
-PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}:  '
-
-export PATH=.:$PATH # make sure program from sources are prefered
-DIR=test-ceph-disk
-if virtualenv virtualenv-$DIR && test -d ceph-detect-init ; then
-    . virtualenv-$DIR/bin/activate
-    (
-       # older versions of pip will not install wrap_console scripts
-       # when using wheel packages
-       pip install --upgrade 'pip >= 6.1'
-       if test -d ceph-detect-init/wheelhouse ; then
-            wheelhouse="--no-index --use-wheel --find-links=ceph-detect-init/wheelhouse"
-       fi
-       pip --log virtualenv-$DIR/log.txt install $wheelhouse --editable ceph-detect-init
-    )
-fi
-OSD_DATA=$DIR/osd
-MON_ID=a
-MONA=127.0.0.1:7451
-TEST_POOL=rbd
-FSID=$(uuidgen)
-export CEPH_CONF=$DIR/ceph.conf
-export CEPH_ARGS="--fsid $FSID"
-CEPH_ARGS+=" --chdir="
-CEPH_ARGS+=" --journal-dio=false"
-CEPH_ARGS+=" --run-dir=$DIR"
-CEPH_ARGS+=" --osd-failsafe-full-ratio=.99"
-CEPH_ARGS+=" --mon-host=$MONA"
-CEPH_ARGS+=" --log-file=$DIR/\$name.log"
-CEPH_ARGS+=" --pid-file=$DIR/\$name.pidfile"
-if test -d .libs ; then
-    CEPH_ARGS+=" --erasure-code-dir=.libs"
-    CEPH_ARGS+=" --compression-dir=.libs"
-fi
-CEPH_ARGS+=" --auth-supported=none"
-CEPH_ARGS+=" --osd-journal-size=100"
-CEPH_DISK_ARGS=
-CEPH_DISK_ARGS+=" --statedir=$DIR"
-CEPH_DISK_ARGS+=" --sysconfdir=$DIR"
-CEPH_DISK_ARGS+=" --prepend-to-path="
-CEPH_DISK_ARGS+=" --verbose"
-TIMEOUT=360
-
-cat=$(which cat)
-timeout=$(which timeout)
-diff=$(which diff)
-mkdir=$(which mkdir)
-rm=$(which rm)
-uuidgen=$(which uuidgen)
-
-function setup() {
-    teardown
-    mkdir $DIR
-    mkdir $OSD_DATA
-    touch $DIR/ceph.conf # so ceph-disk think ceph is the cluster
-}
-
-function teardown() {
-    kill_daemons
-    if [ $(stat -f -c '%T' .) == "btrfs" ]; then
-        rm -fr $DIR/*/*db
-        teardown_btrfs $DIR
-    fi
-    grep " $(pwd)/$DIR/" < /proc/mounts | while read mounted rest ; do
-        umount $mounted
-    done
-    rm -fr $DIR
-}
-
-function run_mon() {
-    local mon_dir=$DIR/$MON_ID
-
-    ceph-mon \
-        --id $MON_ID \
-        --mkfs \
-        --mon-data=$mon_dir \
-        --mon-initial-members=$MON_ID \
-        "$@"
-
-    ceph-mon \
-        --id $MON_ID \
-        --mon-data=$mon_dir \
-        --mon-osd-full-ratio=.99 \
-        --mon-data-avail-crit=1 \
-        --mon-cluster-log-file=$mon_dir/log \
-        --public-addr $MONA \
-        "$@"
-}
-
-function kill_daemons() {
-    if ! test -e $DIR ; then
-        return
-    fi
-    for pidfile in $(find $DIR | grep pidfile) ; do
-        pid=$(cat $pidfile)
-        for try in 0 1 1 1 2 3 ; do
-            kill $pid 2>/dev/null || break
-            sleep $try
-        done
-    done
-}
-
-function command_fixture() {
-    local command=$1
-
-    [ $(which $command) = ./$command ] || [ $(which $command) = `readlink -f $(pwd)/$command` ] || return 1
-
-    cat > $DIR/$command <<EOF
-#!/bin/bash
-touch $DIR/used-$command
-exec ./$command "\$@"
-EOF
-    chmod +x $DIR/$command
-}
-
-function tweak_path() {
-    local tweaker=$1
-
-    setup
-
-    command_fixture ceph-conf || return 1
-    command_fixture ceph-osd || return 1
-
-    test_activate_dir
-
-    [ ! -f $DIR/used-ceph-conf ] || return 1
-    [ ! -f $DIR/used-ceph-osd ] || return 1
-
-    teardown
-
-    setup
-
-    command_fixture ceph-conf || return 1
-    command_fixture ceph-osd || return 1
-
-    $tweaker test_activate_dir || return 1
-
-    [ -f $DIR/used-ceph-osd ] || return 1
-
-    teardown
-}
-
-function use_prepend_to_path() {
-    local ceph_disk_args
-    ceph_disk_args+=" --statedir=$DIR"
-    ceph_disk_args+=" --sysconfdir=$DIR"
-    ceph_disk_args+=" --prepend-to-path=$DIR"
-    ceph_disk_args+=" --verbose"
-    CEPH_DISK_ARGS="$ceph_disk_args" \
-        "$@" || return 1
-}
-
-function test_prepend_to_path() {
-    tweak_path use_prepend_to_path || return 1
-}
-
-function use_path() {
-    PATH="$DIR:$PATH" \
-        "$@" || return 1
-}
-
-function test_path() {
-    tweak_path use_path || return 1
-}
-
-function test_no_path() {
-    ( unset PATH ; test_activate_dir ) || return 1
-}
-
-function test_mark_init() {
-    run_mon
-
-    local osd_data=$(pwd)/$DIR/dir
-    $mkdir -p $osd_data
-
-    local osd_uuid=$($uuidgen)
-
-    $mkdir -p $OSD_DATA
-
-    ceph-disk $CEPH_DISK_ARGS \
-        prepare --osd-uuid $osd_uuid $osd_data || return 1
-
-    $timeout $TIMEOUT ceph-disk $CEPH_DISK_ARGS \
-        --verbose \
-        activate \
-        --mark-init=auto \
-        --no-start-daemon \
-        $osd_data || return 1
-
-    test -f $osd_data/$(ceph-detect-init) || return 1
-
-    if test systemd = $(ceph-detect-init) ; then
-        expected=sysvinit
-    else
-        expected=systemd
-    fi
-    $timeout $TIMEOUT ceph-disk $CEPH_DISK_ARGS \
-        --verbose \
-        activate \
-        --mark-init=$expected \
-        --no-start-daemon \
-        $osd_data || return 1
-
-    ! test -f $osd_data/$(ceph-detect-init) || return 1
-    test -f $osd_data/$expected || return 1
-
-    $rm -fr $osd_data
-}
-
-function test_zap() {
-    local osd_data=$DIR/dir
-    $mkdir -p $osd_data
-
-    ceph-disk $CEPH_DISK_ARGS zap $osd_data 2>&1 | grep -q 'not full block device' || return 1
-
-    $rm -fr $osd_data
-}
-
-# ceph-disk prepare returns immediately on success if the magic file
-# exists in the --osd-data directory.
-function test_activate_dir_magic() {
-    local uuid=$($uuidgen)
-    local osd_data=$DIR/osd
-
-    echo a failure to create the fsid file implies the magic file is not created
-
-    mkdir -p $osd_data/fsid
-    CEPH_ARGS="--fsid $uuid" \
-     ceph-disk $CEPH_DISK_ARGS prepare $osd_data > $DIR/out 2>&1
-    grep --quiet 'Is a directory' $DIR/out || return 1
-    ! [ -f $osd_data/magic ] || return 1
-    rmdir $osd_data/fsid
-
-    echo successfully prepare the OSD
-
-    CEPH_ARGS="--fsid $uuid" \
-     ceph-disk $CEPH_DISK_ARGS prepare $osd_data 2>&1 | tee $DIR/out
-    grep --quiet 'Preparing osd data dir' $DIR/out || return 1
-    grep --quiet $uuid $osd_data/ceph_fsid || return 1
-    [ -f $osd_data/magic ] || return 1
-
-    echo will not override an existing OSD
-
-    CEPH_ARGS="--fsid $($uuidgen)" \
-     ceph-disk $CEPH_DISK_ARGS prepare $osd_data 2>&1 | tee $DIR/out
-    grep --quiet 'ceph-disk:Data dir .* already exists' $DIR/out || return 1
-    grep --quiet $uuid $osd_data/ceph_fsid || return 1
-}
-
-function test_pool_read_write() {
-    local osd_uuid=$1
-
-    $timeout $TIMEOUT ceph osd pool set $TEST_POOL size 1 || return 1
-
-    local id=$(ceph osd create $osd_uuid)
-    local weight=1
-    ceph osd crush add osd.$id $weight root=default host=localhost || return 1
-    echo FOO > $DIR/BAR
-    $timeout $TIMEOUT rados --pool $TEST_POOL put BAR $DIR/BAR || return 1
-    $timeout $TIMEOUT rados --pool $TEST_POOL get BAR $DIR/BAR.copy || return 1
-    $diff $DIR/BAR $DIR/BAR.copy || return 1
-}
-
-function test_activate() {
-    local to_prepare=$1
-    local to_activate=$2
-    local journal=$3
-    local osd_uuid=$($uuidgen)
-
-    $mkdir -p $OSD_DATA
-
-    ceph-disk $CEPH_DISK_ARGS \
-        prepare --osd-uuid $osd_uuid $to_prepare $journal || return 1
-
-    $timeout $TIMEOUT ceph-disk $CEPH_DISK_ARGS \
-        activate \
-        --mark-init=none \
-        $to_activate || return 1
-
-    test_pool_read_write $osd_uuid || return 1
-}
-
-function test_activate_dir() {
-    run_mon
-
-    local osd_data=$DIR/dir
-    $mkdir -p $osd_data
-    test_activate $osd_data $osd_data || return 1
-    $rm -fr $osd_data
-}
-
-function test_find_cluster_by_uuid() {
-    setup
-    test_activate_dir 2>&1 | tee $DIR/test_find
-    ! grep "No cluster conf found in $DIR" $DIR/test_find || return 1
-    teardown
-
-    setup
-    rm $DIR/ceph.conf
-    test_activate_dir > $DIR/test_find 2>&1 
-    grep --quiet "No cluster conf found in $DIR" $DIR/test_find || return 1
-    teardown
-}
-
-# http://tracker.ceph.com/issues/9653
-function test_keyring_path() {
-    test_activate_dir 2>&1 | tee $DIR/test_keyring
-    grep --quiet "keyring $DIR/bootstrap-osd/ceph.keyring" $DIR/test_keyring || return 1
-}
-
-function run() {
-    local default_actions
-    default_actions+="test_path "
-    default_actions+="test_no_path "
-    default_actions+="test_find_cluster_by_uuid "
-    default_actions+="test_prepend_to_path "
-    default_actions+="test_activate_dir_magic "
-    default_actions+="test_activate_dir "
-    default_actions+="test_keyring_path "
-    default_actions+="test_mark_init "
-    default_actions+="test_zap "
-    local actions=${@:-$default_actions}
-    local status
-    for action in $actions  ; do
-        setup
-        set -x
-        $action
-        status=$?
-        set +x
-        teardown
-        if test $status != 0 ; then
-            break
-        fi
-    done
-    rm -fr virtualenv-$DIR
-    return $status
-}
-
-run $@
-
-# Local Variables:
-# compile-command: "cd .. ; test/ceph-disk.sh # test_activate_dir"
-# End:
diff --git a/src/test/test_btrfs_common.sh b/src/test/test_btrfs_common.sh
deleted file mode 100644 (file)
index c406104..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash 
-#
-# Author: Federico Gimenez <fgimenez@coit.es>
-#
-# 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.
-#
-
-#
-# Removes btrfs subvolumes under the given directory param
-#
-function teardown_btrfs() {
-    local btrfs_base_dir=$1
-
-    btrfs_dirs=`ls -l $btrfs_base_dir | egrep '^d' | awk '{print $9}'`
-    for btrfs_dir in $btrfs_dirs
-    do
-        btrfs_subdirs=`ls -l $btrfs_base_dir/$btrfs_dir | egrep '^d' | awk '{print $9}'` 
-        for btrfs_subdir in $btrfs_subdirs
-        do
-           btrfs subvolume delete $btrfs_base_dir/$btrfs_dir/$btrfs_subdir
-        done
-    done
-}