0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 export TESTNAME="test067_postgres"
0039
0040 PWD=`pwd`
0041 if [ `echo $PWD | grep $TESTNAME ` ]; then
0042
0043 echo > /dev/null
0044 else
0045
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 export NDRX_TOUT=55
0056 export NDRX_LIBEXT="so"
0057
0058 if [ "$(uname)" == "Darwin" ]; then
0059 export NDRX_XA_RMLIB=libndrxxaqdisk.dylib
0060 export NDRX_LIBEXT="dylib"
0061 fi
0062
0063 if [ "$(uname)" == "AIX" ]; then
0064 export LIBPATH=$LIBPATH:$EX_PG_LIBPATH
0065 fi
0066
0067
0068
0069
0070 set_dom1() {
0071 echo "Setting domain 1"
0072 . ../dom1.sh
0073 export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0074 export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0075 export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0076 export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0077
0078
0079 export NDRX_XA_RES_ID=1
0080
0081 if [ -f atmisv67.c ]; then
0082 echo "ecpg mode"
0083 export NDRX_XA_OPEN_STR="{ \"url\":\"tcp:postgresql://${EX_PG_HOST}/${EX_PG_DB}\", \"user\":\"${EX_PG_USER}\", \"password\":\"${EX_PG_PASS}\"}"
0084 export NDRX_XA_DRIVERLIB=libndrxxaecpg.$NDRX_LIBEXT
0085 else
0086 echo "pq mode"
0087 export NDRX_XA_OPEN_STR="{ \"url\":\"postgresql://${EX_PG_USER}:${EX_PG_PASS}@${EX_PG_HOST}/${EX_PG_DB}\"}"
0088 export NDRX_XA_DRIVERLIB=libndrxxapq.$NDRX_LIBEXT
0089 fi
0090 export NDRX_XA_CLOSE_STR=$NDRX_XA_OPEN_STR
0091 export NDRX_XA_RMLIB=-
0092 export NDRX_XA_LAZY_INIT=1
0093
0094
0095
0096 }
0097
0098
0099
0100
0101 function go_out {
0102 echo "Test exiting with: $1"
0103
0104 set_dom1;
0105 xadmin stop -y
0106 xadmin down -y
0107
0108
0109
0110 xadmin killall atmiclt67
0111
0112 popd 2>/dev/null
0113 exit $1
0114 }
0115
0116
0117 rm -rf ./RM1
0118 mkdir RM1
0119
0120 rm -rf ./RM2
0121 mkdir RM2
0122
0123
0124 rm -rf ./QSPACE1
0125 mkdir QSPACE1
0126
0127 rm *.log
0128
0129 xadmin killall tpbridge
0130
0131 set_dom1;
0132 xadmin down -y
0133 xadmin start -y || go_out 1
0134
0135
0136
0137 xadmin recoverlocal -p
0138 xadmin abortlocal -y
0139
0140 RET=0
0141
0142 xadmin psc
0143 xadmin ppm
0144 echo "Running off client"
0145
0146 set_dom1;
0147 (./atmiclt67 2>&1) > ./atmiclt-dom1.log
0148
0149
0150 RET=$?
0151
0152 if [[ "X$RET" != "X0" ]]; then
0153 go_out $RET
0154 fi
0155
0156 echo "Checking tmrecover stats..."
0157
0158 if [[ "X`grep 'Rolled back 0 orphan transactions branches' tmrecovercl.log`" == "X" ]]; then
0159 echo "Expecting 'Rolled back 0 orphan transactions branches' in tmrecovercl.log but not found"
0160 go_out -1
0161 fi
0162
0163 if [[ "X`grep 'Rolled back 900 orphan transactions branches' tmrecovercl.log`" == "X" ]]; then
0164 echo "Expecting 'Rolled back 900 orphan transactions branches' in tmrecovercl.log but not found"
0165 go_out -1
0166 fi
0167
0168
0169
0170
0171 echo "Queue tests..."
0172 (./atmiclt67 testq 2>&1) >> ./atmiclt-dom1.log
0173
0174 RET=$?
0175
0176 if [[ "X$RET" != "X0" ]]; then
0177 go_out $RET
0178 fi
0179
0180
0181
0182
0183
0184 echo "Timeout tests..."
0185
0186 (./atmiclt67 tout 2>&1) >> ./atmiclt-dom1.log
0187
0188 RET=$?
0189
0190 if [[ "X$RET" != "X0" ]]; then
0191 go_out $RET
0192 fi
0193
0194
0195
0196
0197 echo "ENDPREPFAIL test..."
0198 export NDRX_TESTMODE=ENDPREPFAIL
0199
0200 (./atmiclt67 endfail 2>&1) >> ./atmiclt-dom1.log
0201
0202 RET=$?
0203
0204 if [[ "X$RET" != "X0" ]]; then
0205 go_out $RET
0206 fi
0207
0208
0209
0210
0211
0212 echo "TMSNOCOMMIT/local commands test..."
0213 export NDRX_TESTMODE=TMSNOCOMMIT
0214
0215 xadmin stop -y
0216 xadmin start -y
0217
0218
0219 xadmin abortlocal -y
0220
0221
0222 echo "Do insert..."
0223 (./atmiclt67 doinsert 2>&1) >> ./atmiclt-dom1.log
0224
0225 RET=$?
0226
0227 if [[ "X$RET" != "X0" ]]; then
0228 go_out $RET
0229 fi
0230
0231 xadmin recoverlocal
0232 CNT=`xadmin recoverlocal | wc | awk '{print $1}'`
0233
0234
0235 if [ "X$CNT" != "X1" ]; then
0236
0237 echo "Expected 1 transaction, got: $CNT"
0238 go_out -10
0239
0240 fi
0241
0242 xadmin commitlocal -y
0243
0244
0245 echo "Check 50"
0246 (./atmiclt67 ck50 2>&1) >> ./atmiclt-dom1.log
0247
0248 RET=$?
0249
0250 if [[ "X$RET" != "X0" ]]; then
0251 go_out $RET
0252 fi
0253
0254
0255 echo "Do insert2..."
0256 (./atmiclt67 insert2 2>&1) >> ./atmiclt-dom1.log
0257
0258 RET=$?
0259
0260 if [[ "X$RET" != "X0" ]]; then
0261 go_out $RET
0262 fi
0263
0264 xadmin abortlocal -y -p
0265
0266 echo "Check 0"
0267 (./atmiclt67 ck0 2>&1) >> ./atmiclt-dom1.log
0268
0269 RET=$?
0270
0271 if [[ "X$RET" != "X0" ]]; then
0272 go_out $RET
0273 fi
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284 unset NDRX_TESTMODE
0285
0286 xadmin stop -y
0287 xadmin start -y
0288
0289 echo "Queue Forward transactional tests..."
0290
0291 (./atmiclt67 enqok 2>&1) >> ./atmiclt-dom1.log
0292
0293 RET=$?
0294
0295 if [[ "X$RET" != "X0" ]]; then
0296 go_out $RET
0297 fi
0298
0299 echo "Sleep 5 - wait for forward"
0300 sleep 5
0301
0302 echo "There should be 1 msg in table"
0303 (./atmiclt67 ck1 2>&1) >> ./atmiclt-dom1.log
0304
0305 RET=$?
0306
0307
0308 if [[ "X$RET" != "X0" ]]; then
0309 echo "Invalid count in table!"
0310 go_out $RET
0311 fi
0312
0313 echo "There should be no messages in queue"
0314
0315 xadmin mqlm -s "MYSPACE" -q "OKQ1"
0316 OUT=`xadmin mqlm -s "MYSPACE" -q "OKQ1"`
0317
0318 if [ "X$OUT" != "X" ]; then
0319 echo "No output expected for Q!"
0320 go_out 100
0321 fi
0322
0323 echo "There should be no prepared transactions"
0324
0325 xadmin recoverlocal
0326
0327 OUT=`xadmin recoverlocal`
0328
0329 if [ "X$OUT" != "X" ]; then
0330 echo "No output expected for transactions!"
0331 go_out 101
0332 fi
0333
0334
0335 echo "Queue dead queue"
0336
0337 (./atmiclt67 enqfail 2>&1) >> ./atmiclt-dom1.log
0338
0339 RET=$?
0340
0341 if [[ "X$RET" != "X0" ]]; then
0342 go_out $RET
0343 fi
0344
0345 echo "Sleep 5 - wait for forward / sill msg in Q"
0346 sleep 2
0347
0348 xadmin mqlm -s "MYSPACE" -q "BADQ1"
0349 OUT=`xadmin mqlm -s "MYSPACE" -q "BADQ1"`
0350
0351 if [ "X$OUT" == "X" ]; then
0352 echo "Expected message BADQ1!"
0353 go_out 100
0354 fi
0355
0356 echo "Wait 45 to finish Q off"
0357 sleep 45
0358
0359 echo "There should be 0 msg in table"
0360 (./atmiclt67 ck0 2>&1) >> ./atmiclt-dom1.log
0361
0362 RET=$?
0363
0364 if [[ "X$RET" != "X0" ]]; then
0365 echo "Invalid count in table, must be 0!"
0366 go_out $RET
0367 fi
0368
0369 echo "There should be no messages in queue (as expired & removed)"
0370
0371 xadmin mqlm -s "MYSPACE" -q "BADQ1"
0372 OUT=`xadmin mqlm -s "MYSPACE" -q "BADQ1"`
0373
0374 if [ "X$OUT" != "X" ]; then
0375 echo "No output expected for Q!"
0376 go_out 100
0377 fi
0378
0379 echo "There should be no prepared transactions"
0380
0381 xadmin recoverlocal
0382
0383 OUT=`xadmin recoverlocal`
0384
0385 if [ "X$OUT" != "X" ]; then
0386 echo "No output expected for transactions!"
0387 go_out 101
0388 fi
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0401 echo "Test error detected!"
0402 RET=-2
0403 fi
0404
0405 go_out $RET
0406
0407
0408