summaryrefslogtreecommitdiffstats
path: root/tests/include.rc
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-10-17 15:51:18 -0700
committerAnand Avati <avati@redhat.com>2012-10-18 14:17:25 -0700
commitbb41c8ab88f1a3d8c54b635674d0a72133623496 (patch)
tree00d2686b4b9e31034ea9efe89d11964736208f06 /tests/include.rc
parent56d1f81949fde78615cd9fec048259d261f99c40 (diff)
tests: pre-commit regression tests
Framework for writing test cases to be submitted with patches. This framework and the test cases get exercised by Jenkins in the pre-commit regression test. Jenkins is configured to give a +1 verified vote only if the regression test passes without failures (which includes test cases added/changed by the patch being tested) Every patch should include a test case (either extensions/changes to existing test cases or add new ones, as appropriate). The test case should be part of the same commit so that both code and test case get reviewed together. Test cases added are cumulative. Every new patch gets tested against its own test case and every test case previously added. A lot of new commits in the near future will be pure test cases (with no code change) which will get added in "catch up" mode. The tool used for implementing test cases is 'prove', and the framework itself is modeled similar to the POSIX compliance filesystem test suite. Under the top level directory, a new directory named 'tests/' is added. This contains top level classifier directories and framework files/scripts. Functionality tests should be created under a classifier directory below 'tests/'. For e.g: tests/basic/mount.t tests/performance/write-behind.t Bugs which get fixed should include a test case script named by the bug id, so that we are guaranteed any new change will not bring the issue back. For e.g: tests/bugs/bug-123456.t Triggering of regression tests in Jenkins is manual at this point as we do not want the entire test suite to run against every revision of a patch while it is still in the review/resubmit cycle. Signed-off-by: Anand Avati <avati@redhat.com> Change-Id: I8078244619135ccaba38e068925f8ca85141055a BUG: 764966 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/4101 Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'tests/include.rc')
-rw-r--r--tests/include.rc93
1 files changed, 93 insertions, 0 deletions
diff --git a/tests/include.rc b/tests/include.rc
new file mode 100644
index 000000000..bc9784cf4
--- /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