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>
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
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"
+ 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
# 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
$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"
$SHOW_QUOTA_USER
$SHOW_QUOTA_GROUP
$SHOW_QUOTA_USER
$SHOW_QUOTA_GROUP
$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"
# cleanup
cleanup_quota_test
# cleanup
cleanup_quota_test