Whamcloud - gitweb
LU-8788 tests: modify create_pool to use as wrapper
[fs/lustre-release.git] / lustre / tests / ost-pools.sh
index 4207f77..b3c205d 100755 (executable)
@@ -194,17 +194,16 @@ add_pool() {
 }
 
 create_pool_nofail() {
-    create_pool $FSNAME.$1
-    if [[ $? != 0 ]]; then
-        error "Pool creation of $1 failed"
-    fi
+       create_pool $FSNAME.$1
+       [[ $? -ne 0 ]] && error "Pool creation of $1 failed"
+       return 0
 }
 
 create_pool_fail() {
-    create_pool $FSNAME.$1
-    if [[ $? == 0 ]]; then
-        error "Pool creation of $1 succeeded; should have failed"
-    fi
+       create_pool $FSNAME.$1
+       [[ $? -ne 0 ]] ||
+               error "Pool creation of $1 succeeded; should have failed"
+       return 0
 }
 
 cleanup_tests() {
@@ -267,7 +266,7 @@ run_test 1e "Create a pool with a 1000 char pool name; should fail"
 
 test_1f() {
        set_cleanup_trap
-       do_facet mgs lctl pool_new .$POOL 2>/dev/null
+       create_pool .$POOL
        [[ $? -ne 0 ]] ||
                error "pool_new did not fail even though fs-name was missing"
 }
@@ -275,7 +274,7 @@ run_test 1f "pool_new should fail if fs-name is missing"
 
 test_1g() {
        set_cleanup_trap
-       do_facet mgs lctl pool_new $POOL 2>/dev/null
+       create_pool $POOL
        [[ $? -ne 0 ]] ||
                error "pool_new did not fail even though fs-name was missing"
 }
@@ -283,7 +282,7 @@ run_test 1g "pool_new should fail if fs-name is missing"
 
 test_1h() {
        set_cleanup_trap
-       do_facet mgs lctl pool_new ${FSNAME}. 2>/dev/null
+       create_pool ${FSNAME}.
        [[ $? -ne 0 ]] ||
                error "pool_new did not fail even though pool name was missing"
 }
@@ -291,32 +290,32 @@ run_test 1h "pool_new should fail if poolname is missing"
 
 test_1i() {
        set_cleanup_trap
-       do_facet mgs lctl pool_new . 2>/dev/null
+       create_pool .
        [[ $? -ne 0 ]] ||
-               error "pool_new did not fail even if pool and fs-name were missing"
+               error "pool_new did not fail even if pool/fs-name was missing"
 }
 run_test 1i "pool_new should fail if poolname and fs-name are missing"
 
 test_1j() {
        set_cleanup_trap
-       do_facet mgs lctl pool_new ${FSNAME},$POOL 2>/dev/null
+       create_pool ${FSNAME},$POOL
        [[ $? -ne 0 ]] ||
-               error "pool_new did not fail even though pool name format was wrong"
+               error "pool_new did not fail even if poolname format was wrong"
 }
 run_test 1j "pool_new should fail if poolname format is wrong"
 
 test_1k() {
        set_cleanup_trap
-       do_facet mgs lctl pool_new ${FSNAME}/$POOL 2>/dev/null
+       create_pool ${FSNAME}/$POOL
        [[ $? -ne 0 ]] ||
-               error "pool_new did not fail even though pool name format was wrong"
+               error "pool_new did not fail even if poolname format was wrong"
 }
 run_test 1k "pool_new should fail if poolname format is wrong"
 
 test_1m() {
        set_cleanup_trap
        create_pool_nofail $POOL2
-       do_facet mgs lctl pool_new ${FSNAME}.$POOL2 2>/dev/null
+       create_pool ${FSNAME}.$POOL2
        [[ $? -ne 0 ]] ||
                error "pool_new did not fail even though $POOL2 existed"
        destroy_pool $POOL2
@@ -704,19 +703,19 @@ run_test 7a "create various pool name"
 test_7b()
 {
        # No fsname
-       do_facet mgs lctl pool_new qwerty
+       create_pool qwerty
        [ $? -ne 22 ] && error "can create a pool with no fsname"
 
        # No pool name
-       do_facet mgs lctl pool_new $FSNAME.
+       create_pool $FSNAME.
        [ $? -ne 22 ] && error "can create a pool with no name"
 
        # Invalid character
-       do_facet mgs lctl pool_new $FSNAME.0123456789^bdef
+       create_pool $FSNAME.0123456789^bdef
        [ $? -ne 22 ] && error "can create a pool with an invalid name"
 
        # Too long
-       do_facet mgs lctl pool_new $FSNAME.0123456789abdefg
+       create_pool $FSNAME.0123456789abdefg
        [ $? -ne 36 ] && error "can create a pool with a name too long"
 
        return 0