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

# check the database "testdb" is available and the user can connect to it
AT_SETUP([PQ/0.0/0.0 PostgreSQL availability])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "no"; then exit 77; fi])
AT_CHECK([echo "\q" | psql testdb], [0], [ignore], [ignore])
AT_CLEANUP

# check the current user has SELECT privilege on table authors
AT_SETUP([PQ/0.0/0.1 authors table exists])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "no"; then exit 77; fi])
AT_CHECK([echo "SELECT * FROM AUTHORS;" | psql testdb >$TESTS_TMP_FILE1 && grep row $TESTS_TMP_FILE1], [0], [ignore], [ignore])
AT_CLEANUP

# check the current user has DELETE & INSERT privilege on table authors
AT_SETUP([PQ/0.0/0.2 DELETE & INSERT INTO authors])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "no"; then exit 77; fi])
AT_CHECK([echo "DELETE FROM authors;" | psql testdb >$TESTS_TMP_FILE1 && grep DELETE $TESTS_TMP_FILE1], [0], [ignore], [ignore])
AT_CHECK([echo "INSERT INTO authors VALUES(999,'surname','name');" | psql testdb >$TESTS_TMP_FILE1 && grep INSERT $TESTS_TMP_FILE1], [0], [ignore], [ignore])
AT_CHECK([echo "DELETE FROM authors;" | psql testdb >$TESTS_TMP_FILE1 && grep DELETE $TESTS_TMP_FILE1], [0], [ignore], [ignore])
AT_CLEANUP

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

# try two phase commit
AT_SETUP([PQ/0.1/0.1 Two phase commit])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; lixa_test_exec.sh noreset none case0037 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_0011 ; lixa_test_exec.sh noreset none case0037 1 0 0], [0], [ignore], [ignore])
AT_CLEANUP

# try rollback after prepare
AT_SETUP([PQ/0.1/0.2 Rollback after prepare])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; lixa_test_exec.sh noreset none case0037 1 1 -2], [0], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([PQ/0.1/1.0 Crash after connect])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; export LIXA_CRASH_POINT=2 ; lixa_test_exec.sh noreset none case0037 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([PQ/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_POSTGRESQL" = "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_0011 ; export LIXA_CRASH_POINT=3 ; lixa_test_exec.sh noreset none case0037 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([PQ/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_POSTGRESQL" = "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_0011 ; export LIXA_CRASH_POINT=4 ; lixa_test_exec.sh noreset none case0037 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([PQ/0.1/1.3 Crash after xa_open])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; export LIXA_CRASH_POINT=5 ; lixa_test_exec.sh noreset none case0037 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([PQ/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_POSTGRESQL" = "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_0011 ; export LIXA_CRASH_POINT=11 ; lixa_test_exec.sh noreset none case0037 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([PQ/0.1/2.1 Automatic recovery])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; lixa_test_exec.sh noreset none case0037 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([PQ/0.1/2.2 Crash after end])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; export LIXA_CRASH_POINT=12 ; lixa_test_exec.sh noreset none case0037 1 0 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([PQ/0.1/2.3 Automatic recovery])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; lixa_test_exec.sh noreset none case0037 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([PQ/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_POSTGRESQL" = "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_0011 ; export LIXA_CRASH_POINT=14 ; lixa_test_exec.sh noreset none case0037 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([PQ/0.1/3.1 Automatic recovery])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; lixa_test_exec.sh noreset none case0037 1 0 0], [0], [ignore], [ignore])
AT_CLEANUP

# crash after prepare
AT_SETUP([PQ/0.1/4.0 Crash after prepare])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; export LIXA_CRASH_POINT=15 ; lixa_test_exec.sh noreset none case0037 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([PQ/0.1/4.1 Automatic recovery])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; lixa_test_exec.sh noreset none case0037 1 0 0], [0], [ignore], [ignore])
AT_CLEANUP

# crash after prepare
AT_SETUP([PQ/0.1/5.0 Crash after prepare])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; export LIXA_CRASH_POINT=15 ; lixa_test_exec.sh noreset stop case0037 1 1 0], [134], [ignore], [ignore])
AT_CLEANUP

AT_SETUP([PQ/0.1/5.1 Manual recovery])
AT_CHECK([if test "$LIXA_CRASH" = "no"; then exit 77; fi])
AT_CHECK([if test "$HAVE_POSTGRESQL" = "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_0011 ; 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_0011 ; lixa_test_exec.sh noreset stop lixar -p -r -X $TESTS_TMP_FILE2], [0], [ignore], [ignore])
AT_CLEANUP