Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief Test that XATMI server reload happens only when original is fully shutdown (even if it freezed at shutdown) - 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="test101_dupsrv"
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 export NDRX_SILENT="Y"
0056 
0057 #
0058 # Domain 1 - here client will live
0059 #
0060 set_dom1() {
0061     echo "Setting domain 1"
0062     . ../dom1.sh
0063     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0064     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0065     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0066     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0067 }
0068 
0069 set_dom1_no_respawn() {
0070     echo "Setting domain 1 (no respawn)"
0071     . ../dom1.sh
0072     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1_no_respawn.xml
0073     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0074     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0075     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0076 }
0077 
0078 set_dom1_pingkill() {
0079     echo "Setting domain 1 (pingkill)"
0080     . ../dom1.sh
0081     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1_pingkill.xml
0082     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0083     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0084     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0085 }
0086 
0087 set_dom1_reload() {
0088     echo "Setting domain 1 (reload)"
0089     . ../dom1.sh
0090     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1_reload.xml
0091     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0092     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0093     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0094 }
0095 
0096 #
0097 # Generic exit function
0098 #
0099 function go_out {
0100     echo "Test exiting with: $1"
0101     
0102     set_dom1;
0103     xadmin stop -y
0104     xadmin down -y
0105 
0106     # If some alive stuff left...
0107     xadmin killall atmiclt101
0108 
0109     popd 2>/dev/null
0110     exit $1
0111 }
0112 
0113 # Call the service to lock-up
0114 function run_call {
0115 
0116     (./atmiclt101 2>&1) >> ./atmiclt-dom1.log
0117 
0118     RET=$?
0119 
0120     if [[ "X$RET" != "X0" ]]; then
0121         go_out $RET
0122     fi
0123 }
0124 
0125 PID1=""
0126 PID2=""
0127 
0128 # Ensure that PIDs are not equal
0129 # as process must restarted by Enduor/X
0130 function get_pid_assert_not_equal {
0131 
0132     if [ "X$PID1" == "X$PID2" ]; then
0133         echo "PIDs are equal: [$PID1] == [$PID2]"
0134         go_out -1
0135     fi
0136 }
0137 
0138 function get_pid_assert_equal {
0139 
0140     if [ "X$PID1" != "X$PID2" ]; then
0141         echo "PIDs are not equal: [$PID1] == [$PID2]"
0142         go_out -1
0143     fi
0144 }
0145 
0146 function get_pid_before {
0147     $PSCMD | grep atmi.sv101 | grep -v grep
0148     PID1=`xadmin ps -a atmi.sv101 | awk '{print $2}'`
0149 }
0150 
0151 function get_pid_after {
0152     $PSCMD | grep atmi.sv101 | grep -v grep
0153     PID2=`xadmin ps -a atmi.sv101 | awk '{print $2}'`
0154     xadmin ppm
0155     get_pid_assert_not_equal;
0156 }
0157 
0158 function get_pid_after_eq {
0159     $PSCMD | grep atmi.sv101 | grep -v grep
0160     PID2=`xadmin ps -a atmi.sv101 | awk '{print $2}'`
0161     get_pid_assert_equal;
0162 }
0163 
0164 rm *.log 2>/dev/null
0165 rm ULOG* 2>/dev/null
0166 # Any bridges that are live must be killed!
0167 xadmin killall tpbridge
0168 
0169 set_dom1;
0170 xadmin down -y
0171 
0172 # check config not loaded case for Support #448
0173 # really small check, no need for new atmitest, add here:
0174 
0175 NO_CONFIG_LOADED=`xadmin sreload atmi.sv101 2>&1`
0176 
0177 if [[ "$NO_CONFIG_LOADED" == "fail, code: 25: NDRXD_ENOCFGLD (last error 25: No configuration loaded!)" ]]; then
0178     echo "Invalid error message in case if configuration not loaded and doing reload."
0179     go_out -1
0180 fi
0181 
0182 xadmin start -y || go_out 1
0183 
0184 RET=0
0185 xadmin psc
0186 xadmin ppm
0187 
0188 for i in 0 1
0189 do
0190 
0191     if [ "$i" == "0" ]; then
0192         echo ">>> Testing with respawn enabled"
0193         #set_dom1; already in this mode
0194     else
0195         echo ">>> Testing with respawn disabled"
0196         set_dom1_no_respawn;
0197         xadmin start -y
0198     fi
0199 
0200     ################################################################################
0201     echo ">>>> xadmin sreload"
0202     ################################################################################
0203     get_pid_before;
0204 
0205     run_call;
0206     xadmin sreload atmi.sv101
0207     xadmin ppm
0208     sleep 30
0209 
0210     get_pid_after;
0211 
0212     CNT=`xadmin ps -a atmi.sv101 | wc | awk '{print($1)}'`
0213     # there shall be no duplicate servers...
0214     if [ "X$CNT" != "X1"  ]; then
0215         echo "Number of atmi.sv101 processes present: $CNT but must be 1"
0216         go_out -1
0217     fi
0218 
0219     ################################################################################
0220     echo ">>>> Reload On Change"
0221     ################################################################################
0222     get_pid_before;
0223     touch atmi.sv101
0224     sleep 20
0225 
0226     get_pid_after;
0227 
0228     CNT=`xadmin ps -a atmi.sv101 | wc | awk '{print($1)}'`
0229     # there shall be no duplicate servers...
0230     if [ "X$CNT" != "X1"  ]; then
0231         echo "Number of atmi.sv101 processes present: $CNT but must be 1"
0232         go_out -1
0233     fi
0234 
0235     ################################################################################
0236     echo ">>>> xadmin stop + start"
0237     ################################################################################
0238 
0239     get_pid_before;
0240 
0241     run_call;
0242     xadmin stop -s atmi.sv101
0243     xadmin start -s atmi.sv101
0244     sleep 30
0245 
0246     get_pid_after;
0247 
0248     CNT=`xadmin ps -a atmi.sv101 | wc | awk '{print($1)}'`
0249     # there shall be no duplicate servers...
0250     if [ "X$CNT" != "X1"  ]; then
0251         echo "Number of atmi.sv101 processes present: $CNT but must be 1"
0252         go_out -1
0253     fi
0254 
0255     ################################################################################
0256     echo ">>>> xadmin restart"
0257     ################################################################################
0258 
0259     get_pid_before;
0260 
0261     run_call;
0262     xadmin restart -s atmi.sv101
0263     sleep 30
0264 
0265     get_pid_after;
0266 
0267     CNT=`xadmin ps -a atmi.sv101 | wc | awk '{print($1)}'`
0268     # there shall be no duplicate servers...
0269     if [ "X$CNT" != "X1"  ]; then
0270         echo "Number of atmi.sv101 processes present: $CNT but must be 1"
0271         go_out -1
0272     fi
0273 
0274     ################################################################################
0275     echo ">>>> xadmin full shutdown (ensure no process left)"
0276     ################################################################################
0277     run_call;
0278     xadmin stop -y
0279 
0280     CNT=`xadmin ps -a atmi.sv101 | wc | awk '{print($1)}'`
0281     # there shall be no duplicate servers...
0282     if [ "X$CNT" != "X0"  ]; then
0283         echo "Number of atmi.sv101 processes present: $CNT but must be 0"
0284         go_out -1
0285     fi
0286 
0287 done
0288 
0289 ################################################################################
0290 echo ">>> Ensure that ping with respawn off does not boot server back..."
0291 ################################################################################
0292 set_dom1_pingkill;
0293 xadmin start -y
0294 run_call;
0295 sleep 15
0296 
0297 CNT=`xadmin ps -a atmi.sv101 | wc | awk '{print($1)}'`
0298 # there shall be no duplicate servers...
0299 if [ "X$CNT" != "X0"  ]; then
0300     echo "Number of atmi.sv101 processes present: $CNT but must be 0"
0301     go_out -1
0302 fi
0303 xadmin stop -y
0304 
0305 ################################################################################
0306 echo ">>> ROC - Reload only started copies (Bug #202)"
0307 ################################################################################
0308 
0309 set_dom1_reload;
0310 xadmin start -y
0311 
0312 get_pid_before;
0313 touch atmi.sv101
0314 sleep 20
0315 get_pid_after;
0316 
0317 CNT=`xadmin ps -a atmi.sv101 | wc | awk '{print($1)}'`
0318 # there shall be no duplicate servers...
0319 if [ "X$CNT" != "X3"  ]; then
0320     echo "Number of atmi.sv101 processes present: $CNT but must be 3"
0321     go_out -1
0322 fi
0323 
0324 ################################################################################
0325 echo ">>> sreload - Reload only started copies (Bug #202)"
0326 ################################################################################
0327 
0328 set_dom1_reload;
0329 xadmin start -y
0330 
0331 get_pid_before;
0332 xadmin sreload atmi.sv101
0333 get_pid_after;
0334 
0335 CNT=`xadmin ps -a atmi.sv101 | wc | awk '{print($1)}'`
0336 # there shall be no duplicate servers...
0337 if [ "X$CNT" != "X3"  ]; then
0338     echo "Number of atmi.sv101 processes present: $CNT but must be 3"
0339     go_out -1
0340 fi
0341 
0342 ################################################################################
0343 echo ">>> sreload by instances..."
0344 ################################################################################
0345 
0346 xadmin stop -s atmi.sv101
0347 xadmin start -i 17
0348 xadmin start -i 18
0349 xadmin start -i 19
0350 
0351 # Ensure that first instances are not reload as marked as not started
0352 get_pid_before
0353 xadmin sreload -i 10
0354 # i.e. pid not changed
0355 get_pid_after_eq
0356 
0357 get_pid_before
0358 xadmin sreload -i 11
0359 get_pid_after_eq
0360 
0361 # Ensure that each reloads and pid changes
0362 get_pid_before
0363 xadmin sreload -i 17
0364 get_pid_after
0365 
0366 get_pid_before
0367 xadmin sreload -i 18
0368 get_pid_after
0369 
0370 get_pid_before
0371 xadmin sreload -i 19
0372 get_pid_after
0373 
0374 CNT=`xadmin ps -a atmi.sv101 | wc | awk '{print($1)}'`
0375 # there shall be no duplicate servers...
0376 if [ "X$CNT" != "X3"  ]; then
0377     echo "Number of atmi.sv101 processes present: $CNT but must be 3"
0378     go_out -1
0379 fi
0380 
0381 # Catch is there is test error!!!
0382 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0383     echo "Test error detected!"
0384     RET=-2
0385 fi
0386 
0387 go_out $RET
0388 
0389 
0390 # vim: set ts=4 sw=4 et smartindent:
0391