From: Elena Gryaznova Date: Thu, 23 Jul 2015 17:46:11 +0000 (+0300) Subject: LU-6119 test: Add testing for Lustre exported via Samba X-Git-Tag: 2.7.59~50 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=1bf48948a99f51ede84a467a23c59c55eb055d7b LU-6119 test: Add testing for Lustre exported via Samba Create a parallel-scale-cifs.sh test which exports Lustre via Samba and runs concurrent load compilebench, dbench, fsx, iozone on Samba clients. The test assumes that Samba server and clients have necessary packages installed. Signed-off-by: Elena Gryaznova Xyratex-bug-id: MRP-1374 Reviewed-by: Vladimir Saveliev Reviewed-by: Vitaly Fertman Change-Id: Iace3b786bd34e42198a2ffdb35c436595fe2b8a5 Reviewed-on: http://review.whamcloud.com/13402 Reviewed-by: Jian Yu Tested-by: Jian Yu Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Emoly Liu Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/Makefile.am b/lustre/tests/Makefile.am index 050a645..f9aab93 100644 --- a/lustre/tests/Makefile.am +++ b/lustre/tests/Makefile.am @@ -33,6 +33,7 @@ noinst_SCRIPTS += lnet-selftest.sh obdfilter-survey.sh mmp.sh mmp_mark.sh noinst_SCRIPTS += sgpdd-survey.sh maloo_upload.sh auster setup-nfs.sh noinst_SCRIPTS += mds-survey.sh parallel-scale-nfs.sh large-lun.sh noinst_SCRIPTS += parallel-scale-nfsv3.sh parallel-scale-nfsv4.sh +noinst_SCRIPTS += setup-cifs.sh parallel-scale-cifs.sh noinst_SCRIPTS += posix.sh sanity-scrub.sh scrub-performance.sh ha.sh noinst_SCRIPTS += sanity-quota-old.sh sanity-lfsck.sh lfsck-performance.sh noinst_SCRIPTS += resolveip diff --git a/lustre/tests/functions.sh b/lustre/tests/functions.sh index e49ca5d..84916b0 100644 --- a/lustre/tests/functions.sh +++ b/lustre/tests/functions.sh @@ -289,6 +289,8 @@ run_compilebench() { # compile dir kernel-0 ~1GB # required space ~1GB * cbench_IDIRS + local dir=${1:-$DIR} + cbench_DIR=${cbench_DIR:-""} cbench_IDIRS=${cbench_IDIRS:-2} cbench_RUNS=${cbench_RUNS:-2} @@ -301,7 +303,7 @@ run_compilebench() { [ -e $cbench_DIR/compilebench ] || \ { skip_env "No compilebench build" && return; } - local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }') + local space=$(df -P $dir | tail -n 1 | awk '{ print $4 }') if [[ $space -le $((1024 * 1024 * cbench_IDIRS)) ]]; then cbench_IDIRS=$((space / 1024 / 1024)) [[ $cbench_IDIRS -eq 0 ]] && @@ -315,7 +317,7 @@ run_compilebench() { # t-f _base needs to be modifyed to set properly tdir # for new "test_foo" functions names # local testdir=$DIR/$tdir - local testdir=$DIR/d0.compilebench + local testdir=$dir/d0.compilebench mkdir -p $testdir local savePWD=$PWD diff --git a/lustre/tests/parallel-scale-cifs.sh b/lustre/tests/parallel-scale-cifs.sh new file mode 100644 index 0000000..b47e043 --- /dev/null +++ b/lustre/tests/parallel-scale-cifs.sh @@ -0,0 +1,245 @@ +#!/bin/bash + +# Requires the pre-configured samba machine +# RPMS required are : +# server: +# samba +# samba-common +# cifs-utils +# clients: +# samba-client +# samba-common +# cifs-utils + +#set -vx + +LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)} +. $LUSTRE/tests/test-framework.sh +init_test_env $@ +. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} +init_logging +. $LUSTRE/tests/setup-cifs.sh + +check_and_setup_lustre + +# first unmount all the lustre clients +cleanup_mount $MOUNT +# lustre client used as samba server (default is mds node) +LUSTRE_CLIENT_SMBSRV=${LUSTRE_CLIENT_SMBSRV:-$(facet_active_host $SINGLEMDS)} +SMBSHARE=${SMBSHARE:-lustretest} +SMBUSER=${SMBUSER:-root} +SMBPASSWD=${SMBPASSWD:-lustre} +SMBSRVMNTPT=${SMBSRVMNTPT:-$MOUNT} +SMBCLIMNTPT=${SMBCLIMNTPT:-$MOUNT} +SMBCLIENTS=${SMBCLIENTS:-$CLIENTS} +SMBCLIENTS=$(exclude_items_from_list $SMBCLIENTS $LUSTRE_CLIENT_SMBSRV) + +[ -z "$SMBCLIENTS" ] && + skip_env "need at least two nodes: samba server and samba client" && + exit 0 + +# set CONFIGURE_SMB=false to skip smb config +CONFIGURE_SMB=${CONFIGURE_SMB:-true} + +# store smb status to restart smb service if it was running initially +SMBSTATUS=0 +smb_status $LUSTRE_CLIENT_SMBSRV || SMBSTATUS=$? +SMBCONFTMP=$(do_node $LUSTRE_CLIENT_SMBSRV "mktemp -t smb.conf.XXX") + +cleanup_exit() { + trap 0 + cleanup + check_and_cleanup_lustre + exit +} + +cleanup() { + cleanup_cifs $LUSTRE_CLIENT_SMBSRV $SMBCLIMNTPT $SMBCLIENTS || + error_noexit false "failed to cleanup cifs" + zconf_umount $LUSTRE_CLIENT_SMBSRV $SMBSRVMNTPT force || + error_noexit false "failed to umount lustre on $LUSTRE_CLIENT_SMBSRV" + # restore lustre mount + restore_mount $MOUNT || + error_noexit false "failed to mount lustre" + + $CONFIGURE_SMB && restore_config_smb $LUSTRE_CLIENT_SMBSRV $SMBCONFTMP + [[ $SMBSTATUS -eq 0 ]] && + do_node $LUSTRE_CLIENT_SMBSRV "service smb start" + unset CIFSCLIENT +} + +$CONFIGURE_SMB && configure_smb $LUSTRE_CLIENT_SMBSRV $SMBSHARE $SMBUSER \ + $SMBPASSWD $SMBSRVMNTPT $SMBCONFTMP || + echo -e "\nSkipping smb config ..." + +trap cleanup_exit EXIT SIGHUP SIGINT + +# mount lustre client on smb server +zconf_mount $LUSTRE_CLIENT_SMBSRV $SMBSRVMNTPT || + error "mount lustre on $LUSTRE_CLIENT_SMBSRV failed" + +# setup the cifs +setup_cifs $LUSTRE_CLIENT_SMBSRV $SMBSHARE $SMBCLIMNTPT $SMBUSER \ + $SMBPASSWD $SMBCLIENTS || + error false "setup cifs failed" + +CIFSCLIENT=yes +FAIL_ON_ERROR=false + +# compilbench +# Run short iteration in cifs mode +cbench_IDIRS=${cbench_IDIRS:-2} +cbench_RUNS=${cbench_RUNS:-2} + +# source the common file after all parameters are set to take effect +. $LUSTRE/tests/functions.sh + +build_test_filter + +check_prog_output() { + local clients=$1 + local file=$2 + local str=$3 + + do_nodes $clients grep -q \\\"$str\\\" $file 2>/dev/null +} + +wait_prog_output() { + local clients=$1 + local file=$2 + local str=$3 + local time=$4 + local start_ts=$(date +%s) + local elapsed + + while ! check_prog_output $clients $file "$str"; do + elapsed=$(($(date +%s) - start_ts)) + if [ $elapsed -gt $time ]; then + return 1 + fi + sleep 1 + done +} + +test_compilebench() { + run_compilebench $SMBCLIMNTPT +} +run_test compilebench "compilebench on cifs clients" + +test_dbench() { + local clients=$SMBCLIENTS + local duration=${DBENCH_DURATION:-300} + local nproc=${DBENCH_NPROC:-1} + local delay=${dbench_STARTDELAY:-120} + local log=$TMP/dbench.log + local pid="" + + local cmd="rundbench $nproc -t $duration" + + echo "Using: $cmd" + + do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \ + PATH=\$PATH DBENCH_LIB=$DBENCH_LIB \ + TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \ + DIR=$SMBCLIMNTPT/$tdir/\\\$(hostname) \ + LCTL=$LCTL $cmd 2>&1 | tee $log; \ + exit \\\${PIPESTATUS[0]}" & + pid=$! + + # check that dbench is started on all clients after + # $dbench_STARTDELAY: the dbench log on each client + # is to be started for this moment and contain "dbench PID"; + if ! wait_prog_output $clients $log "dbench PID" $delay; then + kill -s TERM $pid + killall_process $clients dbench + error "dbench failed to start on $clients!" + fi + + log "Started rundbench load pid=$pid ..." + wait $pid || error "rundbench load on $clients failed!" +} +run_test dbench "dbench on cifs clients" + +test_fsx() { + local clients=$SMBCLIENTS + local seed=${fsx_SEED:-$RANDOM} + local size=${fsx_SIZE:-1024} + local numop=${fsx_NUMOP:-100000} + local delay=${fsx_STARTDELAY:-120} + local log=$TMP/fsx.log + local pid="" + + local nclients=$(get_node_count ${clients//,/ }) + local space=$(df -P $SMBCLIMNTPT | tail -n 1 | awk '{ print $4 }') + [ $space -lt $((size * nclients)) ] && size=$((space * 3 / 4 / nclients)) + + local cmd="$FSX -c 50 -p 500 -S $seed -P $TMP -l $size -N $numop " + + echo "Using: $cmd" + + do_nodesv $clients "set -x; \ + PATH=\$PATH \ + $cmd $SMBCLIMNTPT/f0.fsx_\\\$(hostname) 2>&1 | tee $log; \ + exit \\\${PIPESTATUS[0]}" & + pid=$! + + # check that fsx is started on all clients after + # $fsx_STARTDELAY: the fsx log on each client + # is to be started for this moment and contain "Seed set"; + if ! wait_prog_output $clients $log "Seed set" $delay; then + kill -s TERM $pid + killall_process $clients fsx + error "fsx failed to start on $clients!" + fi + + log "Started fsx load pid=$pid ..." + wait $pid || error "fsx load on $clients failed!" +} +run_test fsx "fsx on cifs clients" + +test_iozone() { + local clients=$SMBCLIENTS + local size=${iozone_SIZE:-262144} # 256m + local delay=${iozone_STARTDELAY:-120} + local log=$TMP/iozone.log + local pid="" + + local nclients=$(get_node_count ${clients//,/ }) + + local space=$(df -P $SMBCLIMNTPT | tail -n 1 | awk '{ print $4 }') + + [[ $((size * nclients)) -gt $((space * 3 / 4)) ]] && + size=$((space * 3 / 4 / nclients)) + + log "free space: $space Kb, using $size size, $nclients number of clients" + + local cmd="iozone -a -e -+d -s $size " + + echo "Using: $cmd" + + do_nodesv $clients "set -x; \ + PATH=\$PATH \ + $cmd -f $SMBCLIMNTPT/f0.iozone_\\\$(hostname) 2>&1 | tee $log; \ + exit \\\${PIPESTATUS[0]}" & + pid=$! + + # check that iozone is started on all clients after + # $iozone_STARTDELAY: the iozone log on each client + # is to be started for this moment and contain "Command line used"; + if ! wait_prog_output $clients $log "Command line used" $delay; then + kill -s TERM $pid + killall_process $clients iozone + error "iozone failed to start on $clients!" + fi + + log "Started iozone load pid=$pid ..." + wait $pid + rc=$? + log "Processing iozone log" + do_nodesv $clients "tail -1 $log | grep -q complete" || rc=2 + [ $rc -eq 0 ] || error "iozone load on $clients failed! rc=$rc" +} +run_test iozone "iozone on cifs clients" + +complete $SECONDS +exit_status diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 8194adb..9998498 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -2027,15 +2027,6 @@ check_for_process () { killall_process $clients "$prog" -0 } -killall_process () { - local clients=${1:-$(hostname)} - local name=$2 - local signal=$3 - local rc=0 - - do_nodes $clients "killall $signal $name" -} - test_70b () { local clients=${CLIENTS:-$HOSTNAME} diff --git a/lustre/tests/setup-cifs.sh b/lustre/tests/setup-cifs.sh new file mode 100644 index 0000000..9815f1e --- /dev/null +++ b/lustre/tests/setup-cifs.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +# Requires the pre-configured samba machine +# RPMS required are : +# server: +# samba +# samba-common +# cifs-utils +# clients: +# samba-client +# samba-common +# cifs-utils + +#set -vx + +smb_status() { + local smbsrv=${1} + local rc=0 + + do_node $smbsrv "service smb status" || rc=$? + return $rc +} + +configure_smb() { + local smbsrv=${1} + local smbshare=${2} + local smbuser=${3} + local smbpasswd=${4} + local path=${5} + local smbconftmp=${6} + local smbconf + local path + + smbconf=$(do_node $smbsrv \ + smbd -b | grep CONFIGFILE | sed -re 's/\s+CONFIGFILE: //g') + grep -q $smbshare $smbconf && return + + do_node $smbsrv "cp $smbconf $smbconftmp" + do_node $smbsrv "cat <> $smbconf + [$smbshare] + path = $path + browseable = yes + writable = yes + guest ok = yes + write list = $smbuser +EOF" + # The samba daemons are constantly (once every 60 seconds) checking the + # smb.conf file, so it is good practice to keep this file small. + local smbsmall=$(do_nodes $smbsrv "mktemp -t smb.conf.small.XXX") + do_node $smbsrv "testparm -s >$smbsmall" + do_node $smbsrv "testparm -s $smbsmall >$smbconf" + + do_node $smbsrv "echo $smbpasswd | tee - | smbpasswd -a $smbuser -s" +} + +restore_config_smb() { + local smbsrv=${1} + local smbconftmp=${2} + local smbconf + + smbconf=$(do_node $smbsrv \ + smbd -b | grep CONFIGFILE | sed -re 's/\s+CONFIGFILE: //g') + + echo -e "\nRestoring smb config from $smbconftmp ..." + do_node $smbsrv "cp $smbconftmp $smbconf" +} + +setup_cifs() { + local smbsrv=${1} + local smbshare=${2} + local smbclimntpt=${3} + local smbuser=${4} + local smbpasswd=${5} + local smbclients=${6} + + do_node $smbsrv "service smb restart" || return 1 + local parameter_path=$(do_node $smbsrv \ + "testparm -s --section-name $smbshare --parameter-name path 2> /dev/null") + [[ -z $parameter_path ]] && return 1 + do_nodesv $smbsrv "chmod a+xrw $parameter_path" + do_nodesv $smbsrv "ls -ald $parameter_path" + + local cmd="mount -t cifs //$smbsrv/$smbshare $smbclimntpt -o user=$smbuser,pass=$smbpasswd" + echo -e "\nMounting CIFS clients $smbclients : $cmd" + do_nodesv $smbclients "$cmd" || return 1 + do_nodesv $smbclients mount | grep $smbclimntpt +} + +cleanup_cifs() { + local smbsrv=${1} + local smbclimntpt=${2} + local smbclients=${3} + + echo -e "\nUnmounting CIFS clients..." + do_nodes $smbclients "umount -f $smbclimntpt" || return 1 + do_node $smbsrv "service smb stop" +} diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 1dd2725..529714d 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -230,6 +230,7 @@ init_test_env() { # Ubuntu, at least, has a truncate command in /usr/bin # so fully path our truncate command. export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate} + export FSX=${FSX:-$LUSTRE/tests/fsx} export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"} [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null) if ! echo $PATH | grep -q $LUSTRE/tests/racer; then @@ -3327,6 +3328,7 @@ cleanup_echo_devs () { cleanupall() { nfs_client_mode && return + cifs_client_mode && return stopall $* cleanup_echo_devs @@ -3563,6 +3565,7 @@ writeconf_all () { setupall() { nfs_client_mode && return + cifs_client_mode && return sanity_mount_check || error "environments are insane!" @@ -3828,6 +3831,11 @@ nfs_client_mode () { return 1 } +cifs_client_mode () { + [ x$CIFSCLIENT = xyes ] && + echo "CIFSCLIENT=$CIFSCLIENT mode: setup, cleanup, check config skipped" +} + check_config_client () { local mntpt=$1 @@ -3875,6 +3883,7 @@ check_config_clients () { local mntpt=$1 nfs_client_mode && return + cifs_client_mode && return do_rpc_nodes "$clients" check_config_client $mntpt @@ -3921,6 +3930,7 @@ is_empty_fs() { check_and_setup_lustre() { nfs_client_mode && return + cifs_client_mode && return local MOUNTED=$(mounted_lustre_filesystems) @@ -7330,3 +7340,12 @@ check_start_ost_idx() { error "OST index of the first stripe on $file is" \ "$start_ost_idx, should be $expected" } + +killall_process () { + local clients=${1:-$(hostname)} + local name=$2 + local signal=$3 + local rc=0 + + do_nodes $clients "killall $signal $name" +}