/ Check-in [407b5ed3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add test cases for running multiple RBU operations within the same process concurrently.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 407b5ed35c178bb0dbc69c8b902652038a0653d55a58a7543f9d4857c6baf3ea
User & Date: dan 2018-01-11 16:16:03
Context
2018-01-11
17:33
Change zipfile to be a WITHOUT ROWID virtual table and table-valued function. check-in: 931201f6 user: dan tags: trunk
16:16
Add test cases for running multiple RBU operations within the same process concurrently. check-in: 407b5ed3 user: dan tags: trunk
14:50
Minor formatting changes in zipfile.c. No logical code differences. check-in: 4f68bed3 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added ext/rbu/rbumulti.test.

            1  +# 2018 January 11
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# This file contains tests of multiple RBU operations running
           13  +# concurrently within the same process. 
           14  +#
           15  +
           16  +source [file join [file dirname [info script]] rbu_common.tcl]
           17  +set ::testprefix rbumulti
           18  +
           19  +db close
           20  +sqlite3_shutdown
           21  +sqlite3_config_uri 1
           22  +
           23  +autoinstall_test_functions
           24  +
           25  +proc build_db {db} {
           26  +  $db eval {
           27  +    CREATE TABLE t1(a PRIMARY KEY, b, c);
           28  +    CREATE INDEX i1 ON t1(b);
           29  +    CREATE INDEX i2 ON t1(c);
           30  +
           31  +    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<500 )
           32  +    INSERT INTO t1 
           33  +    SELECT randomblob(10), randomblob(100), randomblob(100) FROM s;
           34  +  }
           35  +}
           36  +
           37  +proc build_rbu {db} {
           38  +  $db eval {
           39  +    CREATE TABLE data_t1(a, b, c, rbu_control);
           40  +    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100 )
           41  +    INSERT INTO data_t1 
           42  +    SELECT randomblob(10), randomblob(100), randomblob(100), 0 FROM s;
           43  +  }
           44  +}
           45  +
           46  +proc step_rbu2 {bOpenClose openr1 openr2} {
           47  +
           48  +  forcedelete teststate.db1
           49  +  forcedelete teststate.db2
           50  +
           51  +  if {$bOpenClose!=0 && $bOpenClose!=1} { error $bOpenClose }
           52  +  if {$bOpenClose==0} {
           53  +    eval $openr1 
           54  +    eval $openr2 
           55  +  }
           56  +
           57  +  set b1 0
           58  +  set b2 0
           59  +
           60  +  while {$b1==0 || $b2==0} {
           61  +    if {$bOpenClose==1} {
           62  +      if {$b1==0} { eval $openr1 teststate.db1 }
           63  +      if {$b2==0} { eval $openr2 teststate.db2 }
           64  +    }
           65  +    if {$b1==0} {
           66  +      set rc1 [r1 step]
           67  +      if {$rc1 != "SQLITE_OK"} { set b1 1 }
           68  +    }
           69  +    if {$b2==0} {
           70  +      set rc2 [r2 step]
           71  +      if {$rc2 != "SQLITE_OK"} { set b2 1 }
           72  +    }
           73  +    if {$bOpenClose==1} {
           74  +      if {$b1==0} { r1 close }
           75  +      if {$b2==0} { r2 close }
           76  +    }
           77  +  }
           78  +
           79  +  set rc1 [r1 close]
           80  +  set rc2 [r2 close]
           81  +
           82  +  list $rc1 $rc2
           83  +}
           84  +
           85  +
           86  +for {set i 0} {$i<=3} {incr i} {
           87  +
           88  +  if {$i & 0x01} {
           89  +    sqlite3rbu_create_vfs -default myrbu ""
           90  +  }
           91  +  set bOpenClose [expr $i>>1]
           92  +
           93  +  forcedelete test.db
           94  +  forcedelete test.db2
           95  +  forcedelete rbu.db
           96  +  forcedelete rbu.db2
           97  +  
           98  +  do_test 1.$i.0 {
           99  +    sqlite3 db test.db
          100  +    sqlite3 db2 test.db2
          101  +    build_db db
          102  +    build_db db2
          103  +  
          104  +    sqlite3 rbu1 rbu.db
          105  +    sqlite3 rbu2 rbu.db2
          106  +  
          107  +    build_rbu rbu1
          108  +    build_rbu rbu2
          109  +  
          110  +    rbu1 close
          111  +    rbu2 close
          112  +  } {}
          113  +
          114  +  set m1 [db eval {SELECT md5sum(a, b, c) FROM t1}]
          115  +  set m2 [db2 eval {SELECT md5sum(a, b, c) FROM t1}]
          116  +  
          117  +  do_test 1.$i.1 {
          118  +    step_rbu2 $bOpenClose {
          119  +      sqlite3rbu r1 test.db rbu.db
          120  +    } {
          121  +      sqlite3rbu r2 test.db2 rbu.db2
          122  +    }
          123  +  } {SQLITE_DONE SQLITE_DONE}
          124  +  
          125  +  do_execsql_test -db db  1.$i.2.1 { PRAGMA integrity_check } ok
          126  +  do_execsql_test -db db2 1.$i.2.2 { PRAGMA integrity_check } ok
          127  +
          128  +  do_execsql_test -db db  1.$i.3.1 { SELECT md5sum(a, b, c)==$m1 FROM t1 } 0
          129  +  do_execsql_test -db db2 1.$i.3.2 { SELECT md5sum(a, b, c)==$m2 FROM t1 } 0
          130  +  
          131  +  catch { db close }
          132  +  catch { db2 close }
          133  +  #-----------------------------------------------------------------------
          134  +  forcedelete test.db2
          135  +  forcedelete test.db
          136  +  forcedelete rbu.db2
          137  +  
          138  +  do_test 1.$i.4 {
          139  +    sqlite3 db test.db
          140  +    sqlite3 db2 test.db2
          141  +    build_db db
          142  +    build_db db2
          143  +    sqlite3 rbu2 rbu.db2
          144  +    build_rbu rbu2
          145  +    rbu2 close
          146  +  } {}
          147  +
          148  +  set m1 [db eval {SELECT md5sum(a, b, c) FROM t1}]
          149  +  set m2 [db2 eval {SELECT md5sum(a, b, c) FROM t1}]
          150  +
          151  +  do_test 1.$i.5 {
          152  +    step_rbu2 $bOpenClose {
          153  +      sqlite3rbu_vacuum r1 test.db
          154  +    } {
          155  +      sqlite3rbu r2 test.db2 rbu.db2
          156  +    }
          157  +  } {SQLITE_DONE SQLITE_DONE}
          158  +
          159  +  do_execsql_test -db db  1.$i.6.1 { SELECT md5sum(a, b, c)==$m1 FROM t1 } 1
          160  +  do_execsql_test -db db2 1.$i.6.2 { SELECT md5sum(a, b, c)==$m2 FROM t1 } 0
          161  +
          162  +  do_execsql_test -db db  1.$i.7.1 { PRAGMA integrity_check } ok
          163  +  do_execsql_test -db db2 1.$i.7.2 { PRAGMA integrity_check } ok
          164  +
          165  +  catch { db close }
          166  +  catch { db2 close }
          167  +  if {$i & 0x01} {
          168  +    sqlite3rbu_destroy_vfs myrbu
          169  +  }
          170  +
          171  +}
          172  +
          173  +
          174  +finish_test
          175  +