Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief @(#) Test039 - TP Broadcast tests
0004 ##
0005 ## @file run.sh
0006 ##
0007 ## -----------------------------------------------------------------------------
0008 ## Enduro/X Middleware Platform for Distributed Transaction Processing
0009 ## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0010 ## Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0011 ## This software is released under one of the following licenses:
0012 ## AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0013 ## See LICENSE file for full text.
0014 ## -----------------------------------------------------------------------------
0015 ## AGPL license:
0016 ##
0017 ## This program is free software; you can redistribute it and/or modify it under
0018 ## the terms of the GNU Affero General Public License, version 3 as published
0019 ## by the Free Software Foundation;
0020 ##
0021 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0022 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0023 ## PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0024 ## for more details.
0025 ##
0026 ## You should have received a copy of the GNU Affero General Public License along 
0027 ## with this program; if not, write to the Free Software Foundation, Inc.,
0028 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0029 ##
0030 ## -----------------------------------------------------------------------------
0031 ## A commercial use license is available from Mavimax, Ltd
0032 ## contact@mavimax.com
0033 ## -----------------------------------------------------------------------------
0034 ##
0035 
0036 export TESTNO="039"
0037 export TESTNAME_SHORT="tpbroadcast"
0038 export TESTNAME="test${TESTNO}_${TESTNAME_SHORT}"
0039 
0040 PWD=`pwd`
0041 if [ `echo $PWD | grep $TESTNAME ` ]; then
0042         # Do nothing 
0043         echo > /dev/null
0044 else
0045         # started from parent folder
0046         pushd .
0047         echo "Doing cd"
0048         cd $TESTNAME
0049 fi;
0050 
0051 . ../testenv.sh
0052 
0053 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0054 export PATH=$PATH:$TESTDIR
0055 # We do not need timeout, we will kill procs...
0056 export NDRX_TOUT=9999
0057 
0058 #
0059 # Domain 1 - here client will live
0060 #
0061 function set_dom1 {
0062     echo "Setting domain 1"
0063     . ../dom1.sh
0064     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0065     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0066     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0067     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0068 }
0069 
0070 #
0071 # Domain 2 - here server will live
0072 #
0073 function set_dom2 {
0074     echo "Setting domain 2"
0075     . ../dom2.sh    
0076     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom2.xml
0077     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom2.log
0078     export NDRX_LOG=$TESTDIR/ndrx-dom2.log
0079     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom2.conf
0080 }
0081 
0082 #
0083 # Generic exit function
0084 #
0085 function go_out {
0086     echo "Test exiting with: $1"
0087     xadmin killall atmiclt
0088     
0089     set_dom1;
0090     xadmin stop -y
0091     xadmin down -y
0092 
0093     set_dom2;
0094     xadmin stop -y
0095     xadmin down -y
0096 
0097     # If some alive stuff left...
0098     xadmin killall atmiclt39
0099 
0100     popd 2>/dev/null
0101     exit $1
0102 }
0103 
0104 #
0105 # Check the lines of maching codes
0106 #
0107 function chk_lines {
0108     log_file=$1
0109     code=$2
0110     must_be=$3
0111     chk_num=$4
0112 
0113     CNT=`grep $code $log_file | grep T_STRING_FLD | wc | awk '{print $1}'`
0114     echo "$code count in $log_file: $CNT"
0115 
0116     if [[ $CNT -ne $must_be ]]; then
0117             echo "Actual $code $CNT != $must_be!"
0118             go_out $chk_num
0119     fi
0120 
0121 }
0122 
0123 rm *dom*.log
0124 # Any bridges that are live must be killed!
0125 xadmin killall tpbridge
0126 
0127 set_dom1;
0128 xadmin down -y
0129 xadmin start -y || go_out 1
0130 
0131 set_dom2;
0132 xadmin down -y
0133 xadmin start -y || go_out 2
0134 
0135 # Have some wait for ndrxd goes in service - wait for connection establishment.
0136 sleep 60
0137 RET=0
0138 MAX_CALLS=1000 # Same as in atmiclt39.c constant...
0139 
0140 echo "Running off client"
0141 
0142 #
0143 # Dom 1 set
0144 #
0145 set_dom1;
0146 
0147 #
0148 # Bug #269 unit test, check the return number of tpchkunsol()
0149 #
0150 
0151 ./atmicltA39 retnum > ./atmicltA39-retnum-dom1.log  2>&1
0152 RET=$?
0153 
0154 if [[ "X$RET" != "X0" ]]; then
0155     go_out $RET
0156 fi
0157 
0158 #
0159 # Continue with normal tests
0160 #
0161 (./atmicltA39 listen 2>&1 ) > ./atmicltA39-listen-dom1.log &
0162 (./atmicltA39 mutted 2>&1 ) > ./atmicltA39-mutted-dom1.log  &
0163 
0164 (./atmicltB39 listen 2>&1 ) > ./atmicltB39-listen-dom1.log  &
0165 (./atmicltB39 mutted 2>&1 ) > ./atmicltB39-mutted-dom1.log  &
0166 
0167 (./atmicltC39 listen 2>&1 ) > ./atmicltC39-listen-dom1.log  &
0168 (./atmicltC39 mutted 2>&1 ) > ./atmicltC39-mutted-dom1.log  &
0169 
0170 #
0171 # Dom2
0172 #
0173 set_dom2;
0174 (./atmicltA39 listen 2>&1 ) > ./atmicltA39-listen-dom2.log  &
0175 (./atmicltA39 mutted 2>&1 ) > ./atmicltA39-mutted-dom2.log  &
0176 
0177 (./atmicltB39 listen 2>&1 ) > ./atmicltB39-listen-dom2.log  &
0178 (./atmicltB39 mutted 2>&1 ) > ./atmicltB39-mutted-dom2.log  &
0179 
0180 (./atmicltC39 listen 2>&1 ) > ./atmicltC39-listen-dom2.log  &
0181 (./atmicltC39 mutted 2>&1 ) > ./atmicltC39-mutted-dom2.log  &
0182 
0183 
0184 # Let all listeners to wake up (start..)
0185 sleep 5
0186 #
0187 # Broadcast from dom1
0188 #
0189 set_dom1;
0190 # This our broadcaster...
0191 (./atmicltA39 broadcast 2>&1) > ./atmicltA39-broadcast-dom1.log
0192 RET=$?
0193 
0194 if [[ "X$RET" != "X0" ]]; then
0195     go_out $RET
0196 fi
0197 
0198 # let the messages to completes it's processing...
0199 echo "Waiting for completion..."
0200 sleep 180
0201 
0202 #
0203 # Broadcast of AA message to all clients
0204 #
0205 
0206 chk_lines "atmicltA39-broadcast-dom1.log" "AA01" "$MAX_CALLS" "1"
0207 
0208 chk_lines "atmicltA39-listen-dom1.log" "AA01" "$MAX_CALLS" "2"
0209 chk_lines "atmicltA39-mutted-dom1.log" "AA01" "0" "3"
0210 
0211 chk_lines "atmicltB39-listen-dom1.log" "AA01" "$MAX_CALLS" "4"
0212 chk_lines "atmicltB39-mutted-dom1.log" "AA01" "0" "5"
0213 
0214 chk_lines "atmicltC39-listen-dom1.log" "AA01" "$MAX_CALLS" "6"
0215 chk_lines "atmicltC39-mutted-dom1.log" "AA01" "0" "7"
0216 
0217 chk_lines "atmicltA39-listen-dom2.log" "AA01" "$MAX_CALLS" "8"
0218 chk_lines "atmicltA39-mutted-dom2.log" "AA01" "0" "9"
0219 
0220 chk_lines "atmicltB39-listen-dom2.log" "AA01" "$MAX_CALLS" "10"
0221 chk_lines "atmicltB39-mutted-dom2.log" "AA01" "0" "11"
0222 
0223 chk_lines "atmicltC39-listen-dom2.log" "AA01" "$MAX_CALLS" "12"
0224 chk_lines "atmicltC39-mutted-dom2.log" "AA01" "0" "13"
0225 
0226 
0227 #
0228 # Broadcast of BB message to .*B.* matching clients (regex)
0229 #
0230 
0231 chk_lines "atmicltA39-broadcast-dom1.log" "BB01" "0" "14"
0232 
0233 chk_lines "atmicltA39-listen-dom1.log" "BB01" "0" "15"
0234 chk_lines "atmicltA39-mutted-dom1.log" "BB01" "0" "16"
0235 
0236 chk_lines "atmicltB39-listen-dom1.log" "BB01" "$MAX_CALLS" "17"
0237 chk_lines "atmicltB39-mutted-dom1.log" "BB01" "0" "18"
0238 
0239 chk_lines "atmicltC39-listen-dom1.log" "BB01" "0" "19"
0240 chk_lines "atmicltC39-mutted-dom1.log" "BB01" "0" "20"
0241 
0242 chk_lines "atmicltA39-listen-dom2.log" "BB01" "0" "21"
0243 chk_lines "atmicltA39-mutted-dom2.log" "BB01" "0" "22"
0244 
0245 chk_lines "atmicltB39-listen-dom2.log" "BB01" "$MAX_CALLS" "23"
0246 chk_lines "atmicltB39-mutted-dom2.log" "BB01" "0" "24"
0247 
0248 chk_lines "atmicltC39-listen-dom2.log" "BB01" "0" "25"
0249 chk_lines "atmicltC39-mutted-dom2.log" "BB01" "0" "26"
0250 
0251 #
0252 # Broadcast of CC message to dom2 only
0253 #
0254 chk_lines "atmicltA39-broadcast-dom1.log" "CC01" "0" "27"
0255 
0256 chk_lines "atmicltA39-listen-dom1.log" "CC01" "0" "28"
0257 chk_lines "atmicltA39-mutted-dom1.log" "CC01" "0" "29"
0258 
0259 chk_lines "atmicltB39-listen-dom1.log" "CC01" "0" "30"
0260 chk_lines "atmicltB39-mutted-dom1.log" "CC01" "0" "31"
0261 
0262 chk_lines "atmicltC39-listen-dom1.log" "CC01" "0" "32"
0263 chk_lines "atmicltC39-mutted-dom1.log" "CC01" "0" "33"
0264 
0265 chk_lines "atmicltA39-listen-dom2.log" "CC01" "$MAX_CALLS" "34"
0266 chk_lines "atmicltA39-mutted-dom2.log" "CC01" "0" "35"
0267 
0268 chk_lines "atmicltB39-listen-dom2.log" "CC01" "$MAX_CALLS" "36"
0269 chk_lines "atmicltB39-mutted-dom2.log" "CC01" "0" "37"
0270 
0271 chk_lines "atmicltC39-listen-dom2.log" "CC01" "$MAX_CALLS" "38"
0272 chk_lines "atmicltC39-mutted-dom2.log" "CC01" "0" "39"
0273 
0274 
0275 #
0276 # Broadcast of DD message to atmicltC39 only
0277 #
0278 chk_lines "atmicltA39-broadcast-dom1.log" "DD01" "0" "40"
0279 
0280 chk_lines "atmicltA39-listen-dom1.log" "DD01" "0" "41"
0281 chk_lines "atmicltA39-mutted-dom1.log" "DD01" "0" "42"
0282 
0283 chk_lines "atmicltB39-listen-dom1.log" "DD01" "0" "43"
0284 chk_lines "atmicltB39-mutted-dom1.log" "DD01" "0" "44"
0285 
0286 chk_lines "atmicltC39-listen-dom1.log" "DD01" "$MAX_CALLS" "45"
0287 chk_lines "atmicltC39-mutted-dom1.log" "DD01" "0" "46"
0288 
0289 chk_lines "atmicltA39-listen-dom2.log" "DD01" "0" "47"
0290 chk_lines "atmicltA39-mutted-dom2.log" "DD01" "0" "48"
0291 
0292 chk_lines "atmicltB39-listen-dom2.log" "DD01" "0" "49"
0293 chk_lines "atmicltB39-mutted-dom2.log" "DD01" "0" "50"
0294 
0295 chk_lines "atmicltC39-listen-dom2.log" "DD01" "$MAX_CALLS" "51"
0296 chk_lines "atmicltC39-mutted-dom2.log" "DD01" "0" "52"
0297 
0298 # Catch is there is test error!!!
0299 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0300         echo "Test error detected!"
0301         RET=-2
0302 fi
0303 
0304 
0305 go_out $RET
0306 
0307 
0308 
0309 # vim: set ts=4 sw=4 et smartindent: