From 53604724c3e5dd2032303e22511f7be230d4feae Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Thu, 29 Jun 2017 17:03:44 +0800 Subject: [PATCH] LU-9140 nrs: measure the runtime of dd directly This patch changes the way to measure the runtime of "dd". Instead of parsing the output of "dd", we use date command to calculate the runtime of dd directly, avoiding the parsing failure caused by changed output format of "dd". Lustre-change: https://review.whamcloud.com/27878 Lustre-commit: 66abf6ffe9f032aaa7c271ee2bd1f9b569058bd5 Change-Id: Ibd2e3963f791404ee927981238227012cf4dbf2c Test-Parameters: trivial testlist=sanityn Signed-off-by: Qian Yingjin Reviewed-by: James Nunez Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/29686 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: John L. Hammond --- lustre/tests/sanityn.sh | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh index f72dccd..4f8f420 100755 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -3147,33 +3147,41 @@ tbf_verify() { local client1=${CLIENT1:-$(hostname)} local myRUNAS="$3" + local np=$(check_cpt_number ost1) + [ $np -gt 0 ] || error "CPU partitions should not be $np." + echo "cpu_npartitions on ost1 is $np" + mkdir $dir || error "mkdir $dir failed" - $LFS setstripe -c 1 $dir || error "setstripe to $dir failed" + $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed" chmod 777 $dir trap cleanup_tbf_verify EXIT echo "Limited write rate: $1, read rate: $2" echo "Verify the write rate is under TBF control" - local runtime=$(do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \ - bs=1M count=100 oflag=direct 2>&1 | awk '/bytes/ {print $6}') + local start=$SECONDS + do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \ + bs=1M count=100 oflag=direct 2>&1 + local runtime=$((SECONDS - start + 1)) local rate=$(bc <<< "scale=6; 100 / $runtime") echo "Write runtime is $runtime s, speed is $rate IOPS" - # verify the write rate does not exceed 110% of TBF limited rate - [ $(bc <<< "$rate < 1.1 * $1") -eq 1 ] || - error "The write rate ($rate) exceeds 110% of preset rate ($1)" + # verify the write rate does not exceed TBF rate limit + [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] || + error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)" cancel_lru_locks osc echo "Verify the read rate is under TBF control" - runtime=$(do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \ - bs=1M count=100 iflag=direct 2>&1 | awk '/bytes/ {print $6}') + start=$SECONDS + do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \ + bs=1M count=100 iflag=direct 2>&1 + runtime=$((SECONDS - start + 1)) rate=$(bc <<< "scale=6; 100 / $runtime") echo "Read runtime is $runtime s, speed is $rate IOPS" - # verify the read rate does not exceed 110% of TBF limited rate - [ $(bc <<< "$rate < 1.1 * $2") -eq 1 ] || - error "The read rate ($rate) exceeds 110% of preset rate ($2)" + # verify the read rate does not exceed TBF rate limit + [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] || + error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)" cancel_lru_locks osc cleanup_tbf_verify || error "rm -rf $dir failed" -- 1.8.3.1