Run using "./check" in the test directory, individual tests can be run using "./check 003", various other options are also supported. Test 002 is disable for now due to the lack of golden output, cluster drivers other than local aren't tested at the moment but will be supported soon. Signed-off-by: Christoph Hellwig <hch at lst.de> diff --git a/tests/001 b/tests/001 new file mode 100755 index 0000000..1a5749e --- /dev/null +++ b/tests/001 @@ -0,0 +1,55 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in 0 1; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +# start Sheepdog with two nodes +$COLLIE cluster format + +# kill the master node +pkill -f "sheep $STORE/0" +sleep 1 + +# start another sheep +$SHEEP $STORE/2 -z 2 -p 7002 -c $DRIVER +sleep 1 + +# kill all sheeps +for i in 1 2; do + pkill -f "sheep $STORE/$i" + sleep 1 +done + +for i in 0 1 2; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +echo check whether Sheepdog is running with only one node +$COLLIE cluster info -p 7002 | _filter_cluster_info + +# add the other nodes +for i in 0 1; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +echo check whether all nodes have the same cluster info +for i in 0 1 2; do + $COLLIE cluster info -p 700$i | _filter_cluster_info +done diff --git a/tests/001.out b/tests/001.out new file mode 100644 index 0000000..f548cf2 --- /dev/null +++ b/tests/001.out @@ -0,0 +1,46 @@ +QA output created by 001 +using backend farm store +check whether Sheepdog is running with only one node +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [] +DATE 1 [] +check whether all nodes have the same cluster info +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 6 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002] +DATE 5 [127.0.0.1:7000, 127.0.0.1:7002] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 6 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002] +DATE 5 [127.0.0.1:7000, 127.0.0.1:7002] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 6 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002] +DATE 5 [127.0.0.1:7000, 127.0.0.1:7002] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] diff --git a/tests/002 b/tests/002 new file mode 100755 index 0000000..4fe52dd --- /dev/null +++ b/tests/002 @@ -0,0 +1,48 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in 0 1 2; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +# start Sheepdog with three nodes +$COLLIE cluster format + +# kill all sheeps +for i in 0 1 2; do + pkill -f "sheep $STORE/$i" + sleep 1 +done + +# master transfer will happen once +for i in 1 0 2; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +echo check whether Sheepdog is running with only one node +$COLLIE cluster info -p 7002 | _filter_cluster_info + +# add the other nodes +for i in 0 1; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +echo check whether all nodes have the same cluster info +for i in 0 1 2; do + $COLLIE cluster info -p 700$i | _filter_cluster_info +done diff --git a/tests/003 b/tests/003 new file mode 100755 index 0000000..a1b9027 --- /dev/null +++ b/tests/003 @@ -0,0 +1,48 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in 0 1 2; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +# start Sheepdog with three nodes +$COLLIE cluster format + +# kill all sheeps +for i in 0 1 2; do + pkill -f "sheep $STORE/$i" + sleep 1 +done + +# master transfer will happen twice +for i in 0 1 2; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +echo check whether Sheepdog is running with only one node +$COLLIE cluster info -p 7002 | _filter_cluster_info + +# add the other nodes +for i in 0 1; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +echo check whether all nodes have the same cluster info +for i in 0 1 2; do + $COLLIE cluster info -p 700$i | _filter_cluster_info +done diff --git a/tests/003.out b/tests/003.out new file mode 100644 index 0000000..1c2b9c8 --- /dev/null +++ b/tests/003.out @@ -0,0 +1,42 @@ +QA output created by 003 +using backend farm store +check whether Sheepdog is running with only one node +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 3 [127.0.0.1:7002] +DATE 2 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002] +check whether all nodes have the same cluster info +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 5 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002] +DATE 4 [127.0.0.1:7000, 127.0.0.1:7002] +DATE 3 [127.0.0.1:7002] +DATE 2 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 5 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002] +DATE 4 [127.0.0.1:7000, 127.0.0.1:7002] +DATE 3 [127.0.0.1:7002] +DATE 2 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 5 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002] +DATE 4 [127.0.0.1:7000, 127.0.0.1:7002] +DATE 3 [127.0.0.1:7002] +DATE 2 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002] diff --git a/tests/004 b/tests/004 new file mode 100755 index 0000000..0e1ee47 --- /dev/null +++ b/tests/004 @@ -0,0 +1,56 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in 0 1; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +# start Sheepdog with two nodes +$COLLIE cluster format -c 2 + +for i in 2 3 4; do + # add one node after killing existing one node + pkill -f "sheep $STORE/$((i - 2))" + sleep 1 + + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +# kill all existing nodes +for i in 3 4; do + pkill -f "sheep $STORE/$i" + sleep 1 +done + +for i in 0 1 2 3 4; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +echo check whether Sheepdog is running with only one node +$COLLIE cluster info -p 7004 | _filter_cluster_info + +# add the other nodes +for i in 0 1 2 3; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +echo check whether all nodes have the same cluster info +for i in 0 1 2 3 4; do + $COLLIE cluster info -p 700$i | _filter_cluster_info +done diff --git a/tests/004.out b/tests/004.out new file mode 100644 index 0000000..a2cc2e0 --- /dev/null +++ b/tests/004.out @@ -0,0 +1,102 @@ +QA output created by 004 +using backend farm store +check whether Sheepdog is running with only one node +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 8 [127.0.0.1:7004] +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [] +DATE 5 [] +DATE 4 [] +DATE 3 [] +DATE 2 [] +DATE 1 [] +check whether all nodes have the same cluster info +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 12 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 11 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7004] +DATE 10 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7004] +DATE 9 [127.0.0.1:7000, 127.0.0.1:7004] +DATE 8 [127.0.0.1:7004] +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 12 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 11 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7004] +DATE 10 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7004] +DATE 9 [127.0.0.1:7000, 127.0.0.1:7004] +DATE 8 [127.0.0.1:7004] +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 12 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 11 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7004] +DATE 10 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7004] +DATE 9 [127.0.0.1:7000, 127.0.0.1:7004] +DATE 8 [127.0.0.1:7004] +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 12 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 11 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7004] +DATE 10 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7004] +DATE 9 [127.0.0.1:7000, 127.0.0.1:7004] +DATE 8 [127.0.0.1:7004] +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 12 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 11 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7004] +DATE 10 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7004] +DATE 9 [127.0.0.1:7000, 127.0.0.1:7004] +DATE 8 [127.0.0.1:7004] +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] diff --git a/tests/005 b/tests/005 new file mode 100755 index 0000000..c448a0a --- /dev/null +++ b/tests/005 @@ -0,0 +1,54 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in 0 1; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +# start Sheepdog with two nodes +$COLLIE cluster format -c 1 +sleep 1 + +for i in 2 3 4; do + pkill -f "sheep $STORE/$((i - 2))" + sleep 1 + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +$COLLIE cluster shutdown -p 7004 +sleep 1 + +for i in 0 1 2 3 4; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +echo check whether Sheepdog is working with two nodes +for i in 3 4; do + $COLLIE cluster info -p 700$i | _filter_cluster_info +done + +# add the other nodes +for i in 0 1 2; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER + sleep 1 +done + +echo check whether all nodes have the same cluster info +for i in 0 1 2 3 4; do + $COLLIE cluster info -p 700$i | _filter_cluster_info +done diff --git a/tests/005.out b/tests/005.out new file mode 100644 index 0000000..1cc8369 --- /dev/null +++ b/tests/005.out @@ -0,0 +1,103 @@ +QA output created by 005 +using backend farm store +check whether Sheepdog is working with two nodes +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [] +DATE 3 [] +DATE 2 [] +DATE 1 [] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [] +DATE 3 [] +DATE 2 [] +DATE 1 [] +check whether all nodes have the same cluster info +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 10 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 9 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 8 [127.0.0.1:7000, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 10 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 9 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 8 [127.0.0.1:7000, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 10 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 9 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 8 [127.0.0.1:7000, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 10 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 9 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 8 [127.0.0.1:7000, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] +Cluster status: running + +Cluster created at DATE + +Epoch Time Version +DATE 10 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 9 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 8 [127.0.0.1:7000, 127.0.0.1:7003, 127.0.0.1:7004] +DATE 7 [127.0.0.1:7003, 127.0.0.1:7004] +DATE 6 [127.0.0.1:7003] +DATE 5 [127.0.0.1:7002, 127.0.0.1:7003] +DATE 4 [127.0.0.1:7002] +DATE 3 [127.0.0.1:7001, 127.0.0.1:7002] +DATE 2 [127.0.0.1:7001] +DATE 1 [127.0.0.1:7000, 127.0.0.1:7001] diff --git a/tests/006 b/tests/006 new file mode 100755 index 0000000..024804d --- /dev/null +++ b/tests/006 @@ -0,0 +1,36 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +$SHEEP $STORE/0 -z 0 -p 7000 -c $DRIVER +sleep 1 + +# start Sheepdog with one node +$COLLIE cluster format +sleep 1 + +# launch sheeps simultaneously +for i in `seq 1 9`; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER +done + +sleep 1 + +echo check whether all nodes have the same cluster info +for i in `seq 0 9`; do + $COLLIE cluster info -p 700$i | _filter_cluster_info > /tmp/cinfo.$i +done +for i in `seq 1 9`; do + diff -u /tmp/cinfo.0 /tmp/cinfo.$i +done diff --git a/tests/006.out b/tests/006.out new file mode 100644 index 0000000..251372f --- /dev/null +++ b/tests/006.out @@ -0,0 +1,3 @@ +QA output created by 006 +using backend farm store +check whether all nodes have the same cluster info diff --git a/tests/007 b/tests/007 new file mode 100755 index 0000000..808c1e5 --- /dev/null +++ b/tests/007 @@ -0,0 +1,45 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + + +# create a node who has wrong epoch +$SHEEP $STORE/1 -p 7001 -z 1 -c $DRIVER +sleep 1 +$COLLIE cluster format -p 7001 -c 1 +$COLLIE cluster shutdown -p 7001 +sleep 1 + +# start Sheepdog with one node +$SHEEP $STORE/0 -p 7000 -z 0 -c $DRIVER +sleep 1 +$COLLIE cluster format -p 7000 -c 1 + +for i in `seq 0 5`; do + $SHEEP $STORE/1 -p 7001 -z 1 -c $DRIVER # should fail + $SHEEP $STORE/2 -p 7002 -z 2 -c $DRIVER # should succeed + sleep 1 + + if [ "`$COLLIE node list -p 7002 -r | wc -l`" -ne 2 ]; then + echo "test failed" + $COLLIE cluster info -p 7000 | _filter_cluster_info + $COLLIE cluster info -p 7002 | _filter_cluster_info + exit 1 + fi + + pkill -f "$SHEEP $STORE/2" + sleep 1 +done + +echo "success" diff --git a/tests/007.out b/tests/007.out new file mode 100644 index 0000000..91770f3 --- /dev/null +++ b/tests/007.out @@ -0,0 +1,4 @@ +QA output created by 007 +using backend farm store +using backend farm store +success diff --git a/tests/008 b/tests/008 new file mode 100755 index 0000000..a78a156 --- /dev/null +++ b/tests/008 @@ -0,0 +1,66 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in `seq 0 7`; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER +done + +while true; do + sleep 2 + if [ $($COLLIE node list | wc -l) -eq 9 ]; then + break + fi +done + +$COLLIE cluster format -c 3 +sleep 1 + +for i in `seq 0 4`; do + $COLLIE vdi create test$i 100M +done + +for i in `seq 0 4`; do + dd if=/dev/urandom | $COLLIE vdi write test$i -p 7000 & +done + +sleep 3 + +echo begin kill +for i in `seq 1 5`; do + pkill -f "$SHEEP $STORE/$i -z $i -p 700$i" + sleep 3 +done + +for i in `seq 1 5`; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER +done + +echo wait for object recovery to finish +while true; do + if [ "$(pgrep collie)" ]; then + sleep 1 + else + break + fi +done + +for i in `seq 0 4`; do + for port in `seq 0 7`; do + $COLLIE vdi read test$i -p 700$port | md5sum > /tmp/csum.$port + done + for port in `seq 1 7`; do + diff -u /tmp/csum.0 /tmp/csum.$port + done +done diff --git a/tests/008.out b/tests/008.out new file mode 100644 index 0000000..54f0186 --- /dev/null +++ b/tests/008.out @@ -0,0 +1,4 @@ +QA output created by 008 +using backend farm store +begin kill +wait for object recovery to finish diff --git a/tests/009 b/tests/009 new file mode 100755 index 0000000..5aa821e --- /dev/null +++ b/tests/009 @@ -0,0 +1,45 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +# start three sheep daemons +for i in 0 1 2; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER +done + +sleep 1 +$COLLIE cluster format -c 2 + +# create a pre-allocated vdi +$COLLIE vdi create test 80M -P + +# stop the 3rd node +pkill -f "$SHEEP $STORE/2" + +# write data to the vdi +cat /dev/urandom | $COLLIE vdi write test + +# restart the 3rd node +$SHEEP $STORE/2 -z 2 -p 7002 -c $DRIVER + +# wait for object recovery to finish +sleep 10 + +# show md5sum of the vdi on each node +for i in 0 1 2; do + $COLLIE vdi read test -p 700$i | md5sum > /tmp/csum.$i +done + +diff -u /tmp/csum.0 /tmp/csum.1 +diff -u /tmp/csum.0 /tmp/csum.2 diff --git a/tests/009.out b/tests/009.out new file mode 100644 index 0000000..0664a8d --- /dev/null +++ b/tests/009.out @@ -0,0 +1,2 @@ +QA output created by 009 +using backend farm store diff --git a/tests/010 b/tests/010 new file mode 100755 index 0000000..093ac0c --- /dev/null +++ b/tests/010 @@ -0,0 +1,36 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +$SHEEP $STORE/0 -z 0 -p 7000 -c $DRIVER +$SHEEP $STORE/1 -z 1 -p 7001 -c $DRIVER + +sleep 2 + +$COLLIE cluster format -c 2 +$COLLIE cluster recover disable + +qemu-img create sheepdog:test 4G + +# create 20 objects +for i in `seq 0 19`; do + $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512 < /dev/zero +done + +$SHEEP $STORE/2 -z 2 -p 7002 -c $DRIVER + +# overwrite the objects +for i in `seq 0 19`; do + $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512 < /dev/zero +done diff --git a/tests/010.out b/tests/010.out new file mode 100644 index 0000000..01cc1bf --- /dev/null +++ b/tests/010.out @@ -0,0 +1,5 @@ +QA output created by 010 +using backend farm store +*Note*: Only disable the recovery caused by JOIN envets +Cluster recovery: disable +Formatting 'sheepdog:test', fmt=raw size=4294967296 diff --git a/tests/011 b/tests/011 new file mode 100755 index 0000000..973279e --- /dev/null +++ b/tests/011 @@ -0,0 +1,46 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +trap "_cleanup_devices; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup_devices() +{ + killall -9 sheep collie >/dev/null 2>&1 || true + sleep 2 + for i in 0 1 2; do + umount $STORE/$i.img + rm -f $STORE/$i.img + done +} + +_cleanup + +dd if=/dev/zero of=$STORE/0.img seek=$((2 * 1024 ** 3 - 1)) bs=1 count=1 > $seq.full 2>&1 +dd if=/dev/zero of=$STORE/1.img seek=$((4 * 1024 ** 3 - 1)) bs=1 count=1 > $seq.full 2>&1 +dd if=/dev/zero of=$STORE/2.img seek=$((8 * 1024 ** 3 - 1)) bs=1 count=1 > $seq.full 2>&1 + +for i in 0 1 2; do + mkfs.xfs -f $STORE/$i.img > $seq.full + mkdir $STORE/$i + mount -o loop $STORE/$i.img $STORE/$i + $SHEEP $STORE/$i/ -z $i -p 700$i -c $DRIVER +done + +sleep 1 + +echo check the number of vnodes +for i in 0 1 2; do + $COLLIE node list -p 700$i +done + +status=0 diff --git a/tests/011.out b/tests/011.out new file mode 100644 index 0000000..2ecd3d7 --- /dev/null +++ b/tests/011.out @@ -0,0 +1,14 @@ +QA output created by 011 +check the number of vnodes +M Id Host:Port V-Nodes Zone +- 0 127.0.0.1:7000 27 0 +- 1 127.0.0.1:7001 54 1 +- 2 127.0.0.1:7002 110 2 +M Id Host:Port V-Nodes Zone +- 0 127.0.0.1:7000 27 0 +- 1 127.0.0.1:7001 54 1 +- 2 127.0.0.1:7002 110 2 +M Id Host:Port V-Nodes Zone +- 0 127.0.0.1:7000 27 0 +- 1 127.0.0.1:7001 54 1 +- 2 127.0.0.1:7002 110 2 diff --git a/tests/012 b/tests/012 new file mode 100755 index 0000000..f558241 --- /dev/null +++ b/tests/012 @@ -0,0 +1,26 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in 0 1 2; do + $SHEEP $STORE/$i/ -z $i -p 700$i -c $DRIVER +done + +# add gateway node +$SHEEP $STORE/4/ -z 4 -p 7004 -c $DRIVER -g + +sleep 1 + +echo check the number of vnodes +$COLLIE node list diff --git a/tests/012.out b/tests/012.out new file mode 100644 index 0000000..377904b --- /dev/null +++ b/tests/012.out @@ -0,0 +1,7 @@ +QA output created by 012 +check the number of vnodes +M Id Host:Port V-Nodes Zone +- 0 127.0.0.1:7000 64 0 +- 1 127.0.0.1:7001 64 1 +- 2 127.0.0.1:7002 64 2 +- 3 127.0.0.1:7004 0 4 diff --git a/tests/013 b/tests/013 new file mode 100755 index 0000000..b55ccae --- /dev/null +++ b/tests/013 @@ -0,0 +1,33 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in 0 1 2; do + $SHEEP $STORE/$i -p 700$i -z $i -c $DRIVER +done + +sleep 1 + +$COLLIE 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-img snapshot -c tag$i sheepdog:test +done + +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 +done diff --git a/tests/013.out b/tests/013.out new file mode 100644 index 0000000..467db8b --- /dev/null +++ b/tests/013.out @@ -0,0 +1,41 @@ +QA output created by 013 +using backend farm store +Formatting 'sheepdog:test', fmt=raw size=4294967296 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) diff --git a/tests/014 b/tests/014 new file mode 100755 index 0000000..03b4e6d --- /dev/null +++ b/tests/014 @@ -0,0 +1,38 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in 0 2; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER +done + +sleep 1 + +$COLLIE cluster format -c 2 >> $0.full +$COLLIE vdi create test 4G + +echo -n value > $STORE/tmp.dat + +echo "key shouldn't be found" +$COLLIE vdi getattr test key + +$COLLIE vdi setattr test key value +$COLLIE vdi getattr test key | diff - $STORE/tmp.dat + +$COLLIE vdi setattr test key value -d + +echo "key shouldn't be found" +$COLLIE vdi getattr test key + +status=0 diff --git a/tests/014.out b/tests/014.out new file mode 100644 index 0000000..0ea417e --- /dev/null +++ b/tests/014.out @@ -0,0 +1,5 @@ +QA output created by 014 +key shouldn't be found +Attribute 'key' not found +key shouldn't be found +Attribute 'key' not found diff --git a/tests/015 b/tests/015 new file mode 100755 index 0000000..09a526c --- /dev/null +++ b/tests/015 @@ -0,0 +1,57 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in 0 2; do + $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER +done + +sleep 1 + +$COLLIE cluster format -c 2 +$COLLIE vdi create test 539545600 +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi write test 512 512 < /dev/zero +echo "there should be 3 setattr errors" + +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi write test 512 512 < /dev/zero +echo "there should be 8 setattr errors" + +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi write test 512 512 < /dev/zero +echo "there should be 6 setattr errors" + +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi setattr test lock 1 -x & +$COLLIE vdi write test 512 512 < /dev/zero +echo "there should be 5 setattr errors" diff --git a/tests/015.out b/tests/015.out new file mode 100644 index 0000000..ca5c3f4 --- /dev/null +++ b/tests/015.out @@ -0,0 +1,28 @@ +QA output created by 015 +using backend farm store +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +there should be 3 setattr errors +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +there should be 8 setattr errors +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +there should be 6 setattr errors +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +The attribute 'lock' already exists +there should be 5 setattr errors diff --git a/tests/016 b/tests/016 new file mode 100755 index 0000000..7aac223 --- /dev/null +++ b/tests/016 @@ -0,0 +1,46 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in 0 1 2; do + $SHEEP $STORE/$i -p 700$i -z $i -c $DRIVER +done + +sleep 1; + +$COLLIE cluster format -c 3 +$COLLIE vdi create base 100M -P + +qemu-img snapshot -c tag sheepdog:base + +sleep 1 + +$COLLIE vdi clone -s 1 base test + +sleep 1 + +$COLLIE vdi delete test + +sleep 1 +$COLLIE vdi delete base + +sleep 1 +$COLLIE vdi delete -s 1 base + +sleep 3 +echo there should be no vdi +$COLLIE vdi list + +echo there should be no object +$COLLIE node info diff --git a/tests/016.out b/tests/016.out new file mode 100644 index 0000000..ab894f4 --- /dev/null +++ b/tests/016.out @@ -0,0 +1,12 @@ +QA output created by 016 +using backend farm store +there should be no vdi + Name Id Size Used Shared Creation time VDI id Tag +there should be no object +Id Size Used Use% + 0 4.0 GB 12 MB 0% + 1 4.0 GB 12 MB 0% + 2 4.0 GB 12 MB 0% +Total 12 GB 36 MB 0% + +Total virtual image size 0.0 MB diff --git a/tests/017 b/tests/017 new file mode 100755 index 0000000..73bb07a --- /dev/null +++ b/tests/017 @@ -0,0 +1,35 @@ +#!/bin/bash + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_cleanup + +for i in 0 1 2; do + $SHEEP $STORE/$i -p 700$i -z $i -c $DRIVER +done + +sleep 1 + +$COLLIE cluster format -c 1 + +qemu-img create sheepdog:test 4G +qemu-img snapshot -c tag1 sheepdog:test +qemu-img snapshot -c tag2 sheepdog:test +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-img snapshot -c tag3 sheepdog:test2 + +$COLLIE vdi tree | _filter_short_date diff --git a/tests/017.out b/tests/017.out new file mode 100644 index 0000000..f0d1897 --- /dev/null +++ b/tests/017.out @@ -0,0 +1,9 @@ +QA output created by 017 +using backend farm store +Formatting 'sheepdog:test', fmt=raw size=4294967296 +Formatting 'sheepdog:test2', fmt=raw size=4294967296 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +test---[DATE]---[DATE]---[DATE]---(you are here) +test2---[DATE]-+-[DATE]---[DATE] + `-[DATE]---(you are here) diff --git a/tests/check b/tests/check new file mode 100755 index 0000000..cf5e0ef --- /dev/null +++ b/tests/check @@ -0,0 +1,492 @@ +#!/bin/bash +# +# Copyright (C) 2009 Red Hat, Inc. +# Copyright (c) 2000-2002,2005-2006 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# +# Control script for QA +# + +tmp=/tmp/$$ +status=0 +needwrap=true +try=0 +n_bad=0 +bad="" +notrun="" +interrupt=true + +# by default don't output timestamps +timestamp=${TIMESTAMP:=false} + +# generic initialization +iam=check + +# we need common.config +if ! . ./common.config +then + echo "$iam: failed to source common.config" + exit 1 +fi + +_setenvironment() +{ + MSGVERB="text:action" + export MSGVERB +} + +here=`pwd` +rm -f $here/$iam.out +_setenvironment + +check=${check-true} + +diff="diff -u" +verbose=false +group=false +xgroup=false +showme=false +sortme=false +expunge=true +have_test_arg=false +randomize=false +rm -f $tmp.list $tmp.tmp $tmp.sed + +for r +do + + if $group + then + # arg after -g + group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ +s/ .*//p +}'` + if [ -z "$group_list" ] + then + echo "Group \"$r\" is empty or not defined?" + exit 1 + fi + [ ! -s $tmp.list ] && touch $tmp.list + for t in $group_list + do + if grep -s "^$t\$" $tmp.list >/dev/null + then + : + else + echo "$t" >>$tmp.list + fi + done + group=false + continue + + elif $xgroup + then + # arg after -x + [ ! -s $tmp.list ] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list 2>/dev/null + group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ +s/ .*//p +}'` + if [ -z "$group_list" ] + then + echo "Group \"$r\" is empty or not defined?" + exit 1 + fi + numsed=0 + rm -f $tmp.sed + for t in $group_list + do + if [ $numsed -gt 100 ] + then + sed -f $tmp.sed <$tmp.list >$tmp.tmp + mv $tmp.tmp $tmp.list + numsed=0 + rm -f $tmp.sed + fi + echo "/^$t\$/d" >>$tmp.sed + numsed=`expr $numsed + 1` + done + sed -f $tmp.sed <$tmp.list >$tmp.tmp + mv $tmp.tmp $tmp.list + xgroup=false + continue + fi + + xpand=true + case "$r" + in + + -\? | -h | --help) # usage + echo "Usage: $0 [options] [testlist]"' + +common options + -v verbose + +check options + -sheepdog test sheepdog + -xdiff graphical mode diff + -n show me, do not run tests + -T output timestamps + -r randomize test order + +testlist options + -g group[,group...] include tests from these groups + -x group[,group...] exclude tests from these groups + NNN include test NNN + NNN-NNN include test range (eg. 012-021) +' + exit 0 + ;; + + -g) # -g group ... pick from group file + group=true + xpand=false + ;; + + -xdiff) # graphical diff mode + xpand=false + + if [ ! -z "$DISPLAY" ] + then + which xdiff >/dev/null 2>&1 && diff=xdiff + which gdiff >/dev/null 2>&1 && diff=gdiff + which tkdiff >/dev/null 2>&1 && diff=tkdiff + which xxdiff >/dev/null 2>&1 && diff=xxdiff + fi + ;; + + -n) # show me, don't do it + showme=true + xpand=false + ;; + -r) # randomize test order + randomize=true + xpand=false + ;; + + -T) # turn on timestamp output + timestamp=true + xpand=false + ;; + + -v) + verbose=true + xpand=false + ;; + -x) # -x group ... exclude from group file + xgroup=true + xpand=false + ;; + '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]') + echo "No tests?" + status=1 + exit $status + ;; + + [0-9]*-[0-9]*) + eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'` + ;; + + [0-9]*-) + eval `echo $r | sed -e 's/^/start=/' -e 's/-//'` + end=`echo [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //'` + if [ -z "$end" ] + then + echo "No tests in range \"$r\"?" + status=1 + exit $status + fi + ;; + + *) + start=$r + end=$r + ;; + + esac + + # get rid of leading 0s as can be interpreted as octal + start=`echo $start | sed 's/^0*//'` + end=`echo $end | sed 's/^0*//'` + + if $xpand + then + have_test_arg=true + $AWK_PROG </dev/null ' +BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ + | while read id + do + if grep -s "^$id " group >/dev/null + then + # in group file ... OK + echo $id >>$tmp.list + else + if [ -f expunged ] && $expunge && egrep "^$id([ ]|\$)" expunged >/dev/null + then + # expunged ... will be reported, but not run, later + echo $id >>$tmp.list + else + # oops + echo "$id - unknown test, ignored" + fi + fi + done + fi + +done + +if [ -s $tmp.list ] +then + # found some valid test numbers ... this is good + : +else + if $have_test_arg + then + # had test numbers, but none in group file ... do nothing + touch $tmp.list + else + # no test numbers, do everything from group file + sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list + fi +fi + +# should be sort -n, but this did not work for Linux when this +# was ported from IRIX +# +list=`sort $tmp.list` +rm -f $tmp.list $tmp.tmp $tmp.sed + +if $randomize +then + list=`echo $list | awk -f randomize.awk` +fi + +# we need common.rc +if ! . ./common.rc +then + echo "check: failed to source common.rc" + exit 1 +fi + +_wallclock() +{ + date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }' +} + +_timestamp() +{ + now=`date "+%T"` + echo -n " [$now]" +} + +_wrapup() +{ + # for hangcheck ... + # remove files that were used by hangcheck + # + [ -f /tmp/check.pid ] && rm -rf /tmp/check.pid + [ -f /tmp/check.sts ] && rm -rf /tmp/check.sts + + if $showme + then + : + elif $needwrap + then + if [ -f check.time -a -f $tmp.time ] + then + cat check.time $tmp.time \ + | $AWK_PROG ' + { t[$1] = $2 } +END { if (NR > 0) { + for (i in t) print i " " t[i] + } + }' \ + | sort -n >$tmp.out + mv $tmp.out check.time + fi + + if [ -f $tmp.expunged ] + then + notrun=`wc -l <$tmp.expunged | sed -e 's/ *//g'` + try=`expr $try - $notrun` + list=`echo "$list" | sed -f $tmp.expunged` + fi + + echo "" >>check.log + date >>check.log + echo $list | fmt | sed -e 's/^/ /' >>check.log + $interrupt && echo "Interrupted!" >>check.log + + if [ ! -z "$notrun" ] + then + echo "Not run:$notrun" + echo "Not run:$notrun" >>check.log + fi + if [ ! -z "$n_bad" -a $n_bad != 0 ] + then + echo "Failures:$bad" + echo "Failed $n_bad of $try tests" + echo "Failures:$bad" | fmt >>check.log + echo "Failed $n_bad of $try tests" >>check.log + else + echo "Passed all $try tests" + echo "Passed all $try tests" >>check.log + fi + needwrap=false + fi + + rm -f /tmp/*.out /tmp/*.err /tmp/*.time + rm -f /tmp/check.pid /tmp/check.sts + rm -f $tmp.* +} + +trap "_wrapup; exit \$status" 0 1 2 3 15 + +# for hangcheck ... +# Save pid of check in a well known place, so that hangcheck can be sure it +# has the right pid (getting the pid from ps output is not reliable enough). +# +rm -rf /tmp/check.pid +echo $$ >/tmp/check.pid + +# for hangcheck ... +# Save the status of check in a well known place, so that hangcheck can be +# sure to know where check is up to (getting test number from ps output is +# not reliable enough since the trace stuff has been introduced). +# +rm -rf /tmp/check.sts +echo "preamble" >/tmp/check.sts + +# don't leave old full output behind on a clean run +rm -f check.full + +[ -f check.time ] || touch check.time + +FULL_HOST_DETAILS=`_full_platform_details` + +cat <<EOF +PLATFORM -- $FULL_HOST_DETAILS + +EOF + +seq="check" + +[ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG + +for seq in $list +do + err=false + echo -n "$seq" + if [ -n "$TESTS_REMAINING_LOG" ] ; then + sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp + mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG + sync + fi + + if $showme + then + echo + continue + elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null + then + echo " - expunged" + rm -f $seq.out.bad + echo "/^$seq\$/d" >>$tmp.expunged + elif [ ! -f $seq ] + then + echo " - no such test?" + echo "/^$seq\$/d" >>$tmp.expunged + else + # really going to try and run this one + # + rm -f $seq.out.bad + lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time` + if [ "X$lasttime" != X ]; then + echo -n " ${lasttime}s ..." + else + echo -n " " # prettier output with timestamps. + fi + rm -f core $seq.notrun + + # for hangcheck ... + echo "$seq" >/tmp/check.sts + + start=`_wallclock` + $timestamp && echo -n " ["`date "+%T"`"]" + [ ! -x $seq ] && chmod u+x $seq # ensure we can run it + ./$seq >$tmp.out 2>&1 + sts=$? + $timestamp && _timestamp + stop=`_wallclock` + + if [ -f core ] + then + echo -n " [dumped core]" + mv core $seq.core + err=true + fi + + if [ -f $seq.notrun ] + then + $timestamp || echo -n " [not run] " + $timestamp && echo " [not run]" && echo -n " $seq -- " + cat $seq.notrun + notrun="$notrun $seq" + else + if [ $sts -ne 0 ] + then + echo -n " [failed, exit status $sts]" + err=true + fi + if [ ! -f $seq.out ] + then + echo " - no qualified output" + err=true + else + if diff $seq.out $tmp.out >/dev/null 2>&1 + then + echo "" + if $err + then + : + else + echo "$seq `expr $stop - $start`" >>$tmp.time + fi + else + echo " - output mismatch (see $seq.out.bad)" + mv $tmp.out $seq.out.bad + $diff $seq.out $seq.out.bad + err=true + fi + fi + fi + + fi + + # come here for each test, except when $showme is true + # + if $err + then + bad="$bad $seq" + n_bad=`expr $n_bad + 1` + quick=false + fi + [ -f $seq.notrun ] || try=`expr $try + 1` + + seq="after_$seq" +done + +interrupt=false +status=`expr $n_bad` +exit diff --git a/tests/cluster/001.sh b/tests/cluster/001.sh deleted file mode 100755 index 9df1b90..0000000 --- a/tests/cluster/001.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in 0 1; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -# start Sheepdog with two nodes -$COLLIE cluster format - -# kill the master node -pkill -f "sheep $STORE/0" -sleep 1 - -# start another sheep -$SHEEP $STORE/2 -z 2 -p 7002 -c $DRIVER -sleep 1 - -# kill all sheeps -for i in 1 2; do - pkill -f "sheep $STORE/$i" - sleep 1 -done - -for i in 0 1 2; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -echo check whether Sheepdog is running with only one node -$COLLIE cluster info -p 7002 - -# add the other nodes -for i in 0 1; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -echo check whether all nodes have the same cluster info -for i in 0 1 2; do - $COLLIE cluster info -p 700$i -done diff --git a/tests/cluster/002.sh b/tests/cluster/002.sh deleted file mode 100755 index 4b827a0..0000000 --- a/tests/cluster/002.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in 0 1 2; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -# start Sheepdog with three nodes -$COLLIE cluster format - -# kill all sheeps -for i in 0 1 2; do - pkill -f "sheep $STORE/$i" - sleep 1 -done - -# master transfer will happen once -for i in 1 0 2; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -echo check whether Sheepdog is running with only one node -$COLLIE cluster info -p 7002 - -# add the other nodes -for i in 0 1; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -echo check whether all nodes have the same cluster info -for i in 0 1 2; do - $COLLIE cluster info -p 700$i -done diff --git a/tests/cluster/003.sh b/tests/cluster/003.sh deleted file mode 100755 index e0ea8c9..0000000 --- a/tests/cluster/003.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in 0 1 2; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -# start Sheepdog with three nodes -$COLLIE cluster format - -# kill all sheeps -for i in 0 1 2; do - pkill -f "sheep $STORE/$i" - sleep 1 -done - -# master transfer will happen twice -for i in 0 1 2; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -echo check whether Sheepdog is running with only one node -$COLLIE cluster info -p 7002 - -# add the other nodes -for i in 0 1; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -echo check whether all nodes have the same cluster info -for i in 0 1 2; do - $COLLIE cluster info -p 700$i -done diff --git a/tests/cluster/004.sh b/tests/cluster/004.sh deleted file mode 100755 index 5f7f57a..0000000 --- a/tests/cluster/004.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in 0 1; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -# start Sheepdog with two nodes -$COLLIE cluster format -c 2 - -for i in 2 3 4; do - # add one node after killing existing one node - pkill -f "sheep $STORE/$((i - 2))" - sleep 1 - - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -# kill all existing nodes -for i in 3 4; do - pkill -f "sheep $STORE/$i" - sleep 1 -done - -for i in 0 1 2 3 4; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -echo check whether Sheepdog is running with only one node -$COLLIE cluster info -p 7004 - -# add the other nodes -for i in 0 1 2 3; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -echo check whether all nodes have the same cluster info -for i in 0 1 2 3 4; do - $COLLIE cluster info -p 700$i -done diff --git a/tests/cluster/005.sh b/tests/cluster/005.sh deleted file mode 100755 index 380763a..0000000 --- a/tests/cluster/005.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in 0 1; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -# start Sheepdog with two nodes -$COLLIE cluster format -c 1 -sleep 1 - -for i in 2 3 4; do - pkill -f "sheep $STORE/$((i - 2))" - sleep 1 - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -$COLLIE cluster shutdown -p 7004 -sleep 1 - -for i in 0 1 2 3 4; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -echo check whether Sheepdog is working with two nodes -for i in 3 4; do - $COLLIE cluster info -p 700$i -done - -# add the other nodes -for i in 0 1 2; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER - sleep 1 -done - -echo check whether all nodes have the same cluster info -for i in 0 1 2 3 4; do - $COLLIE cluster info -p 700$i -done diff --git a/tests/cluster/006.sh b/tests/cluster/006.sh deleted file mode 100755 index bca477d..0000000 --- a/tests/cluster/006.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -$SHEEP $STORE/0 -z 0 -p 7000 -c $DRIVER -sleep 1 - -# start Sheepdog with one node -$COLLIE cluster format -sleep 1 - -# launch sheeps simultaneously -for i in `seq 1 9`; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER -done - -sleep 1 - -echo check whether all nodes have the same cluster info -for i in `seq 0 9`; do - $COLLIE cluster info -p 700$i -done diff --git a/tests/cluster/007.sh b/tests/cluster/007.sh deleted file mode 100755 index 4f4657a..0000000 --- a/tests/cluster/007.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -# create a node who has wrong epoch -$SHEEP $STORE/1 -p 7001 -z 1 -c $DRIVER -sleep 1 -$COLLIE cluster format -p 7001 -c 1 -$COLLIE cluster shutdown -p 7001 -sleep 1 - -# start Sheepdog with one node -$SHEEP $STORE/0 -p 7000 -z 0 -c $DRIVER -sleep 1 -$COLLIE cluster format -p 7000 -c 1 - -for i in `seq 0 5`; do - $SHEEP $STORE/1 -p 7001 -z 1 -c $DRIVER # should fail - $SHEEP $STORE/2 -p 7002 -z 2 -c $DRIVER # should succeed - sleep 1 - - if [ "`$COLLIE node list -p 7002 -r | wc -l`" -ne 2 ]; then - echo "test failed" - $COLLIE cluster info -p 7000 - $COLLIE cluster info -p 7002 - exit 1 - fi - - pkill -f "$SHEEP $STORE/2" - sleep 1 -done - -echo "success" diff --git a/tests/common.config b/tests/common.config new file mode 100644 index 0000000..e9c8fb4 --- /dev/null +++ b/tests/common.config @@ -0,0 +1,81 @@ +#!/bin/bash +# +# Copyright (C) 2009 Red Hat, Inc. +# Copyright (c) 2000-2003,2006 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# +# setup and check for config parameters +# + +# all tests should use a common language setting to prevent golden +# output mismatches. +export LANG=C + +PATH=".:$PATH" + +HOST=`hostname -s` +HOSTOS=`uname -s` + +export CHECK_OPTIONS=${CHECK_OPTIONS:="-g auto"} +export PWD=`pwd` + +# $1 = prog to look for, $2* = default pathnames if not found in $PATH +set_prog_path() +{ + p=`which $1 2> /dev/null` + if [ -n "$p" -a -x "$p" ]; then + echo $p + return 0 + fi + p=$1 + + shift + for f; do + if [ -x $f ]; then + echo $f + return 0 + fi + done + + echo "" + return 1 +} + +_fatal() +{ + echo "$*" + status=1 + exit 1 +} + +export PERL_PROG="`set_prog_path perl`" +[ "$PERL_PROG" = "" ] && _fatal "perl not found" + +export AWK_PROG="`set_prog_path awk`" +[ "$AWK_PROG" = "" ] && _fatal "awk not found" + +export SED_PROG="`set_prog_path sed`" +[ "$SED_PROG" = "" ] && _fatal "sed not found" + +export BC_PROG="`set_prog_path bc`" +[ "$BC_PROG" = "" ] && _fatal "bc not found" + +export DRIVER=${DRIVER:-local} +export STORE=${STORE:-/tmp/sheepdog} +export SHEEP=${SHEEP:-../sheep/sheep} +export COLLIE=${COLLIE:-../collie/collie} + +# make sure this script returns success +/bin/true diff --git a/tests/common.filter b/tests/common.filter new file mode 100644 index 0000000..bddb7af --- /dev/null +++ b/tests/common.filter @@ -0,0 +1,161 @@ +#!/bin/bash +# +# Copyright (C) 2009 Red Hat, Inc. +# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# +# standard filters +# + +# Checks that given_value is in range of correct_value +/- tolerance. +# Tolerance can be an absolute value or a percentage of the correct value +# (see examples with tolerances below). +# Outputs suitable message to stdout if it's not in range. +# +# A verbose option, -v, may be used as the LAST argument +# +# e.g. +# foo: 0.0298 = 0.03 +/- 5% +# _within_tolerance "foo" 0.0298 0.03 5% +# +# foo: 0.0298 = 0.03 +/- 0.01 +# _within_tolerance "foo" 0.0298 0.03 0.01 +# +# foo: 0.0298 = 0.03 -0.01 +0.002 +# _within_tolerance "foo" 0.0298 0.03 0.01 0.002 +# +# foo: verbose output of 0.0298 = 0.03 +/- 5% +# _within_tolerance "foo" 0.0298 0.03 5% -v +_within_tolerance() +{ + _name=$1 + _given_val=$2 + _correct_val=$3 + _mintol=$4 + _maxtol=$_mintol + _verbose=0 + _debug=false + + # maxtol arg is optional + # verbose arg is optional + if [ $# -ge 5 ] + then + if [ "$5" = "-v" ] + then + _verbose=1 + else + _maxtol=$5 + fi + fi + if [ $# -ge 6 ] + then + [ "$6" = "-v" ] && _verbose=1 + fi + + # find min with or without % + _mintolerance=`echo $_mintol | sed -e 's/%//'` + if [ $_mintol = $_mintolerance ] + then + _min=`echo "scale=5; $_correct_val-$_mintolerance" | bc` + else + _min=`echo "scale=5; $_correct_val-$_mintolerance*0.01*$_correct_val" | bc` + fi + + # find max with or without % + _maxtolerance=`echo $_maxtol | sed -e 's/%//'` + if [ $_maxtol = $_maxtolerance ] + then + _max=`echo "scale=5; $_correct_val+$_maxtolerance" | bc` + else + _max=`echo "scale=5; $_correct_val+$_maxtolerance*0.01*$_correct_val" | bc` + fi + + $_debug && echo "min = $_min" + $_debug && echo "max = $_max" + + cat <<EOF >$tmp.bc.1 +scale=5; +if ($_min <= $_given_val) 1; +if ($_min > $_given_val) 0; +EOF + + cat <<EOF >$tmp.bc.2 +scale=5; +if ($_given_val <= $_max) 1; +if ($_given_val > $_max) 0; +EOF + + _above_min=`bc <$tmp.bc.1` + _below_max=`bc <$tmp.bc.2` + + rm -f $tmp.bc.[12] + + _in_range=`expr $_above_min \& $_below_max` + + # fix up min, max precision for output + # can vary for 5.3, 6.2 + _min=`echo $_min | sed -e 's/0*$//'` # get rid of trailling zeroes + _max=`echo $_max | sed -e 's/0*$//'` # get rid of trailling zeroes + + if [ $_in_range -eq 1 ] + then + [ $_verbose -eq 1 ] && echo $_name is in range + return 0 + else + [ $_verbose -eq 1 ] && echo $_name has value of $_given_val + [ $_verbose -eq 1 ] && echo $_name is NOT in range $_min .. $_max + return 1 + fi +} + +# ctime(3) dates +# +_filter_date() +{ + sed \ + -e 's/[A-Z][a-z][a-z] [A-z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/' +} + +# ISO dates +_filter_iso_date() +{ + sed -e 's/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/DATE/g' +} + +_filter_short_date() +{ + sed -e 's/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]/DATE/g' +} + +# remove trailing whitespace, some versions of sg3_utils do that +_filter_spaces() +{ + sed -e 's/ *$//' +} + +# normalize collie cluster info output +_filter_cluster_info() +{ + _filter_date | _filter_iso_date +} + +# sanitize qemu-io output +_filter_qemu_io() +{ + sed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" +} + +# make sure this script returns success +/bin/true diff --git a/tests/common.rc b/tests/common.rc new file mode 100644 index 0000000..b74fd0f --- /dev/null +++ b/tests/common.rc @@ -0,0 +1,135 @@ +#!/bin/bash +# +# Copyright (C) 2009 Red Hat, Inc. +# Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# we need common.config +if [ "$iam" != "check" ] +then + if ! . ./common.config + then + echo "$iam: failed to source common.config" + exit 1 + fi +fi + +# make sure we have a standard umask +umask 022 + +# 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 +# first prints the message passed in the first argument, and then "done" +# or "fail" depending on the return status of the command passed in the +# second argument. If the command fails and the variable _do_die_on_error +# is set to "always" or the two argument form is used and _do_die_on_error +# is set to "message_only" _do will print an error message to +# $seq.out and exit. + +_do() +{ + if [ $# -eq 1 ]; then + _cmd=$1 + elif [ $# -eq 2 ]; then + _note=$1 + _cmd=$2 + echo -n "$_note... " + else + echo "Usage: _do [note] cmd" 1>&2 + status=1; exit + fi + + (eval "echo '---' \"$_cmd\"") >>$here/$seq.full + (eval "$_cmd") >$tmp._out 2>&1; ret=$? + cat $tmp._out >>$here/$seq.full + if [ $# -eq 2 ]; then + if [ $ret -eq 0 ]; then + echo "done" + else + echo "fail" + fi + fi + if [ $ret -ne 0 ] \ + && [ "$_do_die_on_error" = "always" \ + -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ] + then + [ $# -ne 2 ] && echo + eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full" + status=1; exit + fi + + return $ret +} + +# bail out, setting up .notrun file +# +_notrun() +{ + echo "$*" >$seq.notrun + echo "$seq not run: $*" + status=0 + exit +} + +# just plain bail out +# +_fail() +{ + echo "$*" | tee -a $here/$seq.full + echo "(see $seq.full for details)" + status=1 + exit 1 +} + +# this test requires that a specified command (executable) exists +# +_require_command() +{ + [ -n "`which $1`" ] || _notrun "$1 utility required, skipped this test" + [ -x "`which $1`" ] || _notrun "$1 utility required, skipped this test" +} + +_full_platform_details() +{ + os=`uname -s` + host=`hostname -s` + kernel=`uname -r` + platform=`uname -m` + echo "$os/$platform $host $kernel" +} + +_die() +{ + echo $@ + exit 1 +} + +_cleanup() +{ + killall -9 sheep collie >/dev/null 2>&1 || true + sleep 1 + mkdir -p $STORE + for i in $STORE/?; do + rm -rf $i + done + for i in $STORE/??; do + rm -rf $i + done +} + +# make sure this script returns success +/bin/true diff --git a/tests/foo b/tests/foo new file mode 100644 index 0000000..e69de29 diff --git a/tests/group b/tests/group new file mode 100644 index 0000000..6cd2e04 --- /dev/null +++ b/tests/group @@ -0,0 +1,31 @@ +# +# QA groups control file +# +# Defines test groups +# - do not start group names with a digit +# - test-group association are one line per test +# - each test can be part of multiple groups +# +# auto: tests that are run by defaul +# quick: test that take less than 30 seconds (normally) +# cluster: cluster drivers tests: join/leave/etc +# store: basic data integrity +# vdi: qemu I/O, snapshots, volume creation and deletion +# +001 auto quick cluster +002 auto quick cluster +003 auto quick cluster +004 auto quick cluster +005 auto quick cluster +006 auto quick cluster +007 auto quick cluster +008 auto store +009 auto quick store +010 auto quick store +011 auto quick store +012 auto quick store +013 auto quick vdi +014 auto quick vdi +015 auto quick vdi +016 auto quick vdi +017 auto quick vdi diff --git a/tests/store/001.sh b/tests/store/001.sh deleted file mode 100755 index a6c14cb..0000000 --- a/tests/store/001.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in `seq 0 7`; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER -done -while true; do - if [ $($COLLIE node list | wc -l) -ne 9 ]; then - sleep 1 - else - break - fi -done - -$COLLIE cluster format -c 3 -sleep 1 - -for i in `seq 0 4`; do - $COLLIE vdi create test$i 100M -done - -for i in `seq 0 4`; do - dd if=/dev/urandom | $COLLIE vdi write test$i -p 7000 & -done - -sleep 3 - -echo begin kill -for i in `seq 1 5`; do - pkill -f "$SHEEP $STORE/$i -z $i -p 700$i" - sleep 3 -done - -for i in `seq 1 5`; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER -done - -echo wait for object recovery to finish -while true; do - if [ "$(pgrep collie)" ]; then - sleep 1 - else - break - fi -done - -for i in `seq 0 7`; do - for j in `seq 0 4`; do - $COLLIE vdi read test$j -p 700$i | md5sum - done -done diff --git a/tests/store/002.sh b/tests/store/002.sh deleted file mode 100755 index ffb1024..0000000 --- a/tests/store/002.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -# start three sheep daemons -for i in 0 1 2; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER -done - -sleep 1 -$COLLIE cluster format -c 2 - -# create a pre-allocated vdi -$COLLIE vdi create test 80M -P - -# stop the 3rd node -pkill -f "$SHEEP $STORE/2" - -# write data to the vdi -cat /dev/urandom | $COLLIE vdi write test - -# restart the 3rd node -$SHEEP $STORE/2 -z 2 -p 7002 -c $DRIVER - -# wait for object recovery to finish -sleep 10 - -# show md5sum of the vdi on each node -for i in 0 1 2; do - $COLLIE vdi read test -p 700$i | md5sum -done diff --git a/tests/store/003.sh b/tests/store/003.sh deleted file mode 100755 index 1808a6f..0000000 --- a/tests/store/003.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -$SHEEP $STORE/0 -z 0 -p 7000 -c $DRIVER -$SHEEP $STORE/1 -z 1 -p 7001 -c $DRIVER -$COLLIE cluster format -c 2 -$COLLIE cluster recover disable - -qemu-img create sheepdog:test 4G - -# create 20 objects -for i in `seq 0 19`; do - $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512 < /dev/zero -done - -$SHEEP $STORE/2 -z 2 -p 7002 -c $DRIVER - -# overwrite the objects -for i in `seq 0 19`; do - $COLLIE vdi write test $((i * 4 * 1024 * 1024)) 512 < /dev/zero -done diff --git a/tests/store/004.sh b/tests/store/004.sh deleted file mode 100755 index d978a4e..0000000 --- a/tests/store/004.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -dd if=/dev/zero of=$STORE/0.img seek=$((2 * 1024 ** 3 - 1)) bs=1 count=1 -dd if=/dev/zero of=$STORE/1.img seek=$((4 * 1024 ** 3 - 1)) bs=1 count=1 -dd if=/dev/zero of=$STORE/2.img seek=$((8 * 1024 ** 3 - 1)) bs=1 count=1 - -for i in 0 1 2; do - mkfs.xfs $STORE/$i.img - mkdir $STORE/$i - mount -o loop $STORE/$i.img $STORE/$i - $SHEEP $STORE/$i/ -z $i -p 700$i -c $DRIVER -done - -sleep 1 - -echo check the number of vnodes -for i in 0 1 2; do - $COLLIE node list -p 700$i -done diff --git a/tests/store/005.sh b/tests/store/005.sh deleted file mode 100755 index 21208fa..0000000 --- a/tests/store/005.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in 0 1 2; do - $SHEEP $STORE/$i/ -z $i -p 700$i -c $DRIVER -done - -# add gateway node -$SHEEP $STORE/4/ -z 4 -p 7004 -c $DRIVER -g - -sleep 1 - -echo check the number of vnodes -$COLLIE node list diff --git a/tests/vdi/001.sh b/tests/vdi/001.sh deleted file mode 100755 index 26a39c1..0000000 --- a/tests/vdi/001.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in 0 1 2; do - $SHEEP $STORE/$i -p 700$i -z $i -c $DRIVER -done - -sleep 1 - -$COLLIE 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 - qemu-img snapshot -c tag$i sheepdog:test -done - -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 -done diff --git a/tests/vdi/002.sh b/tests/vdi/002.sh deleted file mode 100755 index 2f7cf3d..0000000 --- a/tests/vdi/002.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in 0 2; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER -done - -sleep 1 - -$COLLIE cluster format -c 2 -$COLLIE vdi create test 4G - -echo -n value > $STORE/tmp.dat - -echo "key shouldn't be found" -$COLLIE vdi getattr test key || true - -$COLLIE vdi setattr test key value -$COLLIE vdi getattr test key | diff - $STORE/tmp.dat - -$COLLIE vdi setattr test key value -d - -echo "key shouldn't be found" -$COLLIE vdi getattr test key || true diff --git a/tests/vdi/003.sh b/tests/vdi/003.sh deleted file mode 100755 index c39c9bd..0000000 --- a/tests/vdi/003.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in 0 2; do - $SHEEP $STORE/$i -z $i -p 700$i -c $DRIVER -done - -sleep 1 - -$COLLIE cluster format -c 2 -$COLLIE vdi create test 539545600 -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi write test 512 512 < /dev/zero -echo "there should be 3 setattr errors" - -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi write test 512 512 < /dev/zero -echo "there should be 8 setattr errors" - -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi write test 512 512 < /dev/zero -echo "there should be 6 setattr errors" - -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi setattr test lock 1 -x & -$COLLIE vdi write test 512 512 < /dev/zero -echo "there should be 5 setattr errors" diff --git a/tests/vdi/004.sh b/tests/vdi/004.sh deleted file mode 100755 index 91fe654..0000000 --- a/tests/vdi/004.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in 0 1 2; do - $SHEEP $STORE/$i -p 700$i -z $i -c $DRIVER -done - -sleep 1; - -$COLLIE cluster format -c 3 -$COLLIE vdi create base 100M -P - -qemu-img snapshot -c tag sheepdog:base - -sleep 1 - -$COLLIE vdi clone -s 1 base test - -sleep 1 - -$COLLIE vdi delete test - -sleep 1 -$COLLIE vdi delete base - -sleep 1 -$COLLIE vdi delete -s 1 base - -sleep 3 -echo there should be no vdi -$COLLIE vdi list - -echo there should be no object -$COLLIE node info diff --git a/tests/vdi/005.sh b/tests/vdi/005.sh deleted file mode 100755 index b80a6f4..0000000 --- a/tests/vdi/005.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -ex - -DRIVER=${DRIVER:-local} -STORE=${STORE:-/tmp/sheepdog} -SHEEP=${SHEEP:-./sheep/sheep} -COLLIE=${COLLIE:-./collie/collie} - -killall -9 sheep collie || true -sleep 1 -rm -r $STORE/* || true -mkdir -p $STORE - -for i in 0 1 2; do - $SHEEP $STORE/$i -p 700$i -z $i -c $DRIVER -done - -sleep 1 - -$COLLIE cluster format -c 1 - -qemu-img create sheepdog:test 4G -qemu-img snapshot -c tag1 sheepdog:test -qemu-img snapshot -c tag2 sheepdog:test -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 -qemu-img snapshot -c tag3 sheepdog:test2 - -$COLLIE vdi tree - -# expected results: -# -# test---[2012-08-07 18:04]---[2012-08-07 18:04]---[2012-08-07 18:04]---(you are here) -# test2---[2012-08-07 18:04]-+-[2012-08-07 18:04]---[2012-08-07 18:04] -# `-[2012-08-07 18:04]---(you are here) |