#!/bin/sh
# $Id: t-mts-ocr-4.sh,v 1.18 2007/01/31 02:45:13 ca Exp $
# Copyright (c) 2004, 2005 Sendmail, Inc. and its suppliers.
# All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
# ----------------------------------------
# test outgoing connection restrictions.
# fall over to next "MX".
# should this use different ports and two sinks?
# otherwise it's hard to check what happened to the connections;
# maybe parse smtpc.log?
# uses mcpmts.sh
# ----------------------------------------
#
test -s stop && exit 1
#
if test "X"${MTA_TIMING} = "X"
then
echo "SKIPPED: $0: MTA_TIMING is not set"
exit 0
fi
SD=`dirname $0`
if test "${SD}" = "."
then
SD=../chkmts
fi
. ${SD}/common.sh
I=""
OUT="t-mts-ocr-2.out"
if test X"`uname`" != "XOSF1"
then
while getopts s:V FLAG
do
case "${FLAG}" in
s) SKIP="${SKIP} ${OPTARG}";;
V) VERBOSE=true;;
esac
done
shift `expr ${OPTIND} - 1`
fi
# cd to right directory (where the programs will be executed).
cd ../qmgr || exit 1
# create directory to pass socket
if test -d smtps
then
:
else
mkdir smtps
fi
killit()
{
rm -f ${QMGRCONFMAP} ${MTMAP}
exit 1
}
rm -f ${QMGRCONFMAP} ${MTMAP} ${OUT}
# create restrictions: maximum concurrency: 1, 1
${CAT} > ${QMGRCONF} <<EOF
oci:10.1.1.2 1
ocm:10.1.1.2 1
oci:10.1.1.3 1
ocm:10.1.1.3 1
EOF
# create map
${MM} -t' ' -F ${QMGRCONFMAP} < ${QMGRCONF}
trap killit 2
# ----------------------------------------
${CAT} >${SMXCNF} <<EOF
smtps { log_level = 14; pass_fd_socket = smtps/smtpsfd; wait_for_server=4;
listen_socket { type=inet; port=${SRVPORT}; }
start_action = pass; user = ${USER};
path = ../smtps/smtps;
arguments = "smtps -f ${SMXCNF} ${MTA_SERVER_OPTIONS} -d 3";
}
smtpc { log_level = 14; remote_port = ${SNKPORT}; wait_for_server=4;
connect_only_to = 127.0.0.1;
io_timeout=60s;
start_action = wait; user = ${USER};
path = "../smtpc/smtpc"; arguments = "smtpc -f ${SMXCNF} -d 3";
}
qmgr { log_level = 14; wait_for_server=4; wait_for_client=4;
retry_min_delay = 300;
start_action = wait; user = ${USER};
# restart_dependencies = { smtps,smtpc,smar, };
path = "../qmgr/qmgr"; arguments = "qmgr -f ${SMXCNF} -d 5";
}
smar { log_level = 14;
start_action = wait; user = ${USER};
# restart_dependencies = { smtps,qmgr };
path = "../smar/smar"; arguments = "smar -f ${SMXCNF}";
}
EOF
${CAT} > ${MT} <<EOF
dom1.tld [10.1.1.1]
dom2.tld [10.1.1.2] [10.1.1.3]
EOF
# ----------------------------------------
#
TEST=1
if echo "${SKIP} X" | ${GREP} -v " ${TEST} " > /dev/null
then
ERR=false
for i in smar smtps smtpc qmgr
do
cp /dev/null ${i}.log
done
if ${SHELL} ${SD}/mcpmts.sh -Y '-w1' -c '-s 10 -D dom2.tld -F dom1.tld' -N -s 20 -A 10 -E 10
then
if ${GREP} 'Max busy threads .* 2$' ${SRVL} >/dev/null
then
${VERBOSE} && echo "test ${TEST} succeeded"
else
${VERBOSE} && echo "$0: test ${TEST}: wrong number of Max busy threads"
ERR=true
fi
else
${VERBOSE} && echo "$0: test ${TEST}: mcpmts.sh failed"
ERR=true
fi
if ${ERR}
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed"
test X"${MTA_STOPONERROR}" != X && exit 1
fi
fi
# ----------------------------------------
rm -f ${QMGRCONFMAP} ${OUT}
# create restrictions: maximum concurrency: 2, 4
${CAT} > ${QMGRCONF} <<EOF
oci:10.1.1.2 2
ocm:10.1.1.2 2
oci:10.1.1.3 2
ocm:10.1.1.3 4
EOF
# create map
${MM} -t' ' -F ${QMGRCONFMAP} < ${QMGRCONF}
trap killit 2
# ----------------------------------------
#
TEST=2
if echo "${SKIP} X" | ${GREP} -v " ${TEST} " > /dev/null
then
ERR=false
for i in smar smtps smtpc qmgr
do
cp /dev/null ${i}.log
done
if ${SHELL} ${SD}/mcpmts.sh -Y '-w1' -c '-s 10 -D dom2.tld -F dom1.tld' -N -s 20 -A 10 -E 10
then
if ${GREP} 'Max busy threads .* [4-6]$' ${SRVL} >/dev/null
then
:
else
${VERBOSE} && echo "$0: test ${TEST}: wrong number of Max busy threads"
ERR=true
fi
if ${GREP} 'ip=10\.1\.1\.2' qmgr.log >/dev/null
then
:
else
${VERBOSE} && echo "$0: test ${TEST}: ip=10.1.1.2 missing in qmgr.log"
ERR=true
fi
if ${GREP} 'ip=10\.1\.1\.3' qmgr.log >/dev/null
then
:
else
${VERBOSE} && echo "$0: test ${TEST}: ip=10.1.1.3 missing in qmgr.log"
ERR=true
fi
else
ERR=true
fi
if ${ERR}
then
echo "$0: test ${TEST} failed"
ERRS=`expr ${ERRS} + 1 `
test X"${MTA_STOPONERROR}" != X && exit 1
else
${VERBOSE} && echo "test ${TEST} succeeded"
fi
fi
# -----------------
rm -f ${QMGRCONFMAP} ${MTMAP} ${OUT}
# ----------------------------------------
# end
if test "${ERRS}" = "0"
then
exit 0
else
echo "${ERRS} error(s)"
exit 1
fi
syntax highlighted by Code2HTML, v. 0.9.1