1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 2000,2008 Oracle. All rights reserved. 4# 5# $Id: test076.tcl,v 12.7 2008/01/08 20:58:53 bostic Exp $ 6# 7# TEST test076 8# TEST Test creation of many small databases in a single environment. [#1528]. 9proc test076 { method { ndbs 1000 } { tnum "076" } args } { 10 global is_qnx_test 11 source ./include.tcl 12 13 set args [convert_args $method $args] 14 set encargs "" 15 set args [split_encargs $args encargs] 16 set omethod [convert_method $method] 17 18 if { [is_record_based $method] == 1 } { 19 set key "" 20 } else { 21 set key "key" 22 } 23 set data "datamoredatamoredata" 24 25 # Create an env if we weren't passed one. 26 set txnenv 0 27 set eindex [lsearch -exact $args "-env"] 28 if { $eindex == -1 } { 29 set deleteenv 1 30 env_cleanup $testdir 31 set env [eval {berkdb_env -create -home} $testdir $encargs] 32 error_check_good env [is_valid_env $env] TRUE 33 set args "$args -env $env" 34 } else { 35 set deleteenv 0 36 incr eindex 37 set env [lindex $args $eindex] 38 set txnenv [is_txnenv $env] 39 if { $txnenv == 1 } { 40 append args " -auto_commit " 41 if { $ndbs == 1000 } { 42 set ndbs 100 43 } 44 } 45 set testdir [get_home $env] 46 } 47 if { $is_qnx_test && $ndbs > 100 } { 48 set ndbs 100 49 } 50 if { [is_queueext $method] } { 51 set ndbs 500 52 } 53 54 puts -nonewline "Test$tnum $method ($args): " 55 puts -nonewline "Create $ndbs" 56 puts " small databases in one env." 57 58 cleanup $testdir $env 59 set txn "" 60 61 for { set i 1 } { $i <= $ndbs } { incr i } { 62 set testfile test$tnum.$i.db 63 64 set db [eval {berkdb_open -create -mode 0644}\ 65 $args $omethod $testfile] 66 error_check_good db_open($i) [is_valid_db $db] TRUE 67 68 if { $txnenv == 1 } { 69 set t [$env txn] 70 error_check_good txn [is_valid_txn $t $env] TRUE 71 set txn "-txn $t" 72 } 73 set ret [eval {$db put} $txn {$key$i \ 74 [chop_data $method $data$i]}] 75 error_check_good db_put($i) $ret 0 76 if { $txnenv == 1 } { 77 error_check_good txn [$t commit] 0 78 } 79 error_check_good db_close($i) [$db close] 0 80 } 81 82 if { $deleteenv == 1 } { 83 error_check_good env_close [$env close] 0 84 } 85 86 puts "\tTest$tnum passed." 87} 88