Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add new file ota12.test, containing tests for applying ota updates to live databases with other active reader/writer clients. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | ota-update |
Files: | files | file ages | folders |
SHA1: |
0864d127fe42fc0db7ab30a3ebf74c01 |
User & Date: | dan 2015-02-18 20:17:14.502 |
Context
2015-02-19
| ||
13:36 | Add tests for a couple of previously untested branches in the ota code. (check-in: a3c1bc5d5e user: dan tags: ota-update) | |
2015-02-18
| ||
20:17 | Add new file ota12.test, containing tests for applying ota updates to live databases with other active reader/writer clients. (check-in: 0864d127fe user: dan tags: ota-update) | |
20:16 | Add ota tests to increase code coverage. Fix some minor issues in error handling within the ota code. (check-in: 2b10c5d2b8 user: dan tags: ota-update) | |
Changes
Added ext/ota/ota12.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 |