[sheepdog] [PATCH v2 3/4] tests/functional: add support for client cache mode

MORITA Kazutaka morita.kazutaka at gmail.com
Tue Aug 13 06:37:39 CEST 2013


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

This enables us to test the object cache feature.

E.g.

 $ sudo env SHEEP_EXTRA_OPTIONS="-w size=100" ./check
 $ sudo env SHEEP_EXTRA_OPTIONS="-w size=100" ./check -writethrough
 $ sudo env SHEEP_EXTRA_OPTIONS="-w size=100" ./check -direct

Note that writeback is default.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 tests/functional/008           |    6 +++++-
 tests/functional/009           |    4 +++-
 tests/functional/010           |    9 ++++++---
 tests/functional/013           |    6 +++---
 tests/functional/017           |    2 +-
 tests/functional/018           |    4 +++-
 tests/functional/019           |    4 +++-
 tests/functional/020           |    4 +++-
 tests/functional/024           |    6 +++---
 tests/functional/025           |    4 ++--
 tests/functional/028           |    5 +++--
 tests/functional/030           |    8 ++++----
 tests/functional/032           |    4 +++-
 tests/functional/033           |    4 +++-
 tests/functional/034           |    6 ++++--
 tests/functional/035           |    2 +-
 tests/functional/039           |   22 +++++++++++-----------
 tests/functional/041           |    6 +++---
 tests/functional/042           |    4 ++--
 tests/functional/043           |   11 +++++++----
 tests/functional/044           |    6 +++---
 tests/functional/045           |    2 +-
 tests/functional/047           |    6 ++++--
 tests/functional/048           |    2 +-
 tests/functional/049           |    4 +++-
 tests/functional/050           |    2 +-
 tests/functional/055           |    8 ++++----
 tests/functional/056           |    4 ++--
 tests/functional/058           |    4 ++--
 tests/functional/059           |    2 +-
 tests/functional/060           |    6 +++++-
 tests/functional/062           |   12 ++++++------
 tests/functional/065           |    2 +-
 tests/functional/066           |    4 ++--
 tests/functional/071           |    2 +-
 tests/functional/check         |   12 ++++++++++++
 tests/functional/common.config |    2 ++
 tests/functional/common.rc     |   39 ++++++++++++++++++++++++++++++++++++++-
 38 files changed, 162 insertions(+), 78 deletions(-)

diff --git a/tests/functional/008 b/tests/functional/008
index 9afe56b..e0fea50 100755
--- a/tests/functional/008
+++ b/tests/functional/008
@@ -17,7 +17,7 @@ for i in `seq 0 4`; do
 done
 
 for i in `seq 0 4`; do
-    _random | $DOG vdi write test$i -p 7000 &
+    _random | _vdi_write test$i -p 7000 &
 done
 
 sleep 3
@@ -37,6 +37,10 @@ for i in `seq 1 5`; do
     _start_sheep $i
 done
 
+for i in `seq 0 4`; do
+    $DOG vdi cache flush test$i
+done
+
 echo wait for object recovery to finish
 _wait_for_sheep_recovery 0
 wait
diff --git a/tests/functional/009 b/tests/functional/009
index 86a4806..cfefdb2 100755
--- a/tests/functional/009
+++ b/tests/functional/009
@@ -20,11 +20,13 @@ $DOG vdi create test 80M -P
 _kill_sheep 2
 
 # write data to the vdi
-_random | $DOG vdi write test
+_random | _vdi_write test
 
 # restart the 3rd node
 _start_sheep 2
 
+$DOG vdi cache flush test
+
 _wait_for_sheep_recovery 0
 
 # show md5sum of the vdi on each node
diff --git a/tests/functional/010 b/tests/functional/010
index 4e98545..d376d8b 100755
--- a/tests/functional/010
+++ b/tests/functional/010
@@ -19,8 +19,9 @@ $DOG vdi create test 4G
 
 # create 8 objects
 for i in `seq 0 7`; do
