--- /dev/null
+#!/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
--- /dev/null
+#!/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 <<EOF >> $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"
+}
# 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
cleanupall() {
nfs_client_mode && return
+ cifs_client_mode && return
stopall $*
cleanup_echo_devs
setupall() {
nfs_client_mode && return
+ cifs_client_mode && return
sanity_mount_check ||
error "environments are insane!"
return 1
}
+cifs_client_mode () {
+ [ x$CIFSCLIENT = xyes ] &&
+ echo "CIFSCLIENT=$CIFSCLIENT mode: setup, cleanup, check config skipped"
+}
+
check_config_client () {
local mntpt=$1
local mntpt=$1
nfs_client_mode && return
+ cifs_client_mode && return
do_rpc_nodes "$clients" check_config_client $mntpt
check_and_setup_lustre() {
nfs_client_mode && return
+ cifs_client_mode && return
local MOUNTED=$(mounted_lustre_filesystems)
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"
+}