Whamcloud - gitweb
LU-4306 tests: improve test_4a of s-q 83/15483/2
authorNiu Yawei <yawei.niu@intel.com>
Fri, 3 Jul 2015 03:51:41 +0000 (23:51 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 10 Jul 2015 02:57:58 +0000 (02:57 +0000)
test_4a of s-q used "sync; sleep 1; sync" to sync all data, that
could stall for an unexpected long time, this patch changes it
to sync_all_data for better time-efficiency.

This patch also modified the script to report proper error when
the grace has already expired before trying create new file.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I4aa2f69933be37d5f98af8172ed6a20781fe6e38
Reviewed-on: http://review.whamcloud.com/15483
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/sanity-quota.sh

index d792a99..5217551 100644 (file)
@@ -678,7 +678,8 @@ run_test 3 "Block soft limit (start timer, timer goes off, stop timer)"
 test_file_soft() {
        local TESTFILE=$1
        local LIMIT=$2
 test_file_soft() {
        local TESTFILE=$1
        local LIMIT=$2
-       local TIMER=$(($3 * 3 / 2))
+       local grace=$3
+       local TIMER=$(($grace * 3 / 2))
 
        setup_quota_test
        trap cleanup_quota_test EXIT
 
        setup_quota_test
        trap cleanup_quota_test EXIT
@@ -686,13 +687,19 @@ test_file_soft() {
        echo "Create files to exceed soft limit"
        $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) ||
                quota_error a $TSTUSR "create failure, but expect success"
        echo "Create files to exceed soft limit"
        $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) ||
                quota_error a $TSTUSR "create failure, but expect success"
-       sync; sleep 1; sync
+       local trigger_time=$(date +%s)
+
+       sync_all_data || true
+
+       local cur_time=$(date +%s)
+       [ $(($cur_time - $trigger_time)) -ge $grace ] &&
+               error "Passed grace time $grace, $trigger_time, $cur_time"
 
        echo "Create file before timer goes off"
        $RUNAS touch ${TESTFILE}_before ||
                quota_error a $TSTUSR "failed create before timer expired," \
 
        echo "Create file before timer goes off"
        $RUNAS touch ${TESTFILE}_before ||
                quota_error a $TSTUSR "failed create before timer expired," \
-                       "but expect success"
-       sync; sleep 1; sync
+                       "but expect success. $trigger_time, $cur_time"
+       sync_all_data || true
 
        echo "Sleep $TIMER seconds ..."
        sleep $TIMER
 
        echo "Sleep $TIMER seconds ..."
        sleep $TIMER
@@ -707,11 +714,11 @@ test_file_soft() {
        # hasn't been decreased from the pending write, if we acquire quota
        # in this window, we'll acquire more than we needed.
        $RUNAS touch ${TESTFILE}_after_1 ${TESTFILE}_after_2 || true
        # hasn't been decreased from the pending write, if we acquire quota
        # in this window, we'll acquire more than we needed.
        $RUNAS touch ${TESTFILE}_after_1 ${TESTFILE}_after_2 || true
-       sync; sleep 1; sync
+       sync_all_data || true
        $RUNAS touch ${TESTFILE}_after_3 &&
                quota_error a $TSTUSR "create after timer expired," \
                        "but expect EDQUOT"
        $RUNAS touch ${TESTFILE}_after_3 &&
                quota_error a $TSTUSR "create after timer expired," \
                        "but expect EDQUOT"
-       sync; sleep 1; sync
+       sync_all_data || true
 
        $SHOW_QUOTA_USER
        $SHOW_QUOTA_GROUP
 
        $SHOW_QUOTA_USER
        $SHOW_QUOTA_GROUP
@@ -726,7 +733,7 @@ test_file_soft() {
        $RUNAS touch ${TESTFILE}_xxx ||
                quota_error a $TSTUSR "touch after timer stop failure," \
                        "but expect success"
        $RUNAS touch ${TESTFILE}_xxx ||
                quota_error a $TSTUSR "touch after timer stop failure," \
                        "but expect success"
-       sync; sleep 1; sync
+       sync_all_data || true
 
        # cleanup
        cleanup_quota_test
 
        # cleanup
        cleanup_quota_test