Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief Test print queue ops - test launcher. Also test unadv/readv xadmin
0004 ##   commands
0005 ##
0006 ## @file run.sh
0007 ##
0008 ## -----------------------------------------------------------------------------
0009 ## Enduro/X Middleware Platform for Distributed Transaction Processing
0010 ## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0011 ## Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0012 ## This software is released under one of the following licenses:
0013 ## AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0014 ## See LICENSE file for full text.
0015 ## -----------------------------------------------------------------------------
0016 ## AGPL license:
0017 ##
0018 ## This program is free software; you can redistribute it and/or modify it under
0019 ## the terms of the GNU Affero General Public License, version 3 as published
0020 ## by the Free Software Foundation;
0021 ##
0022 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0023 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0024 ## PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0025 ## for more details.
0026 ##
0027 ## You should have received a copy of the GNU Affero General Public License along 
0028 ## with this program; if not, write to the Free Software Foundation, Inc.,
0029 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0030 ##
0031 ## -----------------------------------------------------------------------------
0032 ## A commercial use license is available from Mavimax, Ltd
0033 ## contact@mavimax.com
0034 ## -----------------------------------------------------------------------------
0035 ##
0036 
0037 export TESTNAME="test059_pq"
0038 
0039 PWD=`pwd`
0040 if [ `echo $PWD | grep $TESTNAME ` ]; then
0041     # Do nothing 
0042     echo > /dev/null
0043 else
0044     # started from parent folder
0045     pushd .
0046     echo "Doing cd"
0047     cd $TESTNAME
0048 fi;
0049 
0050 . ../testenv.sh
0051 
0052 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0053 export PATH=$PATH:$TESTDIR
0054 
0055 export NDRX_TOUT=10
0056 
0057 #
0058 # Domain 1 - here client will live
0059 #
0060 set_dom1() {
0061     echo "Setting domain 1"
0062     . ../dom1.sh
0063     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0064     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0065     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0066     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0067 }
0068 
0069 
0070 #
0071 # Generic exit function
0072 #
0073 function go_out {
0074     echo "Test exiting with: $1"
0075     
0076     set_dom1;
0077     # avoid slow stop due to busy servers...
0078     xadmin killall atmi.sv59
0079     xadmin stop -y
0080     xadmin down -y
0081 
0082 
0083 
0084     # If some alive stuff left...
0085     xadmin killall atmiclt59
0086 
0087     popd 2>/dev/null
0088     exit $1
0089 }
0090 
0091 rm *dom*.log
0092 export NDRX_SILENT=Y
0093 # Any bridges that are live must be killed!
0094 xadmin killall tpbridge
0095 
0096 set_dom1;
0097 xadmin down -y
0098 xadmin qrmall ,
0099 xadmin qrmall some_hello_queue
0100 xadmin start -y || go_out 1
0101 
0102 # Have some wait for ndrxd goes in service - wait for connection establishment.
0103 RET=0
0104 
0105 echo "Configure servers..."
0106 
0107 xadmin unadv -i 1892 -s TESTSV2
0108 RET=$?
0109 if [[ "X$RET" != "X0" ]]; then
0110     echo "Failed to undav 1892"
0111     go_out $RET
0112 fi
0113 
0114 xadmin unadv -i 1893 -s TESTSV1
0115 RET=$?
0116 if [[ "X$RET" != "X0" ]]; then
0117     echo "Failed to undav 1893"
0118     go_out $RET
0119 fi
0120 
0121 sleep 1
0122 
0123 echo "Test that services are removed..."
0124 
0125 xadmin psc | grep TESTSV2 | grep 1892
0126 if [ "X`xadmin psc | grep TESTSV2 | grep 1892`" != "X" ]; then
0127     echo "TESTSV2/1892 must be missing"
0128     go_out -1
0129 fi
0130 
0131 xadmin psc | grep TESTSV1 | grep 1893
0132 if [ "X`xadmin psc | grep TESTSV1 | grep 1893`" != "X" ]; then
0133     echo "TESTSV1/1893 must be missing"
0134     go_out -1
0135 fi
0136 
0137 echo "Ready to go - running off client"
0138 
0139 xadmin psc
0140 xadmin ppm
0141 
0142 echo "TESTSV1 2"
0143 (./atmiclt59 s TESTSV1 4 2>&1) > ./atmiclt-dom1.log
0144 RET=$?
0145 if [[ "X$RET" != "X0" ]]; then
0146     go_out $RET
0147 fi
0148 
0149 echo "TESTSV2 3"
0150 (./atmiclt59 s TESTSV2 5 2>&1) >> ./atmiclt-dom1.log
0151 RET=$?
0152 if [[ "X$RET" != "X0" ]]; then
0153     go_out $RET
0154 fi
0155 
0156 echo "Arbitrary queue.."
0157 
0158 (./atmiclt59 q "/some_hello_queue" 2 2>&1) >> ./atmiclt-dom1.log
0159 RET=$?
0160 if [[ "X$RET" != "X0" ]]; then
0161     go_out $RET
0162 fi
0163 
0164 echo "Wait for some averges..."
0165 sleep 10
0166 
0167 echo "Printing services"
0168 xadmin pq
0169 echo "Printing services, DONE"
0170 
0171 echo "Printing domain queues"
0172 xadmin pqa
0173 echo "Printing domain queues, DONE"
0174 
0175 echo "Printing all queues"
0176 xadmin pqa -a
0177 echo "Printing all queues, DONE"
0178 
0179 echo "PRINT Services"
0180 xadmin psc
0181 echo "PRINT Services, DONE"
0182 
0183 echo "Testing busy services..."
0184 
0185 if [ "X`xadmin psc | grep TESTSV1 | grep BUSY`" == "X" ]; then
0186     echo "TESTSV1 must be busy!"
0187     go_out -1
0188 fi
0189 
0190 if [ "X`xadmin psc | grep TESTSV2 | grep BUSY`" == "X" ]; then
0191     echo "TESTSV2 must be busy!"
0192     go_out -1
0193 fi
0194 
0195 echo "Testing service queues..."
0196 
0197 if [ "X`xadmin pqa| egrep '^[ ]*3'`" == "X" ]; then
0198     echo "There must be queue with 3x msgs enqueued...!"
0199     go_out -1
0200 fi
0201 
0202 if [ "X`xadmin pq| grep '3 3'`" == "X" ]; then
0203     echo "There must be stats with '3 3'!"
0204     go_out -1
0205 fi
0206 
0207 if [ "X`xadmin pqa| egrep '^[ ]*4'`" == "X" ]; then
0208     echo "There must be queue with 4x msgs enqueued...!"
0209     go_out -1
0210 fi
0211 
0212 if [ "X`xadmin pq| grep '4 4'`" == "X" ]; then
0213     echo "There must be stats with '4 4'!"
0214     go_out -1
0215 fi
0216 
0217 echo "Test that custom queue is not seen in pqa but in pqa -a"
0218 
0219 if [ "X`xadmin pqa| grep 'some_hello_queue'`" != "X" ]; then
0220     echo "[some_hello_queue] must not be seen in pqa!"
0221     go_out -1
0222 fi
0223 
0224 if [ "X`xadmin pqa -a| grep 'some_hello_queue'`" == "X" ]; then
0225     echo "[some_hello_queue] must be seen in pqa -a!"
0226     go_out -1
0227 fi
0228 
0229 echo "Test hello queue message counts..."
0230 
0231 if [ "X`xadmin pqa -a| grep 'some_hello_queue' | egrep '^[ ]*2'`" == "X" ]; then
0232     echo "[some_hello_queue] must have 2x messages enqueued!"
0233     go_out -1
0234 fi
0235 
0236 # Catch is there is test error!!!
0237 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0238         echo "Test error detected!"
0239         RET=-2
0240 fi
0241 
0242 go_out $RET
0243 
0244 
0245 # vim: set ts=4 sw=4 et smartindent: