Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief @(#) Bug #236 - two pass config (global section reference to global) and process cfg reload - 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="test046_twopasscfg"
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=10
0054 
0055 # We will make some tests with config
0056 export NDRX_CCONFIG=$TESTDIR
0057 export NDRX_CCTAG="2/A"
0058 
0059 #
0060 # Domain 1 - here client will live
0061 #
0062 set_dom1() {
0063     echo "Setting domain 1"
0064     . ../dom1.sh
0065     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0066     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0067     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0068     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0069 }
0070 
0071 
0072 #
0073 # Generic exit function
0074 #
0075 function go_out {
0076     echo "Test exiting with: $1"
0077     
0078     set_dom1;
0079     xadmin stop -y
0080     xadmin down -y
0081 
0082     # If some alive stuff left...
0083     xadmin killall atmiclt46
0084 
0085     popd 2>/dev/null
0086     exit $1
0087 }
0088 
0089 set_dom1;
0090 
0091 rm *.log
0092 
0093 # Any bridges that are live must be killed!
0094 xadmin killall tpbridge
0095 xadmin down -y
0096 
0097 
0098 #
0099 # Make some configuration...
0100 # So basically if we resolve by xadmin pe or by process then variables shall
0101 # be fully resolved
0102 #
0103 
0104 echo "[@global]" > $NDRX_CCONFIG/app.ini
0105 echo "VTEST1=HELLO" >> $NDRX_CCONFIG/app.ini
0106 
0107 #
0108 # There should be this log open because [@debug] also can reference globals
0109 #
0110 echo "TEST_DEBUG_F=common.log" >> $NDRX_CCONFIG/app.ini
0111 #
0112 # This shall be resolved as "HELLO WORLD"
0113 #
0114 echo 'VTEST2=${VTEST1} WORLD' >> $NDRX_CCONFIG/app.ini
0115 #
0116 # This shall be resolved as "Enduro/X is middleware"
0117 #
0118 echo 'VTEST3=Enduro/X is ${VTEST4}' >> $NDRX_CCONFIG/app.ini
0119 
0120 echo "[@global/1]" >> $NDRX_CCONFIG/app.ini
0121 echo "VTEST4=app server" >> $NDRX_CCONFIG/app.ini
0122 
0123 echo "[@global/2]" >> $NDRX_CCONFIG/app.ini
0124 echo "VTEST4=middleware" >> $NDRX_CCONFIG/app.ini
0125 
0126 xadmin start -y || go_out 1
0127 
0128 #
0129 # Test the variables
0130 #
0131 
0132 xadmin pe
0133 
0134 VTEST2=`xadmin pe | grep VTEST2`
0135 
0136 echo "echo got VTEST2=[$VTEST2]"
0137 
0138 if [ "X$VTEST2" != "XVTEST2=HELLO WORLD" ]; then
0139     echo "Expected [VTEST2=HELLO WORLD] but got [$VTEST2]"
0140     go_out -1
0141 fi
0142 
0143 
0144 VTEST3=`xadmin pe | grep VTEST3`
0145 
0146 echo "echo got VTEST3=[$VTEST3]"
0147 
0148 if [ "X$VTEST3" != "XVTEST3=Enduro/X is middleware" ]; then
0149     echo "Expected [VTEST3=Enduro/X is middleware] but got [$VTEST3]"
0150     go_out -2
0151 fi
0152 
0153 
0154 #
0155 # Test what variables sees ATMI46 server
0156 #
0157 
0158 SVCOUT=`cat << EOF | ud | grep T_STRING_FLD | cut -f2
0159 SRVCNM  TESTSV
0160 EOF
0161 `
0162 
0163 echo "Service out: [$SVCOUT]"
0164 
0165 if [ "X$SVCOUT" !=  "XEnduro/X is middleware" ]; then
0166     echo "Invalid output from service: [$SVCOUT]"
0167     go_out  -3
0168 fi
0169 
0170 echo "Update config and check that we have new value"
0171 
0172 
0173 echo "[@global/A]" >> $NDRX_CCONFIG/app.ini
0174 echo "VTEST3=this is changed" >> $NDRX_CCONFIG/app.ini
0175 
0176 xadmin sr -s atmi.sv46
0177 
0178 #
0179 # Update config global section
0180 # and check what server sees now. The values must be changed..
0181 #
0182 
0183 SVCOUT=`cat << EOF | ud | grep T_STRING_FLD | cut -f2
0184 SRVCNM  TESTSV
0185 EOF
0186 `
0187 
0188 echo "Service out: [$SVCOUT]"
0189 
0190 if [ "X$SVCOUT" !=  "Xthis is changed" ]; then
0191     echo "Invalid output from service: [$SVCOUT]"
0192     go_out  -4
0193 fi
0194 
0195 RET=0
0196 
0197 if [[ "X$RET" != "X0" ]]; then
0198     go_out $RET
0199 fi
0200 
0201 # Catch is there is test error!!!
0202 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0203         echo "Test error detected!"
0204         RET=-2
0205 fi
0206 
0207 
0208 go_out $RET
0209 
0210 # vim: set ts=4 sw=4 et smartindent: