summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2012-11-20 12:03:16 +0530
committerAnand Avati <avati@redhat.com>2012-12-04 16:29:27 -0800
commitb2f8d63a191ee01526c4ce90b5ab63bfe4b05655 (patch)
tree56bdf647fb3b6e0003057e91db40980b21b2e3dc /tests
parentee2813f440e9b6874eed93de307b8070c8953d5b (diff)
glusterd-hooks: Made hook runtime work with synctask'ized codepath(s)
Change-Id: If66799c204483c3486a2b8ca842bb1b5f2e53997 BUG: 877992 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/4210 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/bugs/bug-877992.t61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/bugs/bug-877992.t b/tests/bugs/bug-877992.t
new file mode 100755
index 00000000000..932ecc77b86
--- /dev/null
+++ b/tests/bugs/bug-877992.t
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+
+cleanup;
+
+
+## Start and create a volume
+TEST glusterd -LDEBUG
+TEST pidof glusterd
+
+
+function volinfo_field()
+{
+ local vol=$1;
+ local field=$2;
+
+ $CLI volume info $vol | grep "^$field: " | sed 's/.*: //';
+}
+
+
+function hooks_prep ()
+{
+ local event=$1
+ touch /tmp/pre.out /tmp/post.out
+ touch /var/lib/glusterd/hooks/1/"$event"/pre/Spre.sh
+ touch /var/lib/glusterd/hooks/1/"$event"/post/Spost.sh
+
+ printf "#! /bin/bash\necho "$event"Pre > /tmp/pre.out\n" > /var/lib/glusterd/hooks/1/"$event"/pre/Spre.sh
+ printf "#! /bin/bash\necho "$event"Post > /tmp/post.out\n" > /var/lib/glusterd/hooks/1/"$event"/post/Spost.sh
+ chmod a+x /var/lib/glusterd/hooks/1/"$event"/pre/Spre.sh
+ chmod a+x /var/lib/glusterd/hooks/1/"$event"/post/Spost.sh
+}
+
+function hooks_cleanup ()
+{
+ local event=$1
+ rm /tmp/pre.out /tmp/post.out
+ rm /var/lib/glusterd/hooks/1/"$event"/pre/Spre.sh
+ rm /var/lib/glusterd/hooks/1/"$event"/post/Spost.sh
+}
+
+## Verify volume is created and its hooks script ran
+hooks_prep 'create'
+TEST $CLI volume create $V0 $H0:$B0/${V0}1;
+EXPECT "$V0" volinfo_field $V0 'Volume Name';
+EXPECT 'Created' volinfo_field $V0 'Status';
+EXPECT 'createPre' cat /tmp/pre.out;
+EXPECT 'createPost' cat /tmp/post.out;
+hooks_cleanup 'create'
+
+
+## Start volume and verify that its hooks script ran
+hooks_prep 'start'
+TEST $CLI volume start $V0;
+EXPECT 'Started' volinfo_field $V0 'Status';
+EXPECT 'startPre' cat /tmp/pre.out;
+EXPECT 'startPost' cat /tmp/post.out;
+hooks_cleanup 'start'
+
+cleanup;