1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 2003,2008 Oracle. All rights reserved. 4# 5# $Id: test106.tcl,v 12.9 2008/01/08 20:58:53 bostic Exp $ 6# 7# TEST test106 8# TEST 9# TEST 10# TEST 11proc test106 { method {nitems 100} {niter 200} {tnum "106"} args } { 12 source ./include.tcl 13 global dict 14 global rand_init 15 16 # Set random seed for use in t106script procs op2 and create_data. 17 error_check_good set_random_seed [berkdb srand $rand_init] 0 18 19 set args [convert_args $method $args] 20 set omethod [convert_method $method] 21 22 if { [is_btree $method] != 1 } { 23 puts "\tTest$tnum: Skipping for method $method." 24 return 25 } 26 27 # Skip for specified pagesizes. This test runs at the native 28 # pagesize. (For SR #7964 testing, we may need to force 29 # to 8192.) 30 set pgindex [lsearch -exact $args "-pagesize"] 31 if { $pgindex != -1 } { 32 puts "Test$tnum: Skipping for specific pagesizes" 33 return 34 } 35 36 # This test needs a txn-enabled environment. If one is not 37 # provided, create it. 38 # 39 set eindex [lsearch -exact $args "-env"] 40 if { $eindex == -1 } { 41 set env [berkdb_env -create -home $testdir -txn] 42 } else { 43 incr eindex 44 set env [lindex $args $eindex] 45 set txnenv [is_txnenv $env] 46 if { $txnenv != 1 } { 47 puts "Skipping test$tnum for non-txn environment." 48 return 49 } 50 set testdir [get_home $env] 51 } 52 53 cleanup $testdir $env 54 55 # The bulk of the work of this test is done in t106script.tcl. 56 # Here we kick off one consumer, then five producers, then sit 57 # back and wait for them to finish. 58 foreach order { ordered random } { 59 set nproducers 5 60 61 puts "\tTest$tnum.a: Start deadlock detector ($order)." 62 set dpid [exec $util_path/db_deadlock -a o -v -t 5\ 63 -h $testdir >& $testdir/dd.out &] 64 65 puts "\tTest$tnum.b: Start consumer process ($order)." 66 sentinel_init 67 set pidlist {} 68 set cpid [exec $tclsh_path $test_path/wrap.tcl t106script.tcl \ 69 $testdir/t106script.log.cons.$order.1 $testdir WAIT \ 70 0 $nproducers $testdir/CONSUMERLOG 1 $tnum $order $niter \ 71 $args &] 72 lappend pidlist $cpid 73 74 puts "\tTest$tnum.c: Initialize producers ($order)." 75 for { set p 1 } { $p <= $nproducers } { incr p } { 76 set ppid [exec $tclsh_path $test_path/wrap.tcl \ 77 t106script.tcl \ 78 $testdir/t106script.log.init.$order.$p \ 79 $testdir INITIAL $nitems $nproducers \ 80 $testdir/INITLOG.$p $p $tnum \ 81 $order $niter $args &] 82 lappend pidlist $ppid 83 } 84 85 # Wait for all producers to be initialized before continuing 86 # to the RMW portion of the test. 87 watch_procs $pidlist 10 88 89 sentinel_init 90 set pidlist {} 91 puts "\tTest$tnum.d: Run producers in RMW mode ($order)." 92 for { set p 1 } { $p <= $nproducers } { incr p } { 93 set ppid [exec $tclsh_path $test_path/wrap.tcl \ 94 t106script.tcl \ 95 $testdir/t106script.log.prod.$order.$p \ 96 $testdir PRODUCE $nitems $nproducers \ 97 $testdir/PRODUCERLOG.$p $p $tnum \ 98 $order $niter $args &] 99 lappend pidlist $ppid 100 } 101 102 watch_procs $pidlist 10 103 tclkill $dpid 104 } 105 106 # If this test created the env, close it. 107 if { $eindex == -1 } { 108 error_check_good env_close [$env close] 0 109 } 110} 111