]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: move rados put/get tests in a function
authorLoic Dachary <ldachary@redhat.com>
Wed, 1 Apr 2015 14:31:05 +0000 (16:31 +0200)
committerLoic Dachary <ldachary@redhat.com>
Sun, 5 Apr 2015 23:58:19 +0000 (01:58 +0200)
Add the test_pool_read_write function to share the rados put / get test
that demonstrate the osd that has been created can actually be used. Use
it from the both the regular device and dmcrypt tests.

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/test/ceph-disk.sh

index c9f7169639a11bad024627d8f05daead3cb5b0e2..25c00e3e468f7105cc89e88f99f6ac7c9ded3edd 100755 (executable)
@@ -203,6 +203,20 @@ function test_activate_dir_magic() {
     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
@@ -218,15 +232,8 @@ function test_activate() {
         activate \
         --mark-init=none \
         $to_activate || return 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
+    test_pool_read_write $osd_uuid || return 1
 }
 
 function test_activate_dmcrypt() {
@@ -259,15 +266,8 @@ function test_activate_dmcrypt() {
         activate \
         --mark-init=none \
         /dev/mapper/$uuid || return 1
-    $timeout $TIMEOUT ./ceph osd pool set $TEST_POOL size 1 || return 1
 
-    local id=$($cat $OSD_DATA/ceph-?/whoami || $cat $to_activate/whoami)
-    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
+    test_pool_read_write $osd_uuid || return 1
 }
 
 function test_activate_dir() {