+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 mgs 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
+
+ do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
+ [[ $? -ne 0 ]] ||
+ error "pool_add did not fail even though $POOL did not exist"
+}
+run_test 2a "pool_add: non-existant pool $POOL"
+
+test_2b() {
+ set_cleanup_trap
+ do_facet mgs lctl pool_add $FSNAME.${POOL}1234567890 \
+ $FSNAME-OST0000 2>/dev/null
+ [[ $? -ne 0 ]] ||
+ error "pool_add did not fail even though pool name was invalid."
+}
+run_test 2b "pool_add: Invalid pool name"
+
+# Testing various combinations of OST name list
+test_2c() {
+ set_cleanup_trap
+ local TGT
+ local RC
+
+ lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
+ [[ $? -ne 0 ]] || destroy_pool $POOL
+
+ create_pool_nofail $POOL
+
+ # 1. OST0000
+ do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
+ RC=$?; [[ $RC -eq 0 ]] ||
+ error "pool_add failed. $FSNAME $POOL OST0000: $RC"
+ do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
+ drain_pool $POOL
+
+ # 2. $FSNAME-OST0000
+ do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
+ RC=$?; [[ $RC -eq 0 ]] ||
+ error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
+ do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
+ drain_pool $POOL
+
+ # 3. $FSNAME-OST0000_UUID
+ do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
+ RC=$?; [[ $RC -eq 0 ]] ||
+ error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
+ do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
+ drain_pool $POOL
+
+ # 4. $FSNAME-OST[0,1,2,3,]
+ TGT="$FSNAME-OST["
+ for i in $TGT_LIST; do TGT=${TGT}$(printf "%04x," $i); done
+ TGT="${TGT}]"
+ do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
+ [[ $? -eq 0 ]] || error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
+ do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT
+ drain_pool $POOL
+
+ # 5. $FSNAME-OST[0-5/1]
+ do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
+ RC=$?; [[ $RC -eq 0 ]] ||
+ error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
+ wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
+ sort -u | tr '\n' ' ' " "$TGT_UUID" ||
+ error "Add to pool failed"
+ do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
+ drain_pool $POOL
+
+ destroy_pool $POOL
+}
+run_test 2c "pool_add: OST index combinations"