Add new file ota12.test, containing tests for applying ota updates to live databases with other active reader/writer clients.
FossilOrigin-Name: 0864d127fe42fc0db7ab30a3ebf74c0114095648
This commit is contained in:
parent
e3e031ce85
commit
7551c5c3e6
172
ext/ota/ota12.test
Normal file
172
ext/ota/ota12.test
Normal file
@ -0,0 +1,172 @@
|
||||
# 2015 February 16
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
if {![info exists testdir]} {
|
||||
set testdir [file join [file dirname [info script]] .. .. test]
|
||||
}
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
set ::testprefix ota12
|
||||
|
||||
set setup_sql {
|
||||
DROP TABLE IF EXISTS xx;
|
||||
DROP TABLE IF EXISTS xy;
|
||||
CREATE TABLE xx(a, b, c PRIMARY KEY);
|
||||
INSERT INTO xx VALUES(1, 2, 3);
|
||||
CREATE TABLE xy(a, b, c PRIMARY KEY);
|
||||
|
||||
ATTACH 'ota.db' AS ota;
|
||||
DROP TABLE IF EXISTS data_xx;
|
||||
CREATE TABLE ota.data_xx(a, b, c, ota_control);
|
||||
INSERT INTO data_xx VALUES(4, 5, 6, 0);
|
||||
INSERT INTO data_xx VALUES(7, 8, 9, 0);
|
||||
CREATE TABLE ota.data_xy(a, b, c, ota_control);
|
||||
INSERT INTO data_xy VALUES(10, 11, 12, 0);
|
||||
DETACH ota;
|
||||
}
|
||||
|
||||
do_multiclient_test tn {
|
||||
|
||||
# Initialize a target (test.db) and ota (ota.db) database.
|
||||
#
|
||||
forcedelete ota.db
|
||||
sql1 $setup_sql
|
||||
|
||||
# Using connection 2, open a read transaction on the target database.
|
||||
# OTA will still be able to generate "test.db-oal", but it will not be
|
||||
# able to rename it to "test.db-wal".
|
||||
#
|
||||
do_test 1.$tn.1 {
|
||||
sql2 { BEGIN; SELECT * FROM xx; }
|
||||
} {1 2 3}
|
||||
do_test 1.$tn.2 {
|
||||
sqlite3ota ota test.db ota.db
|
||||
while 1 {
|
||||
set res [ota step]
|
||||
if {$res!="SQLITE_OK"} break
|
||||
}
|
||||
set res
|
||||
} {SQLITE_BUSY}
|
||||
|
||||
do_test 1.$tn.3 { sql2 { SELECT * FROM xx; } } {1 2 3}
|
||||
do_test 1.$tn.4 { sql2 { SELECT * FROM xy; } } {}
|
||||
do_test 1.$tn.5 {
|
||||
list [file exists test.db-wal] [file exists test.db-oal]
|
||||
} {0 1}
|
||||
do_test 1.$tn.6 { sql2 COMMIT } {}
|
||||
|
||||
# The ota object that hit the SQLITE_BUSY error above cannot be reused.
|
||||
# It is stuck in a permanent SQLITE_BUSY state at this point.
|
||||
#
|
||||
do_test 1.$tn.7 { ota step } {SQLITE_BUSY}
|
||||
do_test 1.$tn.8 {
|
||||
list [catch { ota close } msg] $msg
|
||||
} {1 SQLITE_BUSY}
|
||||
|
||||
do_test 1.$tn.9.1 { sql2 { BEGIN EXCLUSIVE } } {}
|
||||
do_test 1.$tn.9.2 {
|
||||
sqlite3ota ota test.db ota.db
|
||||
ota step
|
||||
} {SQLITE_BUSY}
|
||||
do_test 1.$tn.9.3 {
|
||||
list [catch { ota close } msg] $msg
|
||||
} {1 {SQLITE_BUSY - database is locked}}
|
||||
do_test 1.$tn.9.4 { sql2 COMMIT } {}
|
||||
|
||||
sqlite3ota ota test.db ota.db
|
||||
do_test 1.$tn.10.1 { sql2 { BEGIN EXCLUSIVE } } {}
|
||||
do_test 1.$tn.10.2 {
|
||||
ota step
|
||||
} {SQLITE_BUSY}
|
||||
do_test 1.$tn.10.3 {
|
||||
list [catch { ota close } msg] $msg
|
||||
} {1 SQLITE_BUSY}
|
||||
do_test 1.$tn.10.4 { sql2 COMMIT } {}
|
||||
|
||||
# A new ota object can finish the work though.
|
||||
#
|
||||
do_test 1.$tn.11 {
|
||||
sqlite3ota ota test.db ota.db
|
||||
ota step
|
||||
} {SQLITE_OK}
|
||||
do_test 1.$tn.12 {
|
||||
list [file exists test.db-wal] [file exists test.db-oal]
|
||||
} {1 0}
|
||||
do_test 1.$tn.13 {
|
||||
while 1 {
|
||||
set res [ota step]
|
||||
if {$res!="SQLITE_OK"} break
|
||||
}
|
||||
set res
|
||||
} {SQLITE_DONE}
|
||||
|
||||
do_test 1.$tn.14 {
|
||||
ota close
|
||||
} {SQLITE_DONE}
|
||||
}
|
||||
|
||||
do_multiclient_test tn {
|
||||
|
||||
# Initialize a target (test.db) and ota (ota.db) database.
|
||||
#
|
||||
forcedelete ota.db
|
||||
sql1 $setup_sql
|
||||
|
||||
do_test 2.$tn.1 {
|
||||
sqlite3ota ota test.db ota.db
|
||||
while {[file exists test.db-wal]==0} {
|
||||
if {[ota step]!="SQLITE_OK"} {error "problem here...."}
|
||||
}
|
||||
ota close
|
||||
} {SQLITE_OK}
|
||||
|
||||
|
||||
do_test 2.$tn.2 { sql2 { BEGIN IMMEDIATE } } {}
|
||||
|
||||
do_test 2.$tn.3 {
|
||||
sqlite3ota ota test.db ota.db
|
||||
ota step
|
||||
} {SQLITE_BUSY}
|
||||
|
||||
do_test 2.$tn.4 { list [catch { ota close } msg] $msg } {1 SQLITE_BUSY}
|
||||
|
||||
do_test 2.$tn.5 {
|
||||
sql2 { SELECT * FROM xx ; COMMIT }
|
||||
} {1 2 3 4 5 6 7 8 9}
|
||||
|
||||
do_test 2.$tn.6 {
|
||||
sqlite3ota ota test.db ota.db
|
||||
ota step
|
||||
ota close
|
||||
} {SQLITE_OK}
|
||||
|
||||
do_test 2.$tn.7 { sql2 { BEGIN EXCLUSIVE } } {}
|
||||
|
||||
do_test 2.$tn.8 {
|
||||
sqlite3ota ota test.db ota.db
|
||||
ota step
|
||||
} {SQLITE_BUSY}
|
||||
do_test 2.$tn.9 { list [catch { ota close } msg] $msg } {1 SQLITE_BUSY}
|
||||
do_test 2.$tn.10 {
|
||||
sql2 { SELECT * FROM xx ; COMMIT }
|
||||
} {1 2 3 4 5 6 7 8 9}
|
||||
|
||||
do_test 2.$tn.11 {
|
||||
sqlite3ota ota test.db ota.db
|
||||
while {[ota step]=="SQLITE_OK"} {}
|
||||
ota close
|
||||
} {SQLITE_DONE}
|
||||
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
11
manifest
11
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sota\stests\sto\sincrease\scode\scoverage.\sFix\ssome\sminor\sissues\sin\serror\shandling\swithin\sthe\sota\scode.
|
||||
D 2015-02-18T20:16:15.838
|
||||
C Add\snew\sfile\sota12.test,\scontaining\stests\sfor\sapplying\sota\supdates\sto\slive\sdatabases\swith\sother\sactive\sreader/writer\sclients.
|
||||
D 2015-02-18T20:17:14.502
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 6b9e7677829aa94b9f30949656e27312aefb9a46
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -128,6 +128,7 @@ F ext/ota/ota.c c11a85af71dccc45976622fe7a51169a481caa91
|
||||
F ext/ota/ota1.test ba408c5e777c320ef72f328e20cd2ae2a8888cda
|
||||
F ext/ota/ota10.test 85e0f6e7964db5007590c1b299e75211ed4240d4
|
||||
F ext/ota/ota11.test 2f606cd2b4af260a86b549e91b9f395450fc75cb
|
||||
F ext/ota/ota12.test 0dff44474de448fb4b0b28c20da63273a4149abb
|
||||
F ext/ota/ota3.test 1f12eba0b69ef12a45e5c17bb1bebd13211663e7
|
||||
F ext/ota/ota5.test ad0799daf8923ddebffe75ae8c5504ca90b7fadb
|
||||
F ext/ota/ota6.test 3bde7f69a894748b27206b6753462ec3b75b6bb6
|
||||
@ -1256,7 +1257,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 144bb29ffcbfe96dc10c0224113e73a80e89314b
|
||||
R 651c92e3909a9521816fc3a304b913d3
|
||||
P 2b10c5d2b8b8b535d3dec0c68a777db16268e1e5
|
||||
R e6e6a761469f9b7bde91bfe8bec8a34e
|
||||
U dan
|
||||
Z 24ae6a68f15f30a6afab37fb8335827c
|
||||
Z 3faf6af4ff9eafb0628a6c29cfea0807
|
||||
|
@ -1 +1 @@
|
||||
2b10c5d2b8b8b535d3dec0c68a777db16268e1e5
|
||||
0864d127fe42fc0db7ab30a3ebf74c0114095648
|
Loading…
Reference in New Issue
Block a user