Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief @(#) Test012, Test semaphore for startup, so that if process is killed other processes can continue to work!
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 # So plan is following:
0037 # 1. we start auto deadly process with xadmin start -y
0038 # 2. we kill deadly process  & wait for background ndrxd will respawn it.
0039 # 3. we start manually good process inbackground - now it cannot compelete the init, because bad process have semaphore
0040 # 4. we test that OK service is not advertised
0041 # 5. we kill the bad service, system releases sempahore, good process gets advertised & we test that
0042 # .... this is the test ....
0043 #
0044 
0045 
0046 export TESTNO="012"
0047 export TESTNAME_SHORT="admqfull"
0048 export TESTNAME="test${TESTNO}_${TESTNAME_SHORT}"
0049 
0050 PWD=`pwd`
0051 if [ `echo $PWD | grep $TESTNAME ` ]; then
0052         # Do nothing 
0053         echo > /dev/null
0054 else
0055         # started from parent folder
0056         pushd .
0057         echo "Doing cd"
0058         cd $TESTNAME
0059 fi;
0060 
0061 . ../testenv.sh
0062 
0063 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0064 export PATH=$PATH:$TESTDIR
0065 # Configure the runtime - override stuff here!
0066 export NDRX_CONFIG=$TESTDIR/ndrxconfig.xml
0067 export NDRX_DMNLOG=$TESTDIR/ndrxd.log
0068 export NDRX_LOG=$TESTDIR/ndrx.log
0069 export NDRX_DEBUG_CONF=$TESTDIR/debug.conf
0070 # Override timeout!
0071 export NDRX_TOUT=4
0072 export NDRX_MSGMAX=50
0073 export NDRX_DQMAX=50
0074 # For system-v store all qids
0075 export NDRX_SVCMAX=30
0076 export NDRX_MAXSVCSRVS=600
0077 
0078 
0079 # Default process count for Q full tests
0080 export TEST_PROCS=400
0081 
0082 # OSX hangs at 500 procs running, thus reduce test to 200
0083 if [ "$(uname)" == "Darwin" ]; then
0084     export TEST_PROCS=200
0085 fi
0086 
0087 echo "Running tests with: $TEST_PROCS processes...."
0088 ##################################
0089 
0090 #
0091 # Generic exit function
0092 #
0093 function go_out {
0094     echo "Test exiting with: $1"
0095     xadmin killall sleep
0096 # Might cause respawn for that one process...
0097     xadmin stop -y
0098     xadmin down -y
0099 
0100     popd 2>/dev/null
0101     exit $1
0102 }
0103 
0104 ###################################
0105 # Time-out processing.
0106 ###################################
0107 #Time to wait for stuck processes before killing them                           
0108 export ALARMTIME=900
0109 
0110 PARENTPID=$$
0111 
0112 exit_timeout() {
0113     echo "Alarm signal received - TEST FAILED!"
0114     go_out 128
0115 
0116 }
0117 
0118 #Prepare to catch SIGALRM, call exit_timeout
0119 trap exit_timeout SIGALRM
0120 (sleep $ALARMTIME && kill -ALRM $PARENTPID) &
0121 ##################################
0122 
0123 rm *.log
0124 
0125 xadmin killall atmisv
0126 xadmin killall ndrxd
0127 xadmin down -y
0128 xadmin start -y
0129 # Why?
0130 #xadmin start -y &
0131 
0132 #### WHY?
0133 # Enter the both servers in respawn state
0134 # sleep 30
0135 #####
0136 
0137 # ALARM: THIS SHOULD NOT HANG!
0138 $PSCMD | grep atmisv_012 | grep -v grep
0139 xadmin ppm
0140 xadmin psc
0141 CNT=`xadmin psc | wc | awk '{print $1}'`
0142 echo "Process count: $CNT"
0143 if [[ $CNT -ne $TEST_PROCS ]]; then
0144         echo "Service count != $TEST_PROCS! (1)"
0145         go_out 1        
0146 fi
0147 # Count should be around 1K
0148 echo 
0149 echo "Before running kill -9"
0150 date
0151 xadmin psc
0152 
0153 xadmin killall atmisv_$TESTNO
0154 
0155 echo "After runing kill -9"
0156 date
0157 xadmin psc
0158 
0159 # Wait for respawn, now it should be respawned...
0160 sleep 100
0161 
0162 echo "After sleeping of kill -9"
0163 date
0164 xadmin psc
0165 xadmin ppm
0166 xadmin svmaps
0167 xadmin svmaps -s
0168 
0169 # This should raise the fail!
0170 # sleep 30
0171 # ALARM: THIS SHOULD NOT HANG & should be all servers booted.
0172 CNT=`xadmin psc | wc | awk '{print $1}'`
0173 echo "Process count: $CNT"
0174 if [[ $CNT -ne $TEST_PROCS ]]; then
0175         echo "Service count != 500! (2)"
0176         go_out 2
0177 fi
0178 # Count should be around 1K
0179 
0180 go_out 0
0181 
0182 # vim: set ts=4 sw=4 et smartindent: