Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief @(#) Test089 - tmrecover testing
0004 ##
0005 ## @file run-dom.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="089"
0037 export TESTNAME_SHORT="tmrecover"
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 # Override timeout!
0056 export NDRX_TOUT=90
0057 export NDRX_LIBEXT="so"
0058 export NDRX_ULOG=$TESTDIR
0059 export NDRX_SILENT=Y
0060 
0061 #
0062 # Domain 1 - here client will live
0063 #
0064 function set_dom1 {
0065     echo "Setting domain 1"
0066     . ../dom1.sh
0067     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0068     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0069     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0070     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0071 
0072 # XA config, mandatory for TMQ:
0073     export NDRX_XA_RES_ID=1
0074     export NDRX_XA_OPEN_STR="datadir=./QSPACE1,qspace=MYSPACE"
0075     export NDRX_XA_CLOSE_STR=$NDRX_XA_OPEN_STR
0076 # Used from parent
0077     export NDRX_XA_DRIVERLIB=$NDRX_XA_DRIVERLIB_FILENAME
0078 
0079     export NDRX_XA_RMLIB=libndrxxaqdisk.so
0080 if [ "$(uname)" == "Darwin" ]; then
0081     export NDRX_XA_RMLIB=libndrxxaqdisk.dylib
0082     export NDRX_LIBEXT="dylib"
0083 fi
0084     export NDRX_XA_LAZY_INIT=0
0085 }
0086 
0087 #
0088 # Domain 3 - here client will live
0089 #
0090 function set_dom2 {
0091     echo "Setting domain 2"
0092     . ../dom2.sh
0093     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom2.xml
0094     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom2.log
0095     export NDRX_LOG=$TESTDIR/ndrx-dom2.log
0096     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom2.conf
0097 
0098 # XA config, mandatory for TMQ:
0099     export NDRX_XA_RES_ID=2
0100     export NDRX_XA_OPEN_STR="datadir=./QSPACE2,qspace=MYSPACE"
0101     export NDRX_XA_CLOSE_STR=$NDRX_XA_OPEN_STR
0102 # Used from parent
0103     export NDRX_XA_DRIVERLIB=$NDRX_XA_DRIVERLIB_FILENAME
0104 
0105     export NDRX_XA_RMLIB=libndrxxaqdisk.so
0106 if [ "$(uname)" == "Darwin" ]; then
0107     export NDRX_XA_RMLIB=libndrxxaqdisk.dylib
0108     export NDRX_LIBEXT="dylib"
0109 fi
0110     export NDRX_XA_LAZY_INIT=0
0111 }
0112 
0113 #
0114 # Generic exit function
0115 #
0116 function go_out {
0117     echo "Test exiting with: $1"
0118     
0119     set_dom1;
0120     xadmin stop -y
0121     xadmin down -y
0122 
0123     set_dom2;
0124     xadmin stop -y
0125     xadmin down -y
0126 
0127     popd 2>/dev/null
0128     exit $1
0129 }
0130 
0131 function clean_logs {
0132 
0133     # clean-up the logs for debbuging at the error.
0134     for f in `ls *.log`; do
0135         echo > $f
0136     done
0137 
0138 }
0139 
0140 UNAME=`uname`
0141 
0142 # Where to store TM logs
0143 rm -rf ./RM1
0144 mkdir RM1
0145 
0146 rm -rf ./RM2
0147 mkdir RM2
0148 
0149 # Where to store Q messages (QSPACE1)
0150 rm -rf ./QSPACE1
0151 mkdir QSPACE1
0152 
0153 rm -rf ./QSPACE2
0154 mkdir QSPACE2
0155 
0156 set_dom1;
0157 xadmin start -y || go_out 1
0158 
0159 set_dom2;
0160 xadmin start -y || go_out 2
0161 
0162 
0163 ################################################################################
0164 echo "Testing RAW CLI transaction recovery...."
0165 ################################################################################
0166 set_dom1;
0167 
0168 echo "Wait for connection..."
0169 sleep 10
0170 
0171 # Run the client test...
0172 xadmin psc
0173 xadmin psvc
0174 xadmin ppm
0175 clean_logs;
0176 rm ULOG*
0177 
0178 echo "load 1100 msgs..."
0179 exbenchcl -n1 -P -t1000 -b "{}" -f EX_DATA -S1024 -QMYSPACE -sTEST1 -E -R1100 || go_out 3
0180 echo "Move to prepared..."
0181 
0182 # get the transaction names (so that we do not have to generate ones...)
0183 # get the base names of the transactions, with out the number
0184 trans=0
0185 grep 'Writing command fil' *.log | cut -d '[' -f2 | cut -d ']' -f1 | cut -d '/' -f 4 | cut -d '-' -f 1 | while read -r line ; do
0186 
0187     # seq 1
0188     MSG_FILE=`ls -1 QSPACE1/committed | tail -1`
0189     echo "Injecting transaction: [mv QSPACE1/committed/$MSG_FILE QSPACE1/prepared/${line}-001]"
0190     mv QSPACE1/committed/$MSG_FILE QSPACE1/prepared/${line}-001 || go_out 4
0191 
0192     # seq 2
0193     MSG_FILE=`ls -1 QSPACE1/committed | tail -1`
0194     echo "Injecting transaction: [mv QSPACE1/committed/$MSG_FILE QSPACE1/prepared/${line}-002]"
0195     mv QSPACE1/committed/$MSG_FILE QSPACE1/prepared/${line}-002 || go_out 5
0196 
0197     trans=$((trans+1))
0198     # done with 550 * 2 transactions, transaction identifiers are half used, but no problem
0199     if [[ $trans -ge 550 ]]; then
0200         break;
0201     fi
0202 
0203 done
0204 
0205 # re-read the messages
0206 xadmin sreload tmqueue
0207 
0208 # test remove recover...
0209 set_dom2;
0210 
0211 echo "Recovering..."
0212 xadmin recoverlocal 2>/dev/null
0213 CNT=`xadmin recoverlocal | wc | awk '{print $1}'`
0214 
0215 echo "Got txns: $CNT"
0216 if [[ "X$CNT" != "X550" ]]; then
0217     echo "Expecting X550, got X$CNT"
0218     go_out 6
0219 fi
0220 
0221 echo "Aborting..."
0222 # count number aborted... (lines actually)
0223 CNT=`xadmin abortlocal -y | wc | awk '{print $1}'`
0224 
0225 echo "Got processed recs: $CNT"
0226 if [[ "X$CNT" != "X1100" ]]; then
0227     echo "Expecting X110, got X$CNT (abortlocal processing)"
0228     go_out 6
0229 fi
0230 
0231 # all must be aborted...
0232 echo "Check..."
0233 CNT=`xadmin recoverlocal | wc | awk '{print $1}'`
0234 echo "Got txns: $CNT"
0235 if [[ "X$CNT" != "X0" ]]; then
0236     echo "Expecting X0, got X$CNT"
0237     go_out 7
0238 fi
0239 
0240 ################################################################################
0241 echo "Testing automatic background transaction recovery..."
0242 ################################################################################
0243 set_dom1;
0244 clean_logs;
0245 
0246 echo "load 100 msgs... DOM1"
0247 exbenchcl -n1 -P -t1000 -b "{}" -f EX_DATA -S1024 -QMYSPACE -sTEST1 -E -R100 || go_out 3
0248 echo "Move to prepared..."
0249 
0250 # get the transaction names (so that we do not have to generate ones...)
0251 # get the base names of the transactions, with out the number
0252 trans=0
0253 grep 'Writing command fil' *dom1*.log | cut -d '[' -f2 | cut -d ']' -f1 | cut -d '/' -f 4 | cut -d '-' -f 1 | while read -r line ; do
0254 
0255     # seq 1
0256     MSG_FILE=`ls -1 QSPACE1/committed | tail -1`
0257     echo "Injecting transaction: [mv QSPACE1/committed/$MSG_FILE QSPACE1/prepared/${line}-001]"
0258     mv QSPACE1/committed/$MSG_FILE QSPACE1/prepared/${line}-001 || go_out 4
0259 
0260     # seq 2
0261     MSG_FILE=`ls -1 QSPACE1/committed | tail -1`
0262     echo "Injecting transaction: [mv QSPACE1/committed/$MSG_FILE QSPACE1/prepared/${line}-002]"
0263     mv QSPACE1/committed/$MSG_FILE QSPACE1/prepared/${line}-002 || go_out 5
0264 
0265     trans=$((trans+1))
0266 
0267     # done with 50 * 2 transactions, transaction identifiers are half used, but no problem
0268     if [[ $trans -ge 50 ]]; then
0269         break;
0270     fi
0271 
0272 done
0273 
0274 # re-read the messages...
0275 xadmin sreload tmqueue
0276 
0277 echo "Checking..."
0278 xadmin recoverlocal 2>/dev/null
0279 CNT=`xadmin recoverlocal | wc | awk '{print $1}'`
0280 
0281 echo "Got txns: $CNT"
0282 if [[ "X$CNT" != "X50" ]]; then
0283     echo "Expecting X50, got X$CNT"
0284     go_out 9
0285 fi
0286 
0287 echo "load 200 msgs... DOM2"
0288 # test remove recover...
0289 set_dom2;
0290 exbenchcl -n1 -P -t1000 -b "{}" -f EX_DATA -S1024 -QMYSPACE -sTEST1 -E -R200 || go_out 10
0291 
0292 echo "Move to prepared..."
0293 # get the transaction names (so that we do not have to generate ones...)
0294 # get the base names of the transactions, with out the number
0295 trans=0
0296 grep 'Writing command fil' *dom2*.log | cut -d '[' -f2 | cut -d ']' -f1 | cut -d '/' -f 4 | cut -d '-' -f 1 | while read -r line ; do
0297 
0298     # seq 1
0299     MSG_FILE=`ls -1 QSPACE2/committed | tail -1`
0300     echo "Injecting transaction: [mv QSPACE2/committed/$MSG_FILE QSPACE2/prepared/${line}-001]"
0301     mv QSPACE2/committed/$MSG_FILE QSPACE2/prepared/${line}-001 || go_out 4
0302 
0303     # seq 2
0304     MSG_FILE=`ls -1 QSPACE2/committed | tail -1`
0305     echo "Injecting transaction: [mv QSPACE2/committed/$MSG_FILE QSPACE2/prepared/${line}-002]"
0306     mv QSPACE2/committed/$MSG_FILE QSPACE2/prepared/${line}-002 || go_out 5
0307 
0308     trans=$((trans+1))
0309 
0310     # done with 200 * 2 transactions, transaction identifiers are half used, but no problem
0311     if [[ $trans -ge 100 ]]; then
0312         break;
0313     fi
0314 
0315 done
0316 
0317 # re-read the messages...
0318 xadmin sreload tmqueue
0319 
0320 echo "Checking..."
0321 xadmin recoverlocal 2>/dev/null
0322 CNT=`xadmin recoverlocal | wc | awk '{print $1}'`
0323 
0324 echo "Got txns: $CNT"
0325 if [[ "X$CNT" != "X150" ]]; then
0326     echo "Expecting X150, got X$CNT"
0327     go_out 13
0328 fi
0329 
0330 # start the recovery from dom1
0331 set_dom1;
0332 
0333 xadmin start -i 8888 || go_out 14
0334 
0335 echo "Std queue test.... (shall complete OK)"
0336 exbenchcl -n2 -P -t60 -b "{}" -f EX_DATA -S1024 -QMYSPACE -sTEST2 || go_out 15
0337 
0338 sleep 40
0339 # after the 60 sec, the tmrecoversv at 8888 must have completed all rollbacks...
0340 
0341 if [ "$(ls -A QSPACE1/prepared)" ]; then
0342     echo "Take action QSPACE1/prepared is not Empty"
0343     ls -l QSPACE1/prepared
0344     go_out 16
0345 fi
0346 
0347 if [ "$(ls -A QSPACE2/prepared)" ]; then
0348     echo "Take action QSPACE2/prepared is not Empty"
0349     ls -l QSPACE2/prepared
0350     go_out 17
0351 fi
0352 
0353 
0354 echo "Checking..."
0355 xadmin recoverlocal 2>/dev/null
0356 CNT=`xadmin recoverlocal | wc | awk '{print $1}'`
0357 
0358 echo "Got txns: $CNT"
0359 if [[ "X$CNT" != "X0" ]]; then
0360     echo "Expecting X0, got X$CNT"
0361     go_out 18
0362 fi
0363 
0364 echo "All ok"
0365 go_out 0
0366 
0367 # vim: set ts=4 sw=4 et smartindent: