[sheepdog] [PATCH 1/2] tests: don't use /dev/urandom for better performance

MORITA Kazutaka morita.kazutaka at gmail.com
Sat May 4 11:11:33 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

/dev/urandom is too slow.  We don't need good random values to fill vdis.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 tests/008       |    3 ++-
 tests/009       |    2 +-
 tests/018       |    2 +-
 tests/019       |    2 +-
 tests/020       |    2 +-
 tests/030       |    6 +++---
 tests/035       |    2 +-
 tests/049       |    2 +-
 tests/055       |    6 +++---
 tests/056       |    2 +-
 tests/common.rc |    5 +++++
 11 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/tests/008 b/tests/008
index 1af5bcf..c09863f 100755
--- a/tests/008
+++ b/tests/008
@@ -33,7 +33,7 @@ for i in `seq 0 4`; do
 done
 
 for i in `seq 0 4`; do
-    dd if=/dev/urandom | $COLLIE vdi write test$i -p 7000 &
+    _random | $COLLIE vdi write test$i -p 7000 &
 done
 
 sleep 3
@@ -54,6 +54,7 @@ for i in `seq 1 5`; do
 done
 
 echo wait for object recovery to finish
+_wait_for_sheep_recovery 0
 wait
 
 for i in `seq 0 4`; do
diff --git a/tests/009 b/tests/009
index e139524..b8b2f1d 100755
--- a/tests/009
+++ b/tests/009
@@ -31,7 +31,7 @@ $COLLIE vdi create test 80M -P
 _kill_sheep 2
 
 # write data to the vdi
-cat /dev/urandom | $COLLIE vdi write test
+_random | $COLLIE vdi write test
 
 # restart the 3rd node
 _start_sheep 2
diff --git a/tests/018 b/tests/018
index d8af69b..50ec779 100755
--- a/tests/018
+++ b/tests/018
@@ -25,7 +25,7 @@ $COLLIE cluster format -c 2
 
 $COLLIE vdi create test 4M
 
-dd if=/dev/urandom | $COLLIE vdi write -w test
+_random | $COLLIE vdi write -w test
 
 $COLLIE vdi flush test
 
diff --git a/tests/019 b/tests/019
index 98fc2b8..9bc2a88 100755
--- a/tests/019
+++ b/tests/019
@@ -25,7 +25,7 @@ $COLLIE cluster format -c 2
 
 $COLLIE vdi create test 4M
 
-dd if=/dev/urandom | $COLLIE vdi write test
+_random | $COLLIE vdi write test
 
 for port in `seq 0 2`; do
     $COLLIE vdi read test -p 700$port | md5sum > /tmp/csum.$port
diff --git a/tests/020 b/tests/020
index 6fe2e32..c5993f8 100755
--- a/tests/020
+++ b/tests/020
@@ -25,7 +25,7 @@ $COLLIE cluster format -c 2
 
 $COLLIE vdi create test 40M
 
-dd if=/dev/urandom | $COLLIE vdi write test
+_random | $COLLIE vdi write test
 
 # check cache size, should be 20 * 80%
 nr=`ls $STORE/0/cache/7c2b25 | wc -l`
diff --git a/tests/030 b/tests/030
index 7c5ed98..6c58658 100755
--- a/tests/030
+++ b/tests/030
@@ -25,15 +25,15 @@ $COLLIE cluster format -c 2
 
 $COLLIE vdi create test 8M
 
-dd if=/dev/urandom | $COLLIE vdi write test
+_random | $COLLIE vdi write test
 $COLLIE cluster snapshot
 $COLLIE vdi read test | md5sum > /tmp/csum.1
 
-dd if=/dev/urandom | $COLLIE vdi write test
+_random | $COLLIE vdi write test
 $COLLIE cluster snapshot
 $COLLIE vdi read test | md5sum > /tmp/csum.2
 
-dd if=/dev/urandom | $COLLIE vdi write test
+_random | $COLLIE vdi write test
 $COLLIE cluster snapshot -l | _filter_date
 
 $COLLIE cluster snapshot -R 2
diff --git a/tests/035 b/tests/035
index 5b948c9..f2c59e2 100755
--- a/tests/035
+++ b/tests/035
@@ -35,7 +35,7 @@ _wait_for_sheep 6
 $COLLIE cluster format -c 3 -m unsafe
 
 $COLLIE vdi create test 40M
-dd if=/dev/urandom | $COLLIE vdi write test &
+_random | $COLLIE vdi write test &
 
 sleep 3
 # Test write timeout
diff --git a/tests/049 b/tests/049
index 1336b5f..b27be1a 100755
--- a/tests/049
+++ b/tests/049
@@ -25,7 +25,7 @@ $COLLIE cluster format -c 1
 sleep 1
 
 $COLLIE vdi create test 20M
-dd if=/dev/urandom | $COLLIE vdi write -w test
+_random | $COLLIE vdi write -w test
 
 $COLLIE cluster shutdown
 _wait_for_sheep_stop
diff --git a/tests/055 b/tests/055
index 6b99552..9b908e4 100755
--- a/tests/055
+++ b/tests/055
@@ -25,14 +25,14 @@ $COLLIE vdi create test 200M -P
 
 # simulate one disk failure
 rm $STORE/0/d0 -rf
-dd if=/dev/urandom | $COLLIE vdi write test
+_random | $COLLIE vdi write test
 _wait_for_sheep_recovery 0
 $COLLIE vdi check test
 $COLLIE cluster info | _filter_cluster_info
 
 # simulate multiple disk failure
 rm $STORE/1/d0 -rf
-dd if=/dev/urandom | $COLLIE vdi write test &
+_random | $COLLIE vdi write test &
 sleep 1
 rm $STORE/1/d1 -rf
 _wait_for_sheep_recovery 0
@@ -42,7 +42,7 @@ $COLLIE cluster info | _filter_cluster_info
 
 # simulate all disks failure
 rm $STORE/1/d2 -rf
-dd if=/dev/urandom | $COLLIE vdi write test
+_random | $COLLIE vdi write test
 $COLLIE vdi check test
 $COLLIE cluster info | _filter_cluster_info
 
diff --git a/tests/056 b/tests/056
index 25dd22f..8d1dd64 100755
--- a/tests/056
+++ b/tests/056
@@ -25,7 +25,7 @@ $COLLIE vdi create test 200M -P
 
 # node event after disk failure
 rm $STORE/0/d0 -rf
-dd if=/dev/urandom | $COLLIE vdi write test &
+_random | $COLLIE vdi write test &
 sleep 1
 _start_sheep 3
 _wait_for_sheep 4
diff --git a/tests/common.rc b/tests/common.rc
index 197dfff..dd78cd0 100644
--- a/tests/common.rc
+++ b/tests/common.rc
@@ -41,6 +41,11 @@ _need_to_be_root()
     fi
 }
 
+_random()
+{
+    perl -e 'print rand() x 1024 while true'
+}
+
 # Do a command, log it to $seq.full, optionally test return status
 # and die if command fails. If called with one argument _do executes the
 # command, logs it, and returns its exit status. With two arguments _do
-- 
1.7.9.5




More information about the sheepdog mailing list