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

MORITA Kazutaka morita.kazutaka at gmail.com
Mon Aug 12 11:30:22 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           |    2 +-
 tests/functional/009           |    2 +-
 tests/functional/010           |    9 ++++++---
 tests/functional/013           |    6 +++---
 tests/functional/017           |    2 +-
 tests/functional/018           |    4 +++-
 tests/functional/019           |    4 +++-
 tests/functional/020           |    2 +-
 tests/functional/024           |    6 +++---
 tests/functional/025           |    4 ++--
 tests/functional/028           |    4 ++--
 tests/functional/030           |    8 ++++----
 tests/functional/032           |    4 +++-
 tests/functional/033           |    4 +++-
 tests/functional/034           |    4 ++--
 tests/functional/035           |    2 +-
 tests/functional/039           |   22 +++++++++++-----------
 tests/functional/041           |    6 +++---
 tests/functional/042           |    4 ++--
 tests/functional/043           |    8 ++++----
 tests/functional/044           |    6 +++---
 tests/functional/045           |    2 +-
 tests/functional/047           |    6 ++++--
 tests/functional/048           |    2 +-
 tests/functional/049           |    2 +-
 tests/functional/050           |    2 +-
 tests/functional/055           |    8 ++++----
 tests/functional/056           |    4 ++--
 tests/functional/058           |    4 ++--
 tests/functional/059           |    2 +-
 tests/functional/060           |    2 +-
 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, 142 insertions(+), 78 deletions(-)

diff --git a/tests/functional/008 b/tests/functional/008
index 665cb6b..052faeb 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 | $COLLIE vdi write test$i -p 7000 &
+    _random | _vdi_write test$i -p 7000 &
 done
 
 sleep 3
diff --git a/tests/functional/009 b/tests/functional/009
index acf9693..0222436 100755
--- a/tests/functional/009
+++ b/tests/functional/009
@@ -20,7 +20,7 @@ $COLLIE vdi create test 80M -P
 _kill_sheep 2
 
 # write data to the vdi
-_random | $COLLIE vdi write test
+_random | _vdi_write test
 
 # restart the 3rd node
 _start_sheep 2
diff --git a/tests/functional/010 b/tests/functional/010
index 126efcf..1090380 100755
--- a/tests/functional/010
+++ b/tests/functional/010
@@ -19,8 +19,9 @@ $COLLIE vdi create test 4G
 
 # create 8 objects
 for i in `seq 0 7`; do
-    echo $i | $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
+$COLLIE 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
     $COLLIE vdi read test $((i * 4 * 1024 * 1024)) 512 | md5sum
