[DRBD-cvs] testing by lars; * some "local" vars * better handling o...
drbd-user@lists.linbit.com
drbd-user@lists.linbit.com
Tue, 1 Jun 2004 09:02:01 +0200 (CEST)
DRBD CVS committal
Author : lars
Project : drbd
Module : testing
Dir : drbd/testing/CTH
Modified Files:
Tag: rel-0_7-branch
CTH_bash.helpers CTH_bash.sh T-000.sh T-001.sh T-002.sh
functions.sh
Log Message:
* some "local" vars
* better handling of set -o errexit
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/CTH_bash.helpers,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -3 -r1.1.2.5 -r1.1.2.6
--- CTH_bash.helpers 28 May 2004 11:52:43 -0000 1.1.2.5
+++ CTH_bash.helpers 1 Jun 2004 07:01:56 -0000 1.1.2.6
@@ -1,5 +1,5 @@
#!/bin/bash -nv
-# $Id: CTH_bash.helpers,v 1.1.2.5 2004/05/28 11:52:43 lars Exp $
+# $Id: CTH_bash.helpers,v 1.1.2.6 2004/06/01 07:01:56 lars Exp $
#
# define some implicit magic
# so the definition of the DRBDs will be easier
@@ -211,6 +211,7 @@
# initial boot
boot_and_setup_nodes()
{ (
+ set -e
initial=true
for n in ${!Node_*}; do
node_to_env $n
@@ -286,7 +287,7 @@
Stop()
{
- local rs=$1
+ local rs=$1 i fs cn CN which
i=${rs#RS_}
which=${!rs}; [[ $which == *CN=* ]] && cn=${which#*CN=} || cn=''
fs=FS_$i; CN=""
@@ -305,10 +306,16 @@
Dump_RS
}
-Relocate()
+Reloc()
{
- local rs=$1 nn=$2
+ local rs=$1 nn=$2 cn
if [[ ${!rs} == *CN=* ]] ; then
+ cn=${!rs}; cn=${rs#*CN=}
+ if [[ $cn == $nn ]] ; then
+ echo "$rs already running on $nn"
+ Dump_RS
+ return
+ fi
Stop $rs
fi
Start $rs $nn
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/CTH_bash.sh,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -3 -r1.1.2.5 -r1.1.2.6
--- CTH_bash.sh 28 May 2004 11:52:43 -0000 1.1.2.5
+++ CTH_bash.sh 1 Jun 2004 07:01:56 -0000 1.1.2.6
@@ -1,5 +1,5 @@
#!/usr/bin/env - /bin/bash
-# $Id: CTH_bash.sh,v 1.1.2.5 2004/05/28 11:52:43 lars Exp $
+# $Id: CTH_bash.sh,v 1.1.2.6 2004/06/01 07:01:56 lars Exp $
# example for scripting failures
#
@@ -11,41 +11,61 @@
# source CTH_bash.sh bloodymary.sh.conf CASE=interactive
#
+[[ $- == *i* ]] && INTERACTIVE=true || INTERACTIVE=false
+
CONF=$1 CASE=$2
: ${CONF:?please tell me the config file of your choice}
: ${CASE:?please tell me the test case to run}
-source ./CTH_bash.helpers
-
-# get the configuration
-# YOU MUST GET THIS RIGHT !
-# source ./CTH_bash.conf # uml-minna.sh.conf
-# source ./bloodymary.sh.conf
-clear_env
-source $CONF
-
-# verify
-# Dump_All
-# exit 0
-
-# get the generic test harness functions
-# DEBUG=-vx
-__I_MEAN_IT__=__YES__
-source ./functions.sh
-
-trap 'echo "exit_code: $?"' ERR EXIT # show exit codes != 0
-boot_and_setup_nodes
+Run()
+{
+ source ./CTH_bash.helpers || return
+
+ # get the configuration
+ # YOU MUST GET THIS RIGHT !
+ # source ./CTH_bash.conf # uml-minna.sh.conf
+ # source ./bloodymary.sh.conf
+ clear_env
+ source $CONF || return
+
+ # verify
+ # Dump_All
+ # exit 0
+
+ # get the generic test harness functions
+ # DEBUG=-vx
+ __I_MEAN_IT__=__YES__
+ source ./functions.sh || return
+
+ boot_and_setup_nodes || return
+
+ cat <<-___
+ #
+ # ok, all up and configured, and fresh file systems created...
+ #
+ ___
+
+ set +o errexit # disable this again, but do something similar, and
+ trap 'ex=$?; echo "exit_code: $ex"; [[ $FUNCNAME ]] && return $ex' ERR # show exit codes != 0
+ if [[ -e $CASE ]] ; then
+ echo "now run CASE=$CASE"
+ source $CASE || return
+ fi
+
+ return
+}
+
+if Run; then
+ cat <<-___
+ #--- $CASE ----
+ # PASSED
+ #-----------------
+ ___
+else
+ echo "something went wrong. exit_code: $?"
+fi
-cat <<___
-#
-# ok, all up and configured, and fresh file systems created...
-#
-___
-if [[ -e $CASE ]] ; then
- echo "now run CASE=$CASE"
- ( source $CASE )
-elif [[ $- == *i* ]] ; then
- set +errexit # disable this again.
+if $INTERACTIVE ; then
cat <<-___
#
# now you can:
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/T-000.sh,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -3 -r1.1.2.1 -r1.1.2.2
--- T-000.sh 28 May 2004 08:35:01 -0000 1.1.2.1
+++ T-000.sh 1 Jun 2004 07:01:56 -0000 1.1.2.2
@@ -1,6 +1,6 @@
#!/usr/bin/env - /bin/bash
-# $Id: T-000.sh,v 1.1.2.1 2004/05/28 08:35:01 lars Exp $
+# $Id: T-000.sh,v 1.1.2.2 2004/06/01 07:01:56 lars Exp $
echo "dummy test: just wait_for_boot and mkfs"
echo "if this is reached, this test has"
-echo "PASSED"
+# PASSED
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/T-001.sh,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -3 -r1.1.2.1 -r1.1.2.2
--- T-001.sh 28 May 2004 08:35:01 -0000 1.1.2.1
+++ T-001.sh 1 Jun 2004 07:01:56 -0000 1.1.2.2
@@ -1,5 +1,5 @@
#!/usr/bin/env - /bin/bash
-# $Id: T-001.sh,v 1.1.2.1 2004/05/28 08:35:01 lars Exp $
+# $Id: T-001.sh,v 1.1.2.2 2004/06/01 07:01:56 lars Exp $
echo "START"
Start RS_1 Node_1
@@ -16,5 +16,3 @@
echo "STOP"
Stop RS_1
Stop RS_2
-
-echo "PASSED"
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/T-002.sh,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -3 -r1.1.2.1 -r1.1.2.2
--- T-002.sh 28 May 2004 08:35:01 -0000 1.1.2.1
+++ T-002.sh 1 Jun 2004 07:01:56 -0000 1.1.2.2
@@ -1,17 +1,27 @@
#!/usr/bin/env - /bin/bash
-# $Id: T-002.sh,v 1.1.2.1 2004/05/28 08:35:01 lars Exp $
+# $Id: T-002.sh,v 1.1.2.2 2004/06/01 07:01:56 lars Exp $
Start RS_1 Node_1
sleep 10
Fail_Disk Disk_1
-Node_State Node_1
sleep 5
-Stop RS_1
-Node_State Node_1
+Relocate RS_1 Node_2
-Start RS_1 Node_2 # Oops. Node_1 panics ??
+sleep 5
+
+Heal_Disk Disk_1
+
+# ToDo write a wrapper for this, and integrate with Heal_Disk ...
+on $Node_1: drbd_reattach minor=0 name=r0
+
+sleep 5
+
+Relocate RS_1 Node_1
+
+sleep 10
+Stop RS_1
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/functions.sh,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -3 -r1.1.2.3 -r1.1.2.4
--- functions.sh 28 May 2004 08:32:52 -0000 1.1.2.3
+++ functions.sh 1 Jun 2004 07:01:56 -0000 1.1.2.4
@@ -1,6 +1,6 @@
#!/bin/bash
# vim: set foldmethod=marker nofoldenable :
-# $Id: functions.sh,v 1.1.2.3 2004/05/28 08:32:52 lars Exp $
+# $Id: functions.sh,v 1.1.2.4 2004/06/01 07:01:56 lars Exp $
#DEBUG="-vx"
#DEBUG="-v"
@@ -312,8 +312,9 @@
{
: ${minor:?unknown minor number}
: ${name:?unknown resource name}
- if drbdsetup /dev/nb$minor show | grep "^Lower device:.*null"; then
+ if drbdsetup /dev/nb$minor show | grep -q "^Lower device:.*null"; then
drbdadm attach $name
+ echo "reattached $name on $HOSTNAME"
fi
}