Hi,

This is little something which could help while debugging
resource agents. Setting the environment variable __OCF_TRACE_RA
would cause the resource agent run to be traced (as in set -x).
PS4 is set accordingly (that's a bash feature, don't know if
other shells support it). ocf-tester got an option (-X) to turn
the feature on. The agent itself can also turn on/off tracing
via ocf_start_trace/ocf_stop_trace.

Do you find anything amiss?

Thanks,

Dejan
commit 77b3c997289a097fecab13179c4a2364bc34f15a
Author: Dejan Muhamedagic <de...@suse.de>
Date:   Wed Nov 21 16:24:20 2012 +0100

    Dev: add RA trace capability

diff --git a/doc/dev-guides/ra-dev-guide.txt b/doc/dev-guides/ra-dev-guide.txt
index af5e3b1..11e9a5d 100644
--- a/doc/dev-guides/ra-dev-guide.txt
+++ b/doc/dev-guides/ra-dev-guide.txt
@@ -1623,6 +1623,12 @@ Beginning tests for /home/johndoe/ra-dev/foobar...
 /home/johndoe/ra-dev/foobar passed all tests
 --------------------------------------------------------------------------
 
+If the resource agent exhibits some difficult to grasp behaviour,
+which is typically the case with just developed software, there
+are +-v+ and +-d+ options to dump more output. If that does not
+help, instruct +ocf-tester+ to trace the resource agent with
++-X+ (make sure to redirect output to a file, unless you are a
+really fast reader).
 
 === Testing with +ocft+
 
diff --git a/heartbeat/ocf-shellfuncs.in b/heartbeat/ocf-shellfuncs.in
index f3822b7..04e4ecb 100644
--- a/heartbeat/ocf-shellfuncs.in
+++ b/heartbeat/ocf-shellfuncs.in
@@ -675,4 +675,14 @@ ocf_stop_processes() {
 	return 1
 }
 
+ocf_start_trace() {
+	PS4='+ `date +"%T"`: ${FUNCNAME[0]:+${FUNCNAME[0]}:}${LINENO}: '
+	set -x
+}
+ocf_stop_trace() {
+	set +x
+}
+
 __ocf_set_defaults "$@"
+
+[ "$__OCF_TRACE_RA" ] && ocf_start_trace
diff --git a/tools/ocf-tester.8 b/tools/ocf-tester.8
index ba07058..850ec0b 100644
--- a/tools/ocf-tester.8
+++ b/tools/ocf-tester.8
@@ -3,7 +3,7 @@
 ocf-tester \- Part of the Linux-HA project
 .SH SYNOPSIS
 .B ocf-tester
-[\fI-Lh\fR] \fI-n resource_name \fR[\fI-o name=value\fR]\fI* /full/path/to/resource/agent\fR
+[\fI-LhvqdX\fR] \fI-n resource_name \fR[\fI-o name=value\fR]\fI* /full/path/to/resource/agent\fR
 .SH DESCRIPTION
 Tool for testing if a cluster resource is OCF compliant
 .SH OPTIONS
@@ -43,6 +43,9 @@ Be quiet while testing
 \fB\-d\fR
 Turn on RA debugging
 .TP
+\fB\-X\fR
+Turn on RA tracing (expect large output)
+.TP
 \fB\-n\fR name
 Name of the resource
 .TP
diff --git a/tools/ocf-tester.in b/tools/ocf-tester.in
index 214e25c..2eaf220 100755
--- a/tools/ocf-tester.in
+++ b/tools/ocf-tester.in
@@ -51,13 +51,14 @@ usage() {
 
     echo "Tool for testing if a cluster resource is OCF compliant"
     echo ""
-    echo "Usage: ocf-tester [-Lh] -n resource_name [-o name=value]* /full/path/to/resource/agent"
+    echo "Usage: ocf-tester [-LhvqdX] -n resource_name [-o name=value]* /full/path/to/resource/agent"
     echo ""
     echo "Options:"
     echo "  -h       		This text"
     echo "  -v       		Be verbose while testing"
     echo "  -q       		Be quiet while testing"
     echo "  -d       		Turn on RA debugging"
+    echo "  -X       		Turn on RA tracing (expect large output)"
     echo "  -n name		Name of the resource"	
     echo "  -o name=value		Name and value of any parameters required by the agent"
     echo "  -L			Use lrmadmin/lrmd for tests"
@@ -106,6 +107,7 @@ while test "$done" = "0"; do
 	-L) use_lrmd=1; shift;;
 	-v) verbose=1; shift;;
 	-d) export HA_debug=1; shift;;
+	-X) export __OCF_TRACE_RA=1; verbose=1; shift;;
 	-q) quiet=1; shift;;
 	-?|--help) usage 0;;
 	--version) echo "@PACKAGE_VERSION@"; exit 0;;
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to