Whamcloud - gitweb
LU-590 tests: obdfilter-survey.sh fails test 2a.
[fs/lustre-release.git] / lustre / tests / obdfilter-survey.sh
index 8bfaeae..42a6c0f 100644 (file)
@@ -7,26 +7,25 @@ LUSTRE=${LUSTRE:-`dirname $0`/..}
 init_test_env $@
 
 nobjhi=${nobjhi:-1}
-thrhi=${thrhi:-16} 
+thrhi=${thrhi:-16}
 size=${size:-1024}
 
-# the summary file a bit smaller than OSTSIZE  
+# the summary file a bit smaller than OSTSIZE
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+init_logging
 
 [ "$SLOW" = no ] && { nobjhi=1; thrhi=4; }
+thrlo=${thrlo:-$(( thrhi / 2))}
 
 # Skip these tests
-ALWAYS_EXCEPT="$OBDFILTER_SURVEY_EXCEPT"
+# bug number   23791 23791
+ALWAYS_EXCEPT="1b    2b    $OBDFILTER_SURVEY_EXCEPT"
 
 OBDSURVEY=${OBDSURVEY:-$(which obdfilter-survey)}
 
 build_test_filter
 check_and_setup_lustre
 
-min_ost_size () {
-    $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1
-}
-
 # FIXME: the summary file a bit smaller than OSTSIZE, add estimation
 minsize=$(min_ost_size)
 if [ $(( size * 1024 )) -ge $minsize  ]; then
@@ -34,17 +33,24 @@ if [ $(( size * 1024 )) -ge $minsize  ]; then
     echo min kbytesavail: $minsize using size=${size} MBytes per obd instance
 fi
 
+get_devs() {
+        echo $(do_nodes $1 'lctl dl | grep obdfilter' | \
+             awk '{print $4}' | sort -u)
+}
+
 get_targets () {
         local targets
         local devs
+        local nid
         local oss
 
         for oss in $(osts_nodes); do
-                devs=$(do_node $oss "lctl dl |grep obdfilter |sort" | awk '{print $4}')
+                devs=$(get_devs $oss)
+                nid=$(host_nids_address $oss $NETTYPE)
                 for d in $devs; do
                         # if oss is local -- obdfilter-survey needs dev wo/ host
                         target=$d
-                        [[ $oss = `hostname` ]] || target=$oss:$target
+                        [[ $oss = `hostname` && "$1" == "netdisk" ]] || target=$nid:$target
                         targets="$targets $target"
                 done
         done
@@ -52,50 +58,140 @@ get_targets () {
        echo $targets
 }
 
-test_1 () {
+obdflter_survey_targets () {
+       local case=$1
+       local targets
+
+       case $case in
+               disk)    targets=$(get_targets $case);;
+               netdisk) targets=$(get_targets $case);;
+               network) targets=$(host_nids_address $(comma_list $(osts_nodes)) $NETTYPE);;
+               *) error "unknown obdflter-survey case!" ;;
+       esac
+       echo $targets
+}
+
+obdflter_survey_run () {
+       local case=$1
+
        rm -f ${TMP}/obdfilter_survey*
 
-       local targets=$(get_targets)
-       local cmd="nobjhi=$nobjhi thrhi=$thrhi size=$size case=disk rslt_loc=${TMP} targets=\"$targets\" sh $OBDSURVEY"
+       local targets=$(obdflter_survey_targets $case)
+       local cmd="NETTYPE=$NETTYPE thrlo=$thrlo nobjhi=$nobjhi thrhi=$thrhi size=$size case=$case rslt_loc=${TMP} targets=\"$targets\" $OBDSURVEY"
        echo + $cmd
        eval $cmd
 
        cat ${TMP}/obdfilter_survey*
 }
-run_test 1 "Object Storage Targets survey"
+test_1a () {
+       obdflter_survey_run disk
+}
+run_test 1a "Object Storage Targets survey"
 
