/ Check-in [abb6e076]
Login

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

Overview
Comment:Add tests to this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | server-process-edition
Files: files | file ages | folders
SHA3-256:abb6e076c851c0b10f62c02d0d7e54f24d86c75f01036dddbc0a8a7dfc627a0d
User & Date: dan 2017-08-18 18:55:22
Context
2017-08-19
15:50
Ensure that write-locks on pages are dropped at the end of each write transaction, even if there is still a read transaction open. check-in: 2dd36ade user: dan tags: server-process-edition
2017-08-18
18:55
Add tests to this branch. check-in: abb6e076 user: dan tags: server-process-edition
16:04
Do not search for locks to clear when connecting to a db in multi-process mode unless it looks like the previous user of the client-id crashed. check-in: 66fb9e1c user: dan tags: server-process-edition
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/permutations.test.

274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
  All FTS5 tests.
} -files [glob -nocomplain $::testdir/../ext/fts5/test/*.test]

test_suite "server" -prefix "" -description {
  All server-edition tests.
} -files [
  test_set \
      select1.test server2.test server3.test server4.test server5.test \
      servercrash.test
]

test_suite "fts5-light" -prefix "" -description {
  All FTS5 tests.
} -files [
  test_set \
      [glob -nocomplain $::testdir/../ext/fts5/test/*.test] \







|
|







274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
  All FTS5 tests.
} -files [glob -nocomplain $::testdir/../ext/fts5/test/*.test]

test_suite "server" -prefix "" -description {
  All server-edition tests.
} -files [
  test_set \
      select1.test server2.test server3.test serverfreelist.test \
      serverreadonly.test servercrash.test serverlimit.test
]

test_suite "fts5-light" -prefix "" -description {
  All FTS5 tests.
} -files [
  test_set \
      [glob -nocomplain $::testdir/../ext/fts5/test/*.test] \

Changes to test/server_common.tcl.

27
28
29
30
31
32
33

34
35
36





37
38
39


proc server_reset_db {} {
  catch {db close}
  forcedelete test.db test.db-journal test.db-wal
  file mkdir test.db-journal
  server_sqlite3 db test.db 
}


set ::server_vfs unix-excl
proc server_set_vfs {vfs} {





  set ::server_vfs $vfs
}









>



>
>
>
>
>
|
|
|
>
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

proc server_reset_db {} {
  catch {db close}
  forcedelete test.db test.db-journal test.db-wal
  file mkdir test.db-journal
  server_sqlite3 db test.db 
}


set ::server_vfs unix-excl
proc server_set_vfs {vfs} {
  if {$vfs=="single"} {
    set ::server_vfs unix-excl
  } elseif {$vfs=="multi"} {
    set ::server_vfs unix
  } else {
    set ::server_vfs $vfs
  }
}

Name change from test/server5.test to test/serverfreelist.test.

Added test/serverlimit.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
173
174
175
176
177
# 2017 April 25
#
# 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.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the server mode of SQLite.
#


set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix serverlimit

source $testdir/server_common.tcl
source $testdir/lock_common.tcl
return_if_no_server

#-------------------------------------------------------------------------
# Test plan:
#
#   1.* The concurrent connections limit in multi-process mode. With all
#       connections in the local process.
#
#   2.* The concurrent connections limit in multi-process mode. Using
#       multiple processes.
#
#   3.* The concurrent transactions limit in single-process mode.
#

server_set_vfs multi
server_reset_db

set MLIMIT 16           ;# maximum number of allowed connections

do_test 1.0 {
  server_sqlite3 db test.db
  db eval {
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES('hello'), ('world');
  }
  db close
  for {set i 0} {$i < $MLIMIT} {incr i} {
    server_sqlite3 db.$i test.db
    db.$i eval { SELECT * FROM t1 }
  }
  set {} {}
} {}

# Connection [db] cannot connect - all client slots are occupied.
#
do_test 1.1 {
  server_sqlite3 db test.db
  list [catch { db eval { SELECT * FROM t1 } } msg] $msg
} {1 {database is locked}}

# But, if one connection disconnects, [db] can then connect and
# query the db.
#
do_test 1.2 {
  db.0 close
  list [catch { db eval { SELECT * FROM t1 } } msg] $msg
} {0 {hello world}}

do_test 1.3 {
  for {set i 0} {$i < $MLIMIT} {incr i} {
    catch { db.$i close }
  }
  set {} {}
} {}

#-------------------------------------------------------------------------
# Connections in different processes.
do_multiclient_test tn {
  code1 { db close }
  code2 { db2 close }
  code3 { db3 close }

  set N1 [expr $MLIMIT / 2]
  set N2 [expr $MLIMIT - $N1]

  do_test 2.$tn.0 {
    file mkdir test.db-journal
    code1 {
      sqlite3 db test.db
      db eval {
        CREATE TABLE t11(a, b);
        INSERT INTO t11 VALUES(1, 2), (3, 4);
      }
      db close

      for {set i 0} {$i < $N1} {incr i} {
        sqlite3 db.$i test.db
        db.$i eval { SELECT * FROM t11 }
      }
    }

    code2 [string map [list %N2% $N2] {
      for {set i 0} {$i < %N2%} {incr i} {
        sqlite3 db2.$i test.db
        db2.$i eval { SELECT * FROM t11 }
      }
    }]

    code2 { db2.0 eval {SELECT * FROM t11} }
  } {1 2 3 4}

  do_test 2.$tn.1 {
    code3 { sqlite3 db3 test.db }
    csql3 { SELECT * FROM t11 }
  } {1 {database is locked}}

  do_test 2.$tn.2 {
    code2 { db2.0 close }
    csql3 { SELECT * FROM t11 }
  } {0 {1 2 3 4}}

  do_test 2.$tn.3 {
    code1 { sqlite3 db test.db }
    csql1 { SELECT * FROM t11 }
  } {1 {database is locked}}

  do_test 2.$tn.4 {
    code2 { db2.1 close }
    csql1 { SELECT * FROM t11 }
  } {0 {1 2 3 4}}

  do_test 2.$tn.X {
    code1 { for {set i 0} {$i < 50} {incr i} { catch {db.$i close} } }
    code2 { for {set i 0} {$i < 50} {incr i} { catch {db2.$i close} } }
  } {}
}

server_set_vfs single
server_reset_db

set TLIMIT 16

do_test 3.0 {
  execsql "CREATE TABLE t1 (o PRIMARY KEY) WITHOUT ROWID"
  for {set i 0} {$i < $TLIMIT} {incr i} {
    execsql "CREATE TABLE x$i (o PRIMARY KEY) WITHOUT ROWID"
  }
  set "" ""
} {}
do_test 3.1 {
  for {set i 0} {$i < $TLIMIT} {incr i} {
    sqlite3 db.$i test.db
    db.$i eval "
      BEGIN;
        INSERT INTO x$i VALUES ('one');
    "
  }
} {}
do_catchsql_test 3.2 {
  INSERT INTO t1 VALUES('two');
} {1 {database is locked}}
do_test 3.3 {
  db.0 eval COMMIT
  execsql { INSERT INTO t1 VALUES('two'); }
} {}
do_catchsql_test 3.4 { SELECT * FROM x1 } {1 {database is locked}}
do_catchsql_test 3.5 { SELECT * FROM x0 } {0 one}
do_test 3.6 {
  for {set i 1} {$i < $TLIMIT} {incr i} {
    db.$i eval COMMIT
  }
} {}


finish_test

Name change from test/server4.test to test/serverreadonly.test.