Whamcloud - gitweb
LU-17265 tests: allow margin for sanity/39r 35/53035/5
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Wed, 8 Nov 2023 06:38:07 +0000 (12:08 +0530)
committerOleg Drokin <green@whamcloud.com>
Wed, 29 Nov 2023 21:29:38 +0000 (21:29 +0000)
The timestamp may be little outdated due to a gap between
writing a file and checking the timestamp, so take that into
consideration and allow 2 second leniency when comparing
timestamps.

The on-disk inode may also not be flushed from the journal
immediately, so allow some time for it to be updated.

This patch also converts the hex value read via debugfs
to decimal.

Test-Parameters: trivial testlist=sanity env=ONLY=39r,ONLY_REPEAT=100
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: I9e765f9cd572fb25821f9a0401c34209b7c3f574
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53035
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: xinliang <xinliang.liu@linaro.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/tests/sanity.sh

index 60460e3..1aa2d54 100755 (executable)
@@ -5263,6 +5263,7 @@ test_39r() {
        fi
 
        local saved_adiff
+       local ahost=$(facet_active_host ost1)
        saved_adiff=$(do_facet ost1 \
                lctl get_param -n obdfilter.*OST0000.atime_diff)
        stack_trap "do_facet ost1 \
@@ -5280,11 +5281,9 @@ test_39r() {
        dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
                error "can't udpate atime"
 
+       # atime_cli value is in decimal
        local atime_cli=$(stat -c %X $DIR/$tfile)
        echo "client atime: $atime_cli"
-       # allow atime update to be written to device
-       do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
-       sleep 5
 
        local ostdev=$(ostdevname 1)
        local fid=($($LFS getstripe $DIR/$tfile | grep 0x))
@@ -5300,11 +5299,30 @@ test_39r() {
        local objpath="O/$seq/d$(($oid % 32))/$oid_hex"
        local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
 
+       # allow atime update to be written to device
+       do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync=1"
        echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
+
+       # Give enough time for server to get updated. Until then
+       # the value read is defaulted to "0x00000000:00000000"
+       # Wait until atime read via debugfs is not equal to zero.
+       # Max limit to wait is 30 seconds.
+       wait_update_cond $ahost                                         \
+               "$cmd |& awk -F'[: ]' '/atime:/ { print \\\$4 }'"       \
+               "-gt" "0" 30 || error "atime on ost is still 0 after 30 seconds"
+       # atime_ost value is in hex
        local atime_ost=$(do_facet ost1 "$cmd" |&
                          awk -F'[: ]' '/atime:/ { print $4 }')
-       (( atime_cli == atime_ost )) ||
-               error "atime on client $atime_cli != ost $atime_ost"
+       # debugfs returns atime in 0xNNNNNNNN:00000000 format
+       # convert Hex to decimal before comparing
+       local atime_ost_dec=$((atime_ost))
+
+       # The test pass criteria is that the client time and server should
+       # be same (2s gap accepted). This gap could arise due to VFS updating
+       # the atime after the read(dd), stat and the updated time from the
+       # inode
+       (( $((atime_cli - atime_ost_dec)) <= 2 )) ||
+               error "atime on client $atime_cli != ost $atime_ost_dec"
 }
 run_test 39r "lazy atime update on OST"