adding test scripts
[csql.git] / test / cache / CacheTable / test012.ksh
blobc6677790a99377c1eb67c467e583f0c0afbe942d
1 #!/bin/ksh
2 # Test Case
4 # Create table t1 and t2 in mysql and insert 10 records each.
5 # Cache the tables into csql with -R option.
6 # Remove 5 entries from table t1 in csql and 5 entries from table t2 in mysql.
7 # Reload both tables with -r option.
8 # CSQL now should have 10 entries in t1 and 5 entries in t2
10 input=${PWD}/cache/CacheTable/create.sql
11 REL_PATH=.
12 if [ -s "$input" ]
13 then
14 REL_PATH=${PWD}/cache/CacheTable
17 cp $CSQL_CONFIG_FILE /tmp/csql.conf
18 echo CACHE_TABLE=true >>$CSQL_CONFIG_FILE
19 echo DSN=$DSN >>$CSQL_CONFIG_FILE
20 DS="$DSN $DBUSER $PASSWORD"
21 rm -f /tmp/csql/csqlds.conf
22 touch /tmp/csql/csqlds.conf
23 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
24 if [ $? -ne 0 ]
25 then
26 cp /tmp/csql.conf $CSQL_CONFIG_FILE
27 exit 1;
30 isql $DS < ${REL_PATH}/create.sql >/dev/null 2>&1
31 echo table t1 and t2 are created with records in target db
33 rm -f /tmp/csql/csqltable.conf
34 touch /tmp/csql/csqltable.conf
36 # write to the csqltable.conf file
37 echo "1 t1 NULL NULL NULL $DSN" > /tmp/csql/csqltable.conf
38 echo "2 t2 NULL t2f1>5 NULL $DSN" >> /tmp/csql/csqltable.conf
40 if [ "$VALGRIND" = "true" ]
41 then
42 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/cachetable -R 2> $0.valgr
43 else
44 $CSQL_INSTALL_ROOT/bin/cachetable -R
45 if [ $? -ne 0 ]
46 then
47 cp /tmp/csql.conf $CSQL_CONFIG_FILE
48 exit 2;
51 if [ "$VALGRIND" = "true" ]
52 then
53 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectstar.sql 2> $0.valgr
54 else
55 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectstar.sql
57 if [ "$VALGRIND" = "true" ]
58 then
59 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/deletefromt1csql.sql 2>> $0.valgr
60 else
61 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/deletefromt1csql.sql
63 isql $DS < $REL_PATH/deletefromt2mysql.sql
65 if [ "$VALGRIND" = "true" ]
66 then
67 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -r 2>> $0.valgr
68 else
69 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -r
70 if [ $? -ne 0 ]
71 then
72 cp /tmp/csql.conf $CSQL_CONFIG_FILE
73 exit 2;
76 echo table t1 reloaded
77 if [ "$VALGRIND" = "true" ]
78 then
79 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/cachetable -t t2 -r 2>> $0.valgr
80 else
81 $CSQL_INSTALL_ROOT/bin/cachetable -t t2 -r
82 if [ $? -ne 0 ]
83 then
84 cp /tmp/csql.conf $CSQL_CONFIG_FILE
85 exit 3;
88 echo table t2 reloaded
90 if [ "$VALGRIND" = "true" ]
91 then
92 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectstar.sql 2>> $0.valgr
93 else
94 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectstar.sql
96 rm -f /tmp/csql/csqltable.conf
97 touch /tmp/csql/csqltable.conf
98 isql $DS < ${REL_PATH}/dropall.sql >/dev/null 2>&1
99 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/dropall.sql > /dev/null 2>&1
100 cp /tmp/csql.conf $CSQL_CONFIG_FILE
101 exit 0;