3 #==================================================================================
4 # Copyright (c) 2019 Nokia
5 # Copyright (c) 2018-2019 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_rts_test.ksh
23 # Abstract: This is a simple script to set up and run the basic send/receive
24 # processes for some library validation on top of nano/nng. This
25 # particular test starts several senders and one receiver. All messages
26 # go to the receiver and an ack is sent back to the sending process.
27 # Each sender puts a tag into the message allowing it to verify that
28 # all messages received were 'acks' to the ones it sent, and that no
29 # rts messages were routed to the wrong sender.
31 # Example command line:
34 # Author: E. Scott Daniels
35 # ---------------------------------------------------------------------------------
38 # The sender and receivers are run asynch. Their exit statuses are captured in a
39 # file in order for the 'main' to pick them up easily.
40 # $1 is the instance so we can keep logs separate.
43 export RMR_RTG_SVC=$(( 9991 + $1 ))
44 port=$(( 43080 + $1 ))
47 ./sender_nano $nmsg $delay 5:6 $port # 5:6 causes mtype 5 only which is what receiver acks
49 ./sender $nmsg $delay 5:6 $port
51 echo $? >/tmp/PID$$.$1.src # must communicate state back via file b/c asynch
54 # $1 is the instance so we can keep logs separate
59 export RMR_RTG_SVC=9990
60 if (( $nano_receiver ))
62 ./receiver_nano $(( nmsg * nsenders )) $port
64 ./receiver $(( nmsg * nsenders )) $port
66 echo $? >/tmp/PID$$.rrc
69 # Drop in a contrived route table. It should have only one entry which points
70 # message type 0 to the receiver. The sender must NOT be defined for a valid
71 # tests (rts should not require the sendter be in the route thable).
76 mse |5 | -1 | localhost:4460
82 # ---------------------------------------------------------
84 nmsg=10 # total number of messages to be exchanged (-n value changes)
85 delay=1000000 # microsec sleep between msg 1,000,000 == 1s
86 nano_sender=0 # start nano version if set (-N)
92 nsenders=3 # this is sane, but -s allows it to be set up
98 -b) rebuild=1; nopull="nopull";; # build without pulling
104 -s) nsenders=$2; shift;;
107 *) echo "unrecognised option: $1"
108 echo "usage: $0 [-B] [-d micor-sec-delay] [-N] [-n num-msgs] [-s nsenders]"
109 echo " -B forces a rebuild which will use .build"
120 export RMR_VCTL_FILE=".verbose"
126 ksh ./rebuild.ksh $nopull | read build_path
129 build_path=${BUILD_PATH:-"../../.build"} # we prefer .build at the root level, but allow user option
131 if [[ ! -d $build_path ]]
133 echo "cannot find build in: $build_path"
134 echo "either create, and then build RMr, or set BUILD_PATH as an evironment var before running this"
139 if [[ -d $build_path/lib64 ]]
141 export LD_LIBRARY_PATH=$build_path:$build_path/lib64
143 export LD_LIBRARY_PATH=$build_path:$build_path/lib
145 export LIBRARY_PATH=$LD_LIBRARY_PATH
146 export RMR_SEED_RT=./rts.rt
148 set_rt # create the route table
150 if [[ ! -f ./sender ]]
152 if ! make >/dev/null 2>&1
154 echo "[FAIL] cannot find sender binary, and cannot make it.... humm?"
161 sleep 2 # let receivers init so we don't shoot at an empty target
162 for (( i=0; i < nsenders; i++ )) # start the receivers with an instance number
170 for (( i=0; i < nsenders; i++ )) # collect return codes
172 head -1 /tmp/PID$$.$i.src | read x
176 head -1 /tmp/PID$$.rrc | read rrc
178 if (( !! (src + rrc) ))
180 echo "[FAIL] sender rc=$src receiver rc=$rrc"
182 echo "[PASS] sender rc=$src receiver rc=$rrc"
189 exit $(( !! (src + rrc) ))