Mailing List Archive

2 patchs for ocft
patch 1, this is ready for next patch:

- add new option 'Agent'
- corresponding configs update

patch 2:
- add new test case 'linbit: drbd'
Re: 2 patchs for ocft [ In reply to ]
Hi John,

On Wed, Nov 09, 2011 at 07:46:17AM -0700, John Shi wrote:
>
> patch 1, this is ready for next patch:
>
> - add new option 'Agent'
> - corresponding configs update
>
> patch 2:
> - add new test case 'linbit: drbd'

Patches applied. Many thanks!

Cheers,

Dejan

> From a09f2d90a75c60fcc797b9e562a9e2dc1e784038 Mon Sep 17 00:00:00 2001
> From: John Shi <jshi@suse.com>
> Date: Wed, 9 Nov 2011 22:39:15 +0800
> Subject: [PATCH 1/2] Medium: Tools: ocft: new option Agent, corresponding configs update
>
> ---
> tools/ocft/ChangeLog | 5 ++-
> tools/ocft/Filesystem | 3 +-
> tools/ocft/IPaddr2 | 3 +-
> tools/ocft/IPsrcaddr | 3 +-
> tools/ocft/LVM | 3 +-
> tools/ocft/MailTo | 3 +-
> tools/ocft/README.in | 4 ++
> tools/ocft/README.zh_CN.in | 10 ++++--
> tools/ocft/SendArp | 3 +-
> tools/ocft/apache | 3 +-
> tools/ocft/caselib.in | 3 +-
> tools/ocft/db2 | 2 +
> tools/ocft/iscsi | 3 +-
> tools/ocft/mysql | 3 +-
> tools/ocft/named | 3 ++
> tools/ocft/nfsserver | 3 +-
> tools/ocft/ocft.in | 80 ++++++++++++++++++++++++++-----------------
> tools/ocft/pgsql | 3 +-
> tools/ocft/portblock | 3 +-
> tools/ocft/postfix | 3 +-
> 20 files changed, 96 insertions(+), 50 deletions(-)
>
> diff --git a/tools/ocft/ChangeLog b/tools/ocft/ChangeLog
> index 9755982..8b00210 100644
> --- a/tools/ocft/ChangeLog
> +++ b/tools/ocft/ChangeLog
> @@ -1,4 +1,6 @@
> 0.43:
> + - Add an option 'Agent' in 'CONFIG'
> + - Fix a bug about remote shell.
> - Add top level option 'VARIABLE'.
> - Add top level option 'CLEANUP-AGENT'.
> - Rename Var & Unvar to Env & Unenv.
> @@ -34,7 +36,8 @@
> - Use 127.0.0.x(and lo for interface) for agents IP*
> 0.4:
> - Add a 'CASE-BLOCK' top option, it can be included by 'CASE'
> - - Add a 'SETUP-AGENT' top option, you can initialize agents before testing. - Add a 'Include' sub-option.
> + - Add a 'SETUP-AGENT' top option, you can initialize agents before testing.
> + - Add a 'Include' sub-option.
> - Add a 'Unvar' sub-option.
> - Rename 'GLOBAL' to 'CONFIG'.
> - Modify a part of syntax.
> diff --git a/tools/ocft/Filesystem b/tools/ocft/Filesystem
> index 65cab58..47700a6 100644
> --- a/tools/ocft/Filesystem
> +++ b/tools/ocft/Filesystem
> @@ -3,7 +3,8 @@
> # Tue Feb 15 18:50:04 CET 2011
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent Filesystem
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> HangTimeout 20
>
> VARIABLE
> diff --git a/tools/ocft/IPaddr2 b/tools/ocft/IPaddr2
> index 3a0c3ea..71d7182 100644
> --- a/tools/ocft/IPaddr2
> +++ b/tools/ocft/IPaddr2
> @@ -1,7 +1,8 @@
> # IPaddr2
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent IPaddr2
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage iproute2
> HangTimeout 20
>
> diff --git a/tools/ocft/IPsrcaddr b/tools/ocft/IPsrcaddr
> index cf3145b..011407c 100644
> --- a/tools/ocft/IPsrcaddr
> +++ b/tools/ocft/IPsrcaddr
> @@ -1,7 +1,8 @@
> # IPsrcaddr
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent IPsrcaddr
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage iproute2
> HangTimeout 20
>
> diff --git a/tools/ocft/LVM b/tools/ocft/LVM
> index e5a41a4..f7154ae 100644
> --- a/tools/ocft/LVM
> +++ b/tools/ocft/LVM
> @@ -3,7 +3,8 @@
> # Wed Feb 16 13:15:01 CET 2011
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent LVM
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> HangTimeout 20
>
> VARIABLE
> diff --git a/tools/ocft/MailTo b/tools/ocft/MailTo
> index f9beae2..8754035 100644
> --- a/tools/ocft/MailTo
> +++ b/tools/ocft/MailTo
> @@ -1,7 +1,8 @@
> # MailTo
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent MailTo
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage mailx
> HangTimeout 20
>
> diff --git a/tools/ocft/README.in b/tools/ocft/README.in
> index 3f6e16a..e3022c8 100644
> --- a/tools/ocft/README.in
> +++ b/tools/ocft/README.in
> @@ -50,6 +50,10 @@ HOW TO WRITE CONFIGURATION FILE
> - Grammar: CONFIG
> - The design in this option is global and influences every test case.
>
> + ** 'Agent' (sub-option)
> + - Grammar: Agent AGENT_NAME
> + - The agent name you want to test.
> +
> ** 'AgentRoot' (sub-option)
> - Grammar: AgentRoot /usr/lib/ocf/resource.d/xxx
> - A few agents will go to "linbit" or "pacemaker" directory, if you define this option,
> diff --git a/tools/ocft/README.zh_CN.in b/tools/ocft/README.zh_CN.in
> index 65dac04..cfd79f4 100644
> --- a/tools/ocft/README.zh_CN.in
> +++ b/tools/ocft/README.zh_CN.in
> @@ -36,17 +36,21 @@ ocft ???????????????????????????resouce agents??????????????????????????????reso
> ?????????CONFIG
> ???option????????????????????????????????????test case??????????????????
>
> -2.1.1 'AgentRoot' ??????
> +2.1.1 'Agent' ??????
> +?????????Agent AGENT_NAME
> +???????????????Agent????????????
> +
> +2.1.2 'AgentRoot' ??????
> ?????????AgentRoot /usr/lib/ocf/resource.d/xxx
> ??????agent??????????????? "pacemaker" ??? "linbit" ??????????????????????????????????????????ocft???????????????
> ?????????????????????"heartbeat"???
>
> -2.1.1 'InstallPackage' ??????
> +2.1.3 'InstallPackage' ??????
> ??????:InstallPackage package [package2 [...]]
> ????????????????????????????????????resource agent???service?????????????????????????????????????????????????????????
> package_name?????????resouce agent???????????????????????????????????????
>
> -2.1.2 'HangTimeout' ??????
> +2.1.4 'HangTimeout' ??????
> ?????????HangTimeout secs
> ???????????????????????????????????????????????????resouce agent?????????????????????????????????????????????????????????
> ?????????test case??????????????????????????????????????????????????????resouce agent??????????????????????????????
> diff --git a/tools/ocft/SendArp b/tools/ocft/SendArp
> index ee46e39..832897c 100644
> --- a/tools/ocft/SendArp
> +++ b/tools/ocft/SendArp
> @@ -1,7 +1,8 @@
> # SendArp
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent SendArp
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage resource-agents
> HangTimeout 15
>
> diff --git a/tools/ocft/apache b/tools/ocft/apache
> index f444d51..c5f8bb9 100644
> --- a/tools/ocft/apache
> +++ b/tools/ocft/apache
> @@ -1,7 +1,8 @@
> # apache
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent apache
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage apache2
> HangTimeout 20
>
> diff --git a/tools/ocft/caselib.in b/tools/ocft/caselib.in
> index 0617bfd..8c8a45a 100644
> --- a/tools/ocft/caselib.in
> +++ b/tools/ocft/caselib.in
> @@ -115,7 +115,8 @@ agent_run()
> sleep 3
> kill -SIGKILL -$pid >/dev/null 2>&1
> echo -n "${__OCFT__showhost}ERROR: The agent was hanging, killed it, "
> - echo "maybe you damaged the agent or system's environment."
> + echo "maybe you damaged the agent or system's environment, see details below:"
> + cat /tmp/.ocft_runlog
> echo
> quit 1
> fi
> diff --git a/tools/ocft/db2 b/tools/ocft/db2
> index 9b69350..7013a99 100644
> --- a/tools/ocft/db2
> +++ b/tools/ocft/db2
> @@ -30,6 +30,8 @@
> # In order to install a real cluster refer to http://www.linux-ha.org/wiki/db2_(resource_agent)
>
> CONFIG
> + Agent db2
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> HangTimeout 40
>
> SETUP-AGENT
> diff --git a/tools/ocft/iscsi b/tools/ocft/iscsi
> index 0b09a25..c1325a1 100644
> --- a/tools/ocft/iscsi
> +++ b/tools/ocft/iscsi
> @@ -1,7 +1,8 @@
> # iscsi
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent iscsi
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage open-iscsi
> InstallPackage iscsitarget
> HangTimeout 20
> diff --git a/tools/ocft/mysql b/tools/ocft/mysql
> index f0b475e..27fcb58 100644
> --- a/tools/ocft/mysql
> +++ b/tools/ocft/mysql
> @@ -1,7 +1,8 @@
> # mysql
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent mysql
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage mysql
> HangTimeout 20
>
> diff --git a/tools/ocft/named b/tools/ocft/named
> index c1f4624..90a4351 100644
> --- a/tools/ocft/named
> +++ b/tools/ocft/named
> @@ -4,8 +4,11 @@
> # packages installed.
>
> CONFIG
> + Agent named
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage bind
> InstallPackage bind-utils
> +
> SETUP-AGENT
> /etc/init.d/named start
> /etc/init.d/named stop
> diff --git a/tools/ocft/nfsserver b/tools/ocft/nfsserver
> index 2fa905f..cd73164 100644
> --- a/tools/ocft/nfsserver
> +++ b/tools/ocft/nfsserver
> @@ -1,7 +1,8 @@
> # nfsserver
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent nfsserver
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage nfs-kernel-server
> HangTimeout 20
>
> diff --git a/tools/ocft/ocft.in b/tools/ocft/ocft.in
> index c286b52..4be27b9 100644
> --- a/tools/ocft/ocft.in
> +++ b/tools/ocft/ocft.in
> @@ -196,6 +196,7 @@ agent_finish()
> rm -f $CASES_DIR/${agent}_cleanup
> rm -f $CASES_DIR/${agent}_var
> rm -f $CASES_DIR/${agent}_hosts
> + cfg_agent=
> cfg_agent_root=
> cfg_install_package=()
> cfg_hang_timeout=20
> @@ -255,7 +256,7 @@ parse_cfg()
> cat >$sh <<EOF
> #!/bin/bash
>
> -# Agent: $agent
> +# Agent: $cfg_agent
> # Summary: ${branch[0]}
>
> . $OCFT_DIR/caselib || {
> @@ -286,6 +287,10 @@ EOF
> case "$stat" in
> 1)
> case "${trunk[0]}" in
> + Agent)
> + trunk2branch
> + cfg_agent="${branch[0]}"
> + ;;
> AgentRoot)
> trunk2branch
> cfg_agent_root="${branch[0]}"
> @@ -332,11 +337,11 @@ __OCFT__VERBOSE=\$__OCFT__VERBOSE
> CMD
> backbash $host <$OCFT_DIR/caselib
> backbash $host <<'CMD'
> -__OCFT__showhost="${host}: "
> -__OCFT__MYROOT="$cfg_agent_root"
> -
> $(test -r $CASES_DIR/${agent}_var && cat $CASES_DIR/${agent}_var)
>
> +__OCFT__MYROOT="$cfg_agent_root"
> +__OCFT__showhost="${host}: "
> +
> $(test -n "$cfg_install_package" && echo "agent_install ${cfg_install_package[@]}")
> CMD
> EOF
> @@ -374,54 +379,60 @@ EOF
> if [ -z "${branch[1]}" ]; then
> if [ "${branch[0]}" = "start" ]; then
> cat >>$sh <<EOF
> -agent_run $(add_quotes 1 "$agent") status $cfg_hang_timeout
> +agent_run $(add_quotes 1 "$cfg_agent") status $cfg_hang_timeout
> __OCFT__rc=\$?
> if [ \$__OCFT__rc -eq \$OCF_ERR_UNIMPLEMENTED ]; then
> - agent_run $(add_quotes 1 "$agent") monitor $cfg_hang_timeout
> + agent_run $(add_quotes 1 "$cfg_agent") monitor $cfg_hang_timeout
> __OCFT__rc=\$?
> fi
>
> -if [ \$__OCFT__rc -eq \$OCF_SUCCESS ]; then
> +if [ \$__OCFT__rc -eq \$OCF_SUCCESS -o \$__OCFT__rc -eq \$OCF_RUNNING_MASTER ]; then
> : #The status I want, so I can do nothing.
> elif [ \$__OCFT__rc -eq \$OCF_NOT_RUNNING ]; then
> if [ -n "\$__OCFT__VERBOSE" ]; then
> - echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$agent start")
> + echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$cfg_agent ${branch[0]}")
> fi
> - agent_run $(add_quotes 1 "$agent") start $cfg_hang_timeout
> - check_success \$? $(add_quotes 1 "./$agent start")
> + agent_run $(add_quotes 1 "$cfg_agent") start $cfg_hang_timeout
> + check_success \$? $(add_quotes 1 "./$cfg_agent ${branch[0]}")
> else
> - check_success \$__OCFT__rc $(add_quotes 1 "./$agent status|monitor")
> + check_success \$__OCFT__rc $(add_quotes 1 "./$cfg_agent status|monitor")
> fi
> EOF
> elif [ "${branch[0]}" = "stop" ]; then
> cat >>$sh <<EOF
> -agent_run $(add_quotes 1 "$agent") status $cfg_hang_timeout
> +agent_run $(add_quotes 1 "$cfg_agent") status $cfg_hang_timeout
> __OCFT__rc=\$?
> if [ \$__OCFT__rc -eq \$OCF_ERR_UNIMPLEMENTED ]; then
> - agent_run $(add_quotes 1 "$agent") monitor $cfg_hang_timeout
> + agent_run $(add_quotes 1 "$cfg_agent") monitor $cfg_hang_timeout
> __OCFT__rc=\$?
> fi
>
> if [ \$__OCFT__rc -eq \$OCF_NOT_RUNNING ]; then
> : #The status I want, so I can do nothing.
> -elif [ \$__OCFT__rc -eq \$OCF_SUCCESS ]; then
> +elif [ \$__OCFT__rc -eq \$OCF_SUCCESS -o \$__OCFT__rc -eq \$OCF_RUNNING_MASTER ]; then
> if [ -n "\$__OCFT__VERBOSE" ]; then
> - echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$agent stop")
> + echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$cfg_agent ${branch[0]}")
> fi
> - agent_run $(add_quotes 1 "$agent") stop $cfg_hang_timeout
> - check_success \$? $(add_quotes 1 "./$agent stop")
> + agent_run $(add_quotes 1 "$cfg_agent") stop $cfg_hang_timeout
> + check_success \$? $(add_quotes 1 "./$cfg_agent ${branch[0]}")
> else
> - check_success \$__OCFT__rc $(add_quotes 1 "./$agent status|monitor")
> + check_success \$__OCFT__rc $(add_quotes 1 "./$cfg_agent status|monitor")
> fi
> EOF
> elif [ "${branch[0]}" = "status" -o "${branch[0]}" = "monitor" ]; then
> cat >>$sh <<EOF
> -agent_run $(add_quotes 1 "$agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
> +if [ -n "\$__OCFT__VERBOSE" ]; then
> + echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$cfg_agent ${branch[0]}")
> +fi
> +agent_run $(add_quotes 1 "$cfg_agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
> EOF
> else
> cat >>$sh <<EOF
> -agent_run $(add_quotes 1 "$agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
> -check_success \$? $(add_quotes 1 "./$agent ${branch[0]}")
> +if [ -n "\$__OCFT__VERBOSE" ]; then
> + echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$cfg_agent ${branch[0]}")
> +fi
> +agent_run $(add_quotes 1 "$cfg_agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
> +check_success \$? $(add_quotes 1 "./$cfg_agent ${branch[0]}")
> EOF
> fi
> else
> @@ -429,9 +440,9 @@ EOF
> test -n $(add_quotes 2 "\$${branch[1]}")
> check_success \$? $(add_quotes 1 "test -n \"\$${branch[1]}\"")
> if [ -n "\$__OCFT__VERBOSE" ]; then
> - echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$agent ${branch[0]}")
> + echo $(add_quotes 2 " \${__OCFT__showhost}Running agent: ./$cfg_agent ${branch[0]}")
> fi
> -agent_run $(add_quotes 1 "$agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
> +agent_run $(add_quotes 1 "$cfg_agent") $(add_quotes 1 "${branch[0]}") $cfg_hang_timeout
> __OCFT__ret=\$?
> if [ -n "\$__OCFT__VERBOSE" ]; then
> echo -n " \${__OCFT__showhost}Checking return value:"
> @@ -501,10 +512,10 @@ EOF
> cat >$CASES_DIR/setup_${agent}.sh <<EOF
> #!/bin/bash
>
> -# Agent: $agent
> +# Agent: $cfg_agent
> # Summary: SETUP before test
>
> -echo "Initializing '$agent' ..."
> +echo "Initializing '$cfg_agent' ..."
>
> . $OCFT_DIR/caselib || {
> echo "ERROR: '$OCFT_DIR/caselib' not found."
> @@ -514,9 +525,6 @@ echo "Initializing '$agent' ..."
> $(test -r "$CASES_DIR/${agent}_var" && cat $CASES_DIR/${agent}_var)
> $(test -n "$cfg_install_package" && echo "agent_install ${cfg_install_package[@]}")
>
> -$(cat $CASES_DIR/${agent}_setup)
> -check_success \$? "SETUP-AGENT"
> -
> EOF
> for host in $(test -r $CASES_DIR/${agent}_hosts && cat $CASES_DIR/${agent}_hosts); do
> cat >>$CASES_DIR/setup_${agent}.sh <<EOF
> @@ -527,9 +535,11 @@ __OCFT__VERBOSE=\$__OCFT__VERBOSE
> CMD
> backbash $host <$OCFT_DIR/caselib
> backbash $host <<'CMD'
> +$(test -r "$CASES_DIR/${agent}_var" && cat $CASES_DIR/${agent}_var)
> +
> __OCFT__MYROOT="$cfg_agent_root"
> __OCFT__showhost="${host}: "
> -$(test -r "$CASES_DIR/${agent}_var" && cat $CASES_DIR/${agent}_var)
> +
> $(test -n "$cfg_install_package" && echo "agent_install ${cfg_install_package[@]}")
>
> $(cat $CASES_DIR/${agent}_setup)
> @@ -539,6 +549,9 @@ backbash_stop $host
> EOF
> done
> cat >>$CASES_DIR/setup_${agent}.sh <<EOF
> +$(cat $CASES_DIR/${agent}_setup)
> +check_success \$? "SETUP-AGENT"
> +
> echo "Done."
> echo
> quit 0
> @@ -550,10 +563,10 @@ EOF
> cat >$CASES_DIR/cleanup_${agent}.sh <<EOF
> #!/bin/bash
>
> -# Agent: $agent
> +# Agent: $cfg_agent
> # Summary: CLEANUP after test
>
> -echo "Cleaning '$agent' ..."
> +echo "Cleaning '$cfg_agent' ..."
>
> . $OCFT_DIR/caselib || {
> echo "ERROR: '$OCFT_DIR/caselib' not found."
> @@ -576,9 +589,11 @@ __OCFT__VERBOSE=\$__OCFT__VERBOSE
> CMD
> backbash $host <$OCFT_DIR/caselib
> backbash $host <<'CMD'
> +$(test -r "$CASES_DIR/${agent}_var" && cat $CASES_DIR/${agent}_var)
> +
> __OCFT__MYROOT="$cfg_agent_root"
> __OCFT__showhost="${host}: "
> -$(test -r "$CASES_DIR/${agent}_var" && cat $CASES_DIR/${agent}_var)
> +
> $(test -n "$cfg_install_package" && echo "agent_install ${cfg_install_package[@]}")
>
> $(cat $CASES_DIR/${agent}_cleanup)
> @@ -729,6 +744,7 @@ agent=
> line_num=
>
> # default configuration
> +cfg_agent=
> cfg_agent_root=
> cfg_install_package=()
> cfg_hang_timeout=20
> diff --git a/tools/ocft/pgsql b/tools/ocft/pgsql
> index 859b82e..9944b09 100644
> --- a/tools/ocft/pgsql
> +++ b/tools/ocft/pgsql
> @@ -1,7 +1,8 @@
> # pgsql
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent pgsql
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage postgresql-server
> HangTimeout 20
>
> diff --git a/tools/ocft/portblock b/tools/ocft/portblock
> index 57794fe..3475c63 100644
> --- a/tools/ocft/portblock
> +++ b/tools/ocft/portblock
> @@ -1,7 +1,8 @@
> # portblock
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent portblock
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage iptables
> HangTimeout 15
>
> diff --git a/tools/ocft/postfix b/tools/ocft/postfix
> index 2d897c9..f17e968 100644
> --- a/tools/ocft/postfix
> +++ b/tools/ocft/postfix
> @@ -12,7 +12,8 @@
> # -o config_dir="/root/postfix/" /usr/lib/ocf/resource.d/heartbeat/postfix; echo $?
>
> CONFIG
> - #AgentRoot /usr/lib/ocf/resource.d/heartbeat
> + Agent postfix
> + AgentRoot /usr/lib/ocf/resource.d/heartbeat
> InstallPackage postfix
> HangTimeout 20
>
> --
> 1.6.4.2
>

> From 3fa7e4db8125707ff7e4c77ebf79d513030ec9a2 Mon Sep 17 00:00:00 2001
> From: John Shi <jshi@suse.com>
> Date: Wed, 9 Nov 2011 22:43:56 +0800
> Subject: [PATCH 2/2] Low: tools: ocft: add test case for linbit-drbd
>
> ---
> tools/ocft/Makefile.am | 1 +
> tools/ocft/drbd.linbit | 183 ++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 184 insertions(+), 0 deletions(-)
> create mode 100644 tools/ocft/drbd.linbit
>
> diff --git a/tools/ocft/Makefile.am b/tools/ocft/Makefile.am
> index 97c2d96..fb54e76 100644
> --- a/tools/ocft/Makefile.am
> +++ b/tools/ocft/Makefile.am
> @@ -31,6 +31,7 @@ ocftcfgs_DATA = apache \
> mysql \
> pgsql \
> db2 \
> + drbd.linbit \
> nfsserver \
> portblock \
> iscsi \
> diff --git a/tools/ocft/drbd.linbit b/tools/ocft/drbd.linbit
> new file mode 100644
> index 0000000..4cc5519
> --- /dev/null
> +++ b/tools/ocft/drbd.linbit
> @@ -0,0 +1,183 @@
> +# linbit: drbd
> +
> +CONFIG
> + Agent drbd
> + AgentRoot /usr/lib/ocf/resource.d/linbit
> + InstallPackage drbd
> + HangTimeout 20
> +
> +VARIABLE
> + DRBDCONF=/tmp/ocft_drbd_tmp.conf
> +
> + # should be this machine's hostname/ip, please modify it by yourself.
> + NAME_1=HOSTNAME1
> + IP_1=IP_ADDRESS1
> +
> + # the block device just for test, please modify it by yourself.
> + DISK_1=/dev/DEVICE1
> +
> + PORT_1=5735
> + DEVICE_1=/dev/drbd0
> +
> + ####################################################################
> +
> + # please modify it by yourself.
> + NAME_2=HOSTNAME2
> + IP_2=IP_ADDRESS2
> +
> + # the block device just for test, please modify it by yourself.
> + DISK_2=/dev/DEVICE2
> +
> + PORT_2=5735
> + DEVICE_2=/dev/drbd0
> +
> +
> +
> +SETUP-AGENT
> + cat >$DRBDCONF <<EOF
> + global {
> + usage-count no;
> + }
> +
> + resource ocft0 {
> + protocol C;
> + disk {
> + on-io-error detach;
> + }
> + on $NAME_1 {
> + device $DEVICE_1;
> + address $IP_1:$PORT_1;
> + meta-disk internal;
> + disk $DISK_1;
> + }
> + on $NAME_2 {
> + device $DEVICE_2;
> + address $IP_2:$PORT_2;
> + meta-disk internal;
> + disk $DISK_2;
> + }
> + }
> +EOF
> + HOST=$(uname -n)
> + DRBDADM="drbdadm -c $DRBDCONF"
> +
> + # prepare
> + modprobe drbd $(drbdadm sh-mod-parms)
> + $DRBDADM down ocft0
> +
> + # create meta data block if necessary
> + $DRBDADM dump-md ocft0 >/dev/null 2>&1
> + if [ $? -eq 255 ]; then
> + $DRBDADM create-md ocft0
> + fi
> +
> + # start drbd
> + $DRBDADM up ocft0
> +
> + # UpToDate
> + if [ "$HOST" = "$NAME_1" ]; then
> + $DRBDADM wait-connect ocft0
> + echo "drbd Syncing .."
> + $DRBDADM primary --force ocft0
> + while true; do
> + CSTATE=$($DRBDADM cstate ocft0)
> + DSTATE=$($DRBDADM dstate ocft0)
> + if [ "$CSTATE" = "Connected" -a "$DSTATE" = "UpToDate/UpToDate" ]; then
> + break
> + else
> + sleep 3
> + fi
> + done
> + echo "done"
> + fi
> +
> +CLEANUP-AGENT
> + drbdadm -c $DRBDCONF down ocft0
> + rm -f $DRBDCONF
> +
> +CASE-BLOCK required_args
> + Env OCF_RESKEY_drbdconf=$DRBDCONF
> + Env OCF_RESKEY_drbd_resource=ocft0
> + Env OCF_RESKEY_CRM_meta_notify=true
> + Env OCF_RESKEY_CRM_meta_clone_max=2
> +
> +CASE-BLOCK default_status
> + AgentRun stop
> +
> +CASE-BLOCK prepare
> + Include required_args
> + Include default_status
> +
> +CASE "check base env"
> + Include required_args
> + AgentRun validate-all OCF_SUCCESS
> +
> +CASE "normal start"
> + Include prepare
> + AgentRun start OCF_SUCCESS
> +
> +CASE "normal stop"
> + Include prepare
> + AgentRun start
> + AgentRun stop OCF_SUCCESS
> +
> +CASE "wrong path of config file"
> + Include prepare
> + Env OCF_RESKEY_drbdconf=no_such_file
> + AgentRun start OCF_ERR_INSTALLED
> +
> +CASE "wrong resource name"
> + Include prepare
> + Env OCF_RESKEY_drbd_resource=no_such_src
> + # OCF_RESKEY_drbd_resource is a required parameter in agent meta-data,
> + # if wrong, I think the agent should return OCF_ERR_CONFIGURED.
> + AgentRun start OCF_ERR_CONFIGURED
> +
> +CASE "double start"
> + Include prepare
> + AgentRun start
> + AgentRun start OCF_SUCCESS
> +
> +CASE "double stop"
> + Include prepare
> + AgentRun stop OCF_SUCCESS
> +
> +CASE "running monitor"
> + Include prepare
> + AgentRun start
> + AgentRun monitor OCF_SUCCESS
> +
> +CASE "not running monitor"
> + Include prepare
> + AgentRun monitor OCF_NOT_RUNNING
> +
> +CASE "Primary/Secondary monitor"
> + Include prepare
> + AgentRun start
> + AgentRun promote
> + AgentRun monitor OCF_RUNNING_MASTER
> + AgentRun demote
> + AgentRun monitor OCF_SUCCESS
> +
> +CASE "unimplemented command"
> + Include prepare
> + AgentRun no_cmd OCF_ERR_UNIMPLEMENTED
> +
> +CASE "try to 'promote' in single-primary mode"
> + Include prepare
> + Include@$IP_2 prepare
> +
> + # start drbd
> + AgentRun start
> + AgentRun@$IP_2 start
> +
> + # promote local drbd first
> + AgentRun promote OCF_SUCCESS
> +
> + # demote local drbd prepare for remote drbd promote
> + AgentRun demote
> + # remote drbd promote
> + AgentRun@$IP_2 promote OCF_SUCCESS
> +
> + # promote fails, because remote drbd promote first.
> + AgentRun promote OCF_ERR_GENERIC
> --
> 1.6.4.2
>

_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical