1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Small random tester
10
# TEST Runs a number of random add/delete/retrieve operations.
11
# TEST Tests both successful conditions and error conditions.
13
# TEST Run the random db tester on the specified access method.
16
# -adds <maximum number of keys before you disable adds>
17
# -cursors <number of cursors>
18
# -dataavg <average data size>
19
# -delete <minimum number of keys before you disable deletes>
20
# -dups <allow duplicates in file>
21
# -errpct <Induce errors errpct of the time>
22
# -init <initial number of entries in database>
23
# -keyavg <average key size>
24
proc test045 { method {nops 10000} args } {
29
# If we are using an env, then skip this test. It needs its own.
30
set eindex [lsearch -exact $args "-env"]
31
if { $eindex != -1 } {
33
set env [lindex $args $eindex]
34
puts "Test045 skipping for env $env"
37
set args [convert_args $method $args]
38
if { $encrypt != 0 } {
39
puts "Test045 skipping for security"
42
set omethod [convert_method $method]
44
puts "Test045: Random tester on $method for $nops operations"
46
# Set initial parameters
47
set adds [expr $nops * 10]
54
if { [is_record_based $method] == 1 } {
62
for { set i 0 } { $i < [llength $args] } {incr i} {
63
switch -regexp -- [lindex $args $i] {
64
-adds { incr i; set adds [lindex $args $i] }
65
-cursors { incr i; set cursors [lindex $args $i] }
66
-dataavg { incr i; set dataavg [lindex $args $i] }
67
-delete { incr i; set delete [lindex $args $i] }
68
-dups { incr i; set dups [lindex $args $i] }
69
-errpct { incr i; set errpct [lindex $args $i] }
70
-init { incr i; set init [lindex $args $i] }
71
-keyavg { incr i; set keyavg [lindex $args $i] }
73
lappend oargs "-extent" "100" }
74
default { lappend oargs [lindex $args $i] }
78
# Create the database and and initialize it.
79
set root $testdir/test045
83
# Run the script with 3 times the number of initial elements to
85
set db [eval {berkdb_open \
86
-create -mode 0644 $omethod} $oargs {$f}]
87
error_check_good dbopen:$f [is_valid_db $db] TRUE
90
error_check_good dbclose:$f $r 0
92
# We redirect standard out, but leave standard error here so we
95
puts "\tTest045.a: Initializing database"
97
set n [expr 3 * $init]
99
$test_path/dbscript.tcl $method $f $n \
100
1 $init $n $keyavg $dataavg $dups 0 -1 \
101
> $testdir/test045.init
103
# Check for test failure
104
set e [findfail $testdir/test045.init]
105
error_check_good "FAIL: error message(s) in init file" $e 0
107
puts "\tTest045.b: Now firing off berkdb rand dbscript, running: "
108
# Now the database is initialized, run a test
110
$test_path/dbscript.tcl $method $f $nops $cursors $delete $adds \
111
$keyavg $dataavg $dups $errpct > $testdir/test045.log"
114
$test_path/dbscript.tcl $method $f \
115
$nops $cursors $delete $adds $keyavg \
116
$dataavg $dups $errpct \
117
> $testdir/test045.log
119
# Check for test failure
120
set e [findfail $testdir/test045.log]
121
error_check_good "FAIL: error message(s) in log file" $e 0