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

« back to all changes in this revision

Viewing changes to libdb/test/recd015.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  recd015
9
 
# TEST  This is a recovery test for testing lots of prepared txns.
10
 
# TEST  This test is to force the use of txn_recover to call with the
11
 
# TEST  DB_FIRST flag and then DB_NEXT.
12
 
proc recd015 { method args } {
13
 
        source ./include.tcl
14
 
 
15
 
        set args [convert_args $method $args]
16
 
        set omethod [convert_method $method]
17
 
 
18
 
        puts "Recd015: $method ($args) prepared txns test"
19
 
 
20
 
        # Create the database and environment.
21
 
 
22
 
        set numtxns 1
23
 
        set testfile NULL
24
 
 
25
 
        set env_cmd "berkdb_env -create -txn -home $testdir"
26
 
        set msg "\tRecd015.a"
27
 
        puts "$msg Simple test to prepare $numtxns txn "
28
 
        foreach op { abort commit discard } {
29
 
                env_cleanup $testdir
30
 
                recd015_body $env_cmd $testfile $numtxns $msg $op
31
 
        }
32
 
 
33
 
        #
34
 
        # Now test large numbers of prepared txns to test DB_NEXT
35
 
        # on txn_recover.
36
 
        #
37
 
        set numtxns 250
38
 
        set testfile recd015.db
39
 
        set txnmax [expr $numtxns + 5]
40
 
        #
41
 
        # For this test we create our database ahead of time so that we
42
 
        # don't need to send methods and args to the script.
43
 
        #
44
 
        env_cleanup $testdir
45
 
        set env_cmd "berkdb_env -create -txn_max $txnmax -txn -home $testdir"
46
 
        set env [eval $env_cmd]
47
 
        error_check_good dbenv [is_valid_env $env] TRUE
48
 
        set db [eval {berkdb_open -create} $omethod -env $env $args $testfile]
49
 
        error_check_good dbopen [is_valid_db $db] TRUE
50
 
        error_check_good dbclose [$db close] 0
51
 
        error_check_good envclose [$env close] 0
52
 
 
53
 
        set msg "\tRecd015.b"
54
 
        puts "$msg Large test to prepare $numtxns txn "
55
 
        foreach op { abort commit discard } {
56
 
                recd015_body $env_cmd $testfile $numtxns $msg $op
57
 
        }
58
 
 
59
 
        set stat [catch {exec $util_path/db_printlog -h $testdir \
60
 
            > $testdir/LOG } ret]
61
 
        error_check_good db_printlog $stat 0
62
 
        fileremove $testdir/LOG
63
 
}
64
 
 
65
 
proc recd015_body { env_cmd testfile numtxns msg op } {
66
 
        source ./include.tcl
67
 
 
68
 
        sentinel_init
69
 
        set gidf $testdir/gidfile
70
 
        fileremove -f $gidf
71
 
        set pidlist {}
72
 
        puts "$msg.0: Executing child script to prepare txns"
73
 
        berkdb debug_check
74
 
        set p [exec $tclsh_path $test_path/wrap.tcl recd15scr.tcl \
75
 
            $testdir/recdout $env_cmd $testfile $gidf $numtxns &]
76
 
 
77
 
        lappend pidlist $p
78
 
        watch_procs $pidlist 5
79
 
        set f1 [open $testdir/recdout r]
80
 
        set r [read $f1]
81
 
        puts $r
82
 
        close $f1
83
 
        fileremove -f $testdir/recdout
84
 
 
85
 
        berkdb debug_check
86
 
        puts -nonewline "$msg.1: Running recovery ... "
87
 
        flush stdout
88
 
        berkdb debug_check
89
 
        set env [eval $env_cmd -recover]
90
 
        error_check_good dbenv-recover [is_valid_env $env] TRUE
91
 
        puts "complete"
92
 
 
93
 
        puts "$msg.2: getting txns from txn_recover"
94
 
        set txnlist [$env txn_recover]
95
 
        error_check_good txnlist_len [llength $txnlist] $numtxns
96
 
 
97
 
        set gfd [open $gidf r]
98
 
        set i 0
99
 
        while { [gets $gfd gid] != -1 } {
100
 
                set gids($i) $gid
101
 
                incr i
102
 
        }
103
 
        close $gfd
104
 
        #
105
 
        # Make sure we have as many as we expect
106
 
        error_check_good num_gids $i $numtxns
107
 
 
108
 
        set i 0
109
 
        puts "$msg.3: comparing GIDs and $op txns"
110
 
        foreach tpair $txnlist {
111
 
                set txn [lindex $tpair 0]
112
 
                set gid [lindex $tpair 1]
113
 
                error_check_good gidcompare $gid $gids($i)
114
 
                error_check_good txn:$op [$txn $op] 0
115
 
                incr i
116
 
        }
117
 
        if { $op != "discard" } {
118
 
                error_check_good envclose [$env close] 0
119
 
                return
120
 
        }
121
 
        #
122
 
        # If we discarded, now do it again and randomly resolve some
123
 
        # until all txns are resolved.
124
 
        #
125
 
        puts "$msg.4: resolving/discarding txns"
126
 
        set txnlist [$env txn_recover]
127
 
        set len [llength $txnlist]
128
 
        set opval(1) "abort"
129
 
        set opcnt(1) 0
130
 
        set opval(2) "commit"
131
 
        set opcnt(2) 0
132
 
        set opval(3) "discard"
133
 
        set opcnt(3) 0
134
 
        while { $len != 0 } {
135
 
                set opicnt(1) 0
136
 
                set opicnt(2) 0
137
 
                set opicnt(3) 0
138
 
                #
139
 
                # Abort/commit or discard them randomly until
140
 
                # all are resolved.
141
 
                #
142
 
                for { set i 0 } { $i < $len } { incr i } {
143
 
                        set t [lindex $txnlist $i]
144
 
                        set txn [lindex $t 0]
145
 
                        set newop [berkdb random_int 1 3]
146
 
                        set ret [$txn $opval($newop)]
147
 
                        error_check_good txn_$opval($newop):$i $ret 0
148
 
                        incr opcnt($newop)
149
 
                        incr opicnt($newop)
150
 
                }
151
 
#               puts "$opval(1): $opicnt(1) Total: $opcnt(1)"
152
 
#               puts "$opval(2): $opicnt(2) Total: $opcnt(2)"
153
 
#               puts "$opval(3): $opicnt(3) Total: $opcnt(3)"
154
 
 
155
 
                set txnlist [$env txn_recover]
156
 
                set len [llength $txnlist]
157
 
        }
158
 
 
159
 
        error_check_good envclose [$env close] 0
160
 
}