Whamcloud - gitweb
LU-7114 ldiskfs: corrupted bitmaps handling patches
[fs/lustre-release.git] / lustre / tests / ost-pools.sh
index ad56980..eb2ec58 100644 (file)
@@ -237,20 +237,20 @@ test_1b() {
     create_pool_nofail ${POOL}12
     destroy_pool ${POOL}12
 }
-run_test 1b "Create a pool with a 10 character pool name"
+run_test 1b "Create a pool with a 10 char pool name"
 
 test_1c() {
     set_cleanup_trap
-    create_pool_nofail ${POOL}12345678
-    destroy_pool ${POOL}12345678
+    create_pool_nofail ${POOL}1234567
+    destroy_pool ${POOL}1234567
 }
-run_test 1c "Create a pool with a 16 character pool name"
+run_test 1c "Create a pool with a 15 char pool name"
 
 test_1d() {
     set_cleanup_trap
-    create_pool_fail ${POOL}123456789
+    create_pool_fail ${POOL}12345678
 }
-run_test 1d "Create a pool with a 17 char pool name; should fail"
+run_test 1d "Create a pool with a 16 char pool name; should fail"
 
 test_1e() {
     set_cleanup_trap
@@ -318,6 +318,23 @@ test_1m() {
 }
 run_test 1m "pool_new did not fail even though $POOL2 existed"
 
+test_1n() {
+    set_cleanup_trap
+    create_pool_nofail ${POOL}1234567
+
+    add_pool ${POOL}1234567 "OST0000" "$FSNAME-OST0000_UUID "
+    local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
+    create_dir $POOL_ROOT ${POOL}1234567
+    dd if=/dev/zero of=$POOL_ROOT/file bs=1M count=100
+    RC=$?; [[ $RC -eq 0 ]] ||
+        error "failed to write to $POOL_ROOT/file: $RC"
+    do_facet $SINGLEMDS lctl pool_remove $FSNAME.${POOL}1234567 OST0000
+    drain_pool ${POOL}1234567
+
+    destroy_pool ${POOL}1234567
+}
+run_test 1n "Pool with a 15 char pool name works well"
+
 test_2a() {
     set_cleanup_trap
     destroy_pool $POOL
@@ -632,6 +649,96 @@ test_6() {
 }
 run_test 6 "getstripe/setstripe"
 
+helper_test_7a()
+{
+       # Create a pool, stripe a directory and file with it
+       local pool=$1
+
+       pool_add $pool || error "pool_add failed"
+       pool_add_targets $pool 0 1 || error "pool_add_targets failed"
+
+       $SETSTRIPE -c 1 $DIR/$tdir/testfile1 --pool "$pool" || \
+               error "setstripe failed"
+       $SETSTRIPE -c 1 $DIR/$tdir/testfile2 --pool "$FSNAME.$pool" || \
+               error "setstripe failed"
+
+       mkdir $DIR/$tdir/testdir
+       $SETSTRIPE -c 1 $DIR/$tdir/testdir  -p "$pool" || \
+               error "setstripe failed"
+       $SETSTRIPE -c 1 $DIR/$tdir/testdir  -p "$FSNAME.$pool" || \
+               error "setstripe failed"
+
+       rm -f $DIR/$tdir/testfile1
+       rm -f $DIR/$tdir/testfile2
+       rmdir $DIR/$tdir/testdir
+
+       destroy_pool_int $FSNAME.$pool
+}
+
+test_7a()
+{
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+
+       mkdir -p $DIR/$tdir
+
+       # Generate pool with random name from 1 to 15 characters
+       for i in 1 9 15 ; do
+               POOLNAME=$(echo $$$RANDOM$RANDOM |
+                          tr -dc 'a-zA-Z0-9' | fold -w $i |
+                          head -n 1)
+               echo set poolname to $POOLNAME
+               helper_test_7a $POOLNAME
+       done
+}
+run_test 7a "create various pool name"
+
+test_7b()
+{
+       # No fsname
+       do_facet mgs lctl pool_new qwerty
+       [ $? -ne 22 ] && error "can create a pool with no fsname"
+
+       # No pool name
+       do_facet mgs lctl pool_new $FSNAME.
+       [ $? -ne 22 ] && error "can create a pool with no name"
+
+       # Invalid character
+       do_facet mgs lctl pool_new $FSNAME.0123456789^bdef
+       [ $? -ne 22 ] && error "can create a pool with an invalid name"
+
+       # Too long
+       do_facet mgs lctl pool_new $FSNAME.0123456789abdefg
+       [ $? -ne 36 ] && error "can create a pool with a name too long"
+
+       return 0
+}
+run_test 7b "try to create pool name with invalid lengths or names"
+
+test_7c()
+{
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+
+       mkdir -p $DIR/$tdir
+
+       # Create a pool with 15 letters
+       local pool=0123456789abcde
+       pool_add $pool || error "pool_add failed"
+       pool_add_targets $pool 0 1 || error "pool_add_targets failed"
+
+       # setstripe with the same pool name plus 1 letter
+       $SETSTRIPE -c 1 $DIR/$tdir/testfile1 --pool "${pool}X" && \
+               error "setstripe succedeed"
+
+       # setstripe with the same pool name minus 1 letter
+       $SETSTRIPE -c 1 $DIR/$tdir/testfile1 --pool "${pool%?}" && \
+               error "setstripe succedeed"
+
+       rm -f $DIR/$tdir/testfile1
+
+       destroy_pool_int $FSNAME.$pool
+}
+run_test 7c "create a valid pool name and setstripe with a bad one"
+
 test_11() {
     set_cleanup_trap
     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}