Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief System V polling tests - test launcher
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 TESTNAME="test058_systemv"
0037 
0038 PWD=`pwd`
0039 if [ `echo $PWD | grep $TESTNAME ` ]; then
0040     # Do nothing 
0041     echo > /dev/null
0042 else
0043     # started from parent folder
0044     pushd .
0045     echo "Doing cd"
0046     cd $TESTNAME
0047 fi;
0048 
0049 . ../testenv.sh
0050 
0051 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0052 export PATH=$PATH:$TESTDIR
0053 export NDRX_SILENT=Y
0054 export NDRX_TOUT=20
0055 
0056 #
0057 # Domain 1 - here client will live
0058 #
0059 set_dom1() {
0060     echo "Setting domain 1"
0061     . ../dom1.sh
0062     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0063     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0064     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0065     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0066 }
0067 
0068 #
0069 # Generic exit function
0070 #
0071 function go_out {
0072     echo "Test exiting with: $1"
0073     
0074     set_dom1;
0075     xadmin stop -y
0076     xadmin down -y
0077 
0078 
0079 
0080     # If some alive stuff left...
0081     xadmin killall atmiclt58
0082 
0083     popd 2>/dev/null
0084     exit $1
0085 }
0086 
0087 rm *dom*.log
0088 # Any bridges that are live must be killed!
0089 xadmin killall tpbridge
0090 
0091 set_dom1;
0092 xadmin down -y
0093 xadmin start -y || go_out 1
0094 
0095 RET=0
0096 
0097 xadmin psc
0098 xadmin ppm
0099 xadmin psvc -r
0100 #
0101 # Check psvc that there is two queues according to regexp map
0102 #
0103 RES=`xadmin psvc -r | egrep '^[^0-9]+0[^0-9]+[0-9]+[^0-9]+2$'`
0104 if [ "X$RES" == "X" ]; then
0105     echo "Invalid service count (0.2)!"
0106     go_out -10
0107 fi
0108 
0109 RES=`xadmin psvc -r | egrep '^[^0-9]+1[^0-9]+[0-9]+[^0-9]+2$'`
0110 if [ "X$RES" == "X" ]; then
0111     echo "Invalid service count (1.2)!"
0112     go_out -10
0113 fi
0114 
0115 # expect count 2
0116 RES=`xadmin psvc -r | egrep '^[^0-9]+[0-9]+[^0-9]+[0-9]+[^0-9]+[0-9]+$' | wc | awk '{print $1}'`
0117 if [ "X$RES" != "X2" ]; then
0118     echo "Invalid identifier count, expected 2 got $RES!"
0119     go_out -10
0120 fi
0121 
0122 #
0123 # Stop one service the map should be changed
0124 #
0125 echo "Stop one"
0126 xadmin stop -i 10
0127 xadmin psvc -r
0128 RES=`xadmin psvc -r | egrep '^[^0-9]+0[^0-9]+[0-9]+[^0-9]+1$'`
0129 
0130 if [ "X$RES" == "X" ]; then
0131     echo "Invalid service count (0.1)!"
0132     go_out -11
0133 fi
0134 
0135 RES=`xadmin psvc -r | egrep '^[^0-9]+1[^0-9]+[0-9]+[^0-9]+2$'`
0136 
0137 if [ "X$RES" == "X" ]; then
0138     echo "Invalid service count (1.2)!"
0139     go_out -11
0140 fi
0141 
0142 # expect count 2
0143 RES=`xadmin psvc -r | egrep '^[^0-9]+[0-9]+[^0-9]+[0-9]+[^0-9]+[0-9]+$' | wc | awk '{print $1}'`
0144 if [ "X$RES" != "X2" ]; then
0145     echo "Invalid identifier count, expected 2 got $RES!"
0146     go_out -11
0147 fi
0148 
0149 
0150 #
0151 # Stop another service from rqaddr map should be changed once again
0152 #
0153 
0154 echo "Stop another"
0155 
0156 xadmin stop -i 11
0157 xadmin psvc -r
0158 
0159 RES=`xadmin psvc -r | egrep '^[^0-9]+0[^0-9]+[0-9]+[^0-9]+2$'`
0160 
0161 if [ "X$RES" == "X" ]; then
0162     echo "Invalid service count (0.2)!"
0163     go_out -12
0164 fi
0165 
0166 # expect count 1
0167 RES=`xadmin psvc -r | egrep '^[^0-9]+[0-9]+[^0-9]+[0-9]+[^0-9]+[0-9]+$' | wc | awk '{print $1}'`
0168 if [ "X$RES" != "X1" ]; then
0169     echo "Invalid identifier count, expected 1 got $RES!"
0170     go_out -12
0171 fi
0172 
0173 #
0174 # start servers back, services should be back as in first test
0175 #
0176 
0177 xadmin start -y
0178 xadmin psvc -r 
0179 
0180 
0181 RES=`xadmin psvc -r | egrep '^[^0-9]+0[^0-9]+[0-9]+[^0-9]+2$'`
0182 if [ "X$RES" == "X" ]; then
0183     echo "Invalid service count (0.2)!"
0184     go_out -13
0185 fi
0186 
0187 RES=`xadmin psvc -r | egrep '^[^0-9]+1[^0-9]+[0-9]+[^0-9]+2$'`
0188 if [ "X$RES" == "X" ]; then
0189     echo "Invalid service count (1.2)!"
0190     go_out -13
0191 fi
0192 
0193 # expect count 2
0194 RES=`xadmin psvc -r | egrep '^[^0-9]+[0-9]+[^0-9]+[0-9]+[^0-9]+[0-9]+$' | wc | awk '{print $1}'`
0195 if [ "X$RES" != "X2" ]; then
0196     echo "Invalid identifier count, expected 2 got $RES!"
0197     go_out -13
0198 fi
0199 
0200 echo "Running off client"
0201 
0202 set_dom1;
0203 
0204 # Test scenario for round robins
0205 # do some call
0206 (./atmiclt58 GpriQQMLVdaBg 2>&1) > ./atmiclt-dom1.log
0207 #(valgrind --leak-check=full --log-file="v.out" -v ./atmiclt58 2>&1) > ./atmiclt-dom1.log
0208 
0209 RET=$?
0210 
0211 if [[ "X$RET" != "X0" ]]; then
0212     go_out $RET
0213 fi
0214 
0215 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0216         echo "Test error detected!"
0217         RET=-2
0218 fi
0219 
0220 #
0221 # Above performs 4x calls to sleepy services, thus with round robin all
0222 # of the must got the 1x calls, now validate it.
0223 #
0224 echo "Waiting for servers to finish..."
0225 sleep 6
0226 
0227 xadmin psc
0228 
0229 RES=`xadmin psc | egrep "atmi\.sv58[ \\t\\r\\n\\v\\f]+10[ \\t\\r\\n\\v\\f]+1[ \\t\\r\\n\\v\\f]+0"`
0230 
0231 if [ "X$RES" == "X" ]; then
0232     echo "Processed entries missing (5)!"
0233     go_out -14
0234 fi
0235 
0236 RES=`xadmin psc | egrep "atmi\.sv58[ \\t\\r\\n\\v\\f]+11[ \\t\\r\\n\\v\\f]+1[ \\t\\r\\n\\v\\f]+0"`
0237 
0238 if [ "X$RES" == "X" ]; then
0239     echo "Processed entries missing (6)!"
0240     go_out -14
0241 fi
0242 
0243 RES=`xadmin psc | egrep "atmi\.sv58[ \\t\\r\\n\\v\\f]+100[ \\t\\r\\n\\v\\f]+1[ \\t\\r\\n\\v\\f]+0"`
0244 
0245 if [ "X$RES" == "X" ]; then
0246     echo "Processed entries missing (7)!"
0247     go_out -15
0248 fi
0249 
0250 RES=`xadmin psc | egrep "atmi\.sv58[ \\t\\r\\n\\v\\f]+101[ \\t\\r\\n\\v\\f]+1[ \\t\\r\\n\\v\\f]+0"`
0251 
0252 if [ "X$RES" == "X" ]; then
0253     echo "Processed entries missing (8)!"
0254     go_out -15
0255 fi
0256 
0257 go_out $RET
0258 
0259 # vim: set ts=4 sw=4 et smartindent: