Project: lixa
Code Location: https://lixa.svn.sourceforge.net/svnroot/lixa/tests//tests
Browse
/
Download File
ibmdb2.at
#
# WARNING
# This file must be manually kept synchronized with the content of 
# "oracle.at", "postgresql.at", etc...
#
AT_BANNER([IBM DB2])

# check the schema "hr" is available and the user can connect to it
AT_SETUP([DB2/0.0/0.0 IBM DB2 availability])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([input.db2],
[[
connect to SAMPLE
QUIT
]])
AT_CHECK([cat input.db2 | db2 >$TESTS_TMP_FILE1 && grep "Local database alias.*SAMPLE" $TESTS_TMP_FILE1], [0], [ignore], [ignore])
AT_CLEANUP

# check the current user has SELECT privilege on table authors
AT_SETUP([DB2/0.0/0.1 dept table exists])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([input.db2],
[[
connect to SAMPLE
SELECT * FROM db2inst1.dept
QUIT
]])
AT_CHECK([db2 -f input.db2 >$TESTS_TMP_FILE1 && grep "record.*selected" $TESTS_TMP_FILE1], [0], [ignore], [ignore])
AT_CLEANUP

# check the current user has DELETE & INSERT privilege on table authors
AT_SETUP([DB2/0.0/0.2 DELETE & INSERT INTO countries])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
# the command is duplicated to force rc=1
AT_DATA([input1.db2],
[[
connect to SAMPLE
DELETE FROM db2inst1.dept WHERE deptno = 'Y69'
DELETE FROM db2inst1.dept WHERE deptno = 'Y69'
QUIT
]])
AT_CHECK([db2 -f input1.db2], [1], [ignore], [ignore])
AT_DATA([input2.db2],
[[
connect to SAMPLE
INSERT INTO DB2INST1.DEPT (DEPTNO, DEPTNAME, ADMRDEPT) VALUES('Y69', 'MARKETING', 'E01')
QUIT
]])
AT_CHECK([db2 -f input2.db2 >$TESTS_TMP_FILE1 && grep "^DB20000I" $TESTS_TMP_FILE1], [0], [ignore], [ignore])
AT_CHECK([db2 -f input1.db2 >$TESTS_TMP_FILE1 && grep "^DB20000I" $TESTS_TMP_FILE1], [1], [ignore], [ignore])
AT_CLEANUP

# try one phase commit
AT_SETUP([DB2/0.1/0.0 One phase commit])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0016 ; lixa_test_exec.sh reset start case0039 1 1 0], [0], [ignore], [ignore])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0016 ; lixa_test_exec.sh noreset none case0039 1 0 0], [0], [ignore], [ignore])
AT_CLEANUP

# try two phase commit
AT_SETUP([DB2/0.1/0.1 Two phase commit])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
xa_prepare/0
xa_commit/0
xa_close/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; lixa_test_exec.sh noreset none case0039 1 1 0], [0], [ignore], [ignore])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
xa_prepare/0
xa_commit/0
xa_close/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; lixa_test_exec.sh noreset none case0039 1 0 0], [0], [ignore], [ignore])
AT_CLEANUP

# try rollback after prepare
AT_SETUP([DB2/0.1/0.2 Rollback after prepare])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
xa_prepare/-3
xa_rollback/0
xa_close/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; lixa_test_exec.sh noreset none case0039 1 1 -2], [0], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([DB2/0.1/1.0 Crash after connect])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; export LIXA_CRASH_POINT=2 ; lixa_test_exec.sh noreset none case0039 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([DB2/0.1/1.1 Crash in the middle of xa_open])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; export LIXA_CRASH_POINT=3 ; lixa_test_exec.sh noreset none case0039 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([DB2/0.1/1.2 Crash in the middle of xa_open (2)])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; export LIXA_CRASH_POINT=4 ; lixa_test_exec.sh noreset none case0039 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([DB2/0.1/1.3 Crash after xa_open])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; export LIXA_CRASH_POINT=5 ; lixa_test_exec.sh noreset none case0039 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([DB2/0.1/2.0 Crash in the middle of xa_end])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; export LIXA_CRASH_POINT=11 ; lixa_test_exec.sh noreset none case0039 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([DB2/0.1/2.1 Automatic recovery])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_rollback/0
xa_start/0
xa_end/0
xa_prepare/0
xa_commit/0
xa_close/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; lixa_test_exec.sh noreset none case0039 1 1 0], [0], [ignore], [ignore])
AT_CHECK([lixad --config-file=$TESTS_ETC_DIR/lixad_conf.xml --dump=u|tee $TESTS_TMP_FILE1 ; grep 'recovery failed: 1' $TESTS_TMP_FILE1], [1], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([DB2/0.1/2.2 Crash after end])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; export LIXA_CRASH_POINT=12 ; lixa_test_exec.sh noreset none case0039 1 0 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([DB2/0.1/2.3 Automatic recovery])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_rollback/0
xa_start/0
xa_end/0
xa_prepare/0
xa_commit/0
xa_close/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; lixa_test_exec.sh noreset none case0039 1 0 0], [0], [ignore], [ignore])
AT_CHECK([lixad --config-file=$TESTS_ETC_DIR/lixad_conf.xml --dump=u|tee $TESTS_TMP_FILE1 ; grep 'recovery failed: 1' $TESTS_TMP_FILE1], [1], [ignore], [ignore])
AT_CLEANUP

# crash in the middle of prepare
AT_SETUP([DB2/0.1/3.0 Crash in the middle of prepare])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
xa_prepare/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; export LIXA_CRASH_POINT=14 ; lixa_test_exec.sh noreset none case0039 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([DB2/0.1/3.1 Automatic recovery])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_commit/0
xa_start/0
xa_end/0
xa_prepare/0
xa_commit/0
xa_close/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; lixa_test_exec.sh noreset none case0039 1 0 0], [0], [ignore], [ignore])
AT_CLEANUP

# crash after prepare
AT_SETUP([DB2/0.1/4.0 Crash after prepare])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
xa_prepare/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; export LIXA_CRASH_POINT=15 ; lixa_test_exec.sh noreset none case0039 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([DB2/0.1/4.1 Automatic recovery])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_commit/0
xa_start/0
xa_end/0
xa_prepare/0
xa_commit/0
xa_close/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; lixa_test_exec.sh noreset none case0039 1 0 0], [0], [ignore], [ignore])
AT_CLEANUP

# crash after prepare
AT_SETUP([DB2/0.1/5.0 Crash after prepare])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_start/0
xa_end/0
xa_prepare/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; export LIXA_CRASH_POINT=15 ; lixa_test_exec.sh noreset stop case0039 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([DB2/0.1/5.1 Manual recovery])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_IBMDB2" = "no"; then exit 77; fi])
AT_DATA([monkey1s.conf],
[[# monkey R.M. config
xa_open/0
xa_recover/0
xa_close/0
]])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; lixa_test_exec.sh reset start lixar -p >$TESTS_TMP_FILE1], [0], [ignore], [ignore])
AT_CHECK([grep '^xid=' $TESTS_TMP_FILE1 | cut -d "'" -f 2 > $TESTS_TMP_FILE2], [0], [ignore], [ignore])
AT_CHECK([export LIXA_PROFILE=CASE_PROF_0017 ; lixa_test_exec.sh noreset stop lixar -p -r -X $TESTS_TMP_FILE2], [0], [ignore], [ignore])
AT_CLEANUP