Imported Upstream version 5.3.21
[platform/upstream/libdb.git] / test / xa / src1 / run.sh
1 #! /bin/sh
2 #
3 # Run test 1.
4
5 msg()
6 {
7         test "$DVERBOSE" == 1 && {
8                 echo "========"
9                 echo "======== $1"
10                 echo "========"
11         }
12 }
13
14 init_tmadmin()
15 {
16 tmadmin << END_OF_TMADMIN
17         crdl -z $TLOGDEVICE -b 500
18         crlog -m cluster3
19 END_OF_TMADMIN
20 }
21
22 mkdir $RUN/data2
23
24 # Everything else is done in run/bin.
25 cd $RUN/bin
26
27 # The CFLAGS variable defines the pre-processor defines -- start with
28 # whatever the user set, and add our own stuff.
29 #
30 # For debugging output, add -DDVERBOSE 
31
32 test "$DVERBOSE" == 1 && {
33         COMPILE_FLAGS="-DDVERBOSE"
34         DVERBOSE_FLAG="-v"
35 }
36 COMPILE_FLAGS="$CFLAGS $COMPILE_FLAGS -g -I../../.."
37 UTILITY_FILES="-f ../../src1/htimestampxa.c -f ../../utilities/bdb_xa_util.c"
38
39 msg "BUILDING CLIENT"
40 CFLAGS="$COMPILE_FLAGS"; export CFLAGS
41 buildclient -r BERKELEY-DB $DVERBOSE_FLAG -o client \
42     $UTILITY_FILES -f ../../src1/client.c
43 test "$?" -eq 0 || {
44         echo "FAIL: buildclient failed."
45         exit 1
46 }
47
48 msg "BUILDING SERVER #1"
49 CFLAGS="$COMPILE_FLAGS -DSERVER1"; export CFLAGS
50 buildserver -r BERKELEY-DB $DVERBOSE_FLAG -o server1 \
51   -s TestTxn1:TestTxn1 \
52     $UTILITY_FILES -f ../../src1/server.c
53 test "$?" -eq 0 || {
54         echo "FAIL: buildserver failed."
55         exit 1
56 }
57
58 msg "BUILDING SERVER #2"
59 CFLAGS="$COMPILE_FLAGS -DSERVER2"; export CFLAGS
60 buildserver $DVERBOSE_FLAG -r BERKELEY-DB -o server2 \
61    -s TestTxn2:TestTxn2 \
62     $UTILITY_FILES -f ../../src1/server.c
63 test "$?" -eq 0 || {
64         echo "FAIL: buildserver failed."
65         exit 1
66 }
67
68 msg "BUILDING THE RESOURCE MANAGER."
69 buildtms -o DBRM -r BERKELEY-DB
70
71 init_tmadmin
72
73 # Boot Tuxedo.
74 # You should see something like:
75 #
76 # Booting admin processes ...
77 #
78 # exec BBL -A :
79 #         process id=13845 ... Started.
80 #
81 # Booting server processes ...
82 #
83 # exec DBRM -A :
84 #         process id=13846 ... Started.
85 # exec DBRM -A :
86 #         process id=13847 ... Started.
87 # exec server1 -A :
88 #         process id=13848 ... Started.
89 # exec server2 -A :
90 #         process id=13849 ... Started.
91 # 5 processes started.
92 msg "BOOTING TUXEDO."
93 tmboot -y
94
95 # Run the client with 10, 100 and 1000 transactions.
96 exitval=0
97 for i in 10 100 1000; do
98         msg "RUN THE CLIENT WITH $i TRANSACTIONS."
99         ./client $DVERBOSE_FLAG -n $i
100         test "$?" -ne 0 && {
101                 echo "FAIL: client failed"
102                 exitval=1
103                 break;
104         }
105 done
106
107 msg "SHUTTING DOWN THE TRANSACTION MANAGER."
108 echo 'y' | tmshutdown
109
110 # Copy out any server output.
111 echo "STDOUT:"
112 cat stdout
113
114 # Copy out any server errors.echo "STDERR:"
115 cat stderr
116 test -s stderr && {
117         echo "STDERR:"
118         cat stderr
119         echo "FAIL: stderr file not empty"
120         exitval=1
121 }
122
123 # We never checkpointed, run recovery to make sure it all works.
124 msg "RECOVERY:"
125 db_recover -h ../data -v
126 test "$?" -ne 0 && {
127         echo "FAIL: recovery failed"
128         exitval=1
129 }
130
131 exit $exitval