~ubuntu-branches/ubuntu/natty/evolution-data-server/natty

« back to all changes in this revision

Viewing changes to libdb/test/recd016.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  recd016
9
 
# TEST  This is a recovery test for testing running recovery while
10
 
# TEST  recovery is already running.  While bad things may or may not
11
 
# TEST  happen, if recovery is then run properly, things should be correct.
12
 
proc recd016 { method args } {
13
 
        source ./include.tcl
14
 
 
15
 
        set args [convert_args $method $args]
16
 
        set omethod [convert_method $method]
17
 
 
18
 
        puts "Recd016: $method ($args) simultaneous recovery test"
19
 
        puts "Recd016: Skipping; waiting on SR #6277" 
20
 
        return
21
 
 
22
 
        # Create the database and environment.
23
 
        set testfile recd016.db
24
 
 
25
 
        #
26
 
        # For this test we create our database ahead of time so that we
27
 
        # don't need to send methods and args to the script.
28
 
        #
29
 
        cleanup $testdir NULL
30
 
 
31
 
        #
32
 
        # Use a smaller log to make more files and slow down recovery.
33
 
        #
34
 
        set gflags ""
35
 
        set pflags ""
36
 
        set log_max [expr 256 * 1024]
37
 
        set nentries 10000
38
 
        set nrec 6
39
 
        set t1 $testdir/t1
40
 
        set t2 $testdir/t2
41
 
        set t3 $testdir/t3
42
 
        set t4 $testdir/t4
43
 
        set t5 $testdir/t5
44
 
        # Since we are using txns, we need at least 1 lock per
45
 
        # record (for queue).  So set lock_max accordingly.
46
 
        set lkmax [expr $nentries * 2]
47
 
 
48
 
        puts "\tRecd016.a: Create environment and database"
49
 
        set env_cmd "berkdb_env -create -log_max $log_max \
50
 
            -lock_max $lkmax -txn -home $testdir"
51
 
        set env [eval $env_cmd]
52
 
        error_check_good dbenv [is_valid_env $env] TRUE
53
 
        set db [eval {berkdb_open -create} \
54
 
            $omethod -auto_commit -env $env $args $testfile]
55
 
        error_check_good dbopen [is_valid_db $db] TRUE
56
 
        set did [open $dict]
57
 
        set abid [open $t4 w]
58
 
 
59
 
        if { [is_record_based $method] == 1 } {
60
 
                set checkfunc recd016_recno.check
61
 
                append gflags " -recno"
62
 
        } else {
63
 
                set checkfunc recd016.check
64
 
        }
65
 
        puts "\tRecd016.b: put/get loop"
66
 
        # Here is the loop where we put and get each key/data pair
67
 
        set count 0
68
 
        while { [gets $did str] != -1 && $count < $nentries } {
69
 
                if { [is_record_based $method] == 1 } {
70
 
                        global kvals
71
 
 
72
 
                        set key [expr $count + 1]
73
 
                        if { 0xffffffff > 0 && $key > 0xffffffff } {
74
 
                                set key [expr $key - 0x100000000]
75
 
                        }
76
 
                        if { $key == 0 || $key - 0xffffffff == 1 } {
77
 
                                incr key
78
 
                                incr count
79
 
                        }
80
 
                        set kvals($key) [pad_data $method $str]
81
 
                } else {
82
 
                        set key $str
83
 
                        set str [reverse $str]
84
 
                }
85
 
                #
86
 
                # Start a transaction.  Alternately abort and commit them.
87
 
                # This will create a bigger log for recovery to collide.
88
 
                #
89
 
                set txn [$env txn]
90
 
                set ret [eval \
91
 
                    {$db put} -txn $txn $pflags {$key [chop_data $method $str]}]
92
 
                error_check_good put $ret 0
93
 
 
94
 
                if {[expr $count % 2] == 0} {
95
 
                        set ret [$txn commit]
96
 
                        error_check_good txn_commit $ret 0
97
 
                        set ret [eval {$db get} $gflags {$key}]
98
 
                        error_check_good commit_get \
99
 
                            $ret [list [list $key [pad_data $method $str]]]
100
 
                } else {
101
 
                        set ret [$txn abort]
102
 
                        error_check_good txn_abort $ret 0
103
 
                        set ret [eval {$db get} $gflags {$key}]
104
 
                        error_check_good abort_get [llength $ret] 0
105
 
                        puts $abid $key
106
 
                }
107
 
                incr count
108
 
        }
109
 
        close $did
110
 
        close $abid
111
 
        error_check_good dbclose [$db close] 0
112
 
        error_check_good envclose [$env close] 0
113
 
 
114
 
        set pidlist {}
115
 
        puts "\tRecd016.c: Start up $nrec recovery processes at once"
116
 
        for {set i 0} {$i < $nrec} {incr i} {
117
 
                set p [exec $util_path/db_recover -h $testdir -c &]
118
 
                lappend pidlist $p
119
 
        }
120
 
        watch_procs $pidlist 5
121
 
        #
122
 
        # Now that they are all done run recovery correctly
123
 
        puts "\tRecd016.d: Run recovery process"
124
 
        set stat [catch {exec $util_path/db_recover -h $testdir -c} result]
125
 
        if { $stat == 1 } {
126
 
                error "FAIL: Recovery error: $result."
127
 
        }
128
 
 
129
 
        puts "\tRecd016.e: Open, dump and check database"
130
 
        # Now compare the keys to see if they match the dictionary (or ints)
131
 
        if { [is_record_based $method] == 1 } {
132
 
                set oid [open $t2 w]
133
 
                for {set i 1} {$i <= $nentries} {incr i} {
134
 
                        set j $i
135
 
                        if { 0xffffffff > 0 && $j > 0xffffffff } {
136
 
                                set j [expr $j - 0x100000000]
137
 
                        }
138
 
                        if { $j == 0 } {
139
 
                                incr i
140
 
                                incr j
141
 
                        }
142
 
                        puts $oid $j
143
 
                }
144
 
                close $oid
145
 
        } else {
146
 
                set q q
147
 
                filehead $nentries $dict $t2
148
 
        }
149
 
        filesort $t2 $t3
150
 
        file rename -force $t3 $t2
151
 
        filesort $t4 $t3
152
 
        file rename -force $t3 $t4
153
 
        fileextract $t2 $t4 $t3
154
 
        file rename -force $t3 $t5
155
 
 
156
 
        set env [eval $env_cmd]
157
 
        error_check_good dbenv [is_valid_env $env] TRUE
158
 
 
159
 
        open_and_dump_file $testfile $env $t1 $checkfunc \
160
 
            dump_file_direction "-first" "-next"
161
 
        filesort $t1 $t3
162
 
        error_check_good envclose [$env close] 0
163
 
 
164
 
        error_check_good Recd016:diff($t5,$t3) \
165
 
            [filecmp $t5 $t3] 0
166
 
 
167
 
        set stat [catch {exec $util_path/db_printlog -h $testdir \
168
 
            > $testdir/LOG } ret]
169
 
        error_check_good db_printlog $stat 0
170
 
        fileremove $testdir/LOG
171
 
}
172
 
 
173
 
# Check function for recd016; keys and data are identical
174
 
proc recd016.check { key data } {
175
 
        error_check_good "key/data mismatch" $data [reverse $key]
176
 
}
177
 
 
178
 
proc recd016_recno.check { key data } {
179
 
        global kvals
180
 
 
181
 
        error_check_good key"$key"_exists [info exists kvals($key)] 1
182
 
        error_check_good "key/data mismatch, key $key" $data $kvals($key)
183
 
}