Whamcloud - gitweb
LU-2902 test: ost stat parameters were not present 64/6564/10
authorKeith Mannthey <keith.mannthey@intel.com>
Fri, 12 Jul 2013 05:33:04 +0000 (22:33 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 7 Aug 2013 17:19:55 +0000 (17:19 +0000)
A few tests use roc_hit to sort out cache hits. These tests
were failing for a while because the lproc stats needed were not
present.

Use roc_hit_init with setstripe to correctly identify that basic
cache_access stats are working for each individual ost before
using roc_hit.

Signed-off-by: Keith Mannthey <keith.mannthey@intel.com>
Change-Id: Iea501433ddcdb367fe5d9614361b4aff049cb1f1
Reviewed-on: http://review.whamcloud.com/6564
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/sanity.sh

index 5b5b0dd..26b3d95 100644 (file)
@@ -8617,12 +8617,48 @@ test_150() {
 }
 run_test 150 "truncate/append tests"
 
 }
 run_test 150 "truncate/append tests"
 
+#LU-2902 roc_hit was not able to read all values from lproc
+function roc_hit_init() {
+       local list=$(comma_list $(osts_nodes))
+       local dir=$DIR/$tdir-check
+       local file=$dir/file
+       local BEFORE
+       local AFTER
+       local idx
+
+       test_mkdir -p $dir
+       #use setstripe to do a write to every ost
+       for i in $(seq 0 $((OSTCOUNT-1))); do
+               $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
+               dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
+               idx=$(printf %04x $i)
+               BEFORE=$(get_osd_param $list *OST*$idx stats |
+                   awk '$1 == "cache_access" {sum += $2} END { print sum }')
+               if [ -z "$BEFORE" ]; then
+                       BEFORE=0
+               fi
+
+               cancel_lru_locks osc
+               cat $file >/dev/null
+
+               AFTER=$(get_osd_param $list *OST*$idx stats |
+                   awk '$1 == "cache_access" {sum += $2} END { print sum }')
+
+               echo BEFORE:$BEFORE AFTER:$AFTER
+               if ! let "AFTER - BEFORE == 4"; then
+                       rm -rf $dir
+                       error "roc_hit is not safe to use"
+               fi
+               rm $file
+       done
+
+       rm -rf $dir
+}
+
 function roc_hit() {
        local list=$(comma_list $(osts_nodes))
 function roc_hit() {
        local list=$(comma_list $(osts_nodes))
-       #debug temp debug for LU-2902: lets see what values we get back
-       echo $(get_osd_param $list '' stats) 1>&2
        echo $(get_osd_param $list '' stats |
        echo $(get_osd_param $list '' stats |
-              awk '/'cache_hit'/ {sum+=$2} END {print sum}')
+               awk '$1 == "cache_hit" {sum += $2} END { print sum }')
 }
 
 function set_cache() {
 }
 
 function set_cache() {
@@ -8664,6 +8700,8 @@ test_151() {
                return 0
        fi
 
                return 0
        fi
 
+       roc_hit_init
+
        #define OBD_FAIL_OBD_NO_LRU  0x609
        do_nodes $list $LCTL set_param fail_loc=0x609
 
        #define OBD_FAIL_OBD_NO_LRU  0x609
        do_nodes $list $LCTL set_param fail_loc=0x609
 
@@ -9079,6 +9117,8 @@ test_156() {
                skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
                return
 
                skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
                return
 
+       roc_hit_init
+
     log "Turn on read and write cache"
     set_cache read on
     set_cache writethrough on
     log "Turn on read and write cache"
     set_cache read on
     set_cache writethrough on