1#! /bin/sh 2# 3# Smoke test XA support. 4 5msg() 6{ 7 echo "========" 8 echo "======== $1" 9 echo "========" 10} 11 12func_clean() 13{ 14 rm -rf run 15} 16 17# Build the configuration file -- 18# We do this work in the shell script because we have to fill in 19# lots of shell variables. 20func_ubbinit() 21{ 22 MACHINE_NAME=`uname -n` 23 cat > $RUN/config/ubb.cfg << END_OF_UBB_FILE 24*RESOURCES 25IPCKEY 200103 26DOMAINID domain3 27MASTER cluster3 28MAXACCESSERS 10 29MAXSERVERS 5 30MAXSERVICES 10 31MODEL SHM 32LDBAL N 33 34*MACHINES 35DEFAULT: 36 APPDIR="$RUN/bin" 37 TUXCONFIG="$TUXCONFIG" 38 TLOGDEVICE="$TLOGDEVICE" 39 TUXDIR="$TUXDIR" 40# Machine name is 30 characters max 41$MACHINE_NAME LMID=cluster3 42 43*GROUPS 44# Group name is 30 characters max 45group_tm LMID=cluster3 GRPNO=1 TMSNAME=DBRM TMSCOUNT=2 OPENINFO="BERKELEY-DB:$RUN/data" 46 47*SERVERS 48DEFAULT: 49 CLOPT="-A" 50 51# Server name is 78 characters max (same for any pathname) 52server1 SRVGRP=group_tm SRVID=1 MAXGEN=3 RESTART=Y 53server2 SRVGRP=group_tm SRVID=2 MAXGEN=3 RESTART=Y 54 55*SERVICES 56# Service name is 15 characters max 57# server1 58TestTxn1 59# server2 60TestTxn2 61END_OF_UBB_FILE 62 tmloadcf -y $RUN/config/ubb.cfg 63} 64 65init_tmadmin() 66{ 67tmadmin << END_OF_TMADMIN 68 crdl -z $TLOGDEVICE -b 500 69 crlog -m cluster3 70END_OF_TMADMIN 71} 72 73# Run a test. 74run() 75{ 76 msg "CLEANING UP FROM THE LAST RUN." 77 rm -rf run 78 mkdir -p run/bin run/config run/data 79 80 msg "BUILDING THE CONFIGURATION FILE." 81 func_ubbinit 82 83 # Everything else is done in run/bin. 84 cd $RUN/bin 85 86 # The CFLAGS variable defines the pre-processor defines -- start with 87 # whatever the user set, and add our own stuff. 88 # 89 # For debugging output, add -DVERBOSE to COMPILE_FLAGS, by uncommenting 90 # the following line. 91 # 92 # Verbose output from the client appears in this script's stdout, 93 # (which you can re-direct below, when the client is run). 94 # Verbose output from the server appears in the file run/bin/stdout. 95 # 96 # COMPILE_FLAGS="-DVERBOSE" 97 COMPILE_FLAGS="$CFLAGS $COMPILE_FLAGS -g -I../../.." 98 99 msg "BUILDING CLIENT" 100 CFLAGS="$COMPILE_FLAGS"; export CFLAGS 101 buildclient -v -r BERKELEY-DB -o client \ 102 -f ../../src/htimestampxa.c -f ../../src/client.c 103 test "$?" -eq 0 || { 104 echo "FAIL: buildclient failed." 105 exit 1 106 } 107 108 msg "BUILDING SERVER #1" 109 CFLAGS="$COMPILE_FLAGS -DSERVER1"; export CFLAGS 110 buildserver -v -r BERKELEY-DB -o server1 \ 111 -s TestTxn1:TestTxn1 \ 112 -f ../../src/htimestampxa.c -f ../../src/server.c 113 test "$?" -eq 0 || { 114 echo "FAIL: buildserver failed." 115 exit 1 116 } 117 118 msg "BUILDING SERVER #2" 119 CFLAGS="$COMPILE_FLAGS -DSERVER2"; export CFLAGS 120 buildserver -v -r BERKELEY-DB -o server2 \ 121 -s TestTxn2:TestTxn2 \ 122 -f ../../src/htimestampxa.c -f ../../src/server.c 123 test "$?" -eq 0 || { 124 echo "FAIL: buildserver failed." 125 exit 1 126 } 127 128 msg "BUILDING THE RESOURCE MANAGER." 129 buildtms -v -o DBRM -r BERKELEY-DB 130 131 msg "BUILDING THE LOG DEVICE." 132 init_tmadmin 133 134 # Boot Tuxedo. 135 # You should see something like: 136 # 137 # INFO: BEA Tuxedo, Version 8.1 138 # INFO: Serial #: 650522264138-1510597376252, 139 # Expiration 2005-02-15, Maxusers 100 140 # INFO: Licensed to: BEA Evaluation Customer 141 # 142 # Booting admin processes ... 143 # 144 # exec BBL -A : 145 # process id=13845 ... Started. 146 # 147 # Booting server processes ... 148 # 149 # exec DBRM -A : 150 # process id=13846 ... Started. 151 # exec DBRM -A : 152 # process id=13847 ... Started. 153 # exec server1 -A : 154 # process id=13848 ... Started. 155 # exec server2 -A : 156 # process id=13849 ... Started. 157 # 5 processes started. 158 msg "BOOTING TUXEDO." 159 tmboot -y 160 161 # Run the client with 10, 100 and 1000 transactions. 162 exitval=0 163 for i in 10 100 1000; do 164 msg "RUN THE CLIENT WITH $i TRANSACTIONS." 165 # You can get debugging output on just the client by 166 # adding -v to the command line. 167 # 168 # ./client -v -n $i 169 ./client -n $i 170 test "$?" -ne 0 && { 171 echo "FAIL: client failed" 172 exitval=1 173 break; 174 } 175 done 176 177 msg "SHUTTING DOWN THE TRANSACTION MANAGER." 178 echo 'y' | tmshutdown 179 180 # Copy out Tuxedo's logging. 181 msg "ULOG FILES:" 182 cat ULOG* 183 184 # Copy out any server output. 185 msg "STDOUT:" 186 cat stdout 187 188 # Copy out any server errors. 189 msg "STDERR:" 190 cat stderr 191 test -s stderr && { 192 echo "FAIL: stderr file not empty" 193 exitval=1 194 } 195 196 # We never checkpointed, run recovery to make sure it all works. 197 msg "RECOVERY:" 198 ../../../db_recover -h ../data -v 199 test "$?" -ne 0 && { 200 echo "FAIL: recovery failed" 201 exitval=1 202 } 203 204 return $exitval 205} 206 207# Debug the shell script. 208# set -x 209 210# Check to make sure we have a Tuxedo build we understand. 211test -z "$TUXDIR" && { 212 echo "FAIL: the TUXDIR environment variable NOT set" 213 echo \ 214 "FAIL: TUXDIR must be set to the absolute path of the Tuxedo install" 215 echo "FAIL: immediately above the subdirectories bin, include and lib" 216 exit 1 217} 218dlist="include lib" 219for i in $dlist; do 220 test -d $TUXDIR/$i || { 221 echo "FAIL: check the Tuxedo install" 222 echo "FAIL: the required directory $TUXDIR/$i does not exist" 223 exit 1 224 } 225done 226flist="bin/buildclient bin/buildserver bin/buildtms bin/tmadmin bin/tmboot 227 bin/tmloadcf bin/tmshutdown udataobj/RM" 228for i in $flist; do 229 test -f $TUXDIR/$i || { 230 echo "FAIL: check the Tuxedo install" 231 echo "FAIL: the required file $TUXDIR/$i does not exist" 232 exit 1 233 } 234done 235msg "Using Tuxedo $TUXDIR installation" 236 237# Set the location of the Berkeley DB libraries -- allow the user to override. 238# Check to make sure we have a Berkeley DB installation. (I'd like to use the 239# local DB installation, but I've never been able to make Tuxedo load shared 240# libraries from the .libs directory.) 241REL=../../dist/RELEASE 242test -z "$DB_INSTALL" && test -f $REL && { 243 . $REL 244 DB_INSTALL=/usr/local/BerkeleyDB.${DB_VERSION_MAJOR}.${DB_VERSION_MINOR} 245 export DB_INSTALL 246} 247if test -f "$DB_INSTALL/lib/libdb.so"; then 248 msg "Using Berkeley DB $DB_INSTALL/lib/ installation" 249else 250 echo "FAIL: $DB_INSTALL/lib/libdb.so not found" 251 echo \ 252 "FAIL: DB_INSTALL must be set to the absolute path of the Berkeley DB install" 253 exit 1 254fi 255 256# You may need to update the Tuxedo resource manager file. It should be in: 257# 258# $TUXDIR/udataobj/RM 259# 260# Solaris requires a line something like the following: 261# 262# BERKELEY-DB:db_xa_switch:-L${DB_INSTALL}/lib -ldb 263# 264# where DB_INSTALL is a Berkeley DB install, and /lib contains DB libraries. 265egrep "^BERKELEY-DB:db_xa_switch:" $TUXDIR/udataobj/RM > /dev/null || { 266 echo "FAIL: $TUXDIR/udataobj/RM does not list DB as one of its RMs" 267 echo "FAIL: Try adding:" 268 echo "FAIL: BERKELEY-DB:db_xa_switch:-L\${DB_INSTALL}/lib -ldb" 269 exit 1 270} 271 272# Everything is built in and run from the "run" subdirectory. 273RUN=`pwd`/run; export RUN 274 275FIELDTBLS32=datafml.fml; export FIELDTBLS32 276FLDTBLDIR32=$RUN/config; export FLDTBLDIR32 277TLOGDEVICE=$RUN/data/dlog; export TLOGDEVICE 278TUXCONFIG=$RUN/config/tuxconfig;export TUXCONFIG 279 280PATH="$PATH:$RUN/bin:$TUXDIR/bin" 281LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DB_INSTALL/lib:$TUXDIR/lib; 282export LD_LIBRARY_PATH PATH 283 284if test $# -eq 1; then 285 case "$1" in 286 clean) # Clean up from previous runs. 287 func_clean;; 288 shutdown) # Shutdown Tuxedo from previous runs. 289 echo 'y' | tmshutdown -w 5;; 290 *) 291 echo 'usage: chk.xa [clean | shutdown]' 292 exit 1;; 293 esac 294else 295 run # Run the XA test. 296 if test "$?" -ne 0; then 297 exit 1 298 fi 299fi 300 301exit 0 302