-test_2 () {
-       rm -f ${TMP}/obdfilter_survey*
+print_jbd () {
+       local file=$1
+       local facet=$2
+       local varsvc=${facet}_svc
+       local dev=$(ldiskfs_canon "*.${!varsvc}.mntdev" $facet)
 
-       local targets=$(get_targets)
-       local cmd="nobjhi=$nobjhi thrhi=$thrhi size=$size rslt_loc=${TMP} case=netdisk targets=\"$targets\" sh $OBDSURVEY"
-       echo + $cmd
-       eval $cmd
+       # ext4: /proc/fs/jbd2/sda1:8/history 
+       # ext3: /proc/fs/jbd/sdb1/history
 
-       cat ${TMP}/obdfilter_survey*
+       do_facet $facet cat /proc/fs/jbd*/${dev}*/$file
 }
-run_test 2 "Stripe F/S over the Network"
+
+check_jbd_values () {
+       local facet=$1
+       local thrhi=$2
+
+       # last two lines from history
+       # $4: run >= 5000
+       # $8: hndls >= thrhi * 2
+       local hist=("$(print_jbd history $facet | tail -3 | head -2)")
+       echo "$hist"
+       local run=($(echo "${hist[*]}" | awk '{print $4}'))
+       local hndls=($(echo "${hist[*]}" | awk '{print $8}'))
+
+       local rc=0
+       for (( i=0; i<1; i++)); do
+               [[ ${run[i]} -lt 5000 ]] && \
+                       error "$facet: run expected 5000, have ${run[i]}" && rc=1
+               [[ ${hndls[i]} -lt $((thrhi * 2)) ]] && \
+                       error "$facet: hndls expected > $((thrhi * 2)), have ${hndls[i]}" && rc=2
+       done
+       return $rc
+}
+
+check_jbd_values_facets () {
+       local facets=$1
+       local thrhi=$2
+       local facet
+       local rc=0
+       for facet in  ${facets//,/ }; do
+               check_jbd_values $facet $thrhi || rc=$((rc+$?))
+       done
+       return $rc
+}
+
+test_1b () {
+       local param_file=$TMP/$tfile-params
+
+       do_nodesv $(comma_list $(osts_nodes)) lctl get_param obdfilter.${FSNAME}-*.sync_journal
+
+       save_lustre_params $(comma_list $(osts_nodes)) "obdfilter.${FSNAME}-*.sync_journal" >$param_file
+       do_nodesv $(comma_list $(osts_nodes)) lctl set_param obdfilter.${FSNAME}-*.sync_journal=0
+
+       thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run disk
+
+       check_jbd_values_facets $(get_facets OST) 4 || rc=$((rc+$?))
+
+       restore_lustre_params < $param_file
+
+       rm -f $param_file
+       return $rc
+}
+run_test 1b "Object Storage Targets survey, async journal"
+
+test_2a () {
+       obdflter_survey_run netdisk
+}
+run_test 2a "Stripe F/S over the Network"
+
+test_2b () {
+       local param_file=$TMP/$tfile-params
+
+       do_nodesv $(comma_list $(osts_nodes)) lctl get_param obdfilter.${FSNAME}-*.sync_journal
+
+       save_lustre_params $(comma_list $(osts_nodes)) "obdfilter.${FSNAME}-*.sync_journal" >$param_file
+       do_nodesv $(comma_list $(osts_nodes)) lctl set_param obdfilter.${FSNAME}-*.sync_journal=0
+
+       thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run netdisk
+
+       check_jbd_values_facets $(get_facets OST) 4 || rc=$((rc+$?))
+
+       restore_lustre_params < $param_file
+
+       rm -f $param_file
+       return $rc
+}
+run_test 2b "Stripe F/S over the Network, async journal"
+
 
 # README.obdfilter-survey: In network test only automated run is supported.
-test_3 () {
+test_3a () {
        remote_servers || { skip "Local servers" && return 0; }
 
-
-       rm -f ${TMP}/obdfilter_survey*
        # The Network survey test needs:
        # Start lctl and check for the device list. The device list must be empty.
        cleanupall
-       
-       local cmd="nobjhi=2 thrhi=4 size=$size targets="$(osts_nodes)" case=network sh $OBDSURVEY"
-       echo + $cmd
-       eval $cmd
 
-       cat ${TMP}/obdfilter_survey*
+       obdflter_survey_run network
+
        setupall
 }
-run_test 3 "Network survey"
+run_test 3a "Network survey"
 
-equals_msg `basename $0`: test complete, cleaning up
+complete $(basename $0) $SECONDS
 cleanup_echo_devs
 check_and_cleanup_lustre
-[ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true
+exit_status