summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xrun-tests.sh3
-rwxr-xr-xsmoke.sh83
-rw-r--r--tests/README20
-rwxr-xr-xtests/basic/mount.t62
-rwxr-xr-xtests/basic/volume.t47
-rwxr-xr-xtests/bugs/bug-000000.t9
-rw-r--r--tests/include.rc93
7 files changed, 234 insertions, 83 deletions
diff --git a/run-tests.sh b/run-tests.sh
new file mode 100755
index 00000000000..d0a884b92b0
--- /dev/null
+++ b/run-tests.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+prove -r $(dirname $0)/tests;
diff --git a/smoke.sh b/smoke.sh
deleted file mode 100755
index a87908d794e..00000000000
--- a/smoke.sh
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/bin/bash
-
-set -e;
-
-M=/mnt;
-P=/build;
-H=$(hostname);
-T=600;
-V=patchy;
-
-
-function cleanup()
-{
- killall -15 glusterfs glusterfsd glusterd glusterd 2>&1 || true;
- killall -9 glusterfs glusterfsd glusterd glusterd 2>&1 || true;
- umount -l $M 2>&1 || true;
- rm -rf /var/lib/glusterd /etc/glusterd $P/export;
-}
-
-function start_fs()
-{
- mkdir -p $P/export;
- chmod 0755 $P/export;
-
- glusterd;
- gluster --mode=script volume create $V replica 2 $H:$P/export/export{1,2,3,4};
- gluster volume start $V;
- glusterfs -s $H --volfile-id $V $M;
-# mount -t glusterfs $H:/$V $M;
-}
-
-
-function run_tests()
-{
- cd $M;
-
- (sleep 1; dbench -s -t 60 10 >/dev/null) &
-
- (sleep 1; /opt/qa/tools/posix_compliance.sh) &
-
- wait %2
- wait %3
-
- rm -rf clients;
-
- cd -;
-}
-
-
-function watchdog ()
-{
- # insurance against hangs during the test
-
- sleep $1;
-
- echo "Kicking in watchdog after $1 secs";
-
- cleanup;
-}
-
-
-function finish ()
-{
- cleanup;
- kill %1;
-}
-
-function main ()
-{
- cleanup;
-
- watchdog $T &
-
- trap finish EXIT;
-
- set -x;
-
- start_fs;
-
- run_tests;
-}
-
-main "$@";
diff --git a/tests/README b/tests/README
new file mode 100644
index 00000000000..fe45f5bb829
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,20 @@
+How to use use
+==============
+
+- Build and install the version of glusterfs with your changes. Make
+ sure the installed version is accessible from $PATH.
+
+- (optional) Set environment variables to specify location of
+ export directories and mount points. Unless you have special
+ requirements, the defaults should just work. The variables
+ themselves can be found at the top of tests/include.rc. All
+ of them can be overriden with environment variables.
+
+- Execute run-tests.sh in the top level directory as root.
+
+- If some test cases fail, you can execute the failed test case script
+ directly bypassing run-tests.sh. At this time it might be
+ useful to set the envrionment variable DEBUG=1 before running
+ the individual test script directly by hand.
+
+- BE WARNED THAT THE TEST CASES DELETE /var/lib/glusterd/* !!!
diff --git a/tests/basic/mount.t b/tests/basic/mount.t
new file mode 100755
index 00000000000..0fdef65de55
--- /dev/null
+++ b/tests/basic/mount.t
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+
+cleanup;
+
+
+## Start and create a volume
+TEST glusterd
+TEST pidof glusterd
+TEST $CLI volume info;
+
+TEST $CLI volume create $V0 replica 2 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8};
+
+function volinfo_field()
+{
+ local vol=$1;
+ local field=$2;
+
+ $CLI volume info $vol | grep "^$field: " | sed 's/.*: //';
+}
+
+
+## Verify volume is is created
+EXPECT "$V0" volinfo_field $V0 'Volume Name';
+EXPECT 'Created' volinfo_field $V0 'Status';
+
+
+## Start volume and verify
+TEST $CLI volume start $V0;
+EXPECT 'Started' volinfo_field $V0 'Status';
+
+
+## Make volume tightly consistent for metdata
+TEST $CLI volume set $V0 performance.stat-prefetch off;
+
+## Mount FUSE with caching disabled
+TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0;
+
+## Wait for volume to register with rpc.mountd
+sleep 5;
+
+## Mount NFS
+TEST mount -t nfs -o vers=3,nolock,soft,intr $H0:/$V0 $N0;
+
+
+## Test for consistent views between NFS and FUSE mounts
+TEST ! stat $M0/newfile;
+TEST touch $M0/newfile;
+TEST stat $N0/newfile;
+TEST rm $N0/newfile;
+TEST ! stat $M0/newfile;
+
+
+## Finish up
+TEST $CLI volume stop $V0;
+EXPECT 'Stopped' volinfo_field $V0 'Status';
+
+TEST $CLI volume delete $V0;
+TEST ! $CLI volume info $V0;
+
+cleanup;
diff --git a/tests/basic/volume.t b/tests/basic/volume.t
new file mode 100755
index 00000000000..de3f001e09c
--- /dev/null
+++ b/tests/basic/volume.t
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+
+cleanup;
+
+TEST glusterd
+TEST pidof glusterd
+TEST $CLI volume info;
+
+TEST $CLI volume create $V0 replica 2 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8};
+
+
+function volinfo_field()
+{
+ local vol=$1;
+ local field=$2;
+
+ $CLI volume info $vol | grep "^$field: " | sed 's/.*: //';
+}
+
+
+function brick_count()
+{
+ local vol=$1;
+
+ $CLI volume info $vol | egrep "^Brick[0-9]+: " | wc -l;
+}
+
+
+EXPECT "$V0" volinfo_field $V0 'Volume Name';
+EXPECT 'Created' volinfo_field $V0 'Status';
+EXPECT '8' brick_count $V0
+
+TEST $CLI volume start $V0;
+EXPECT 'Started' volinfo_field $V0 'Status';
+
+TEST $CLI volume add-brick $V0 $H0:$B0/${V0}{9,10,11,12};
+EXPECT '12' brick_count $V0
+
+TEST $CLI volume stop $V0;
+EXPECT 'Stopped' volinfo_field $V0 'Status';
+
+TEST $CLI volume delete $V0;
+TEST ! $CLI volume info $V0;
+
+cleanup;
diff --git a/tests/bugs/bug-000000.t b/tests/bugs/bug-000000.t
new file mode 100755
index 00000000000..7f3d15c9d59
--- /dev/null
+++ b/tests/bugs/bug-000000.t
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+
+cleanup;
+
+TEST glusterd
+
+cleanup;
diff --git a/tests/include.rc b/tests/include.rc
new file mode 100644
index 00000000000..bc9784cf49b
--- /dev/null
+++ b/tests/include.rc
@@ -0,0 +1,93 @@
+M0=${M0:=/mnt/glusterfs/0}; # 0th mount point for FUSE
+M1=${M1:=/mnt/glusterfs/1}; # 1st mount point for FUSE
+N0=${N0:=/mnt/nfs/0}; # 0th mount point for NFS
+N1=${N1:=/mnt/nfs/1}; # 1st mount point for NFS
+V0=${V0:=patchy}; # volume name to use in tests
+B0=${B0:=/d/backends}; # top level of brick directories
+H0=${H0:=`hostname --fqdn`}; # hostname
+DEBUG=${DEBUG:=0} # turn on debugging?
+
+CLI="gluster --mode=script";
+
+mkdir -p $B0;
+mkdir -p $M0 $M1;
+mkdir -p $N0 $N1;
+
+testcnt=`egrep '^[ \t]*(EXPECT|TEST)' $0 | wc -l`;
+echo 1..$testcnt
+
+t=1
+
+function dbg()
+{
+ [ "x$DEBUG" = "x0" ] || echo "$*" >&2;
+}
+
+
+function test_header()
+{
+ dbg "=========================";
+ dbg "TEST $t (line $TESTLINE): $*";
+}
+
+
+function test_footer()
+{
+ RET=$?
+
+ if [ $RET -eq 0 ]; then
+ echo "ok $t";
+ else
+ echo "not ok $t";
+ fi
+
+ dbg "RESULT $t: $RET";
+
+ t=`expr $t + 1`;
+}
+
+
+function _EXPECT()
+{
+ TESTLINE=$1;
+ shift;
+
+ test_header "$@";
+
+ e="$1";
+ shift;
+ "$@" | tail -1 | egrep '^'${e}'$' >/dev/null 2>&1;
+
+ test_footer;
+}
+
+
+function _TEST()
+{
+ TESTLINE=$1;
+ shift;
+
+ test_header "$@";
+
+ eval "$@" >/dev/null 2>&1
+
+ test_footer;
+}
+
+
+function cleanup()
+{
+ killall -15 glusterfs glusterfsd glusterd 2>/dev/null || true;
+ killall -9 glusterfs glusterfsd glusterd 2>/dev/null || true;
+ rm -rf /var/lib/glusterd/* $B0/* /etc/glusterd/*;
+
+ umount -l $M0 2>/dev/null || true;
+ umount -l $M1 2>/dev/null || true;
+ umount -l $N0 2>/dev/null || true;
+ umount -l $N1 2>/dev/null || true;
+}
+
+
+alias EXPECT='_EXPECT $LINENO'
+alias TEST='_TEST $LINENO'
+shopt -s expand_aliases