Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief @(#) Test013, Test process auto restart at no response (long startup, no ping rsp, or long shutdown)
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 TESTNO="013"
0037 export TESTNAME_SHORT="procnorsp"
0038 export TESTNAME="test${TESTNO}_${TESTNAME_SHORT}"
0039 
0040 PWD=`pwd`
0041 if [ `echo $PWD | grep $TESTNAME ` ]; then
0042         # Do nothing 
0043         echo > /dev/null
0044 else
0045         # started from parent folder
0046         pushd .
0047         echo "Doing cd"
0048         cd $TESTNAME
0049 fi;
0050 
0051 . ../testenv.sh
0052 
0053 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0054 export PATH=$PATH:$TESTDIR
0055 # Configure the runtime - override stuff here!
0056 export NDRX_CONFIG=$TESTDIR/ndrxconfig.xml
0057 export NDRX_DMNLOG=$TESTDIR/ndrxd.log
0058 export NDRX_LOG=$TESTDIR/ndrx.log
0059 export NDRX_DEBUG_CONF=$TESTDIR/debug.conf
0060 # Override timeout!
0061 export NDRX_TOUT=4
0062 export NDRX_CMDWAIT=1
0063 
0064 #
0065 # Generic exit function
0066 #
0067 function go_out {
0068     echo "Test exiting with: $1"
0069     xadmin stop -y
0070     xadmin down -y
0071 
0072     popd 2>/dev/null
0073     exit $1
0074 }
0075 
0076 rm *.log
0077 
0078 # Run some extra cleanup
0079 xadmin down -y
0080 xadmin killall ndrxd
0081 xadmin down -y
0082 
0083 # Will do stall servers
0084 echo 1 > $TESTDIR/case_type
0085 
0086 # No ping
0087 xadmin start -i 126 || go_out 1
0088 # Long stop
0089 xadmin start -i 127 || go_out 1
0090 # Will run in background, long start
0091 xadmin start -i 125 &
0092 sleep 2
0093 #tail -n200 ndrxd.log
0094 
0095 #### Capture current PIDs of all 3x processes #####
0096 LONG_START_PID=""
0097 LONG_START_PID=`$PSCMD | grep "\-i 125" | grep -v grep | awk '{print $2}'`;
0098 echo "long_start pid: $LONG_START_PID"
0099 
0100 NO_PING_PROCESS_PID=""
0101 NO_PING_PROCESS_PID=`$PSCMD | grep "\-i 126" | grep -v grep | awk '{print $2}'`;
0102 echo "no_ping_process pid: $NO_PING_PROCESS_PID"
0103 
0104 LONG_STOP_PID=""
0105 LONG_STOP_PID=`$PSCMD | grep "\-i 127" | grep -v grep | awk '{print $2}'`;
0106 echo "long_stop pid: $LONG_STOP_PID"
0107 sleep 2
0108 
0109 # No server stalling
0110 echo 2 > $TESTDIR/case_type
0111 
0112 # will stop the process so that PING will hang
0113 kill -9 $NO_PING_PROCESS_PID
0114 xadmin stop -i 127 &
0115 
0116 #### Sleep some 10 sec
0117 sleep 20
0118 $PSCMD | grep atmi
0119 #### All those processes now should be restarted, so get new PIDs
0120 LONG_START_PID2=""
0121 LONG_START_PID2=`$PSCMD | grep "\-i 125" | grep -v grep |awk '{print $2}'`;
0122 echo "long_start pid2: $LONG_START_PID2"
0123 
0124 NO_PING_PROCESS_PID2=""
0125 NO_PING_PROCESS_PID2=`$PSCMD | grep "\-i 126" | grep -v grep | awk '{print $2}'`;
0126 
0127 echo "no_ping_process pid2: $NO_PING_PROCESS_PID2"
0128 LONG_STOP_PID2=""
0129 LONG_STOP_PID2=`$PSCMD | grep "\-i 127" | grep -v grep | awk '{print $2}'`;
0130 echo "long_stop pid2: $LONG_STOP_PID2"
0131 
0132 
0133 #
0134 # Test long start
0135 #
0136 if [ "X$LONG_START_PID2" == "X$LONG_START_PID" ]; then
0137     echo "long start probl: old PID: $LONG_START_PID new PID: $LONG_START_PID2"
0138     go_out 1
0139 fi
0140 
0141 if [ "X$LONG_START_PID2" == "X" ]; then
0142     echo "long start probl: process not re-spawned!!!"
0143     go_out 2
0144 fi
0145 
0146 #
0147 # Test ping...
0148 #
0149 if [ "X$NO_PING_PROCESS_PID2" == "X$NO_PING_PROCESS_PID" ]; then
0150     echo "no_ping_process probl: old PID: $NO_PING_PROCESS_PID new PID: $NO_PING_PROCESS_PID2"
0151     go_out 3
0152 fi
0153 
0154 if [ "X$NO_PING_PROCESS_PID2" == "X" ]; then
0155     echo "no_ping_process probl: process not re-spawned!!!"
0156     go_out 4
0157 fi
0158 
0159 #
0160 # Test long shutdown
0161 #
0162 if [ "X$LONG_STOP_PID2" == "X$LONG_STOP_PID" ]; then
0163     echo "long stop probl: old PID: $LONG_STOP_PID new PID: $LONG_STOP_PID2"
0164     go_out 5
0165 fi
0166 
0167 # It was requested to shutdown, so should not be re-started!
0168 if [ "X$LONG_STOP_PID2" != "X" ]; then
0169     echo "long stop probl: process not re-spawned!!!"
0170     go_out 6
0171 fi
0172 
0173 # Print process model
0174 xadmin ppm
0175 
0176 # Catch is there is test error!!!
0177 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0178         echo "Test error detected!"
0179         go_out 100
0180 fi
0181 
0182 go_out 0
0183 
0184 # vim: set ts=4 sw=4 et smartindent: