Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | For the stress test: 1) if a workload hits an 'expected' error, it should still perform the remaining iterations. 2) make sure to capture all trace output from the core SQLite library. 3) allow the 'small' and 'big' chunk sizes to be overridden via the command line. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | threadAbortProtect |
Files: | files | file ages | folders |
SHA1: |
c81fcd679429d2e3dbc9a4bb134137c5 |
User & Date: | mistachkin 2012-10-12 16:20:01.332 |
Context
2012-10-13
| ||
06:14 | Update SQLite core library to latest trunk code. Centralize sqlite3_shutdown handling in the test suite infrastructure. check-in: 986baaa70f user: mistachkin tags: threadAbortProtect | |
2012-10-12
| ||
16:20 | For the stress test: 1) if a workload hits an 'expected' error, it should still perform the remaining iterations. 2) make sure to capture all trace output from the core SQLite library. 3) allow the 'small' and 'big' chunk sizes to be overridden via the command line. check-in: c81fcd6794 user: mistachkin tags: threadAbortProtect | |
16:09 | Add a LogMessage method overload to the SQLiteConnection class that takes a SQLiteErrorCode. check-in: d874518f31 user: mistachkin tags: threadAbortProtect | |
Changes
Changes to Tests/stress.eagle.
︙ | ︙ | |||
16 17 18 19 20 21 22 23 24 | ############################################################################### package require System.Data.SQLite.Test runSQLiteTestPrologue ############################################################################### runTest {test stress-1.1 {multithreaded stress testing} -setup { unset -nocomplain result thread index workload noWorkload srcDb db \ | > > > > > > > > > > > | > | 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 | ############################################################################### package require System.Data.SQLite.Test runSQLiteTestPrologue ############################################################################### # # NOTE: Make sure that SQLite core library is completely shutdown prior to # starting any of the tests in this file. # if {[haveConstraint SQLite]} then { object invoke -flags +NonPublic System.Data.SQLite.UnsafeNativeMethods \ sqlite3_shutdown } ############################################################################### runTest {test stress-1.1 {multithreaded stress testing} -setup { unset -nocomplain result thread index workload noWorkload srcDb db \ fileName compiled options count times logFileName logListener \ connection ############################################################################# proc expectedError { error } { return [expr {[regexp -- {\sno such table: t1\s} $error] || \ [regexp -- {\sdatabase is locked\s} $error]}] } |
︙ | ︙ | |||
47 48 49 50 51 52 53 | \n [info level $level] ": " $error \n] exit Failure; # halt all testing now. } ############################################################################# | | | | | > | < > | > | > | | > > > | > > > > > > > > > > > > > | > > > > > > > > > > | > > > > > > > > > > > > | 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 | \n [info level $level] ": " $error \n] exit Failure; # halt all testing now. } ############################################################################# proc setupLogging { fileName } { if {![info exists ::logListener]} then { set ::logListener [object create -alias \ System.Diagnostics.TextWriterTraceListener $fileName] } object invoke System.Diagnostics.Trace.Listeners Add $::logListener object invoke System.Data.SQLite.SQLiteLog Initialize tputs $::test_channel [appendArgs \ "---- enabled SQLite trace logging to file \"" $fileName \"\n] } ############################################################################# proc cleanupLogging { fileName } { if {[info exists ::logListener]} then { object invoke System.Diagnostics.Trace.Listeners Remove $::logListener $::logListener Close } # # NOTE: Copy the trace listener log file to the main test log file. # tlog "---- BEGIN TRACE LISTENER OUTPUT\n" tlog [readFile $fileName] tlog "\n---- END TRACE LISTENER OUTPUT\n" # # NOTE: Delete the trace listener log file because its contents have # been copied to the main test log file. # cleanupFile $fileName tputs $::test_channel [appendArgs \ "---- disabled SQLite trace logging to file \"" $fileName \"\n] } ############################################################################# # # NOTE: The trace listener used with the SQLiteLog class to capture output # from the core SQLite library requires its own log file because the # TextWriterTraceListener class opens and locks the log file it uses # as the basis of the output stream. Before this test is complete, # the entire contents of this trace log file will be copied into the # main test log file and then deleted. # set logFileName [appendArgs $test_log .trace] setupLogging $logFileName ############################################################################# set count(0) 1 set count(1) 5 set count(2) 300 set count(3) 57 set count(4) 10000000 set noWorkload [list] if {[info exists argv] && [llength $argv] > 0} then { parse options -flags \ {-StopOnUnknownOption +IgnoreOnUnknownOption SkipOnUnknownOption} -- \ [list [list null MustHaveIntegerValue -1 -1 -count0 $count(0)] \ [list null MustHaveIntegerValue -1 -1 -count1 $count(1)] \ [list null MustHaveIntegerValue -1 -1 -count2 $count(2)] \ [list null MustHaveIntegerValue -1 -1 -count3 $count(3)] \ [list null MustHaveIntegerValue -1 -1 -count4 $count(4)] \ [list null MustHaveListValue -1 -1 -noWorkload $noWorkload]] $argv set count(0) $options(-count0,value) set count(1) $options(-count1,value) set count(2) $options(-count2,value) set count(3) $options(-count3,value) set count(4) $options(-count4,value) set noWorkload $options(-noWorkload,value) } ############################################################################# tputs $test_channel [appendArgs \ "---- workloads will repeat " $count(0) " time(s)...\n"] tputs $test_channel [appendArgs \ "---- workloads will have " $count(1) " iteration(s)...\n"] tputs $test_channel [appendArgs \ "---- workloads will wait at least " $count(2) " millisecond(s)...\n"] tputs $test_channel [appendArgs \ "---- workload \"small\" chunk size is " $count(3) " byte(s)...\n"] tputs $test_channel [appendArgs \ "---- workload \"big\" chunk size is " $count(4) " byte(s)...\n"] if {[llength $noWorkload] > 0} then { tputs $test_channel [appendArgs \ "---- workloads to be skipped... " $noWorkload \n] } ############################################################################# |
︙ | ︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 | ############################################################################# setupDb $fileName(1) "" "" "" "" "" false false true true srcDb setupDb $fileName(2) ############################################################################# set workload(1) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #1, CREATE TABLE statements. # lappend ::times(1) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false | > > > > > > > < | > < | | | | | > < | > < | | | | | > < | > < | | | | | > < | > < | | | | | > < | > | < | | | | | > < | > | < | | | | | > < | > | < | | | | | > < | > | > | < | | | | | > < | > < | | | | | > < | > < | | | | | > < | > < | | | | | > | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | ############################################################################# setupDb $fileName(1) "" "" "" "" "" false false true true srcDb setupDb $fileName(2) ############################################################################# set connection [getDbConnection] $connection LogMessage Ok [appendArgs \ "starting stress test using database \"" $fileName(2) "\"..."] ############################################################################# set workload(1) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #1, CREATE TABLE statements. # lappend ::times(1) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 2} {$index <= $count} {incr index} { if {[catch { sql execute $db [appendArgs \ "CREATE TABLE IF NOT EXISTS t" $index "(x PRIMARY KEY, y, z);"] showTest A } error]} then { if {[expectedError $error]} then { showTest a } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# set workload(2) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #2, DROP TABLE statements. # lappend ::times(2) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 2} {$index <= $count} {incr index} { if {[catch { sql execute $db [appendArgs \ "DROP TABLE IF EXISTS t" $index \;] showTest B } error]} then { if {[expectedError $error]} then { showTest b } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# set workload(3) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #3, "small" SELECT statements. # lappend ::times(3) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 1} {$index <= $count} {incr index} { if {[catch { sql execute -execute reader $db [appendArgs \ "SELECT x, y FROM " $table " WHERE z = 'small';"] showTest C } error]} then { if {[expectedError $error]} then { showTest c } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# set workload(4) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #4, "big" SELECT statements. # lappend ::times(4) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 1} {$index <= $count} {incr index} { if {[catch { sql execute -execute reader $db [appendArgs \ "SELECT x, y FROM " $table " WHERE z = 'big';"] showTest D } error]} then { if {[expectedError $error]} then { showTest d } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# set workload(5) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #5, "small" INSERT statements. # lappend ::times(5) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 1} {$index <= $count} {incr index} { if {[catch { sql execute $db [appendArgs \ "INSERT INTO " $table "(x, y, z) VALUES('" \ [format %lX [expr {random()}]] "', '" \ [base64 encode -- [expr {randstr($::count(3))}]] \ "', 'small');"] showTest E } error]} then { if {[expectedError $error]} then { showTest e } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# set workload(6) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #6, "big" INSERT statements. # lappend ::times(6) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 1} {$index <= $count} {incr index} { if {[catch { sql execute $db [appendArgs \ "INSERT INTO " $table "(x, y, z) VALUES('" \ [format %lX [expr {random()}]] \ "', RANDOMBLOB(" $::count(4) "), 'big');"] showTest F } error]} then { if {[expectedError $error]} then { showTest f } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# set workload(7) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #7, "small" UPDATE statements. # lappend ::times(7) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 1} {$index <= $count} {incr index} { if {[catch { sql execute $db [appendArgs "UPDATE " $table \ " SET y = '" [base64 encode -- [expr {randstr($::count(3))}]] \ "' WHERE x LIKE '" [format %X $index] "%' AND z = 'small';"] showTest G } error]} then { if {[expectedError $error]} then { showTest g } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# set workload(8) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #8, "big" UPDATE statements. # lappend ::times(8) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 1} {$index <= $count} {incr index} { if {[catch { sql execute $db [appendArgs "UPDATE " $table \ " SET y = RANDOMBLOB(" $::count(4) \ ") WHERE x LIKE '" [format %X $index] \ "%' AND z = 'big';"] showTest H } error]} then { if {[expectedError $error]} then { showTest h } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# set workload(9) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #9, "small" DELETE statements. # lappend ::times(9) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 1} {$index <= $count} {incr index} { if {[catch { sql execute $db [appendArgs "DELETE FROM " $table \ " WHERE x LIKE '" [format %X $index] "%' AND z = 'small';"] showTest I } error]} then { if {[expectedError $error]} then { showTest i } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# set workload(10) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #10, "big" DELETE statements. # lappend ::times(10) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 1} {$index <= $count} {incr index} { if {[catch { sql execute $db [appendArgs "DELETE FROM " $table \ " WHERE x LIKE '" [format %X $index] "%' AND z = 'big';"] showTest J } error]} then { if {[expectedError $error]} then { showTest j } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# set workload(11) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #11, VACUUM statement. # lappend ::times(11) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 1} {$index <= $count} {incr index} { if {[catch { sql execute $db "VACUUM;" showTest K } error]} then { if {[expectedError $error]} then { showTest k } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# |
︙ | ︙ | |||
581 582 583 584 585 586 587 | set workload(14) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #14, PRAGMA integrity check statement. # lappend ::times(14) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false | < | > < | | | | | > < | > < | | | | | > | 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 | set workload(14) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #14, PRAGMA integrity check statement. # lappend ::times(14) [lindex [time { setupDb $dstFileName "" "" "" "" "" true false for {set index 1} {$index <= $count} {incr index} { if {[catch { set result [sql execute -execute scalar $db \ "PRAGMA integrity_check;"] if {$result eq "ok"} then { showTest N } else { error [appendArgs "integrity check failed: " $result] } } error]} then { if {[expectedError $error]} then { showTest n } else { failTest $error } } } cleanupDb $dstFileName db false true false }] 0] }] ############################################################################# set workload(15) [list [list srcFileName dstFileName table count] { # # NOTE: Workload #15, force managed garbage collection # lappend ::times(15) [lindex [time { for {set index 1} {$index <= $count} {incr index} { if {[catch { collectGarbage $::test_channel showTest O } error]} then { if {[expectedError $error]} then { showTest o } else { failTest $error } } } }] 0] }] } -body { for {set index(0) 0} {$index(0) < $count(0)} {incr index(0)} { sql execute $db "CREATE TABLE IF NOT EXISTS t1(x PRIMARY KEY, y, z);" |
︙ | ︙ | |||
692 693 694 695 696 697 698 | foreach index(0) [array names workload] { catch { object removecallback [list apply $workload($index(0)) $fileName(1) \ $fileName(2) t1 $count(1)] } } | > > | < | > | 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 | foreach index(0) [array names workload] { catch { object removecallback [list apply $workload($index(0)) $fileName(1) \ $fileName(2) t1 $count(1)] } } freeDbConnection cleanupLogging $logFileName rename cleanupLogging "" rename setupLogging "" unset -nocomplain result thread index workload noWorkload srcDb db \ fileName compiled options count times logFileName logListener \ connection } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result {}} ############################################################################### runSQLiteTestEpilogue runTestEpilogue |