Whamcloud - gitweb
LU-17179 tests: check the system is clean 30/52630/5
authorSergey Cheremencev <scherementsev@ddn.com>
Mon, 9 Oct 2023 02:45:16 +0000 (06:45 +0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 13 Mar 2024 03:23:26 +0000 (03:23 +0000)
Main part of tests cannot work correctly if the system
is not clean. So check this in the beginning of sanity-quota.

Test-Parameters: trivial
Signed-off-by: Sergey Cheremencev <scherementsev@ddn.com>
Change-Id: Ibfbe4663dee8476486e96eb99ccbcea13216861b
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52630
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-quota.sh

index 88e472a..4bd8d45 100755 (executable)
@@ -552,6 +552,38 @@ wait_quota_synced() {
        done
 }
 
+# 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)) \
@@ -564,6 +596,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"