-    echo $i | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
+$DOG vdi cache flush test
 
 ls $STORE/*/obj/* | _filter_store | sort
 
@@ -34,8 +35,9 @@ ls $STORE/*/obj/* | _filter_store | sort
 # overwrite the objects to invoke object recovery
 for i in `seq 4 7`; do
     $DOG vdi read test $((i * 4 * 1024 * 1024)) 512 | md5sum
-    echo $(($i + 100)) | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $(($i + 100)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
+$DOG vdi cache flush test
 
 $DOG cluster info | head -6 | _filter_cluster_info
 ls $STORE/*/obj/* | _filter_store | sort
@@ -58,7 +60,8 @@ ls $STORE/*/obj/* | _filter_store | sort
 # overwrite the objects to invoke object recovery
 for i in `seq 0 3`; do
     $DOG vdi read test $((i * 4 * 1024 * 1024)) 512 -p 7007 | md5sum
-    echo $(($i + 200)) | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $(($i + 200)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512
+    $DOG vdi cache flush test
 done
 
 $DOG cluster info | head -6 | _filter_cluster_info
diff --git a/tests/functional/013 b/tests/functional/013
index e74b27c..c9377e2 100755
--- a/tests/functional/013
+++ b/tests/functional/013
@@ -14,11 +14,11 @@ _cluster_format -c 1
 
 $QEMU_IMG create sheepdog:test 4G
 for i in `seq 1 9`; do
-    $QEMU_IO -c "write 0 512 -P $i" sheepdog:test | _filter_qemu_io
+    _qemu_io -c "write 0 512 -P $i" sheepdog:test
     $QEMU_IMG snapshot -c tag$i sheepdog:test
 done
 
-$QEMU_IO -c "read 0 512 -P 9" sheepdog:test | _filter_qemu_io
+_qemu_io -c "read 0 512 -P 9" sheepdog:test
 for i in `seq 1 9`; do
-    $QEMU_IO -c "read 0 512 -P $i" sheepdog:test:tag$i | _filter_qemu_io
+    _qemu_io -c "read 0 512 -P $i" sheepdog:test:tag$i
 done
diff --git a/tests/functional/017 b/tests/functional/017
index 93e3d56..fd22608 100755
--- a/tests/functional/017
+++ b/tests/functional/017
@@ -20,7 +20,7 @@ $QEMU_IMG snapshot -c tag3 sheepdog:test
 $QEMU_IMG create sheepdog:test2 4G
 $QEMU_IMG snapshot -c tag1 sheepdog:test2
 $QEMU_IMG snapshot -c tag2 sheepdog:test2
-$QEMU_IO -c "write 0 512" sheepdog:test2:1 | _filter_qemu_io
+_qemu_io -c "write 0 512" sheepdog:test2:1
 $QEMU_IMG snapshot -c tag3 sheepdog:test2
 
 $DOG vdi tree | _filter_short_date
diff --git a/tests/functional/018 b/tests/functional/018
index c0ab9ee..76ad3f2 100755
--- a/tests/functional/018
+++ b/tests/functional/018
@@ -4,6 +4,8 @@
 
 . ./common
 
+_requirement writeback
+
 for i in `seq 0 2`; do
     _start_sheep $i "-w size=100"
 done
@@ -14,7 +16,7 @@ _cluster_format -c 2
 
 $DOG vdi create test 4M
 
-_random | $DOG vdi write -w test
+_random | _vdi_write test
 
 $DOG vdi cache flush test
 
diff --git a/tests/functional/019 b/tests/functional/019
index efe8cb8..d522fe1 100755
--- a/tests/functional/019
+++ b/tests/functional/019
@@ -4,6 +4,8 @@
 
 . ./common
 
+_requirement not_writeback
+
 for i in `seq 0 2`; do
     _start_sheep $i "-w size=100"
 done
@@ -14,7 +16,7 @@ _cluster_format -c 2
 
 $DOG vdi create test 4M
 
-_random | $DOG vdi write test
+_random | _vdi_write test
 
 for port in `seq 0 2`; do
     $DOG vdi read test -p 700$port | md5sum > $STORE/csum.$port
diff --git a/tests/functional/020 b/tests/functional/020
index 77066bf..37bd87e 100755
--- a/tests/functional/020
+++ b/tests/functional/020
@@ -4,6 +4,8 @@
 
 . ./common
 
+_requirement writeback
+
 for i in `seq 0 2`; do
     _start_sheep $i "-w size=20"
 done
@@ -14,7 +16,7 @@ _cluster_format -c 2
 
 $DOG vdi create test 40M
 
-_random | $DOG vdi write test
+_random | _vdi_write test
 
 # check cache size, should be 20 * 80%
 nr=`ls $STORE/0/cache/7c2b25 | wc -l`
diff --git a/tests/functional/024 b/tests/functional/024
index 87421a8..3cb152a 100755
--- a/tests/functional/024
+++ b/tests/functional/024
@@ -23,14 +23,14 @@ $DOG vdi create ${VDI_NAME} ${VDI_SIZE}
 sleep 1
 
 echo "filling ${VDI_NAME} with data"
-$QEMU_IO -c "write 0 ${VDI_SIZE}" sheepdog:${VDI_NAME} | _filter_qemu_io
+_qemu_io -c "write 0 ${VDI_SIZE}" sheepdog:${VDI_NAME}
 
 echo "reading back ${VDI_NAME}"
-$QEMU_IO -c "read 0 1m" sheepdog:${VDI_NAME} | _filter_qemu_io
+_qemu_io -c "read 0 1m" sheepdog:${VDI_NAME}
 
 echo "starting second sheep"
 _start_sheep 1
 _wait_for_sheep 2
 
 echo "reading data from second sheep"
-$QEMU_IO -c "read 0 ${VDI_SIZE}" sheepdog:localhost:7001:${VDI_NAME} | _filter_qemu_io
+_qemu_io -c "read 0 ${VDI_SIZE}" sheepdog:localhost:7001:${VDI_NAME}
diff --git a/tests/functional/025 b/tests/functional/025
index 2eb2f6d..43bac21 100755
--- a/tests/functional/025
+++ b/tests/functional/025
@@ -26,10 +26,10 @@ echo "creating vdi ${NAME}"
 $DOG vdi create ${VDI_NAME} ${VDI_SIZE}
 
 echo "filling ${VDI_NAME} with data"
-$QEMU_IO -c "write 0 ${VDI_SIZE}" sheepdog:${VDI_NAME} | _filter_qemu_io
+_qemu_io -c "write 0 ${VDI_SIZE}" sheepdog:${VDI_NAME}
 
 echo "reading back ${VDI_NAME} from second zone"
-$QEMU_IO -c "read 0 1m" sheepdog:localhost:7002:${VDI_NAME} | _filter_qemu_io
+_qemu_io -c "read 0 1m" sheepdog:localhost:7002:${VDI_NAME}
 
 echo "starting a sheep in the third zone"
 for i in `seq 3 3`; do
diff --git a/tests/functional/028 b/tests/functional/028
index ff813c5..947f765 100755
--- a/tests/functional/028
+++ b/tests/functional/028
@@ -13,7 +13,7 @@ _cluster_format -c 2
 $DOG vdi create test 100M
 
 for i in `seq 0 24`; do
-    echo $i | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 $DOG vdi read test | md5sum
@@ -27,8 +27,9 @@ done
 
 # write different content
 for i in `seq 0 24`; do
-    echo $(($i+1)) | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512 -p 7002
+    echo $(($i+1)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512 -p 7002
 done
+$DOG vdi cache flush test
 
 $DOG vdi read test -p 7002 | md5sum
 
diff --git a/tests/functional/030 b/tests/functional/030
index 219f348..ed63c24 100755
--- a/tests/functional/030
+++ b/tests/functional/030
@@ -16,8 +16,8 @@ _cluster_format -c 3
 $DOG vdi create test1 10M
 $DOG vdi create test2 10M
 
-_random | $DOG vdi write test1
-_random | $DOG vdi write test2
+_random | _vdi_write test1
+_random | _vdi_write test2
 $DOG vdi read test1 | md5sum > $STORE/csum.11.org
 $DOG vdi read test2 | md5sum > $STORE/csum.21.org
 $DOG vdi snapshot test1
@@ -25,8 +25,8 @@ $DOG vdi snapshot test2
 $DOG cluster snapshot save s1 $TMPDIR
 $DOG cluster snapshot list $TMPDIR | _filter_date
 
-_random | $DOG vdi write test1
-_random | $DOG vdi write test2
+_random | _vdi_write test1
+_random | _vdi_write test2
 $DOG vdi read test1 | md5sum > $STORE/csum.12.org
 $DOG vdi read test2 | md5sum > $STORE/csum.22.org
 $DOG vdi snapshot test1
diff --git a/tests/functional/032 b/tests/functional/032
index 5fcda38..6683337 100755
--- a/tests/functional/032
+++ b/tests/functional/032
@@ -17,7 +17,7 @@ _cluster_format
 $DOG vdi create test 100MB
 # create 25 objects
 for i in `seq 0 24`; do
-    echo $i | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 $DOG vdi read test | md5sum
@@ -38,6 +38,8 @@ done
 
 _wait_for_sheep_recovery 0
 
+$DOG vdi cache flush test
+
 ls $STORE/*/obj/807c2b2500000000 | _filter_store | sort
 for i in `seq 0 24`; do
     ls $STORE/*/obj/007c2b25000000`printf "%02x" $i` | _filter_store | sort
diff --git a/tests/functional/033 b/tests/functional/033
index 88a5960..99fb00e 100755
--- a/tests/functional/033
+++ b/tests/functional/033
@@ -17,7 +17,7 @@ _cluster_format
 $DOG vdi create test 100MB
 # create 25 objects
 for i in `seq 0 24`; do
-    echo $i | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 $DOG vdi read test | md5sum
@@ -49,6 +49,8 @@ done
 
 _wait_for_sheep_recovery 0
 
+$DOG vdi cache flush test
+
 ls $STORE/*/obj/807c2b2500000000 | _filter_store | sort
 for i in `seq 0 24`; do
     ls $STORE/*/obj/007c2b25000000`printf "%02x" $i` | _filter_store | sort
diff --git a/tests/functional/034 b/tests/functional/034
index 07caf5c..fa16f74 100755
--- a/tests/functional/034
+++ b/tests/functional/034
@@ -20,7 +20,7 @@ _cluster_format
 $DOG vdi create test 100MB
 # create 25 objects
 for i in `seq 0 24`; do
-    echo $i | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 # kill 5 nodes
@@ -35,7 +35,7 @@ _wait_for_sheep 3
 
 # update vdi
 for i in `seq 0 24`; do
-    echo $(($i + 100)) | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $(($i + 100)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 $DOG vdi read test | md5sum
@@ -47,6 +47,8 @@ done
 
 _wait_for_sheep 8
 
+$DOG vdi cache flush test
+
 for i in `seq 0 7`; do
     $DOG vdi read test -p 700$i | md5sum
 done
diff --git a/tests/functional/035 b/tests/functional/035
index fe5731b..6fff800 100755
--- a/tests/functional/035
+++ b/tests/functional/035
@@ -23,7 +23,7 @@ _wait_for_sheep 6
 _cluster_format -c 3
 
 $DOG vdi create test 40M
-_random | $DOG vdi write test &
+_random | _vdi_write test &
 
 sleep 3
 # Test write timeout
diff --git a/tests/functional/039 b/tests/functional/039
index b7e1f57..2fbe46a 100755
--- a/tests/functional/039
+++ b/tests/functional/039
@@ -13,37 +13,37 @@ _wait_for_sheep 5
 _cluster_format
 $DOG vdi create test 4G
 
-$QEMU_IO -c "write 0 512 -P 1" sheepdog:test | _filter_qemu_io
+_qemu_io -c "write 0 512 -P 1" sheepdog:test
 $DOG vdi snapshot test -s snap1
-$QEMU_IO -c "write 0 512 -P 2" sheepdog:test | _filter_qemu_io
+_qemu_io -c "write 0 512 -P 2" sheepdog:test
 
 echo yes | $DOG vdi rollback test -s snap1
-$QEMU_IO -c "read 0 512 -P 1" sheepdog:test | _filter_qemu_io
+_qemu_io -c "read 0 512 -P 1" sheepdog:test
 $DOG vdi tree | _filter_short_date
 _vdi_list
 
-$QEMU_IO -c "write 0 512 -P 2" sheepdog:test | _filter_qemu_io
+_qemu_io -c "write 0 512 -P 2" sheepdog:test
 $DOG vdi snapshot test -s snap2
-$QEMU_IO -c "write 0 512 -P 3" sheepdog:test | _filter_qemu_io
+_qemu_io -c "write 0 512 -P 3" sheepdog:test
 
 echo yes | $DOG vdi rollback test -s snap1
-$QEMU_IO -c "read 0 512 -P 1" sheepdog:test | _filter_qemu_io
+_qemu_io -c "read 0 512 -P 1" sheepdog:test
 $DOG vdi tree | _filter_short_date
 _vdi_list
 
 echo yes | $DOG vdi rollback test -s snap2
-$QEMU_IO -c "read 0 512 -P 2" sheepdog:test | _filter_qemu_io
+_qemu_io -c "read 0 512 -P 2" sheepdog:test
 $DOG vdi tree | _filter_short_date
 _vdi_list
 
 echo yes | $DOG vdi rollback test -s snap1
-$QEMU_IO -c "read 0 512 -P 1" sheepdog:test | _filter_qemu_io
+_qemu_io -c "read 0 512 -P 1" sheepdog:test
 $DOG vdi tree | _filter_short_date
 _vdi_list
 
-$QEMU_IO -c "write 0 512 -P 3" sheepdog:test | _filter_qemu_io
+_qemu_io -c "write 0 512 -P 3" sheepdog:test
 $DOG vdi snapshot test -s snap3
-$QEMU_IO -c "write 0 512 -P 4" sheepdog:test | _filter_qemu_io
+_qemu_io -c "write 0 512 -P 4" sheepdog:test
 $DOG vdi snapshot test -s snap4
 
 # these fail since the snap ids don't belong to snapshots
@@ -51,6 +51,6 @@ echo yes | $DOG vdi rollback test -s 0
 echo yes | $DOG vdi rollback test -s 5
 
 echo yes | $DOG vdi rollback test -s snap3
-$QEMU_IO -c "read 0 512 -P 3" sheepdog:test | _filter_qemu_io
+_qemu_io -c "read 0 512 -P 3" sheepdog:test
 $DOG vdi tree | _filter_short_date
 _vdi_list
diff --git a/tests/functional/041 b/tests/functional/041
index 6b9d87b..6d3414f 100755
--- a/tests/functional/041
+++ b/tests/functional/041
@@ -14,15 +14,15 @@ _cluster_format
 $DOG vdi create test 12M
 
 # create the first object
-echo 0 | $DOG vdi write test 0 512
+echo 0 | _vdi_write test 0 512
 $DOG vdi snapshot test -s snap1
 
 # create the second object
-echo 1 | $DOG vdi write test $((4 * 1024 * 1024)) 512
+echo 1 | _vdi_write test $((4 * 1024 * 1024)) 512
 $DOG vdi snapshot test -s snap2
 
 # update the first object
-echo 2 | $DOG vdi write test 0 512
+echo 2 | _vdi_write test 0 512
 $DOG vdi snapshot test -s snap3
 
 # check vdis
diff --git a/tests/functional/042 b/tests/functional/042
index 571c501..80be311 100755
--- a/tests/functional/042
+++ b/tests/functional/042
@@ -34,8 +34,8 @@ dd if=/dev/zero of=$STORE/3/zero > /dev/null 2>&1
 
 # test data write against disk-full cluster
 for i in `seq 0 10`; do
-    echo $i | $DOG vdi write test0 $((i * 4 * 1024 * 1024)) 512 -p 7000
-    echo $i | $DOG vdi write test1 $((i * 4 * 1024 * 1024)) 512 -p 7002
+    echo $i | _vdi_write test0 $((i * 4 * 1024 * 1024)) 512 -p 7000
+    echo $i | _vdi_write test1 $((i * 4 * 1024 * 1024)) 512 -p 7002
 done
 
 # test vdi creation against disk-full cluster
diff --git a/tests/functional/043 b/tests/functional/043
index a593bce..7c94719 100755
--- a/tests/functional/043
+++ b/tests/functional/043
@@ -17,8 +17,9 @@ _cluster_format
 $DOG vdi create test 40M
 
 for i in `seq 0 10`; do
-    echo $i | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
+$DOG vdi cache flush test
 
 for i in 0 1 2 3 4; do
     $DOG vdi read test -p 700$i | md5sum
@@ -29,8 +30,9 @@ done
 _safe_remove $STORE/4/obj
 
 for i in `seq 0 10`; do
-    echo $(($i + 100)) | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $(($i + 100)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
+$DOG vdi cache flush test
 
 for i in 0 1 2 3 4; do
     $DOG vdi read test -p 700$i | md5sum
@@ -41,8 +43,9 @@ done
 _kill_sheep 3
 
 for i in `seq 0 10`; do
-    echo $(($i + 200)) | $DOG vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $(($i + 200)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
+$DOG vdi cache flush test
 
 for i in 0 1 2 4; do
     $DOG vdi read test -p 700$i | md5sum
@@ -58,4 +61,4 @@ done
 
 # check whether we can write to a gateway after EIO
 _safe_remove $STORE/0/obj
-echo hello | $DOG vdi write test 0 512
+echo hello | _vdi_write test 0 512
diff --git a/tests/functional/044 b/tests/functional/044
index fc5d8be..965d2cb 100755
--- a/tests/functional/044
+++ b/tests/functional/044
@@ -16,15 +16,15 @@ $DOG vdi create base2 20M -p 7001
 $DOG vdi create base3 20M -p 7002
 
 for i in `seq 0 4`; do
-    echo $i | $DOG vdi write base1 $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write base1 $((i * 4 * 1024 * 1024)) 512
 done &
 
 for i in `seq 0 4`; do
-    echo $i | $DOG vdi write base2 $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write base2 $((i * 4 * 1024 * 1024)) 512
 done &
 
 for i in `seq 0 4`; do
-    echo $i | $DOG vdi write base3 $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write base3 $((i * 4 * 1024 * 1024)) 512
 done &
 
 wait
diff --git a/tests/functional/045 b/tests/functional/045
index 530af28..af9acb9 100755
--- a/tests/functional/045
+++ b/tests/functional/045
@@ -14,7 +14,7 @@ _cluster_format -c 2
 $DOG vdi create test 4M
 
 for i in `seq 0 7`; do
-    echo $i | $DOG vdi write test $(($i * 1536 + 512)) 512
+    echo $i | _vdi_write test $(($i * 1536 + 512)) 512
 done
 
 for i in `seq 0 7`; do
diff --git a/tests/functional/047 b/tests/functional/047
index 675f74e..4d1409c 100755
--- a/tests/functional/047
+++ b/tests/functional/047
@@ -13,8 +13,10 @@ _cluster_format -c 1
 $DOG vdi create test 4G
 
 # write something to vdi 'test'
-echo "hello" | $DOG vdi write test 0 512
-echo "sheepdog" | $DOG vdi write test 4M 512
+echo "hello" | _vdi_write test 0 512
+echo "sheepdog" | _vdi_write test 4M 512
+$DOG vdi cache flush test
+
 # corrupt the vdi...
 _kill_sheep 0
 if $MD; then
diff --git a/tests/functional/048 b/tests/functional/048
index 7565a9a..cc7164f 100755
--- a/tests/functional/048
+++ b/tests/functional/048
@@ -16,7 +16,7 @@ _cluster_format
 
 $DOG vdi create test 1G
 
-echo hello | $DOG vdi write test 4M 512
+echo hello | _vdi_write test 4M 512
 # kill the master gracefully
 $DOG node kill 0
 sleep 2
diff --git a/tests/functional/049 b/tests/functional/049
index d466130..d1b5e39 100755
--- a/tests/functional/049
+++ b/tests/functional/049
@@ -4,6 +4,8 @@
 
 . ./common
 
+requirement writeback
+
 for i in `seq 0 2`; do
     _start_sheep $i "-w size=30"
 done
@@ -13,7 +15,7 @@ _wait_for_sheep 3
 _cluster_format -c 1
 
 $DOG vdi create test 20M
-_random | $DOG vdi write -w test
+_random | _vdi_write test
 
 $DOG cluster shutdown
 _wait_for_sheep_stop
diff --git a/tests/functional/050 b/tests/functional/050
index 0868a75..625f8e5 100755
--- a/tests/functional/050
+++ b/tests/functional/050
@@ -23,7 +23,7 @@ _wait_for_sheep 3
 _cluster_format
 
 $DOG vdi create test 100M
-dd if=/dev/zero | $DOG vdi write test &
+dd if=/dev/zero | _vdi_write test &
 
 # simulate IO NIC down of sheep 1
 iptables -A INPUT -p tcp --sport 8001 -j DROP
diff --git a/tests/functional/055 b/tests/functional/055
index d293a37..e601a85 100755
--- a/tests/functional/055
+++ b/tests/functional/055
@@ -15,14 +15,14 @@ $DOG vdi create test 200M -P
 
 # simulate one disk failure
 _safe_remove $STORE/0/d0
-_random | $DOG vdi write test
+_random | _vdi_write test
 _wait_for_sheep_recovery 0
 $DOG vdi check test
 $DOG cluster info | _filter_cluster_info
 
 # simulate multiple disk failure
 _safe_remove $STORE/1/d0
-_random | $DOG vdi write test &
+_random | _vdi_write test &
 sleep 1
 _safe_remove $STORE/1/d1
 _wait_for_sheep_recovery 0
@@ -32,13 +32,13 @@ $DOG cluster info | _filter_cluster_info
 
 # simulate all disks failure
 _safe_remove $STORE/1/d2
-_random | $DOG vdi write test
+_random | _vdi_write test
 $DOG vdi check test
 $DOG cluster info | _filter_cluster_info
 
 # simulate simultaneous multiple disks failure
 _safe_remove $STORE/2/d0
 _safe_remove $STORE/2/d1
-dd if=/dev/zero | $DOG vdi write test
+dd if=/dev/zero | _vdi_write test
 $DOG vdi check test
 $DOG cluster info | _filter_cluster_info
diff --git a/tests/functional/056 b/tests/functional/056
index 70ceb4e..614e926 100755
--- a/tests/functional/056
+++ b/tests/functional/056
@@ -16,7 +16,7 @@ $DOG vdi create test 200M -P
 # node event after disk failure
 _safe_remove $STORE/0/d0
 
-_random | $DOG vdi write test &
+_random | _vdi_write test &
 sleep 1
 _start_sheep 3
 _wait_for_sheep 4
@@ -27,7 +27,7 @@ $DOG cluster info | _filter_cluster_info
 
 # disk failures after node event
 _safe_remove $STORE/1/d0
-dd if=/dev/zero | $DOG vdi write test &
+dd if=/dev/zero | _vdi_write test &
 sleep 1
 _kill_sheep 2
 _wait_for_sheep 3
diff --git a/tests/functional/058 b/tests/functional/058
index ea584de..03758c0 100755
--- a/tests/functional/058
+++ b/tests/functional/058
@@ -9,8 +9,8 @@ done
 _wait_for_sheep 3
 _cluster_format
 $DOG vdi create test 100M
-dd if=/dev/zero | $DOG vdi write -w test
-$QEMU_IO -c "discard 0 100m" sheepdog:test | _filter_qemu_io
+dd if=/dev/zero | _vdi_write test
+_qemu_io -c "discard 0 100m" sheepdog:test
 $DOG vdi check test
 for i in `seq 0 24`; do
 	$DOG vdi object test -i $i;
diff --git a/tests/functional/059 b/tests/functional/059
index b719a58..0e15aac 100755
--- a/tests/functional/059
+++ b/tests/functional/059
@@ -24,7 +24,7 @@ _input()
     echo quit
 }
 
-_input | $QEMU_IO sheepdog:test > /dev/null
+_input | _qemu_io sheepdog:test > /dev/null
 
 _vdi_list
 $DOG vdi tree | _filter_short_date
diff --git a/tests/functional/060 b/tests/functional/060
index fb6bc31..d960518 100755
--- a/tests/functional/060
+++ b/tests/functional/060
@@ -15,7 +15,7 @@ for i in `seq 0 3`; do
     $DOG vdi create test$i 100M
 
     for j in `seq 0 24`; do
-	echo "$i $j" | $DOG vdi write test$i $(($j * 4 * 1024 ** 2)) 512
+	echo "$i $j" | _vdi_write test$i $(($j * 4 * 1024 ** 2)) 512
     done &
 done
 wait
@@ -44,6 +44,10 @@ for i in 0 1 2; do
     _reboot_without_dog_shutdown
 done
 
+for i in `seq 0 3`; do
+    $DOG vdi cache flush test$i
+done
+
 for i in `seq 0 7`; do
     $DOG cluster info -p 700$i | _filter_cluster_info > $STORE/cinfo.$i
     _vdi_list -p 700$i
diff --git a/tests/functional/062 b/tests/functional/062
index 5133287..ae7d892 100755
--- a/tests/functional/062
+++ b/tests/functional/062
@@ -16,17 +16,17 @@ $DOG vdi create test 1234
 sleep 1
 $DOG vdi list -r test | awk '{$7="MASKED";print $0}'
 
-echo hello | $DOG vdi write test 1 6
+echo hello | _vdi_write test 1 6
 $DOG vdi read test 1 6
-echo world | $DOG vdi write test 1 6
+echo world | _vdi_write test 1 6
 $DOG vdi read test 1 6
 
-echo h*** | $DOG vdi write test 510 512
-echo h!!! | $DOG vdi write test 510 512
+echo h*** | _vdi_write test 510 512
+echo h!!! | _vdi_write test 510 512
 $DOG vdi read test 510 5
-echo ^^ | $DOG vdi write test 511 2
+echo ^^ | _vdi_write test 511 2
 $DOG vdi read test 510 5
-echo xxx | $DOG vdi write test 1020 4
+echo xxx | _vdi_write test 1020 4
 $DOG vdi read test 1020 4
 $DOG vdi read test 510 5
 $DOG vdi read test 1 6
diff --git a/tests/functional/065 b/tests/functional/065
index e0ee1ae..7318cb4 100755
--- a/tests/functional/065
+++ b/tests/functional/065
@@ -18,7 +18,7 @@ _kill_sheep 0
 _start_sheep 0 "-w size=400"
 _wait_for_sheep 2
 
-dd if=/dev/zero | $DOG vdi write -w t &
+dd if=/dev/zero | _vdi_write t &
 
 _wait_for_sheep_recovery 1
 wait
diff --git a/tests/functional/066 b/tests/functional/066
index 97f0b9f..c98c767 100755
--- a/tests/functional/066
+++ b/tests/functional/066
@@ -15,9 +15,9 @@ $DOG vdi create t 300M -P
 $DOG vdi create t0 300M -P
 $DOG vdi create t1 300M -P
 
-dd if=/dev/zero | $DOG vdi write -w t &
+dd if=/dev/zero | _vdi_write t &
 for j in 0 1; do
-    dd if=/dev/zero | $DOG vdi write -w t$j -p 700$j &
+    dd if=/dev/zero | _vdi_write t$j -p 700$j &
 done
 
 for i in `seq 3 7`; do
diff --git a/tests/functional/071 b/tests/functional/071
index de935a4..7e51a6e 100755
--- a/tests/functional/071
+++ b/tests/functional/071
@@ -25,7 +25,7 @@ for skip in 0 1 2 3; do
     for offset in 0 512; do
 	for length in $((4 * 4096)) $((4 * 4096 - 512)); do
 	    dd if=$DATA_FILE bs=4k skip=$skip count=4 2> /dev/null \
-		| $DOG vdi write test $offset $length
+		| _vdi_write test $offset $length
 
 	    $DOG vdi read test $offset $length | hd
 	done
diff --git a/tests/functional/check b/tests/functional/check
index e7b7a17..316b37d 100755
--- a/tests/functional/check
+++ b/tests/functional/check
@@ -146,6 +146,8 @@ check options
     -dio                use direct IO for sheep backend store
     -xdiff		graphical mode diff
     -md                 enable md for backend
+    -writethrough       use writethrough mode
+    -direct             bypass object cache
     -e			exit immediately on test failure
     -n			show me, do not run tests
     -T			output timestamps
@@ -175,6 +177,16 @@ testlist options
 	    xpand=false
 	    ;;
 
+	-writethrough)
+	    CACHE=writethourgh
+	    xpand=false
+	    ;;
+
+	-direct)
+	    CACHE=direct
+	    xpand=false
+	    ;;
+
 	-valgrind)
 	    valgrind=true
 	    xpand=false
diff --git a/tests/functional/common.config b/tests/functional/common.config
index a946f2e..6c98889 100644
--- a/tests/functional/common.config
+++ b/tests/functional/common.config
@@ -78,12 +78,14 @@ export STORE=$WD
 export SHEEP_PROG=${SHEEP_PROG:-../../sheep/sheep}
 export SHEEP=${SHEEP:-$SHEEP_PROG}
 export SHEEP_OPTIONS=${SHEEP_OPTIONS:-"-n -y 127.0.0.1 -d"}
+export SHEEP_EXTRA_OPTIONS=${SHEEP_EXTRA_OPTIONS:-""}
 export DOG_PROG=${DOG_PROG:-../../dog/dog}
 export DOG=${DOG:-$DOG_PROG}
 export VALGRIND_OPTIONS=${VALGRIND_OPTIONS:-"-q"}
 export MD=${MD:-false}
 export QEMU_IO=${QEMU_IO_PROG:-qemu-io}
 export QEMU_IMG=${QEMU_IMG_PROG:-qemu-img}
+export CACHE=${CACHE:-writeback}
 
 # make sure this script returns success
 /bin/true
diff --git a/tests/functional/common.rc b/tests/functional/common.rc
index 52aae79..3a2591a 100644
--- a/tests/functional/common.rc
+++ b/tests/functional/common.rc
@@ -41,6 +41,21 @@ _check_md()
     $MD
 }
 
+_check_writeback()
+{
+    [ "$CACHE" = "writeback" ]
+}
+
+_check_writethrough()
+{
+    [ "$CACHE" = "writethrough" ]
+}
+
+_check_direct()
+{
+    [ "$CACHE" = "direct" ]
+}
+
 _requirement()
 {
     local arg
@@ -334,7 +349,8 @@ _start_sheep()
 	MD_STORE=",$STORE/$1/d0,$STORE/$1/d1,$STORE/$1/d2"
     fi
 
-    $SHEEP $STORE/$1$MD_STORE -z $1 -p $((7000+$1)) -c $DRIVER $SHEEP_OPTIONS $2
+    $SHEEP $STORE/$1$MD_STORE -z $1 -p $((7000+$1)) -c $DRIVER $SHEEP_OPTIONS \
+	$SHEEP_EXTRA_OPTIONS $2
 
     if [ $? != 0 ]; then
         _die "cannot start sheep $1"
@@ -540,5 +556,26 @@ _vdi_list()
 	$DOG vdi list $args | _filter_short_date
 }
 
+_vdi_write()
+{
+    local opts=""
+
+    if [ "$CACHE" = "writeback" ]; then
+	opts="-w"
+    fi
+    $DOG vdi write $opts "$@"
+}
+
+_qemu_io()
+{
+    local opts=""
+
+    if [ "$CACHE" != "" ]; then
+	opts="-t $CACHE"
+    fi
+
+    $QEMU_IO $opts "$@" | _filter_qemu_io
+}
+
 # make sure this script returns success
 /bin/true
-- 
1.7.9.5




More information about the sheepdog mailing list