-    echo $(($i + 100)) | $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $(($i + 100)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
+$COLLIE vdi cache flush test
 
 $COLLIE cluster info | head -6 | _filter_cluster_info
 ls $STORE/*/obj/* | _filter_store | sort
@@ -58,8 +60,9 @@ ls $STORE/*/obj/* | _filter_store | sort
 # overwrite the objects to invoke object recovery
 for i in `seq 0 3`; do
     $COLLIE vdi read test $((i * 4 * 1024 * 1024)) 512 -p 7007 | md5sum
-    echo $(($i + 200)) | $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $(($i + 200)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
+$COLLIE vdi cache flush test
 
 $COLLIE cluster info | head -6 | _filter_cluster_info
 ls $STORE/*/obj/* | _filter_store | sort
diff --git a/tests/functional/013 b/tests/functional/013
index e74b27c..28a376b 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 | _filter_qemu_io
     $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 | _filter_qemu_io
 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 | _filter_qemu_io
 done
diff --git a/tests/functional/017 b/tests/functional/017
index 30552f4..24877f8 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 | _filter_qemu_io
 $QEMU_IMG snapshot -c tag3 sheepdog:test2
 
 $COLLIE vdi tree | _filter_short_date
diff --git a/tests/functional/018 b/tests/functional/018
index acec3c0..efe32ed 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
 
 $COLLIE vdi create test 4M
 
-_random | $COLLIE vdi write -w test
+_random | _vdi_write test
 
 $COLLIE vdi cache flush test
 
diff --git a/tests/functional/019 b/tests/functional/019
index 7fc0921..5579840 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
 
 $COLLIE vdi create test 4M
 
-_random | $COLLIE vdi write test
+_random | _vdi_write test
 
 for port in `seq 0 2`; do
     $COLLIE vdi read test -p 700$port | md5sum > $STORE/csum.$port
diff --git a/tests/functional/020 b/tests/functional/020
index 53f1d20..ed191f1 100755
--- a/tests/functional/020
+++ b/tests/functional/020
@@ -14,7 +14,7 @@ _cluster_format -c 2
 
 $COLLIE vdi create test 40M
 
-_random | $COLLIE 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 9ef591d..01f1b5c 100755
--- a/tests/functional/024
+++ b/tests/functional/024
@@ -23,14 +23,14 @@ $COLLIE 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} | _filter_qemu_io
 
 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} | _filter_qemu_io
 
 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} | _filter_qemu_io
diff --git a/tests/functional/025 b/tests/functional/025
index 2669888..afea609 100755
--- a/tests/functional/025
+++ b/tests/functional/025
@@ -26,10 +26,10 @@ echo "creating vdi ${NAME}"
 $COLLIE 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} | _filter_qemu_io
 
 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} | _filter_qemu_io
 
 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 4b34db3..8196269 100755
--- a/tests/functional/028
+++ b/tests/functional/028
@@ -13,7 +13,7 @@ _cluster_format -c 2
 $COLLIE vdi create test 100M
 
 for i in `seq 0 24`; do
-    echo $i | $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 $COLLIE vdi read test | md5sum
@@ -27,7 +27,7 @@ done
 
 # write different content
 for i in `seq 0 24`; do
-    echo $(($i+1)) | $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512 -p 7002
+    echo $(($i+1)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512 -p 7002
 done
 
 $COLLIE vdi read test -p 7002 | md5sum
diff --git a/tests/functional/030 b/tests/functional/030
index 7e9daae..a9502c2 100755
--- a/tests/functional/030
+++ b/tests/functional/030
@@ -16,8 +16,8 @@ _cluster_format -c 3
 $COLLIE vdi create test1 10M
 $COLLIE vdi create test2 10M
 
-_random | $COLLIE vdi write test1
-_random | $COLLIE vdi write test2
+_random | _vdi_write test1
+_random | _vdi_write test2
 $COLLIE vdi read test1 | md5sum > $STORE/csum.11.org
 $COLLIE vdi read test2 | md5sum > $STORE/csum.21.org
 $COLLIE vdi snapshot test1
@@ -25,8 +25,8 @@ $COLLIE vdi snapshot test2
 $COLLIE cluster snapshot save s1 $TMPDIR
 $COLLIE cluster snapshot list $TMPDIR | _filter_date
 
-_random | $COLLIE vdi write test1
-_random | $COLLIE vdi write test2
+_random | _vdi_write test1
+_random | _vdi_write test2
 $COLLIE vdi read test1 | md5sum > $STORE/csum.12.org
 $COLLIE vdi read test2 | md5sum > $STORE/csum.22.org
 $COLLIE vdi snapshot test1
diff --git a/tests/functional/032 b/tests/functional/032
index e6cf9b9..abdb766 100755
--- a/tests/functional/032
+++ b/tests/functional/032
@@ -17,7 +17,7 @@ _cluster_format
 $COLLIE vdi create test 100MB
 # create 25 objects
 for i in `seq 0 24`; do
-    echo $i | $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 $COLLIE vdi read test | md5sum
@@ -38,6 +38,8 @@ done
 
 _wait_for_sheep_recovery 0
 
+$COLLIE 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 059c9f8..e6a2d86 100755
--- a/tests/functional/033
+++ b/tests/functional/033
@@ -17,7 +17,7 @@ _cluster_format
 $COLLIE vdi create test 100MB
 # create 25 objects
 for i in `seq 0 24`; do
-    echo $i | $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 $COLLIE vdi read test | md5sum
@@ -49,6 +49,8 @@ done
 
 _wait_for_sheep_recovery 0
 
+$COLLIE 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 c0ccab7..e9b3d5c 100755
--- a/tests/functional/034
+++ b/tests/functional/034
@@ -20,7 +20,7 @@ _cluster_format
 $COLLIE vdi create test 100MB
 # create 25 objects
 for i in `seq 0 24`; do
-    echo $i | $COLLIE 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)) | $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $(($i + 100)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 $COLLIE vdi read test | md5sum
diff --git a/tests/functional/035 b/tests/functional/035
index b1bffab..585765a 100755
--- a/tests/functional/035
+++ b/tests/functional/035
@@ -23,7 +23,7 @@ _wait_for_sheep 6
 _cluster_format -c 3
 
 $COLLIE vdi create test 40M
-_random | $COLLIE vdi write test &
+_random | _vdi_write test &
 
 sleep 3
 # Test write timeout
diff --git a/tests/functional/039 b/tests/functional/039
index 74bf2e1..7c78232 100755
--- a/tests/functional/039
+++ b/tests/functional/039
@@ -13,37 +13,37 @@ _wait_for_sheep 5
 _cluster_format
 $COLLIE 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 | _filter_qemu_io
 $COLLIE 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 | _filter_qemu_io
 
 echo yes | $COLLIE 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 | _filter_qemu_io
 $COLLIE 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 | _filter_qemu_io
 $COLLIE 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 | _filter_qemu_io
 
 echo yes | $COLLIE 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 | _filter_qemu_io
 $COLLIE vdi tree | _filter_short_date
 _vdi_list
 
 echo yes | $COLLIE 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 | _filter_qemu_io
 $COLLIE vdi tree | _filter_short_date
 _vdi_list
 
 echo yes | $COLLIE 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 | _filter_qemu_io
 $COLLIE 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 | _filter_qemu_io
 $COLLIE 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 | _filter_qemu_io
 $COLLIE vdi snapshot test -s snap4
 
 # these fail since the snap ids don't belong to snapshots
@@ -51,6 +51,6 @@ echo yes | $COLLIE vdi rollback test -s 0
 echo yes | $COLLIE vdi rollback test -s 5
 
 echo yes | $COLLIE 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 | _filter_qemu_io
 $COLLIE vdi tree | _filter_short_date
 _vdi_list
diff --git a/tests/functional/041 b/tests/functional/041
index f72708d..7af17b5 100755
--- a/tests/functional/041
+++ b/tests/functional/041
@@ -14,15 +14,15 @@ _cluster_format
 $COLLIE vdi create test 12M
 
 # create the first object
-echo 0 | $COLLIE vdi write test 0 512
+echo 0 | _vdi_write test 0 512
 $COLLIE vdi snapshot test -s snap1
 
 # create the second object
-echo 1 | $COLLIE vdi write test $((4 * 1024 * 1024)) 512
+echo 1 | _vdi_write test $((4 * 1024 * 1024)) 512
 $COLLIE vdi snapshot test -s snap2
 
 # update the first object
-echo 2 | $COLLIE vdi write test 0 512
+echo 2 | _vdi_write test 0 512
 $COLLIE vdi snapshot test -s snap3
 
 # check vdis
diff --git a/tests/functional/042 b/tests/functional/042
index d2e2b66..445addb 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 | $COLLIE vdi write test0 $((i * 4 * 1024 * 1024)) 512 -p 7000
-    echo $i | $COLLIE 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 d8c7ca5..8bef984 100755
--- a/tests/functional/043
+++ b/tests/functional/043
@@ -17,7 +17,7 @@ _cluster_format
 $COLLIE vdi create test 40M
 
 for i in `seq 0 10`; do
-    echo $i | $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $i | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 for i in 0 1 2 3 4; do
@@ -29,7 +29,7 @@ done
 _safe_remove $STORE/4/obj
 
 for i in `seq 0 10`; do
-    echo $(($i + 100)) | $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $(($i + 100)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 for i in 0 1 2 3 4; do
@@ -41,7 +41,7 @@ done
 _kill_sheep 3
 
 for i in `seq 0 10`; do
-    echo $(($i + 200)) | $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512
+    echo $(($i + 200)) | _vdi_write test $((i * 4 * 1024 * 1024)) 512
 done
 
 for i in 0 1 2 4; do
@@ -58,4 +58,4 @@ done
 
 # check whether we can write to a gateway after EIO
 _safe_remove $STORE/0/obj
-echo hello | $COLLIE vdi write test 0 512
+echo hello | _vdi_write test 0 512
diff --git a/tests/functional/044 b/tests/functional/044
index 75a427c..c2e3a1a 100755
--- a/tests/functional/044
+++ b/tests/functional/044
@@ -16,15 +16,15 @@ $COLLIE vdi create base2 20M -p 7001
 $COLLIE vdi create base3 20M -p 7002
 
 for i in `seq 0 4`; do
-    echo $i | $COLLIE 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 | $COLLIE 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 | $COLLIE 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 d8f6583..722f860 100755
--- a/tests/functional/045
+++ b/tests/functional/045
@@ -14,7 +14,7 @@ _cluster_format -c 2
 $COLLIE vdi create test 4M
 
 for i in `seq 0 7`; do
-    echo $i | $COLLIE 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 feda20b..763420a 100755
--- a/tests/functional/047
+++ b/tests/functional/047
@@ -13,8 +13,10 @@ _cluster_format -c 1
 $COLLIE vdi create test 4G
 
 # write something to vdi 'test'
-echo "hello" | $COLLIE vdi write test 0 512
-echo "sheepdog" | $COLLIE vdi write test 4M 512
+echo "hello" | _vdi_write test 0 512
+echo "sheepdog" | _vdi_write test 4M 512
+$COLLIE vdi cache flush test
+
 # corrupt the vdi...
 _kill_sheep 0
 if $MD; then
diff --git a/tests/functional/048 b/tests/functional/048
index 8f2d190..535ff87 100755
--- a/tests/functional/048
+++ b/tests/functional/048
@@ -16,7 +16,7 @@ _cluster_format
 
 $COLLIE vdi create test 1G
 
-echo hello | $COLLIE vdi write test 4M 512
+echo hello | _vdi_write test 4M 512
 # kill the master gracefully
 $COLLIE node kill 0
 sleep 2
diff --git a/tests/functional/049 b/tests/functional/049
index bcc1025..a47b7cc 100755
--- a/tests/functional/049
+++ b/tests/functional/049
@@ -13,7 +13,7 @@ _wait_for_sheep 3
 _cluster_format -c 1
 
 $COLLIE vdi create test 20M
-_random | $COLLIE vdi write -w test
+_random | _vdi_write -w test
 
 $COLLIE cluster shutdown
 _wait_for_sheep_stop
diff --git a/tests/functional/050 b/tests/functional/050
index e479e02..7cb8390 100755
--- a/tests/functional/050
+++ b/tests/functional/050
@@ -23,7 +23,7 @@ _wait_for_sheep 3
 _cluster_format
 
 $COLLIE vdi create test 100M
-dd if=/dev/zero | $COLLIE 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 98f0c0e..b27fe40 100755
--- a/tests/functional/055
+++ b/tests/functional/055
@@ -15,14 +15,14 @@ $COLLIE vdi create test 200M -P
 
 # simulate one disk failure
 _safe_remove $STORE/0/d0
-_random | $COLLIE vdi write test
+_random | _vdi_write test
 _wait_for_sheep_recovery 0
 $COLLIE vdi check test
 $COLLIE cluster info | _filter_cluster_info
 
 # simulate multiple disk failure
 _safe_remove $STORE/1/d0
-_random | $COLLIE vdi write test &
+_random | _vdi_write test &
 sleep 1
 _safe_remove $STORE/1/d1
 _wait_for_sheep_recovery 0
@@ -32,13 +32,13 @@ $COLLIE cluster info | _filter_cluster_info
 
 # simulate all disks failure
 _safe_remove $STORE/1/d2
-_random | $COLLIE vdi write test
+_random | _vdi_write test
 $COLLIE vdi check test
 $COLLIE cluster info | _filter_cluster_info
 
 # simulate simultaneous multiple disks failure
 _safe_remove $STORE/2/d0
 _safe_remove $STORE/2/d1
-dd if=/dev/zero | $COLLIE vdi write test
+dd if=/dev/zero | _vdi_write test
 $COLLIE vdi check test
 $COLLIE cluster info | _filter_cluster_info
diff --git a/tests/functional/056 b/tests/functional/056
index e04b365..2f7a237 100755
--- a/tests/functional/056
+++ b/tests/functional/056
@@ -16,7 +16,7 @@ $COLLIE vdi create test 200M -P
 # node event after disk failure
 _safe_remove $STORE/0/d0
 
-_random | $COLLIE vdi write test &
+_random | _vdi_write test &
 sleep 1
 _start_sheep 3
 _wait_for_sheep 4
@@ -27,7 +27,7 @@ $COLLIE cluster info | _filter_cluster_info
 
 # disk failures after node event
 _safe_remove $STORE/1/d0
-dd if=/dev/zero | $COLLIE 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 53393c0..d1a7abc 100755
--- a/tests/functional/058
+++ b/tests/functional/058
@@ -9,8 +9,8 @@ done
 _wait_for_sheep 3
 _cluster_format
 $COLLIE vdi create test 100M
-dd if=/dev/zero | $COLLIE 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 | _filter_qemu_io
 $COLLIE vdi check test
 for i in `seq 0 24`; do
 	$COLLIE vdi object test -i $i;
diff --git a/tests/functional/059 b/tests/functional/059
index 3c133ec..1993f8b 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
 $COLLIE vdi tree | _filter_short_date
diff --git a/tests/functional/060 b/tests/functional/060
index b5c1384..0088895 100755
--- a/tests/functional/060
+++ b/tests/functional/060
@@ -15,7 +15,7 @@ for i in `seq 0 3`; do
     $COLLIE vdi create test$i 100M
 
     for j in `seq 0 24`; do
-	echo "$i $j" | $COLLIE vdi write test$i $(($j * 4 * 1024 ** 2)) 512
+	echo "$i $j" | _vdi_write test$i $(($j * 4 * 1024 ** 2)) 512
     done &
 done
 wait
diff --git a/tests/functional/062 b/tests/functional/062
index 6bd84ee..214ebcb 100755
--- a/tests/functional/062
+++ b/tests/functional/062
@@ -16,17 +16,17 @@ $COLLIE vdi create test 1234
 sleep 1
 $COLLIE vdi list -r test | awk '{$7="MASKED";print $0}'
 
-echo hello | $COLLIE vdi write test 1 6
+echo hello | _vdi_write test 1 6
 $COLLIE vdi read test 1 6
-echo world | $COLLIE vdi write test 1 6
+echo world | _vdi_write test 1 6
 $COLLIE vdi read test 1 6
 
-echo h*** | $COLLIE vdi write test 510 512
-echo h!!! | $COLLIE vdi write test 510 512
+echo h*** | _vdi_write test 510 512
+echo h!!! | _vdi_write test 510 512
 $COLLIE vdi read test 510 5
-echo ^^ | $COLLIE vdi write test 511 2
+echo ^^ | _vdi_write test 511 2
 $COLLIE vdi read test 510 5
-echo xxx | $COLLIE vdi write test 1020 4
+echo xxx | _vdi_write test 1020 4
 $COLLIE vdi read test 1020 4
 $COLLIE vdi read test 510 5
 $COLLIE vdi read test 1 6
diff --git a/tests/functional/065 b/tests/functional/065
index 388d7e8..848e742 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 | $COLLIE vdi write -w t &
+dd if=/dev/zero | _vdi_write -w t &
 
 _wait_for_sheep_recovery 1
 wait
diff --git a/tests/functional/066 b/tests/functional/066
index 1a36492..09de389 100755
--- a/tests/functional/066
+++ b/tests/functional/066
@@ -15,9 +15,9 @@ $COLLIE vdi create t 300M -P
 $COLLIE vdi create t0 300M -P
 $COLLIE vdi create t1 300M -P
 
-dd if=/dev/zero | $COLLIE vdi write -w t &
+dd if=/dev/zero | _vdi_write -w t &
 for j in 0 1; do
-    dd if=/dev/zero | $COLLIE vdi write -w t$j -p 700$j &
+    dd if=/dev/zero | _vdi_write -w t$j -p 700$j &
 done
 
 for i in `seq 3 7`; do
diff --git a/tests/functional/071 b/tests/functional/071
index acf8b9f..b4dac8a 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 \
-		| $COLLIE vdi write test $offset $length
+		| _vdi_write test $offset $length
 
 	    $COLLIE vdi read test $offset $length | hd
 	done
diff --git a/tests/functional/check b/tests/functional/check
index 5addc23..aefc7a2 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 db7d757..21286a5 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 COLLIE_PROG=${COLLIE_PROG:-../../collie/collie}
 export COLLIE=${COLLIE:-$COLLIE_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 d506224..2c30d75 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()
 	$COLLIE vdi list $args | _filter_short_date
 }
 
+_vdi_write()
+{
+    local opts=""
+
+    if [ "$CACHE" = "writeback" ]; then
+	opts="-w"
+    fi
+    $COLLIE vdi write $opts "$@"
+}
+
+_qemu_io()
+{
+    local opts=""
+
+    if [ "$CACHE" != "" ]; then
+	opts="-t $CACHE"
+    fi
+
+    $QEMU_IO $opts "$@"
+}
+
 # make sure this script returns success
 /bin/true
-- 
1.7.9.5




More information about the sheepdog mailing list