Skip to content
Snippets Groups Projects
replay-single.sh 29.6 KiB
Newer Older
Nathan Rutman's avatar
Nathan Rutman committed
#!/bin/bash
Nathan Rutman's avatar
Nathan Rutman committed
#set -v
#
# This test needs to be run on the client
#

LUSTRE=${LUSTRE:-`dirname $0`/..}
. $LUSTRE/tests/test-framework.sh
init_test_env $@
Nathan Rutman's avatar
Nathan Rutman committed
. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
Robert Read's avatar
 
Robert Read committed

Nathan Rutman's avatar
Nathan Rutman committed
# bug number:  4176 
ALWAYS_EXCEPT="39   $REPLAY_SINGLE_EXCEPT"
gen_config() {
    rm -f $XMLCONFIG
Nathan Rutman's avatar
Nathan Rutman committed
    add_mds mds --dev $MDSDEV --size $MDSSIZE
    if [ ! -z "$mdsfailover_HOST" ]; then
	 add_mdsfailover mds --dev $MDSDEV --size $MDSSIZE
Nathan Rutman's avatar
Nathan Rutman committed
    add_lov lov1 mds --stripe_sz $STRIPE_BYTES \
	--stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
scjody's avatar
scjody committed
    add_ost ost --lov lov1 --dev `ostdevname 1` --size $OSTSIZE
    add_ost ost2 --lov lov1 --dev `ostdevname 2` --size $OSTSIZE
Nathan Rutman's avatar
Nathan Rutman committed
    add_client client mds --lov lov1 --path $MOUNT
Nathan Rutman's avatar
Nathan Rutman committed
SETUP=${SETUP:-"setup"}
CLEANUP=${CLEANUP:-"cleanupall"}
if [ "$ONLY" == "cleanup" ]; then
Nathan Rutman's avatar
Nathan Rutman committed
    sysctl -w lnet.debug=0 || true
    $CLEANUP
    exit 0
Robert Read's avatar
Robert Read committed
setup() {
scjody's avatar
scjody committed
    [ "$REFORMAT" ] && formatall
Nathan Rutman's avatar
Nathan Rutman committed
    setupall
Robert Read's avatar
Robert Read committed
}

$SETUP

if [ "$ONLY" == "setup" ]; then
    exit 0
fi

mkdir -p $DIR

test_0() {
Nathan Rutman's avatar
Nathan Rutman committed
    replay_barrier mds
    fail mds
run_test 0 "empty replay"
test_0b() {
    # this test attempts to trigger a race in the precreation code, 
    # and must run before any other objects are created on the filesystem
Nathan Rutman's avatar
Nathan Rutman committed
    fail ost1
    createmany -o $DIR/$tfile 20 || return 1
    unlinkmany $DIR/$tfile 20 || return 2
}
run_test 0b "ensure object created after recover exists. (3284)"

Nathan Rutman's avatar
Nathan Rutman committed
    replay_barrier mds
Nathan Rutman's avatar
Nathan Rutman committed
    fail mds
    $CHECKSTAT -t file $DIR/$tfile || return 1
    rm $DIR/$tfile
run_test 1 "simple create"
Nathan Rutman's avatar
Nathan Rutman committed
test_1a() {
    do_facet ost1 "sysctl -w lustre.fail_loc=0"

    rm -fr $DIR/$tfile
    local old_last_id=`cat $LPROC/obdfilter/*/last_id`
    touch -o $DIR/$tfile 1
    sync
    local new_last_id=`cat $LPROC/obdfilter/*/last_id`
    
    test "$old_last_id" = "$new_last_id" || {
	echo "OST object create is caused by MDS"
	return 1
    }
    
    old_last_id=`cat $LPROC/obdfilter/*/last_id`
    echo "data" > $DIR/$tfile
    sync
    new_last_id=`cat $LPROC/obdfilter/*/last_id`
    test "$old_last_id" = "$new_last_id "&& {
	echo "CROW does not work on write"
	return 1
    }
    
    rm -fr $DIR/$tfile

#define OBD_FAIL_OST_CROW_EIO | OBD_FAIL_ONCE
    do_facet ost1 "sysctl -w lustre.fail_loc=0x80000801"

    rm -fr $DIR/1a1
    old_last_id=`cat $LPROC/obdfilter/*/last_id`
    echo "data" > $DIR/1a1
    sync
    new_last_id=`cat $LPROC/obdfilter/*/last_id`
    test "$old_last_id" = "$new_last_id" || {
	echo "CROW does work with fail_loc=0x80000801"
	return 1
    }
    
    rm -fr $DIR/1a1
    
    do_facet ost1 "sysctl -w lustre.fail_loc=0"
}
#CROW run_test 1a "CROW object create (check OST last_id)"

Nathan Rutman's avatar
Nathan Rutman committed
    replay_barrier mds
Nathan Rutman's avatar
Nathan Rutman committed
    fail mds
    $CHECKSTAT -t file $DIR/$tfile || return 1
    rm $DIR/$tfile
test_2b() {
    ./mcreate $DIR/$tfile
Nathan Rutman's avatar
Nathan Rutman committed
    replay_barrier mds
Nathan Rutman's avatar
Nathan Rutman committed
    fail mds
    $CHECKSTAT -t file $DIR/$tfile || return 1
    rm $DIR/$tfile
Nathan Rutman's avatar
Nathan Rutman committed
    replay_barrier mds
    mcreate $DIR/$tfile
    o_directory $DIR/$tfile
Nathan Rutman's avatar
Nathan Rutman committed
    fail mds
    $CHECKSTAT -t file $DIR/$tfile || return 2
    rm $DIR/$tfile
run_test 3a "replay failed open(O_DIRECTORY)"

test_3b() {
Nathan Rutman's avatar
Nathan Rutman committed
    replay_barrier mds
#define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
    do_facet mds "sysctl -w lustre.fail_loc=0x80000114"
    touch $DIR/$tfile
    do_facet mds "sysctl -w lustre.fail_loc=0"
Nathan Rutman's avatar
Nathan Rutman committed
    fail mds
    $CHECKSTAT -t file $DIR/$tfile && return 2
    return 0
}
run_test 3b "replay failed open -ENOMEM"

test_3c() {
Nathan Rutman's avatar
Nathan Rutman committed
    replay_barrier mds
#define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
    do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
    touch $DIR/$tfile
    do_facet mds "sysctl -w lustre.fail_loc=0"
Nathan Rutman's avatar
Nathan Rutman committed
    fail mds

    $CHECKSTAT -t file $DIR/$tfile && return 2
    return 0
}
run_test 3c "replay failed open -ENOMEM"
Nathan Rutman's avatar
Nathan Rutman committed
    replay_barrier mds
    for i in `seq 10`; do
        echo "tag-$i" > $DIR/$tfile-$i
    done 
Nathan Rutman's avatar
Nathan Rutman committed
    fail mds
    for i in `seq 10`; do
      grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
    done 
}
run_test 4 "|x| 10 open(O_CREAT)s"

test_4b() {
Nathan Rutman's avatar
Nathan Rutman committed
    replay_barrier mds
Nathan Rutman's avatar
Nathan Rutman committed
    fail mds
    $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
}
run_test 4b "|x| rm 10 files"

# The idea is to get past the first block of precreated files on both 
Loading
Loading full blame...