[DRBD-cvs] testing by lars; improvements to the CTH. will hopefully ...
drbd-user@lists.linbit.com
drbd-user@lists.linbit.com
Tue, 15 Jun 2004 10:41:07 +0200 (CEST)
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
uml-minna.conf
Added Files:
Tag: rel-0_7-branch
T-007.sh
Log Message:
improvements to the CTH. will hopefully work out of the box.
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/CTH_bash.conf,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -3 -r1.1.2.4 -r1.1.2.5
--- CTH_bash.conf 7 Jun 2004 10:16:39 -0000 1.1.2.4
+++ CTH_bash.conf 15 Jun 2004 08:41:02 -0000 1.1.2.5
@@ -1,5 +1,5 @@
#!/bin/bash -nv
-# $Id: CTH_bash.conf,v 1.1.2.4 2004/06/07 10:16:39 lars Exp $
+# $Id: CTH_bash.conf,v 1.1.2.5 2004/06/15 08:41:02 lars Exp $
# NOTE that there is no plausibility check going on
# in this bash version of the CTH.
@@ -33,7 +33,7 @@
# name, minor and port, as well as the real_devs,
# better be UNIQUE on the respective nodes.
#
-# name minor port left left_real_dev right right_real_dev link
+# name minor port left left_real_dev right right_real_dev link usize
new_drbd r0 0 7788 Node_1 /dev/ubd/b Node_2 /dev/ubd/b Link_1
new_drbd r1 1 7789 Node_2 /dev/ubd/c Node_1 /dev/ubd/c Link_1
@@ -42,7 +42,7 @@
#
# CTH currently knows about ext2, ext3, resierfs, xfs
# BDEV type mountpoint
-FS_1="BDEV=Drbd_1 TYPE=reiserfs MNT=/mnt/ha0"
+FS_1="BDEV=Drbd_1 TYPE=ext3 MNT=/mnt/ha0"
FS_2="BDEV=Drbd_2 TYPE=ext3 MNT=/mnt/ha1"
# test resources
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/CTH_bash.helpers,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -3 -r1.1.2.9 -r1.1.2.10
--- CTH_bash.helpers 7 Jun 2004 13:58:27 -0000 1.1.2.9
+++ CTH_bash.helpers 15 Jun 2004 08:41:02 -0000 1.1.2.10
@@ -1,5 +1,5 @@
#!/bin/bash -nv
-# $Id: CTH_bash.helpers,v 1.1.2.9 2004/06/07 13:58:27 lars Exp $
+# $Id: CTH_bash.helpers,v 1.1.2.10 2004/06/15 08:41:02 lars Exp $
#
# define some implicit magic
# so the definition of the DRBDs will be easier
@@ -17,12 +17,12 @@
# field name headers for display in _gen_comp()
Fmt_Node="(%-15s %-12s %-10s %9s %10s)"
H_Node=(admin_ip hostname admin_nic timeout min_uptime)
- Fmt_Disk="(%-8s %-8s %-24s)"
- H_Disk=(name Node real_dev)
+ Fmt_Disk="(%-8s %-8s %-24s %7s)"
+ H_Disk=(name Node real_dev usize)
Fmt_Link="\n#\t(%-8s %-15s %-6s)"
H_Link=(Node ip nic)
- Fmt_Drbd="(%-8s %-5s %6s %-8s\n#\t %-8s %-15s %-24s %-8s\n#\t %-8s %-15s %-24s %-8s)"
- H_Drbd=(name minor port link
+ Fmt_Drbd="(%-8s %-5s %6s %-8s %7s\n#\t %-8s %-15s %-24s %-8s\n#\t %-8s %-15s %-24s %-8s)"
+ H_Drbd=(name minor port link usize
left left_ip left_real_dev left_disk
right right_ip right_real_dev right_disk
conf)
@@ -62,6 +62,7 @@
name=$1
node=$2
real_dev=$3
+ USIZE=$4
DEV=$real_dev
}
bdev_to_env()
@@ -80,23 +81,30 @@
minor=$2
port=$3
link=$4
- shift 4; left=$1 left_ip=$2 left_real_dev=$3 left_disk=$4
+ USIZE=$5
+ shift 5; left=$1 left_ip=$2 left_real_dev=$3 left_disk=$4
shift 4; right=$1 right_ip=$2 right_real_dev=$3 right_disk=$4
conf=$5
DEV=/dev/nb$minor
}
new_bdev()
{
- local name node real_dev disk bdev
+ local name node real_dev disk bdev usize
name=$1 ; shift
bdev="$name"
while (( $# )) ; do
[[ $1 == *:/* ]] || return 101
node=${1%%:*} ; real_dev=${1#*:} ; shift
+ if [[ $real_dev == *:* ]] ; then
+ usize=${real_dev#*:}
+ real_dev=${real_dev%:*}
+ else
+ usize=""
+ fi
let ID_DISK++
disk="Disk_$ID_DISK"
- eval "$disk=( $name $node $real_dev )"
+ eval "$disk=( $name $node $real_dev \"${usize}\")"
bdev="$bdev $node $real_dev"
done
let ID_BDEV++
@@ -106,7 +114,7 @@
{
local name minor port left left_real_dev right right_real_dev link
local left_ip left_hostname left_disk
- local right_ip right_hostname right_disk conf
+ local right_ip right_hostname right_disk conf usize
name=$1
minor=$2
port=$3
@@ -115,6 +123,7 @@
right=$6
right_real_dev=$7
link=$8
+ usize=$9
left_ip=$(ip_of $link $left) || return
right_ip=$(ip_of $link $right) || return
@@ -123,10 +132,10 @@
let ID_DISK++
left_disk="Disk_$ID_DISK"
- eval "$left_disk=( $name $left $left_real_dev )"
+ eval "$left_disk=( $name $left $left_real_dev \"${usize:+$[usize+128]}\" )"
let ID_DISK++
right_disk="Disk_$ID_DISK"
- eval "$right_disk=( $name $right $right_real_dev )"
+ eval "$right_disk=( $name $right $right_real_dev \"${usize:+$[usize+128]}\" )"
# funny quoting with cat
conf=$(cat <<-___
@@ -170,8 +179,12 @@
)
let ID_DRBD++
- eval "Drbd_$ID_DRBD=($name $minor $port
+ eval "Drbd_$ID_DRBD=(
+ $name
+ $minor
+ $port
$link
+ \"$usize\"
$left
$left_ip
$left_real_dev
@@ -184,6 +197,54 @@
)"
}
+blockwise_md5_pl()
+{
+ : ${DEV:?unknown device}
+ # we could exclude the meta data...
+ # RSIZE=$(fdisk -s $DEV)
+ # USIZE=${USIZE:+$[(USIZE+128)*1024]}
+ # (( USIZE <= RSIZE )) # assert USIZE <= RSIZE
+ # : ${USIZE:=$RSIZE}
+ # let "MLOC=USIZE-128*1024"
+ perl -e '
+ use Digest::MD5 "md5_hex";
+ $pos=0;
+ while (sysread(STDIN,$buf,4096)==4096) {
+ printf "%6d\t%s\n",$nr++,md5_hex($buf);
+ '${USIZE:+"last if \$pos+=4 >= $USIZE*1024;"}'
+ }' < $DEV
+}
+
+Drbd_MD5_diff()
+{
+ # ONLY use this when DRBD is down or secondary *ON BOTH* nodes!
+ drbd=$1
+ drbd_to_env $drbd
+ on ${!left}: blockwise_md5_pl DEV=/dev/mapper/$name USIZE=$usize \
+ > md5sum-${!left}-$name
+ on ${!right}: blockwise_md5_pl DEV=/dev/mapper/$name USIZE=$usize \
+ > md5sum-${!right}-$name
+ lines=$(wc -l < md5sum-${!right}-$name)
+ echo "NOTE: internal meta data may differ..."
+ echo "md probably starts at blocknr $[lines-(128<<8)]"
+ diff -u md5sum-${!left}-$name md5sum-${!right}-$name
+}
+
+dd_single_block()
+{
+ : ${name:?unknown resource name}
+ : ${blocknr:?which block nr do you want}
+ dd if=/dev/mapper/$name bs=4k count=1 skip=$blocknr
+}
+
+Drbd_hexdump_diff_block()
+{
+ drbd=$1 blocknr=$2
+ : ${blocknr:?which blocknr do you want}
+ drbd_to_env $drbd
+ diff -u <(on ${!left}: dd_single_block name=$name blocknr=$blocknr | hexdump -C) \
+ <(on ${!right}: dd_single_block name=$name blocknr=$blocknr| hexdump -C)
+}
Crash_Node()
{
@@ -225,14 +286,14 @@
{
local d=$1
disk_to_env $d
- on ${!node}: dmsetup_error name=$name dev=$real_dev
+ on ${!node}: dmsetup_error name=$name dev=$real_dev blocks=${USIZE:+$[USIZE*1024]}
}
Heal_Disk()
{
local d=$1
disk_to_env $d
- on ${!node}: dmsetup_linear name=$name dev=$real_dev
+ on ${!node}: dmsetup_linear name=$name dev=$real_dev blocks=${USIZE:+$[USIZE*1024]}
}
# initial boot
@@ -257,8 +318,8 @@
# reset and up all DRBDs
for d in ${!Drbd_*} ; do
drbd_to_env $d
- echo "$conf" | on ${!left}: drbd_append_config NAME=$name RES=$name LO_DEV=$left_real_dev
- echo "$conf" | on ${!right}: drbd_append_config NAME=$name RES=$name LO_DEV=$right_real_dev
+ echo "$conf" | on ${!left}: drbd_append_config USIZE=$USIZE NAME=$name RES=$name LO_DEV=$left_real_dev
+ echo "$conf" | on ${!right}: drbd_append_config USIZE=$USIZE NAME=$name RES=$name LO_DEV=$right_real_dev
done
# wait for connect and initial sync (which should be skipped automatically)
@@ -269,6 +330,7 @@
done
# make file systems
+ wait_for=""
for fs in ${!FS_*} ; do
eval ${!fs}
# fixme add paranoia, should check for availability on the
@@ -276,7 +338,7 @@
bdev_to_env $BDEV
if [[ $BDEV == Drbd_* ]] ; then
n=$left
- on ${!n}: drbdadm_pri name=$name
+ on ${!n}: drbdadm_pri force="-- -d" name=$name
else
n=Node_1
fi
@@ -288,15 +350,14 @@
on ${!n}: mkfs_$TYPE DEV=$DEV
if [[ $BDEV == Drbd_* ]] ; then
on ${!n}: drbdadm_sec name=$name
+ on ${!n}: drbd_wait_sync minor=$minor
fi
done
-
- initial=false
) }
Start()
{
- local rs=$1 nn=$2
+ rs=$1 nn=$2
i=${rs#RS_}
which=${!rs}; [[ $which == *CN=* ]] && cn=${which#*CN=} || cn=''
fs=FS_$i; CN=""
@@ -305,6 +366,7 @@
[[ -z $CN && -z $cn ]] || return 101
[[ $nn == Node_* ]] || return 102
+ ( set -e
# fixme add paranoia, should check for availability on the
# respective node
bdev_to_env $BDEV
@@ -318,6 +380,7 @@
# START IN BACKGROUND
on ${!nn}: ${which}_start MNT=$MNT </dev/null &
+ ) || return
# rememeber current node
eval "$fs=\"\$$fs CN=$nn\""
@@ -328,7 +391,7 @@
}
Stop()
-{
+{ ( set -e
local rs=$1 i fs cn CN which
i=${rs#RS_}
which=${!rs}; [[ $which == *CN=* ]] && cn=${which#*CN=} || cn=''
@@ -352,6 +415,7 @@
else
: "do something to make $BDEV unavailable?"
fi
+) || return
eval "$fs=\${$fs% CN=*}" # forget current node
eval "$rs=\${$rs% CN=*}" # forget current node
Dump_RS
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/CTH_bash.sh,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -3 -r1.1.2.7 -r1.1.2.8
--- CTH_bash.sh 1 Jun 2004 14:27:30 -0000 1.1.2.7
+++ CTH_bash.sh 15 Jun 2004 08:41:02 -0000 1.1.2.8
@@ -1,5 +1,5 @@
#!/usr/bin/env - /bin/bash
-# $Id: CTH_bash.sh,v 1.1.2.7 2004/06/01 14:27:30 lars Exp $
+# $Id: CTH_bash.sh,v 1.1.2.8 2004/06/15 08:41:02 lars Exp $
# example for scripting failures
#
@@ -54,6 +54,7 @@
return
}
+set +e
if Run; then
cat <<-___
#--- $CASE ----
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/functions.sh,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -3 -r1.1.2.6 -r1.1.2.7
--- functions.sh 7 Jun 2004 10:16:39 -0000 1.1.2.6
+++ functions.sh 15 Jun 2004 08:41:02 -0000 1.1.2.7
@@ -1,6 +1,6 @@
#!/bin/bash
# vim: set foldmethod=marker nofoldenable :
-# $Id: functions.sh,v 1.1.2.6 2004/06/07 10:16:39 lars Exp $
+# $Id: functions.sh,v 1.1.2.7 2004/06/15 08:41:02 lars Exp $
#DEBUG="-vx"
#DEBUG="-v"
@@ -52,10 +52,16 @@
echo RESTART >> $WBTLOG
date >> $WBTLOG
- wbtest -s checkpoint -t data -l $WBTLOG -V || true
- df .
-# CHANGE, but be aware that -c 20, and two resources, you will have a load of ~40 :)
- wbtest -p 0 -c 5 -s checkpoint -t data -l $WBTLOG || true
+ wbtest -s checkpoint -t data -l $WBTLOG -V 2>&1 |
+ sed '/Processed checkfile .*: \([0-9]*\)\/\1 passed/d'
+ echo "remaining garbage files:"
+ # FIXME should be empty, but is not.
+ # wbtest does not like to be killed.
+ ls -l checkpoint/ data/
+ du -s checkpoint/ data/
+# CHANGE, but be aware that -c 20,
+# and two resources, you will have a load of ~40 :)
+ wbtest -p 0 -c 5 -m 16384 -M 102400 -s checkpoint -t data -l $WBTLOG
}
#
@@ -83,15 +89,14 @@
{
local host=${1%:}
local cmd=`type $2|tail +2`
- local IFS=$'\n'
local env="\
set -o errexit $DEBUG
PATH=/root/bin:/usr/bin:/bin:/usr/sbin:/sbin
-${*:3}
+$(printf '%q\n' "${@:3}")
"
: ${host:?unknown host}
: ${cmd:?no command}
- # printf "%q " ssh -2 -4 -o BatchMode=yes -o KeepAlive=yes -xl root $host -- "$env$cmd; $2"
+ # printf "%s " ssh -2 -4 -o BatchMode=yes -o KeepAlive=yes -xl root $host -- "$env$cmd; $2"
ssh -2 -4 -o BatchMode=yes -o KeepAlive=yes -xl root $host -- "$env$cmd; $2"
}
@@ -226,8 +231,8 @@
{
: ${name:?unknown dm name}
: ${dev:?unknown lower level device}
+ : ${blocks:=$(fdisk -s $dev)}
dmsetup ls | grep -q $name || dmsetup create $name </dev/null || exit 1
- blocks=$(fdisk -s $dev)
dmsetup suspend $name &&
echo "0 $[blocks*2] linear $dev 0" | dmsetup reload $name /dev/stdin || exit 1
dmsetup resume $name
@@ -240,8 +245,8 @@
{
: ${name:?unknown dm name}
: ${dev:?unknown lower level device}
+ : ${blocks:=$(fdisk -s $dev)}
dmsetup ls | grep -q $name || dmsetup create $name </dev/null || exit 1
- blocks=$(fdisk -s $dev)
dmsetup suspend $name &&
echo "0 $[blocks*2] error" | dmsetup reload $name /dev/stdin || exit 1
dmsetup resume $name
@@ -266,13 +271,14 @@
cat >> /etc/drbd-07.conf
drbdadm dump $RES &>/dev/null
- RSIZE=$(fdisk -s $LO_DEV)
- # USIZE=${USIZE:+$[(USIZE+128)*1024]} # FIXME assert USIZE <= RSIZE
+ RSIZE=$(fdisk -s /dev/mapper/$NAME)
+ USIZE=${USIZE:+$[(USIZE+128)*1024]}
+ (( USIZE <= RSIZE )) # assert USIZE <= RSIZE
: ${USIZE:=$RSIZE}
- let "MLOC=USIZE-128*1024"
+ let "MLOC=(USIZE & ~3) -128*1024"
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
+ dd if=/dev/zero bs=4k seek=$[MLOC/4] count=$[128*256] of=/dev/mapper/$NAME
sync
echo .
drbdadm up $RES
@@ -282,7 +288,7 @@
drbdadm_up() # {{{3
{
- : ${name:?unknown dm name}
+ : ${name:?unknown resource name}
drbdadm up $name
# cat /proc/drbd
echo "up'ed drbd $name on $HOSTNAME"
@@ -290,7 +296,7 @@
drbdadm_down() # {{{3
{
- : ${name:?unknown dm name}
+ : ${name:?unknown resource name}
drbdadm down $name
# cat /proc/drbd
echo "down'ed drbd $name on $HOSTNAME"
@@ -307,9 +313,8 @@
drbd_wait_peer_not_pri() # {{{3
{
: ${minor:?unknown minor number}
- # FIXME does not work for minor > 9
while true; do
- grep -q "^ $minor:.*/Primary" /proc/drbd || break
+ grep -q "^ *$minor:.*/Primary" /proc/drbd || break
sleep 1
# FIXME currently hardcoded timeout ...
(( SECONDS > 30 )) && exit 1
@@ -333,7 +338,13 @@
drbdadm_pri()
{
: ${name:?unknown resource name}
- drbdadm primary $name
+ : ${force:=}
+ # FIXME should not be neccessary!
+ # patch already done, needs to be checked in...
+ drbdadm $force primary $name
+ if [[ $force ]] ; then
+ drbdadm invalidate_remote $name || true
+ fi
echo "$name now Primary on $HOSTNAME"
}
@@ -353,7 +364,7 @@
: ${MNT:?unknown mount point}
: ${TYPE:?unknown fs type}
: ${DEV:?which device are you talkin about}
- mount -v -t $TYPE $DEV $MNT
+ mount -v -t ${TYPE%%_*} $DEV $MNT
}
do_umount()
@@ -365,6 +376,11 @@
sleep 1
done
}
+
+mkfs_reiserfs_nomkfs() { echo "skipped mkreiserfs" ; }
+mkfs_ext2_nomkfs() { echo "skipped mke2fs" ; }
+mkfs_ext3_nomkfs() { echo "skipped mke3fs" ; }
+mkfs_xfs_nomkfs() { echo "skipped mkxfs" ; }
mkfs_reiserfs()
{
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/uml-minna.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
--- uml-minna.conf 7 Jun 2004 10:16:39 -0000 1.1.2.2
+++ uml-minna.conf 15 Jun 2004 08:41:02 -0000 1.1.2.3
@@ -1,4 +1,4 @@
-# $Id: uml-minna.conf,v 1.1.2.2 2004/06/07 10:16:39 lars Exp $
+# $Id: uml-minna.conf,v 1.1.2.3 2004/06/15 08:41:02 lars Exp $
#
# Note that some of the settings here may be overridden in generic_test.pl
# or at the end of this file
@@ -32,6 +32,7 @@
# see the config_template in LGE_CTH/DRBD_Resource.pm
#
$r0 = new LGE_CTH::DRBD_Resource {
+ # usize => 50,
name => 'r0',
minor => 0,
link => $link,
@@ -54,11 +55,11 @@
disk => {
'on-io-error' => 'detach', # passon,panic,detach DEFAULT
},
- net => { # ALL DEFAULT
- 'sndbuf-size' => 2*65535, # 512*1024 or similar
- 'timeout' => 60, # 6 seconds (unit = 0.1 seconds)
- 'connect-int' => 10, # 10 seconds (unit = 1 second)
- 'ping-int' => 10, # 10 seconds (unit = 1 second)
+ net => {
+ 'sndbuf-size' => 2*65535, # DEFAULT:
+ 'timeout' => 30, # 60 centi seconds (unit = 0.1 seconds)
+ 'connect-int' => 7, # 10 seconds (unit = 1 second)
+ 'ping-int' => 7, # 10 seconds (unit = 1 second)
'max-buffers' => 32,
'max-epoch-size' => 2048,
},
@@ -70,6 +71,7 @@
};
$r1 = new LGE_CTH::DRBD_Resource {
+ # usize => 50,
name => 'r1',
minor => 1,
link => $link,
@@ -77,6 +79,11 @@
rate => "30M",
group => 2,
},
+ net => {
+ 'timeout' => 30,
+ 'connect-int' => 7,
+ 'ping-int' => 7,
+ },
peers => [ {
node => $left,
lodev => '/dev/ubd/c',
@@ -97,14 +104,14 @@
# ext2, ext3, reiserfs, xfs
$fs0 = new LGE_CTH::FileSystem {
- type => 'xfs',
- mount_point => "/drbd/0",
+ type => 'ext3',
+ mount_point => "/mnt/ha0",
bdev => $r0,
};
$fs1 = new LGE_CTH::FileSystem {
- type => 'reiserfs',
- mount_point => "/drbd/1",
+ type => 'ext3',
+ mount_point => "/mnt/ha1",
bdev => $r1,
};
@@ -126,4 +133,4 @@
# if you like, override the sync group here to be the same
$r0->{_config}->{syncer}->{group} = 1;
-$r1->{_config}->{syncer}->{group} = 2;
+$r1->{_config}->{syncer}->{group} = 1;