Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief Both sites max send, avoid deadlock of full sockets - 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="test072_qos"
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 
0052 # 
0053 ulimit -c unlimited
0054 export ASAN_OPTIONS=abort_on_error=1:disable_coredump=0:unmap_shadow_on_exit=1
0055 
0056 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0057 export PATH=$PATH:$TESTDIR
0058 export NDRX_ULOG=$TESTDIR
0059 export NDRX_TOUT=1000
0060 export NDRX_SILENT=Y
0061 
0062 #
0063 # Domain 1 - here client will live
0064 #
0065 set_dom1() {
0066     echo "Setting domain 1"
0067     . ../dom1.sh
0068     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0069     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0070     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0071     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0072 }
0073 
0074 
0075 #
0076 # Domain 2 - here server will live
0077 #
0078 set_dom2() {
0079     echo "Setting domain 2"
0080     . ../dom2.sh    
0081     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom2.xml
0082     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom2.log
0083     export NDRX_LOG=$TESTDIR/ndrx-dom2.log
0084     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom2.conf
0085 }
0086 
0087 #
0088 # Generic exit function
0089 #
0090 function go_out {
0091     echo "Test exiting with: $1"
0092     
0093     # Check only if pq shows something on tpbridge...
0094     if [ $1 -ne 0 ]; then
0095 
0096         echo "Collecting stats..."
0097         set_dom1;
0098         xadmin pq
0099         xadmin pqa
0100         
0101         set_dom2;
0102         xadmin pq
0103         xadmin pqa
0104 
0105         echo "Sleep 5..."
0106         sleep 5
0107 
0108         set_dom1;
0109         xadmin pq
0110         xadmin pqa
0111 
0112         set_dom2;
0113         xadmin pq
0114         xadmin pqa
0115 
0116         # TODO: might want to generate only if we have unclear Qs
0117         echo "Generating cores..."
0118         xadmin ps -p -a tpbridge  | xargs kill -11
0119     fi
0120 
0121     set_dom1;
0122     echo "Domain 1 stats"
0123     xadmin stop -y
0124     xadmin down -y
0125 
0126     set_dom2;
0127     echo "Domain 2 stats"
0128     xadmin stop -y
0129     xadmin down -y
0130 
0131     # If some alive stuff left...
0132     xadmin killall atmiclt72
0133 
0134     popd 2>/dev/null
0135     exit $1
0136 }
0137 
0138 #for action in 1 2 3
0139 #
0140 # Seems like for System V we cannot exhaust the queue space?
0141 #
0142 for action in 1
0143 do
0144 
0145     export TEST_ACTION=$action
0146     echo "Testing drop action: $TEST_ACTION"
0147 
0148     rm *dom*.log ULOG*
0149     # Any bridges that are live must be killed!
0150     xadmin killall tpbridge atmiclt72
0151 
0152     set_dom1;
0153     xadmin down -y
0154     xadmin start -y || go_out 1
0155 
0156 
0157     set_dom2;
0158     xadmin down -y
0159     xadmin start -y || go_out 2
0160 
0161     # Have some wait for ndrxd goes in service - wait for connection establishment.
0162     sleep 20
0163     RET=0
0164 
0165     xadmin psc
0166     xadmin ppm
0167     echo "Running off client - dom2 background"
0168 
0169     set_dom2;
0170     (./atmiclt72 TEST1 GETINFOS1 2>&1) > ./atmiclt-dom2.log &
0171     (./atmiclt72 TEST11 GETINFOS11 2>&1) > ./atmiclt-dom2_1.log &
0172 
0173     echo "Running off client - dom1 foreground"
0174 
0175     set_dom1;
0176     (./atmiclt72 TEST22 GETINFOS22 2>&1) >> ./atmiclt-dom1_1.log &
0177     (./atmiclt72 TEST2 GETINFOS2 2>&1) >> ./atmiclt-dom1.log
0178 
0179     RET=$?
0180 
0181     if [[ "X$RET" != "X0" ]]; then
0182 
0183         go_out $RET
0184     fi
0185 
0186     # Catch is there is test error!!!
0187     if [ "X`grep TESTERROR *.log`" != "X" ]; then
0188         echo "Test error detected!"
0189         RET=-2
0190         go_out $RET
0191     fi
0192 
0193     # wait for finish results
0194 
0195     i=`grep "testcl finished" ULOG* | wc -l`
0196 
0197     while [ $i -lt 4 ] && [ $i -lt 65 ]
0198     do
0199         echo "Wait 5 finish..."
0200         sleep 5
0201         i=`grep "testcl finished" ULOG* | wc -l`
0202     done
0203 
0204     ok=`grep "testcl finished - OK" ULOG* | wc -l`
0205     bad=`grep "testcl finished - failed" ULOG* | wc -l`
0206     discard=`grep "Discarding message" ULOG* | wc -l`
0207 
0208     echo "ok=$ok bad=$bad discard=$discard"
0209 
0210     if [ $action -eq 1 ]; then
0211 
0212         if [ $ok -ne 4 ]; then
0213             echo "Expected OK clients 4 got: $ok bad: $fail"
0214             RET=-3
0215             go_out $RET
0216         fi
0217 
0218         if [ $discard -ne 0 ]; then
0219             echo "There must be no discarded messages, but got: $discard"
0220             RET=-4
0221             go_out $RET
0222         fi
0223 
0224     else
0225 
0226         if [ $bad -lt 1 ]; then
0227             
0228             echo "Expected 1 bad client got: $bad ok: $ok"
0229             RET=-3
0230             go_out $RET
0231         fi
0232 
0233         if [ $discard -eq 0 ]; then
0234             echo "There must be discarded messages, but got: $discard"
0235             RET=-4
0236             go_out $RET
0237         fi
0238     fi
0239 done
0240 
0241 go_out $RET
0242 
0243 # vim: set ts=4 sw=4 et smartindent: