~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/test/test065.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# See the file LICENSE for redistribution information.
2
 
#
3
 
# Copyright (c) 1999-2002
4
 
#       Sleepycat Software.  All rights reserved.
5
 
#
6
 
# $Id$
7
 
#
8
 
# TEST  test065
9
 
# TEST  Test of DB->stat(DB_FASTSTAT)
10
 
proc test065 { method args } {
11
 
        source ./include.tcl
12
 
        global errorCode
13
 
        global alphabet
14
 
 
15
 
        set nentries 10000
16
 
        set args [convert_args $method $args]
17
 
        set omethod [convert_method $method]
18
 
        set tnum 65
19
 
 
20
 
        set txnenv 0
21
 
        set eindex [lsearch -exact $args "-env"]
22
 
        #
23
 
        # If we are using an env, then testfile should just be the db name.
24
 
        # Otherwise it is the test directory and the name.
25
 
        if { $eindex == -1 } {
26
 
                set testfile $testdir/test0$tnum.db
27
 
                set env NULL
28
 
        } else {
29
 
                set testfile test0$tnum.db
30
 
                incr eindex
31
 
                set env [lindex $args $eindex]
32
 
                set txnenv [is_txnenv $env]
33
 
                if { $txnenv == 1 } {
34
 
                        append args " -auto_commit "
35
 
                        #
36
 
                        # If we are using txns and running with the 
37
 
                        # default, set the default down a bit.
38
 
                        #
39
 
                        if { $nentries == 10000 } {
40
 
                                set nentries 100
41
 
                        }
42
 
                }
43
 
                set testdir [get_home $env]
44
 
        }
45
 
        cleanup $testdir $env
46
 
 
47
 
        puts "Test0$tnum: $method ($args) DB->stat(DB_FAST_STAT) test."
48
 
 
49
 
        puts "\tTest0$tnum.a: Create database and check it while empty."
50
 
 
51
 
        set db [eval {berkdb_open_noerr -create -mode 0644} \
52
 
            $omethod $args $testfile]
53
 
        error_check_good db_open [is_valid_db $db] TRUE
54
 
 
55
 
        set ret [catch {eval $db stat -faststat} res]
56
 
 
57
 
        error_check_good db_close [$db close] 0
58
 
 
59
 
        if { ([is_record_based $method] && ![is_queue $method]) \
60
 
            || [is_rbtree $method] } {
61
 
                error_check_good recordcount_ok [is_substr $res \
62
 
                    "{{Number of keys} 0}"] 1
63
 
        } else {
64
 
                puts "\tTest0$tnum: Test complete for method $method."
65
 
                return
66
 
        }
67
 
 
68
 
        # If we've got this far, we're on an access method for
69
 
        # which record counts makes sense.  Thus, we no longer
70
 
        # catch EINVALs, and no longer care about __db_errs.
71
 
        set db [eval {berkdb_open -create -mode 0644} $omethod $args $testfile]
72
 
 
73
 
        puts "\tTest0$tnum.b: put $nentries keys."
74
 
 
75
 
        if { [is_record_based $method] } {
76
 
                set gflags " -recno "
77
 
                set keypfx ""
78
 
        } else {
79
 
                set gflags ""
80
 
                set keypfx "key"
81
 
        }
82
 
 
83
 
        set txn ""
84
 
        set data [pad_data $method $alphabet]
85
 
 
86
 
        for { set ndx 1 } { $ndx <= $nentries } { incr ndx } {
87
 
                if { $txnenv == 1 } {
88
 
                        set t [$env txn]
89
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
90
 
                        set txn "-txn $t"
91
 
                }
92
 
                set ret [eval {$db put} $txn {$keypfx$ndx $data}]
93
 
                error_check_good db_put $ret 0
94
 
                if { $txnenv == 1 } {
95
 
                        error_check_good txn [$t commit] 0
96
 
                }
97
 
        }
98
 
 
99
 
        set ret [$db stat -faststat]
100
 
        error_check_good recordcount_after_puts \
101
 
            [is_substr $ret "{{Number of keys} $nentries}"] 1
102
 
 
103
 
        puts "\tTest0$tnum.c: delete 90% of keys."
104
 
        set end [expr {$nentries / 10 * 9}]
105
 
        for { set ndx 1 } { $ndx <= $end } { incr ndx } {
106
 
                if { $txnenv == 1 } {
107
 
                        set t [$env txn]
108
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
109
 
                        set txn "-txn $t"
110
 
                }
111
 
                if { [is_rrecno $method] == 1 } {
112
 
                        # if we're renumbering, when we hit key 5001 we'll
113
 
                        # have deleted 5000 and we'll croak!  So delete key
114
 
                        # 1, repeatedly.
115
 
                        set ret [eval {$db del} $txn {[concat $keypfx 1]}]
116
 
                } else {
117
 
                        set ret [eval {$db del} $txn {$keypfx$ndx}]
118
 
                }
119
 
                error_check_good db_del $ret 0
120
 
                if { $txnenv == 1 } {
121
 
                        error_check_good txn [$t commit] 0
122
 
                }
123
 
        }
124
 
 
125
 
        set ret [$db stat -faststat]
126
 
        if { [is_rrecno $method] == 1 || [is_rbtree $method] == 1 } {
127
 
                # We allow renumbering--thus the stat should return 10%
128
 
                # of nentries.
129
 
                error_check_good recordcount_after_dels [is_substr $ret \
130
 
                    "{{Number of keys} [expr {$nentries / 10}]}"] 1
131
 
        } else {
132
 
                # No renumbering--no change in RECORDCOUNT!
133
 
                error_check_good recordcount_after_dels \
134
 
                    [is_substr $ret "{{Number of keys} $nentries}"] 1
135
 
        }
136
 
 
137
 
        puts "\tTest0$tnum.d: put new keys at the beginning."
138
 
        set end [expr {$nentries / 10 * 8}]
139
 
        for { set ndx 1 } { $ndx <= $end } {incr ndx } {
140
 
                if { $txnenv == 1 } {
141
 
                        set t [$env txn]
142
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
143
 
                        set txn "-txn $t"
144
 
                }
145
 
                set ret [eval {$db put} $txn {$keypfx$ndx $data}]
146
 
                error_check_good db_put_beginning $ret 0
147
 
                if { $txnenv == 1 } {
148
 
                        error_check_good txn [$t commit] 0
149
 
                }
150
 
        }
151
 
 
152
 
        set ret [$db stat -faststat]
153
 
        if { [is_rrecno $method] == 1 } {
154
 
                # With renumbering we're back up to 80% of $nentries 
155
 
                error_check_good recordcount_after_dels [is_substr $ret \
156
 
                    "{{Number of keys} [expr {$nentries / 10 * 8}]}"] 1
157
 
        } elseif { [is_rbtree $method] == 1 } {
158
 
                # Total records in a btree is now 90% of $nentries
159
 
                error_check_good recordcount_after_dels [is_substr $ret \
160
 
                    "{{Number of keys} [expr {$nentries / 10 * 9}]}"] 1
161
 
        } else {
162
 
                # No renumbering--still no change in RECORDCOUNT.
163
 
                error_check_good recordcount_after_dels [is_substr $ret \
164
 
                    "{{Number of keys} $nentries}"] 1
165
 
        }
166
 
 
167
 
        puts "\tTest0$tnum.e: put new keys at the end."
168
 
        set start [expr {1 + $nentries / 10 * 9}]
169
 
        set end [expr {($nentries / 10 * 9) + ($nentries / 10 * 8)}]
170
 
        for { set ndx $start } { $ndx <= $end } { incr ndx } {
171
 
                if { $txnenv == 1 } {
172
 
                        set t [$env txn]
173
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
174
 
                        set txn "-txn $t"
175
 
                }
176
 
                set ret [eval {$db put} $txn {$keypfx$ndx $data}]
177
 
                error_check_good db_put_end $ret 0
178
 
                if { $txnenv == 1 } {
179
 
                        error_check_good txn [$t commit] 0
180
 
                }
181
 
        }
182
 
 
183
 
        set ret [$db stat -faststat]
184
 
        if { [is_rbtree $method] != 1 } {
185
 
                # If this is a recno database, the record count should be up
186
 
                # to (1.7 x nentries), the largest number we've seen, with
187
 
                # or without renumbering.
188
 
                error_check_good recordcount_after_puts2 [is_substr $ret \
189
 
                    "{{Number of keys} [expr {$start - 1 + $nentries / 10 * 8}]}"] 1
190
 
        } else {
191
 
                # In an rbtree, 1000 of those keys were overwrites, so there
192
 
                # are (.7 x nentries) new keys and (.9 x nentries) old keys 
193
 
                # for a total of (1.6 x nentries).
194
 
                error_check_good recordcount_after_puts2 [is_substr $ret \
195
 
                    "{{Number of keys} [expr {$start -1 + $nentries / 10 * 7}]}"] 1
196
 
        }
197
 
 
198
 
        error_check_good db_close [$db close] 0
199
 
}