Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief Ndrxd sanity scans / ulog entries - 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="test074_sanitulog"
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_ULOG=$TESTDIR
0054 export NDRX_TOUT=10
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 atmiclt74
0082 
0083     popd 2>/dev/null
0084     exit $1
0085 }
0086 
0087 manual_mode=0
0088 
0089 if [ "$#" -gt 0 ]; then
0090     echo "We are running in hand test mode.."
0091     manual_mode=1
0092 fi
0093 
0094 rm *.log
0095 rm ULOG*
0096 # Any bridges that are live must be killed!
0097 xadmin killall tpbridge
0098 
0099 set_dom1;
0100 xadmin down -y
0101 xadmin start -y || go_out 1
0102 
0103 RET=0
0104 
0105 xadmin psc
0106 xadmin ppm
0107 
0108 echo "Running off client - 120s - wait for ULOG / no die in ULOG"
0109 
0110 (./atmiclt74 2>&1) > ./atmiclt-dom1.log
0111 
0112 RET=$?
0113 
0114 if [[ "X$RET" != "X0" ]]; then
0115     go_out $RET
0116 fi
0117 
0118 ULOG=`cat ULOG*`
0119 
0120 if [ "X$ULOG" != "X" ]; then
0121     echo "Found ulog, but shouldn't: [$ULOG]"
0122     go_out -1
0123 fi
0124 
0125 #
0126 # Normal process die...
0127 #
0128 echo "Running client / normal die.."
0129 
0130 (./atmiclt74 die 2>&1) > ./atmiclt-dom1.log
0131 
0132 #
0133 # Let ndrxd to zap..
0134 #
0135 sleep 5
0136 
0137 ULOG=`cat ULOG*`
0138 
0139 if [ "X$ULOG" == "X" ]; then
0140     echo "ULOG not found, but should!"
0141     go_out -2
0142 fi
0143 
0144 ################################################################################
0145 # Thread die, as thread race condition might not be found
0146 # as main thread finishes out and only at next scan it sees thread queue
0147 # and that will be treated as process died. Thus cannot depend on race condition
0148 # for tests.
0149 ################################################################################
0150 
0151 if [ "X$manual_mode" == "X1" ]; then
0152     rm ULOG*
0153     echo "Running client / thread die.."
0154 
0155     (./atmiclt74 thread_die 2>&1) > ./atmiclt-dom1.log
0156 
0157     ULOG=`cat ULOG* | grep "unclean shutdown"`
0158 
0159     if [ "X$ULOG" == "X" ]; then
0160         echo "There shall be unclean shutdown of ther thread!"
0161         go_out -3
0162     fi
0163 fi
0164 
0165 ################################################################################
0166 # Main thread die, other threads die too..
0167 # thus here we must see in ndrxd logs that 
0168 ################################################################################
0169 rm ULOG*
0170 
0171 echo "Running client / main thread die..."
0172 
0173 (./atmiclt74 main_die 2>&1) > ./atmiclt-dom1.log
0174 
0175 ULOG=`cat ULOG* | grep "Client process"`
0176 
0177 if [ "X$ULOG" == "X" ]; then
0178     echo "There shall be normal process die...!"
0179     go_out -4
0180 fi
0181 
0182 ULOG=`cat ULOG* | grep "unclean shutdown"`
0183 
0184 if [ "X$ULOG" != "X" ]; then
0185     echo "There shall be no unclean shutdown as main thread died..!"
0186     go_out -5
0187 fi
0188 
0189 NDRXDLOG=`grep "Previous same process" ndrxd-dom1.log`
0190 
0191 if [ "X$NDRXDLOG" == "X" ]; then
0192     echo "Ndrxd shall notify that thread queues are dead too & removed...!"
0193     go_out -6
0194 fi
0195 
0196 sleep 5
0197 
0198 #
0199 # check the queues, all must be unlinked
0200 #
0201 
0202 echo "Queues:"
0203 xadmin pqa -a
0204 
0205 CLTQ=`xadmin pqa -a | grep atmiclt74`
0206 
0207 if [ "X$CLTQ" != "X" ]; then
0208     echo "There must be no client queues left!"
0209     go_out -7
0210 fi
0211 
0212 # Catch is there is test error!!!
0213 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0214     echo "Test error detected!"
0215     go_out -8
0216 fi
0217 
0218 go_out 0
0219 
0220 # vim: set ts=4 sw=4 et smartindent:
0221