[prev in list] [next in list] [prev in thread] [next in thread] 

List:       drbd-cvs
Subject:    [DRBD-cvs] testing by lars; more improvements for the bash CTH
From:       drbd-cvs () linbit ! com
Date:       2004-05-28 8:32:57
Message-ID: 20040528083257.7488C15DF60 () garcon ! linbit ! com
[Download RAW message or body]

DRBD CVS committal

Author  : lars
Project : drbd
Module  : testing

Dir     : drbd/testing/CTH


Modified Files:
      Tag: rel-0_7-branch
	CTH_bash.conf CTH_bash.helpers CTH_bash.sh functions.sh 


Log Message:
more improvements for the bash CTH
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/CTH_bash.conf,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -3 -r1.1.2.2 -r1.1.2.3
--- CTH_bash.conf	27 May 2004 17:46:58 -0000	1.1.2.2
+++ CTH_bash.conf	28 May 2004 08:32:52 -0000	1.1.2.3
@@ -1,10 +1,12 @@
 #!/bin/bash -nv
-# $Id: CTH_bash.conf,v 1.1.2.2 2004/05/27 17:46:58 lars Exp $
+# $Id: CTH_bash.conf,v 1.1.2.3 2004/05/28 08:32:52 lars Exp $
 
 # NOTE that there is no plausibility check going on
 # in this bash version of the CTH.
 # You have to get the config right.
 
+# this one is similar to uml-minna.conf
+
 Node_1=(
 	192.168.200.1	# admin_ip
 	uml-1		# node name
@@ -41,7 +43,7 @@
 # CTH currently knows about ext2, ext3, resierfs, xfs
 #      DRBD        type         mountpoint
 FS_1="DRBD=Drbd_1 TYPE=reiserfs MNT=/mnt/ha0"
-FS_2="DRBD=Drbd_2 TYPE=ext3     MNT=/mnt/ha0"
+FS_2="DRBD=Drbd_2 TYPE=ext3     MNT=/mnt/ha1"
 
 # test resources
 RS_1=wbtest
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/CTH_bash.helpers,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -3 -r1.1.2.2 -r1.1.2.3
--- CTH_bash.helpers	27 May 2004 17:46:58 -0000	1.1.2.2
+++ CTH_bash.helpers	28 May 2004 08:32:52 -0000	1.1.2.3
@@ -1,5 +1,5 @@
 #!/bin/bash -nv
-# $Id: CTH_bash.helpers,v 1.1.2.2 2004/05/27 17:46:58 lars Exp $
+# $Id: CTH_bash.helpers,v 1.1.2.3 2004/05/28 08:32:52 lars Exp $
 #
 # define some implicit magic
 # so the definition of the DRBDs will be easier
@@ -8,6 +8,8 @@
 ID_DISK=0
 ID_DRBD=0
 DRBD_CONF=""
+unset ${!Node_*} ${!Link_*} ${!Disk_*} ${!Drbd_*} ${!FS_*} ${!RS_*}
+
 link_for_each_node()
 {
 	local link=$1 doit=$2
@@ -139,41 +141,50 @@
 }	
 
 
-crash_Node()
+Crash_Node()
 {
 	local n=$1
 	on ${!n}: generic_do_crash
 }
 
-wait_for_boot()
+Wait_for_boot()
 {
 	local n=$1
 	node_to_env $n
-	on ${!n}: generic_do_crash
 	ip=$admin_ip
 	generic_wait_for_boot
 }
 
-fail_Link()
+cat_proc_blah()
+{
+	cat /proc/{drbd,loadavg,meminfo} 2>&1
+	grep "drbd\|xfs\|reiser\|ext" /proc/slabinfo
+}
+Node_State()
+{
+	on ${!1}: cat_proc_blah
+}
+
+Fail_Link()
 {
 	local l=$1
 	link_for_each_node $l 'on ${!node}: iptables_DROP   nic=$nic hostname=$hostname'
 }
 
-heal_Link()
+Heal_Link()
 {
 	local l=$1
 	link_for_each_node $l 'on ${!node}: iptables_UNDROP   nic=$nic hostname=$hostname'
 }
 
-fail_Disk()
+Fail_Disk()
 {
 	local d=$1
 	disk_to_env $d
 	on ${!node}: dmsetup_error name=$name dev=$real_dev
 }
 
-heal_Disk()
+Heal_Disk()
 {
 	local d=$1
 	disk_to_env $d
@@ -182,19 +193,20 @@
 
 # initial boot
 boot_and_setup_nodes()
-{
+{ (
 	initial=true
 	for n in ${!Node_*}; do
 		node_to_env $n
 		ip=$admin_ip
+		echo "looking for $hostname ($ip)"
 		generic_wait_for_boot
 	done
 
 	# undrop all links
-	for l in ${!Link_*} ; do heal_Link $l ; done
+	for l in ${!Link_*} ; do Heal_Link $l ; done
 
 	# configure all dm disks
-	for d in ${!Disk_*} ; do heal_Disk $d ; done
+	for d in ${!Disk_*} ; do Heal_Disk $d ; done
 
 	# reset and up all DRBDs
 	for d in ${!Drbd_*} ; do
@@ -226,9 +238,9 @@
 	done
 
 	initial=false
-}
+) }
 
-resource_Start_on_Node()
+Start()
 {
 	local rs=$1 nn=$2
 	i=${rs#RS_}
@@ -236,24 +248,26 @@
 	fs=FS_$i; CN=""
 	eval ${!fs}
 
-	[[ -z $CN && -z $cn ]] || exit 101
-	[[ $nn == Node_* ]]    || exit 102
+	[[ -z $CN && -z $cn ]] || return 101
+	[[ $nn == Node_* ]]    || return 102
 
 	drbd_to_env $DRBD
+	on ${!nn}: drbd_wait_peer_not_pri minor=$minor
 	on ${!nn}: drbdadm_pri   name=$name
 	on ${!nn}: do_mount      DEV=/dev/nb$minor TYPE=$TYPE MNT=$MNT
 
 	# START IN BACKGROUND
-	on ${!nn}: ${which}_start   MNT=$MNT &
+	on ${!nn}: ${which}_start   MNT=$MNT </dev/null &
 
 	# rememeber current node
 	eval "$fs=\"\$$fs CN=$nn\""
 	eval "$rs=\"\$$rs CN=$nn\""
 
 	echo "$rs now RUNNING on $nn"
+	Dump_RS
 }
 
-resource_Stop()
+Stop()
 {
 	local rs=$1
 	i=${rs#RS_}
@@ -261,9 +275,9 @@
 	fs=FS_$i; CN=""
 	eval "${!fs}"
 
-	[[ -z $CN || -z $cn ]] && exit 101
-	[[ $CN == $cn ]]       || exit 102
-	[[ $cn == Node_* ]]    || exit 103
+	[[ -z $CN || -z $cn ]] && return 101
+	[[ $CN == $cn ]]       || return 102
+	[[ $cn == Node_* ]]    || return 103
 
 	drbd_to_env $DRBD
 	on ${!cn}: generic_test_stop MNT=$MNT
@@ -271,15 +285,16 @@
 	on ${!cn}: drbdadm_sec       name=$name
 	eval "$fs=\${$fs% CN=*}"   # forget current node
 	eval "$rs=\${$rs% CN=*}"   # forget current node
+	Dump_RS
 }
 
-resource_relocate_to_Node()
+Relocate()
 {
 	local rs=$1 nn=$2
 	if [[ ${!rs} == *CN=* ]] ; then
-		resource_Stop $rs
+		Stop $rs
 	fi
-	resource_Start_on_Node $rs $nn
+	Start $rs $nn
 }
 
 # for verification
@@ -295,3 +310,45 @@
 		Dump $n
 	done
 }
+Dump_RS()
+{
+	for r in ${!RS_*}; do
+		printf "%s=%q\n" "$r" "${!r}"
+	done
+}
+
+Help()
+{
+	cat <<-___
+	#
+	#  start something on some node:
+	#     Start RS_1 Node_1
+	#
+	#  relocate it:
+	#     Reloc RS_1 Node_2
+	#
+	#  stop it again:
+	#     Stop RS_1
+	#
+	#  sleep \$for_a_while # ;-)
+	#
+	#  fail and heal hardware:
+	#     Crash_Node    Node_#
+	#     Wait_for_boot Node_#
+	#     Fail_Link Link_#
+	#     Heal_Link Link_#
+	#     Fail_Disk Disk_#
+	#     Heal_Disk Disk_#
+	#
+	# see this text again:
+	#     Help  # <<=== note the capital H
+	# 
+	# see your resources:
+	#     Dump_RS
+	# 
+	# ask for
+	#     Node_State Node_1
+	#
+___
+}
+
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/CTH_bash.sh,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -3 -r1.1.2.2 -r1.1.2.3
--- CTH_bash.sh	27 May 2004 17:46:58 -0000	1.1.2.2
+++ CTH_bash.sh	28 May 2004 08:32:52 -0000	1.1.2.3
@@ -1,5 +1,5 @@
 #!/usr/bin/env - /bin/bash
-# $Id: CTH_bash.sh,v 1.1.2.2 2004/05/27 17:46:58 lars Exp $
+# $Id: CTH_bash.sh,v 1.1.2.3 2004/05/28 08:32:52 lars Exp $
 
 # example for scripting failures
 # 
@@ -7,12 +7,21 @@
 # ot generate random hardware failures and resource relocations,
 # this is meant to script a particular failure scenario.
 #
+# if you source this, you can use it interactively:
+#   source CTH_bash.sh bloodymary.sh.conf CASE=interactive
+#
+
+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
+# source ./CTH_bash.conf # uml-minna.sh.conf
+# source ./bloodymary.sh.conf
+source $CONF
 
 # verify
 # Dump_All
@@ -23,38 +32,44 @@
 __I_MEAN_IT__=__YES__
 source ./functions.sh
 
+trap 'echo "exit_code: $?"' ERR EXIT # show exit codes != 0
 boot_and_setup_nodes
 
 cat <<___
 #
 # ok, all up and configured, and fresh file systems created...
 #
-# now we can
-#
-#  start something on some node:
-#     resource_Start_on_Node RS_1 Node_1
-#
-#  relocate it:
-#     resource_relocate_to_Node RS_1 Node_2
+___
+if [[ -e $CASE ]] ; then
+	echo "now run CASE=$CASE"
+	( source $CASE )
+fi
+
+set +errexit # disable this again.
+cat <<___
 #
-#  stop it again:
-#     resource_Stop RS_1
-#
-#  sleep \$for_a_while # ;-)
-#
-#  fail and heal hardware:
-#     crash_Node    Node_#
-#     wait_for_boot Node_#
-#     fail_Link Link_#
-#     heal_Link Link_#
-#     fail_Disk Disk_#
-#     heal_Disk Disk_#
+# now you can:
 #
 ___
+Help
+Dump_RS
+
+# interactive TAB completion
+_start_and_reloc_completion()
+{
+	local v
+	eval "v=\${!${COMP_WORDS[COMP_CWORD]}*}"
+	if (( COMP_CWORD <= 1 )) ; then
+		COMPREPLY=(${v:-${!RS_*}})
+	elif (( COMP_CWORD <= 2 )) ; then
+		COMPREPLY=(${v:-${!Node_*}})
+	else
+		COMPREPLY=()
+	fi
+}
+complete -v -X '!Node_*' Node_State Crash_Node Wait_for_boot
+complete -v -X '!Link_*' Fail_Link Heal_Link
+complete -v -X '!Disk_*' Fail_Disk Heal_Disk
+complete -v -X '!RS_*'   Stop
+complete -F _start_and_reloc_completion Start Relocate
 
-# for example:
-#   resource_Start_on_Node RS_1 Node_1
-#   sleep 30
-#   resource_relocate_to_Node RS_1 Node_2
-#   sleep 30
-#   resource_Stop RS_1
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/functions.sh,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -3 -r1.1.2.2 -r1.1.2.3
--- functions.sh	27 May 2004 17:46:58 -0000	1.1.2.2
+++ functions.sh	28 May 2004 08:32:52 -0000	1.1.2.3
@@ -1,6 +1,6 @@
 #!/bin/bash
 # vim: set foldmethod=marker nofoldenable :
-# $Id: functions.sh,v 1.1.2.2 2004/05/27 17:46:58 lars Exp $
+# $Id: functions.sh,v 1.1.2.3 2004/05/28 08:32:52 lars Exp $
 #DEBUG="-vx"
 #DEBUG="-v"
 
@@ -19,6 +19,7 @@
 {
 	: ${MNT:?unknown mount point}
 	grep -q " $MNT " /proc/mounts && {
+		echo "killall users of $HOSTNAME:$MNT/"
 		fuser -TERM -vkm $MNT/ && sleep 2 &&
 		while fuser -vkm $MNT/ ; do sleep 1 ; done
 	}
@@ -144,6 +145,7 @@
 	[[ -z $initial ]] && initial=false || initial=true
 	: ${ip:?unknown admin ip} 
 	: ${hostname:?unknown hostname} 
+	SECONDS=0   # reset bash magic variable
 	while true; do
 		ping -c 1 $ip > /dev/null && break
 		[[ $? == 2 ]] && exit 2
@@ -259,7 +261,7 @@
 	# USIZE=${USIZE:+$[(USIZE+128)*1024]} # FIXME assert USIZE <= RSIZE
 	: ${USIZE:=$RSIZE}
 	let "MLOC=USIZE-128*1024"
-	echo -n "Wipeout GC and AL area on $LO_DEV via /dev/mapper/$NAME for resource $RES"
+	echo -n "Wipeout GC and AL area on $HOSTNAME:$LO_DEV via /dev/mapper/$NAME for resource $RES"
 	# drbdadm down $RES
 	dd if=/dev/zero bs=1024 seek=$MLOC count=128 of=/dev/mapper/$NAME &>/dev/null
 	sync



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic