2 # vim: ts=4 sw=4 noet :
3 #==================================================================================
4 # Copyright (c) 2019-2021 Nokia
5 # Copyright (c) 2018-2021 AT&T Intellectual Property.
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #==================================================================================
21 # ---------------------------------------------------------------------------------
22 # Mnemonic: run_exrts_test.ksh
23 # Abstract: This is a simple script to set up and run the v_send/ex_rts_receive
24 # processes for some library validation on top of nng. This test
25 # starts these processes to verify that when a receiver has an ack
26 # message larger than the received message it is able to allocate
27 # a new payload which can be returned via the RMR return to sender
30 # Example command line:
31 # # run with 10 caller threads sending 10,000 meessages each,
32 # # 5 receivers, and a 10 mu-s delay between each caller send
33 # ksh ./run_lcall_test.ksh -d 10 -n 10000 -r 5 -c 10
35 # Date: 28 October 2019
36 # Author: E. Scott Daniels
37 # ---------------------------------------------------------------------------------
41 # driven with -L sender or -L receiver on the command line
42 # run something though valgrind to check for leaks; requires valgind
44 valgrind -v --leak-resolution=high --leak-check=yes $opt "$@"
47 # The sender and receivers are run asynch. Their exit statuses are captured in a
48 # file in order for the 'main' to pick them up easily.
53 leak_anal ./v_sender ${nmsg:-10} ${delay:-100000} ${mtype_start_stop:-0:1} >/tmp/la.log 2>&1
55 ./v_sender ${nmsg:-10} ${delay:-100000} ${mtype_start_stop:-0:1}
57 echo $? >/tmp/PID$$.src # must communicate state back via file b/c asynch
60 # $1 is the instance so we can keep logs separate
64 port=$(( 4460 + ${1:-0} ))
65 export RMR_RTG_SVC=$(( 9990 + $1 ))
68 leak_anal ./ex_rts_receiver $copyclone -p $port >/tmp/la.log 2>&1
70 ./ex_rts_receiver $copyclone -p $port
72 echo $? >/tmp/PID$$.$1.rrc
75 # Drop a contrived route table in such that the sender sends each message to n
80 typeset groups="127.0.0.1:4460"
81 for (( i=1; i < ${1:-3}; i++ ))
83 groups="$groups,127.0.0.1:$((port+i))"
86 cat <<endKat >ex_rts.rt
106 # ---------------------------------------------------------
108 if [[ ! -f local.rt ]] # we need the real host name in the local.rt; build one from mask if not there
111 sed "s!%%hostname%%!$hn!" rt.mask >local.rt
115 export RMR_ASYNC_CONN=0 # ensure we don't lose first msg as drops waiting for conn look like errors
116 nmsg=100 # total number of messages to be exchanged (-n value changes)
117 delay=500 # microsec sleep between msg 1,000,000 == 1s
121 nrcvrs=1 # this is sane, but -r allows it to be set up
128 -c) copyclone="-c $2"; shift;;
130 -d) delay=${2//,/}; shift;; # delay in micro seconds allow 1,000 to make it easier on user
131 -i) use_installed=1;;
132 -L) leak_anal=$2; shift;;
133 -m) mtype_start_stop="$2"; shift;;
134 -M) mt_call_flag="EX_CFLAGS=-DMTC=1";; # turn on mt-call receiver option
135 -N) ;; # ignored for back compat; nng not supported
137 -r) nrcvrs=$2; shift;;
138 -S) ;; # ignored for back compat; si95 is the only supported transport
141 *) echo "unrecognised option: $1"
142 echo "usage: $0 [-B] [-c caller-threads] [-d micor-sec-delay] [-i] [-M] [-m mtype] [-n num-msgs] [-r num-receivers] [-S] [-v]"
143 echo " -B forces a rebuild which will use .build"
144 echo " -i will use installed libraries (/usr/local) and cause -B to be ignored if supplied)"
145 echo " -L {sender|receiver} run the sender or recevier code under valgrind for leak analysis (output to /tmp/la.log)"
146 echo " -m mtype will set the stopping (max) message type; sender will loop through 0 through mtype-1"
147 echo " -m start:stop will set the starting and stopping mtypes; start through stop -1"
148 echo " -M enables mt-call receive processing to test the RMR asynch receive pthread"
149 echo " -N enables NNG based testing (default)"
150 echo " -S enables SI95 based testing"
152 echo "The receivers will run until they have not received a message for a few seconds. The"
153 echo "sender will send the requested number of messages, 10 by default."
161 # set leak analysis (do not do this from any automated tests)
170 export RMR_VCTL_FILE=".verbose"
173 if (( use_installed )) # point at installed library
175 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH-:/usr/local/lib} # use caller's or set sane default
179 build_path=../../.build # if we rebuild we can insist that it is in .build :)
184 build_path=${BUILD_PATH:-"../../.build"} # we prefer .build at the root level, but allow user option
186 if [[ ! -d $build_path ]]
188 echo "cannot find build in: $build_path"
189 echo "either create, and then build RMr, or set BUILD_PATH as an evironment var before running this"
194 if [[ -z $LD_LIBRARY_PATH ]] # cmake test will set this up and we must honour
196 if [[ -d $build_path/lib64 ]]
198 export LD_LIBRARY_PATH=$build_path:$build_path/lib64:$LD_LIBRARY_PATH
200 export LD_LIBRARY_PATH=$build_path:$build_path/lib:$LD_LIBRARY_PATH
205 export LIBRARY_PATH=$LD_LIBRARY_PATH
206 export RMR_SEED_RT=./ex_rts.rt
208 set_rt $nrcvrs # set up the rt for n receivers
210 if ! build_path=$build_path make -B $mt_call_flag v_sender ex_rts_receiver >/tmp/PID$$.log 2>&1 # for sanity, always rebuild test binaries
212 echo "[FAIL] cannot make binaries"
221 echo "<RUN> binaries built"
223 for (( i=0; i < nrcvrs; i++ ))
228 sleep 2 # let receivers init so we don't shoot at empty targets
231 netstat -an|grep LISTEN
238 for (( i=0; i < nrcvrs; i++ )) # collect return codes
240 head -1 /tmp/PID$$.$i.rrc | read x
244 head -1 /tmp/PID$$.src | read src
246 if (( !! (src + rrc) ))
248 echo "[FAIL] sender rc=$src receiver rc=$rrc"
250 echo "[PASS] sender rc=$src receiver rc=$rrc"
257 exit $(( !! (src + rrc) ))