Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief @(#) Test server connection to Oracle DB from C - 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="test047_oradb"
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_TOUT=20
0054 export NDRX_SILENT=Y
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     # We need DB Config here too...
0068 
0069     # XA SECTION
0070     export NDRX_XA_RES_ID=1
0071     export NDRX_XA_OPEN_STR="ORACLE_XA+SqlNet=$EX_ORA_SID+ACC=P/$EX_ORA_USER/$EX_ORA_PASS+SesTM=180+LogDir=./+NoLocal=true+Threads=true+Loose_Coupling=false"
0072     export NDRX_XA_CLOSE_STR=$NDRX_XA_OPEN_STR
0073     export NDRX_XA_RMLIB=$EX_ORA_OCILIB
0074     export NDRX_XA_LAZY_INIT=1
0075     export NDRX_XA_FLAGS="RECON:*:3:100"
0076     # XA SECTION, END
0077 }
0078 
0079 #
0080 # Generic exit function
0081 #
0082 function go_out {
0083     echo "Test exiting with: $1"
0084     
0085     set_dom1;
0086     xadmin stop -y
0087     xadmin down -y
0088 
0089     # If some alive stuff left...
0090     xadmin killall atmiclt47
0091 
0092     popd 2>/dev/null
0093     exit $1
0094 }
0095 
0096 set_dom1;
0097 
0098 #
0099 # Do static switch / dynamic switch tests
0100 #
0101 swmode=0
0102 while [ $swmode -lt 2 ]; do
0103 
0104     if [ $swmode -eq 0 ]; then
0105         echo ">>> Static Switch testing"
0106         export NDRX_XA_DRIVERLIB=libndrxxaoras.so
0107     else
0108         echo ">>> Dynamic Switch testing"
0109         export NDRX_XA_DRIVERLIB=libndrxxaorad.so
0110     fi
0111 
0112     echo "Going down..."
0113     xadmin down -y
0114     #
0115     # assuming sudos are configured
0116     #
0117     if type "tcpkill" > /dev/null; then
0118         sudo LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH` PATH=`echo $PATH` `which xadmin` killall tcpkill
0119     fi
0120 
0121     rm *.log 2>/dev/null
0122     j=0
0123     while [ $j -lt 2 ]; do
0124 
0125         if [ $j -eq 1 ]; then
0126             echo ">>>> No Join, tight branching test"
0127             export NDRX_XA_FLAGS="$NDRX_XA_FLAGS;NOJOIN;BTIGHT"
0128         else
0129             echo ">>>> With JOIN"
0130         fi
0131 
0132         xadmin down -y
0133         xadmin start -y || go_out 1
0134 
0135         RET=0
0136 
0137         xadmin psc
0138         xadmin ppm
0139         echo "Running off client"
0140 
0141         xadmin forgetlocal -y
0142         xadmin abortlocal -y
0143         xadmin recoverlocal
0144 
0145         (./atmiclt47 2>&1) >> ./atmiclt-dom1.log
0146 
0147         RET=$?
0148 
0149         if [ "X$RET" != "X0" ]; then
0150             go_out $RET
0151         fi
0152 
0153         # Catch is there is test error!!!
0154         if [ "X`grep TESTERROR *.log`" != "X" ]; then
0155             echo "Test error detected!"
0156             RET=-2
0157             go_out -2
0158         fi
0159 
0160         j=$(( j + 1 ))
0161     done
0162 
0163     #
0164     # Currently this is linux only test!
0165     #
0166     # only if have tcpkill 
0167     # test recon engine, when connections randomly breaks up
0168     #
0169     # For Ora tests  required sudo configuration, adjust the paths accordingly to the OS
0170     # ----------------------
0171     # user1   ALL=(ALL)   NOPASSWD: /sbin/tcpkill,/bin/kill,/bin/xadmin,/home/user1/endurox/dist/bin/xadmin
0172     # ----------------------
0173     # 
0174     # To recover from broken connections, enable tcp keepalive
0175     # ----------------------
0176     # # cat << EOF >> /etc/sysctl.conf
0177     #
0178     # net.ipv4.tcp_keepalive_time=15
0179     # net.ipv4.tcp_keepalive_intvl=15
0180     # net.ipv4.tcp_keepalive_probes=3
0181     # 
0182     # EOF
0183     # # sysctl -f /etc/sysctl.conf
0184     # ----------------------
0185     # 
0186     # Enable broken connections on tnsname.ora
0187     # ----------------------
0188     # XASVC =
0189     # (DESCRIPTION=
0190     # (FAILOVER=on)
0191     # (ENABLE=broken)
0192     # (ADDRESS=(PROTOCOL=tcp)(HOST=rac1-vip)(PORT=1521))
0193     # (ADDRESS=(PROTOCOL=tcp)(HOST=rac2-vip)(PORT=1521))
0194     # (CONNECT_DATA=
0195     # (SERVICE_NAME=XASVC)
0196     # (FAILOVER_MODE=
0197     # (TYPE=SESSION)
0198     # (METHOD=BASIC)
0199     # (RETRIES=10)
0200     # (DELAY=15)
0201     # )
0202     # )
0203     # )
0204     # ----------------------
0205 
0206     if type "tcpkill" > /dev/null; then
0207         echo ">>>> Loop testing of recon (if available)"
0208         # use common incl normal use
0209         #export NDRX_XA_FLAGS="RECON:*:3:100:-3,-7"
0210         # reset btight flag...
0211         export NDRX_XA_FLAGS="RECON:*:3:100"
0212         export NDRX_TOUT=800
0213         export NDRX_DEBUG_CONF=$TESTDIR/debug_loop-dom1.conf
0214         export NDRX_TEST047_KILL=1
0215         sudo LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH` PATH=`echo $PATH` `which xadmin` killall tcpkill >/dev/null 2>&1
0216         xadmin stop -y
0217         xadmin start -y
0218         (./atmiclt47_loop 2>&1) > ./atmiclt_loop-dom1.log &
0219         LOOP_PID=$!
0220         echo "Wait for startup..."
0221         sleep 5
0222         # while binary is working kill connections periodically
0223         # and expect binary to complete in the time
0224         while kill -0 $LOOP_PID >/dev/null 2>&1
0225         do
0226 
0227             # kill connections for 5 sec
0228             sudo tcpkill -i $EX_ORA_IF port $EX_ORA_PORT >/dev/null  2>&1 & 
0229             TCPKILL_PID=$!
0230             echo "Wait 5 (tcpkill work)"
0231             sleep 5
0232             sudo LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH` PATH=`echo $PATH` `which xadmin` killall tcpkill >/dev/null 2>&1 
0233 
0234             # let binary 
0235             echo "Wait 220 (OK work)"
0236             sleep 220
0237 
0238         done
0239 
0240         sudo LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH` PATH=`echo $PATH` `which xadmin` killall tcpkill >/dev/null 2>&1 
0241     fi
0242 
0243     # Catch is there is test error!!!
0244     if [ "X`grep TESTERROR *.log`" != "X" ]; then
0245         echo "Test error detected!"
0246         RET=-3
0247     fi
0248 
0249     if [ "X`grep -i "timed out" *.log | grep aborting`" != "X" ]; then
0250         echo "There must be no timed-out transactions!"
0251         RET=-4
0252     fi
0253 
0254     swmode=$(( swmode + 1 ))
0255 done
0256 
0257 
0258 go_out $RET
0259 
0260 # vim: set ts=4 sw=4 et smartindent: