Whamcloud - gitweb
LU-17179 tests: check the system is clean
authorSergey Cheremencev <scherementsev@ddn.com>
Mon, 9 Oct 2023 02:45:16 +0000 (06:45 +0400)
committerOleg Drokin <green@linuxhacker.ru>
Thu, 22 May 2025 04:55:45 +0000 (00:55 -0400)
Main part of tests cannot work correctly if the system
is not clean. So check this in the beginning of sanity-quota.

Lustre-change: https://review.whamcloud.com/52630
Lustre-commit: 7e1fb1a296ec7ab21be7ec39e2b6a38fbca76b6c

Test-Parameters: trivial
Signed-off-by: Sergey Cheremencev <scherementsev@ddn.com>
Change-Id: Ibfbe4663dee8476486e96eb99ccbcea13216861b

lustre/tests/sanity-quota.sh

index 709739c..75cc31e 100755 (executable)
@@ -489,6 +489,38 @@ reset_quota_settings() {
        resetquota -p $TSTPRJID
 }
 
+# make sure the system is clean
+check_system_is_clean() {
+       local used
+
+       lfs quota -uv quota_usr /mnt/lustre
+       for cur in "curspace" "curinodes";
+       do
+               used=$(getquota -u $TSTUSR global $cur)
+               [ $used -ne 0 ] && quota_error u $TSTUSR \
+                       "Used ${cur:3}($used) for user $TSTUSR isn't 0."
+
+               used=$(getquota -u $TSTUSR2 global $cur)
+               [ $used -ne 0 ] && quota_error u $TSTUSR2 \
+                       "Used ${cur:3}($used) for user $TSTUSR2 isn't 0."
+
+               used=$(getquota -g $TSTUSR global $cur)
+               [ $used -ne 0 ] && quota_error g $TSTUSR \
+                       "Used ${cur:3}($used) for group $TSTUSR isn't 0."
+
+               used=$(getquota -g $TSTUSR2 global $cur)
+               [ $used -ne 0 ] && quota_error g $TSTUSR2 \
+                       "Used ${cur:3}($used) for group $TSTUSR2 isn't 0."
+
+               if is_project_quota_supported; then
+                       used=$(getquota -p $TSTPRJID global $cur)
+                       [ $used -ne 0 ] && quota_error p $TSTPRJID \
+                               "Used ${cur:3}($used) for project $TSTPRJID isn't 0"
+               fi
+       done
+       return 0
+}
+
 # enable quota debug
 quota_init() {
        do_nodes $(comma_list $(nodes_list)) \
@@ -501,6 +533,7 @@ check_runas_id_ret $TSTUSR $TSTUSR $RUNAS ||
        error "Please create user $TSTUSR($TSTID) and group $TSTUSR($TSTID)"
 check_runas_id_ret $TSTUSR2 $TSTUSR2 $RUNAS2 ||
        error "Please create user $TSTUSR2($TSTID2) and group $TSTUSR2($TSTID2)"
+check_system_is_clean
 
 test_quota_performance() {
        local TESTFILE="$DIR/$tdir/$tfile-0"