Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief @(#) See README. Test second cache db, test service dissapearance after shutdown
0004 ##   have cached results when service is back.
0005 ##
0006 ## @file 02_run.sh
0007 ##
0008 ## -----------------------------------------------------------------------------
0009 ## Enduro/X Middleware Platform for Distributed Transaction Processing
0010 ## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0011 ## Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0012 ## This software is released under one of the following licenses:
0013 ## AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0014 ## See LICENSE file for full text.
0015 ## -----------------------------------------------------------------------------
0016 ## AGPL license:
0017 ##
0018 ## This program is free software; you can redistribute it and/or modify it under
0019 ## the terms of the GNU Affero General Public License, version 3 as published
0020 ## by the Free Software Foundation;
0021 ##
0022 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0023 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0024 ## PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0025 ## for more details.
0026 ##
0027 ## You should have received a copy of the GNU Affero General Public License along 
0028 ## with this program; if not, write to the Free Software Foundation, Inc.,
0029 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0030 ##
0031 ## -----------------------------------------------------------------------------
0032 ## A commercial use license is available from Mavimax, Ltd
0033 ## contact@mavimax.com
0034 ## -----------------------------------------------------------------------------
0035 ##
0036 
0037 export TESTNAME="test048_cache"
0038 
0039 PWD=`pwd`
0040 if [ `echo $PWD | grep $TESTNAME ` ]; then
0041     # Do nothing 
0042     echo > /dev/null
0043 else
0044     # started from parent folder
0045     pushd .
0046     echo "Doing cd"
0047     cd $TESTNAME
0048 fi;
0049 
0050 export NDRX_CCONFIG=`pwd`
0051 . ../testenv.sh
0052 
0053 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0054 export PATH=$PATH:$TESTDIR
0055 export NDRX_TOUT=10
0056 export NDRX_ULOG=$TESTDIR
0057 export TESTDIR_DB=$TESTDIR
0058 export TESTDIR_SHM=$TESTDIR
0059 
0060 source ./test-func-include.sh
0061 
0062 
0063 #
0064 # Domain 1 - here client will live
0065 #
0066 set_dom1() {
0067     echo "Setting domain 1"
0068     . ../dom1.sh
0069     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0070     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0071     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0072     export NDRX_CCTAG=dom1
0073 }
0074 
0075 #
0076 # Generic exit function
0077 #
0078 function go_out {
0079     echo "Test exiting with: $1"
0080     
0081     set_dom1;
0082     xadmin stop -y
0083     xadmin down -y
0084 
0085 
0086 
0087     # If some alive stuff left...
0088     xadmin killall atmiclt48
0089 
0090     popd 2>/dev/null
0091     exit $1
0092 }
0093 
0094 rm *dom*.log
0095 # Any bridges that are live must be killed!
0096 xadmin killall tpbridge
0097 
0098 set_dom1;
0099 xadmin down -y
0100 xadmin start -y || go_out 1
0101 
0102 
0103 
0104 RET=0
0105 
0106 xadmin psc
0107 xadmin ppm
0108 echo "Running off client"
0109 
0110 set_dom1;
0111 
0112 (time ./testtool48 -sTESTSV02 -b '{"T_STRING_FLD":"KEY1","T_FLOAT_FLD":"1.1","T_SHORT_FLD":123,"T_CHAR_FLD":"A"}' \
0113     -m '{"T_STRING_FLD":"KEY1","T_FLOAT_FLD":"1.1","T_SHORT_FLD":123}' \
0114     -cY -n100 -fY 2>&1) > ./02_testtool48.log
0115 
0116 if [ $? -ne 0 ]; then
0117     echo "testtool48 failed (1)"
0118     go_out 1
0119 fi
0120 
0121 (time ./testtool48 -sTESTSV02_2 -b '{"T_STRING_FLD":"KEY4","T_FLOAT_FLD":"1.1","T_SHORT_FLD":123,"T_CHAR_FLD":"A"}' \
0122     -m '{"T_STRING_FLD":"KEY4","T_FLOAT_FLD":"1.1","T_SHORT_FLD":123}' \
0123     -cY -n100 -fY 2>&1) >> ./02_testtool48.log
0124 
0125 if [ $? -ne 0 ]; then
0126     echo "testtool48 failed (1.2)"
0127     go_out 101
0128 fi
0129 
0130 
0131 echo "Show cache... "
0132 
0133 #
0134 # Must be empty
0135 #
0136 xadmin cs -d db02_1
0137 
0138 if [ $? -ne 0 ]; then
0139     echo "xadmin cs failed"
0140     go_out 2
0141 fi
0142 
0143 #
0144 # Must have some 1 record
0145 #
0146 xadmin cs -d db02_2
0147 
0148 if [ $? -ne 0 ]; then
0149     echo "xadmin cs failed"
0150     go_out 2
0151 fi
0152 
0153 ensure_keys db02_2 1
0154 
0155 (time ./testtool48 -sTESTSV02 -b '{"T_STRING_FLD":"KEY2","T_FLOAT_FLD":"1.2","T_SHORT_FLD":44,"T_CHAR_FLD":"B"}' \
0156     -m '{"T_STRING_FLD":"KEY2","T_FLOAT_FLD":"1.2","T_SHORT_FLD":44}' \
0157     -cY -n100 -fY 2>&1) >> ./02_testtool48.log
0158 
0159 
0160 if [ $? -ne 0 ]; then
0161     echo "testtool48 failed (2)"
0162     go_out 3
0163 fi
0164 
0165 #
0166 # Test the message dump for saved fields
0167 #
0168 ensure_field db02_2 SV2KEY2 T_STRING_FLD KEY2 1
0169 ensure_field db02_2 SV2KEY2 T_FLOAT_FLD 1.2 1
0170 ensure_field db02_2 SV2KEY2 T_SHORT_FLD 44 1
0171 ensure_field db02_2 SV2KEY2 T_CHAR_FLD B 0
0172 
0173 #
0174 # Must have some 2 records
0175 #
0176 xadmin cs -d db02_2
0177 
0178 if [ $? -ne 0 ]; then
0179     echo "xadmin cs failed"
0180     go_out 2
0181 fi
0182 
0183 # DB1 is empty
0184 ensure_keys db02_1 1
0185 ensure_keys db02_2 2
0186 
0187 xadmin stop -s atmi.sv48
0188 
0189 #
0190 # Now service call shall fail
0191 #
0192 
0193 (time ./testtool48 -sTESTSV02 -b '{"T_STRING_FLD":"KEY2","T_FLOAT_FLD":"1.3","T_CHAR_FLD":"C"}' \
0194     -cY -n1 -fY -e6 2>&1) >> ./02_testtool48.log
0195 
0196 if [ $? -ne 0 ]; then
0197     echo "Failed to validate tpcall error 6"
0198     go_out 5
0199 fi
0200 
0201 #
0202 # This still responds with cached data
0203 #
0204 (time ./testtool48 -sTESTSV02_2 -b '{"T_STRING_FLD":"KEY4","T_FLOAT_FLD":"1.1","T_SHORT_FLD":123,"T_CHAR_FLD":"A"}' \
0205     -m '{"T_STRING_FLD":"KEY4","T_FLOAT_FLD":"1.1","T_SHORT_FLD":123}' \
0206     -cY -n100 -fN 2>&1) >> ./02_testtool48.log
0207 
0208 if [ $? -ne 0 ]; then
0209     echo "testtool48 failed (5.1)"
0210     go_out 101
0211 
0212 fi
0213 
0214 #
0215 # We shall get error 6 for nosvcok, but no data available...
0216 #
0217 (time ./testtool48 -sTESTSV02 -b '{"T_STRING_FLD":"KEY5","T_FLOAT_FLD":"1.3","T_CHAR_FLD":"C"}' \
0218     -cY -n1 -fY -e6 2>&1) >> ./02_testtool48.log
0219 
0220 if [ $? -ne 0 ]; then
0221     echo "Failed to validate tpcall error 6 (5.2)"
0222     go_out 102
0223 fi
0224 
0225 xadmin start -s atmi.sv48
0226 
0227 
0228 #
0229 # now we shall get cached results...
0230 #
0231 
0232 (time ./testtool48 -sTESTSV02 -b '{"T_STRING_FLD":"KEY1","T_FLOAT_FLD":"1.4","T_CHAR_FLD":"D"}' \
0233     -m '{"T_STRING_FLD":"KEY1","T_FLOAT_FLD":"1.1","T_SHORT_FLD":123}' \
0234     -cY -n100 -fN 2>&1) >> ./02_testtool48.log
0235 
0236 if [ $? -ne 0 ]; then
0237     echo "testtool48 failed (3)"
0238     go_out 6
0239 fi
0240 
0241 
0242 (time ./testtool48 -sTESTSV02 -b '{"T_STRING_FLD":"KEY2","T_FLOAT_FLD":"1.5","T_CHAR_FLD":"E"}' \
0243     -m '{"T_STRING_FLD":"KEY2","T_FLOAT_FLD":"1.2","T_SHORT_FLD":44}' \
0244     -cY -n100 -fN 2>&1) >> ./02_testtool48.log
0245 
0246 if [ $? -ne 0 ]; then
0247     echo "testtool48 failed (4)"
0248     go_out 7
0249 fi
0250 
0251 
0252 go_out $RET
0253 
0254 # vim: set ts=4 sw=4 et smartindent: