adding test scripts
[csql.git] / test / cache / CacheTable / test011.ksh
blobc6707588f650a8b784c28cafd972e7393143991b
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 # Unload both tables. Both the tables should get unloaded.
8 #Run this test only under csql/test or on this directory.
9 #Otherwise, it may fail
10 dropAll() {
11 rm -f /tmp/csql/csqltable.conf
12 touch /tmp/csql/csqltable.conf
13 #cp $CSQL_CONFIG_FILE /tmp/csql.conf
14 #echo DSN=$DSN >>$CSQL_CONFIG_FILE
15 isql $DS < ${REL_PATH}/dropall.sql >/dev/null 2>&1
16 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/dropall.sql > /dev/null 2>&1
17 #cp /tmp/csql.conf $CSQL_CONFIG_FILE
21 input=${PWD}/cache/CacheTable/create.sql
22 REL_PATH=.
23 if [ -s "$input" ]
24 then
25 REL_PATH=${PWD}/cache/CacheTable
28 cp $CSQL_CONFIG_FILE /tmp/csql.conf
29 echo CACHE_TABLE=true >>$CSQL_CONFIG_FILE
30 echo DSN=$DSN >>$CSQL_CONFIG_FILE
31 DS="$DSN $DBUSER $PASSWORD"
32 rm -f /tmp/csql/csqlds.conf
33 touch /tmp/csql/csqlds.conf
34 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
35 if [ $? -ne 0 ]
36 then
37 cp /tmp/csql.conf $CSQL_CONFIG_FILE
38 exit 1;
41 isql $DS < ${REL_PATH}/create.sql >/dev/null 2>&1
42 echo table t1 and t2 are created with records in target db
44 rm -f /tmp/csql/csqltable.conf
45 touch /tmp/csql/csqltable.conf
47 # write to csqltable.conf
48 echo "1 t1 NULL NULL NULL $DSN" > /tmp/csql/csqltable.conf
49 echo "2 t2 NULL t2f1<5 NULL $DSN" >> /tmp/csql/csqltable.conf
51 $CSQL_INSTALL_ROOT/bin/cachetable -R
52 if [ $? -ne 0 ]
53 then
54 dropAll
55 cp /tmp/csql.conf $CSQL_CONFIG_FILE
56 exit 1;
59 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u
60 if [ $? -ne 0 ]
61 then
62 dropAll
63 cp /tmp/csql.conf $CSQL_CONFIG_FILE
64 exit 2;
66 echo table t1 unloaded
67 $CSQL_INSTALL_ROOT/bin/cachetable -t t2 -u
68 if [ $? -ne 0 ]
69 then
70 dropAll
71 cp /tmp/csql.conf $CSQL_CONFIG_FILE
72 exit 3;
74 echo table t2 unloaded
75 grep t1 /tmp/csql/csqltable.conf
76 if [ $? -eq 0 ]
77 then
78 dropAll
79 cp /tmp/csql.conf $CSQL_CONFIG_FILE
80 exit 4;
83 grep t2 /tmp/csql/csqltable.conf
84 if [ $? -eq 0 ]
85 then
86 dropAll
87 cp /tmp/csql.conf $CSQL_CONFIG_FILE
88 exit 5;
90 dropAll
91 cp /tmp/csql.conf $CSQL_CONFIG_FILE
92 exit 0;