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

« back to all changes in this revision

Viewing changes to libdb/test/recd009.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  recd009
9
 
# TEST  Verify record numbering across split/reverse splits and recovery.
10
 
proc recd009 { method {select 0} args} {
11
 
        global fixed_len
12
 
        source ./include.tcl
13
 
 
14
 
        if { [is_rbtree $method] != 1 && [is_rrecno $method] != 1} {
15
 
                puts "Recd009 skipping for method $method."
16
 
                return
17
 
        }
18
 
 
19
 
        set opts [convert_args $method $args]
20
 
        set method [convert_method $method]
21
 
 
22
 
        puts "\tRecd009: Test record numbers across splits and recovery"
23
 
 
24
 
        set testfile recd009.db
25
 
        env_cleanup $testdir
26
 
        set mkeys 1000
27
 
        set nkeys 5
28
 
        set data "data"
29
 
 
30
 
        puts "\tRecd009.a: Create $method environment and database."
31
 
        set flags "-create -txn -home $testdir"
32
 
 
33
 
        set env_cmd "berkdb_env $flags"
34
 
        set dbenv [eval $env_cmd]
35
 
        error_check_good dbenv [is_valid_env $dbenv] TRUE
36
 
 
37
 
        set oflags "-env $dbenv -pagesize 8192 -create -mode 0644 $opts $method"
38
 
        set db [eval {berkdb_open} $oflags $testfile]
39
 
        error_check_good dbopen [is_valid_db $db] TRUE
40
 
 
41
 
        # Fill page with small key/data pairs.  Keep at leaf.
42
 
        puts "\tRecd009.b: Fill page with $nkeys small key/data pairs."
43
 
        for { set i 1 } { $i <= $nkeys } { incr i } {
44
 
                if { [is_recno $method] == 1 } {
45
 
                        set key $i
46
 
                } else {
47
 
                        set key key000$i
48
 
                }
49
 
                set ret [$db put $key $data$i]
50
 
                error_check_good dbput $ret 0
51
 
        }
52
 
        error_check_good db_close [$db close] 0
53
 
        error_check_good env_close [$dbenv close] 0
54
 
 
55
 
        set newnkeys [expr $nkeys + 1]
56
 
        # List of recovery tests: {CMD MSG} pairs.
57
 
        set rlist {
58
 
        { {recd009_split DB TXNID 1 $method $newnkeys $mkeys}
59
 
            "Recd009.c: split"}
60
 
        { {recd009_split DB TXNID 0 $method $newnkeys $mkeys}
61
 
            "Recd009.d: reverse split"}
62
 
        }
63
 
 
64
 
        foreach pair $rlist {
65
 
                set cmd [subst [lindex $pair 0]]
66
 
                set msg [lindex $pair 1]
67
 
                if { $select != 0 } {
68
 
                        set tag [lindex $msg 0]
69
 
                        set tail [expr [string length $tag] - 2]
70
 
                        set tag [string range $tag $tail $tail]
71
 
                        if { [lsearch $select $tag] == -1 } {
72
 
                                continue
73
 
                        }
74
 
                }
75
 
                set reverse [string first "reverse" $msg]
76
 
                if { $reverse == -1 } {
77
 
                        set abortkeys $nkeys
78
 
                        set commitkeys $mkeys
79
 
                        set abortpg 0
80
 
                        set commitpg 1
81
 
                } else {
82
 
                        set abortkeys $mkeys
83
 
                        set commitkeys $nkeys
84
 
                        set abortpg 1
85
 
                        set commitpg 0
86
 
                }
87
 
                op_recover abort $testdir $env_cmd $testfile $cmd $msg
88
 
                recd009_recnocheck $testdir $testfile $opts $abortkeys $abortpg
89
 
                op_recover commit $testdir $env_cmd $testfile $cmd $msg
90
 
                recd009_recnocheck $testdir $testfile $opts \
91
 
                    $commitkeys $commitpg
92
 
        }
93
 
        puts "\tRecd009.e: Verify db_printlog can read logfile"
94
 
        set tmpfile $testdir/printlog.out
95
 
        set stat [catch {exec $util_path/db_printlog -h $testdir \
96
 
            > $tmpfile} ret]
97
 
        error_check_good db_printlog $stat 0
98
 
        fileremove $tmpfile
99
 
}
100
 
 
101
 
#
102
 
# This procedure verifies that the database has only numkeys number
103
 
# of keys and that they are in order.
104
 
#
105
 
proc recd009_recnocheck { tdir testfile opts numkeys numpg} {
106
 
        source ./include.tcl
107
 
 
108
 
        set db [eval {berkdb_open} $opts $tdir/$testfile]
109
 
        error_check_good dbopen [is_valid_db $db] TRUE
110
 
 
111
 
        puts "\tRecd009_recnocheck: Verify page count of $numpg on split."
112
 
        set stat [$db stat]
113
 
        error_check_bad stat:check-split [is_substr $stat \
114
 
                "{{Internal pages} 0}"] $numpg
115
 
 
116
 
        set type [$db get_type]
117
 
        set dbc [$db cursor]
118
 
        error_check_good dbcursor [is_valid_cursor $dbc $db] TRUE
119
 
        set i 1
120
 
        puts "\tRecd009_recnocheck: Checking $numkeys record numbers."
121
 
        for {set d [$dbc get -first]} { [llength $d] != 0 } {
122
 
            set d [$dbc get -next]} {
123
 
                if { [is_btree $type] } {
124
 
                        set thisi [$dbc get -get_recno]
125
 
                } else {
126
 
                        set thisi [lindex [lindex $d 0] 0]
127
 
                }
128
 
                error_check_good recno_check $i $thisi
129
 
                error_check_good record_count [expr $i <= $numkeys] 1
130
 
                incr i
131
 
        }
132
 
        error_check_good curs_close [$dbc close] 0
133
 
        error_check_good db_close [$db close] 0
134
 
}
135
 
 
136
 
proc recd009_split { db txn split method nkeys mkeys } {
137
 
        global errorCode
138
 
        source ./include.tcl
139
 
 
140
 
        set data "data"
141
 
 
142
 
        set isrecno [is_recno $method]
143
 
        # if mkeys is above 1000, need to adjust below for lexical order
144
 
        if { $split == 1 } {
145
 
                puts "\tRecd009_split: Add $mkeys pairs to force split."
146
 
                for {set i $nkeys} { $i <= $mkeys } { incr i } {
147
 
                        if { $isrecno == 1 } {
148
 
                                set key $i
149
 
                        } else {
150
 
                                if { $i >= 100 } {
151
 
                                        set key key0$i
152
 
                                } elseif { $i >= 10 } {
153
 
                                        set key key00$i
154
 
                                } else {
155
 
                                        set key key000$i
156
 
                                }
157
 
                        }
158
 
                        set ret [$db put -txn $txn $key $data$i]
159
 
                        error_check_good dbput:more $ret 0
160
 
                }
161
 
        } else {
162
 
                puts "\tRecd009_split: Delete added keys to force reverse split."
163
 
                # Since rrecno renumbers, we delete downward.
164
 
                for {set i $mkeys} { $i >= $nkeys } { set i [expr $i - 1] } {
165
 
                        if { $isrecno == 1 } {
166
 
                                set key $i
167
 
                        } else {
168
 
                                if { $i >= 100 } {
169
 
                                        set key key0$i
170
 
                                } elseif { $i >= 10 } {
171
 
                                        set key key00$i
172
 
                                } else {
173
 
                                        set key key000$i
174
 
                                }
175
 
                        }
176
 
                        error_check_good db_del:$i [$db del -txn $txn $key] 0
177
 
                }
178
 
        }
179
 
        return 0
180
 
}