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

« back to all changes in this revision

Viewing changes to libdb/test/rep004.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
 
#
2
 
# Copyright (c) 2002
3
 
#       Sleepycat Software.  All rights reserved.
4
 
#
5
 
# $Id$
6
 
#
7
 
# TEST rep004
8
 
# TEST Test of DB_REP_LOGSONLY.
9
 
# TEST
10
 
# TEST Run a quick put test in a master environment that has one logs-only
11
 
# TEST client.  Shut down, then run catastrophic recovery in the logs-only
12
 
# TEST client and check that the database is present and populated.
13
 
 
14
 
proc rep004 { method { nitems 10 } { tnum "04" } args } {
15
 
        source ./include.tcl
16
 
        global testdir
17
 
 
18
 
        env_cleanup $testdir
19
 
        set dbname rep0$tnum.db
20
 
 
21
 
        set omethod [convert_method $method]
22
 
        set oargs [convert_args $method $args]
23
 
 
24
 
        puts "Rep0$tnum: Test of logs-only replication clients"
25
 
 
26
 
        replsetup $testdir/MSGQUEUEDIR
27
 
        set masterdir $testdir/MASTERDIR
28
 
        file mkdir $masterdir
29
 
        set clientdir $testdir/CLIENTDIR
30
 
        file mkdir $clientdir
31
 
        set logsonlydir $testdir/LOGSONLYDIR
32
 
        file mkdir $logsonlydir
33
 
 
34
 
        # Open a master, a logsonly replica, and a normal client.
35
 
        repladd 1
36
 
        set masterenv [berkdb_env -create -home $masterdir -txn -rep_master \
37
 
            -rep_transport [list 1 replsend]]
38
 
        error_check_good master_env [is_valid_env $masterenv] TRUE
39
 
 
40
 
        repladd 2
41
 
        set loenv [berkdb_env -create -home $logsonlydir -txn -rep_logsonly \
42
 
            -rep_transport [list 2 replsend]]
43
 
        error_check_good logsonly_env [is_valid_env $loenv] TRUE
44
 
 
45
 
        repladd 3
46
 
        set clientenv [berkdb_env -create -home $clientdir -txn -rep_client \
47
 
            -rep_transport [list 3 replsend]]
48
 
        error_check_good client_env [is_valid_env $clientenv] TRUE
49
 
 
50
 
 
51
 
        puts "\tRep0$tnum.a: Populate database."
52
 
 
53
 
        set db [eval {berkdb open -create -mode 0644 -auto_commit} \
54
 
            -env $masterenv $oargs $omethod $dbname]
55
 
        error_check_good dbopen [is_valid_db $db] TRUE
56
 
 
57
 
        set did [open $dict]
58
 
        set count 0
59
 
        while { [gets $did str] != -1 && $count < $nitems } {
60
 
                if { [is_record_based $method] == 1 } {
61
 
                        set key [expr $count + 1]
62
 
                        set data $str
63
 
                } else {
64
 
                        set key $str
65
 
                        set data [reverse $str]
66
 
                }
67
 
                set kvals($count) $key
68
 
                set dvals($count) [pad_data $method $data]
69
 
 
70
 
                set txn [$masterenv txn]
71
 
                error_check_good txn($count) [is_valid_txn $txn $masterenv] TRUE
72
 
 
73
 
                set ret [eval \
74
 
                    {$db put} -txn $txn {$key [chop_data $method $data]}] 
75
 
                error_check_good put($count) $ret 0
76
 
 
77
 
                error_check_good commit($count) [$txn commit] 0
78
 
 
79
 
                incr count
80
 
        }
81
 
 
82
 
        puts "\tRep0$tnum.b: Sync up clients."
83
 
        set donenow 0
84
 
        while { 1 } {
85
 
                set nproced 0
86
 
 
87
 
                incr nproced [replprocessqueue $masterenv 1]
88
 
                incr nproced [replprocessqueue $loenv 2]
89
 
                incr nproced [replprocessqueue $clientenv 3]
90
 
 
91
 
                if { $nproced == 0 } {
92
 
                        break
93
 
                }
94
 
        }
95
 
 
96
 
 
97
 
        puts "\tRep0$tnum.c: Get master and logs-only client ahead."
98
 
        set newcount 0
99
 
        while { [gets $did str] != -1 && $newcount < $nitems } {
100
 
                if { [is_record_based $method] == 1 } {
101
 
                        set key [expr $count + 1]
102
 
                        set data $str
103
 
                } else {
104
 
                        set key $str
105
 
                        set data [reverse $str]
106
 
                }
107
 
                set kvals($count) $key
108
 
                set dvals($count) [pad_data $method $data]
109
 
 
110
 
                set txn [$masterenv txn]
111
 
                error_check_good txn($count) [is_valid_txn $txn $masterenv] TRUE
112
 
 
113
 
                set ret [eval \
114
 
                    {$db put} -txn $txn {$key [chop_data $method $data]}] 
115
 
                error_check_good put($count) $ret 0
116
 
 
117
 
                error_check_good commit($count) [$txn commit] 0
118
 
 
119
 
                incr count
120
 
                incr newcount
121
 
        }
122
 
 
123
 
        error_check_good db_close [$db close] 0
124
 
 
125
 
        puts "\tRep0$tnum.d: Sync up logs-only client only, then fail over."
126
 
        set donenow 0
127
 
        while { 1 } {
128
 
                set nproced 0
129
 
 
130
 
                incr nproced [replprocessqueue $masterenv 1]
131
 
                incr nproced [replprocessqueue $loenv 2]
132
 
 
133
 
                if { $nproced == 0 } {
134
 
                        break
135
 
                }
136
 
        }
137
 
 
138
 
 
139
 
        # "Crash" the master, and fail over to the upgradeable client.
140
 
        error_check_good masterenv_close [$masterenv close] 0
141
 
        replclear 3     
142
 
 
143
 
        error_check_good upgrade_client [$clientenv rep_start -master] 0
144
 
        set donenow 0
145
 
        while { 1 } {
146
 
                set nproced 0
147
 
 
148
 
                incr nproced [replprocessqueue $clientenv 3]
149
 
                incr nproced [replprocessqueue $loenv 2]
150
 
 
151
 
                if { $nproced == 0 } {
152
 
                        break
153
 
                }
154
 
        }
155
 
 
156
 
        error_check_good loenv_close [$loenv close] 0
157
 
 
158
 
        puts "\tRep0$tnum.e: Run catastrophic recovery on logs-only client."
159
 
        set loenv [berkdb_env -create -home $logsonlydir -txn -recover_fatal]
160
 
 
161
 
        puts "\tRep0$tnum.f: Verify logs-only client contents."
162
 
        set lodb [eval {berkdb open} -env $loenv $oargs $omethod $dbname]
163
 
        set loc [$lodb cursor]
164
 
 
165
 
        set cdb [eval {berkdb open} -env $clientenv $oargs $omethod $dbname]
166
 
        set cc [$cdb cursor]
167
 
 
168
 
        # Make sure new master and recovered logs-only replica match.
169
 
        for { set cdbt [$cc get -first] } \
170
 
            { [llength $cdbt] > 0 } { set cdbt [$cc get -next] } {
171
 
                set lodbt [$loc get -next]
172
 
 
173
 
                error_check_good newmaster_replica_match $cdbt $lodbt
174
 
        }
175
 
 
176
 
        # Reset new master cursor.
177
 
        error_check_good cc_close [$cc close] 0
178
 
        set cc [$cdb cursor]
179
 
        
180
 
        for { set lodbt [$loc get -first] } \
181
 
            { [llength $lodbt] > 0 } { set lodbt [$loc get -next] } {
182
 
                set cdbt [$cc get -next]
183
 
 
184
 
                error_check_good replica_newmaster_match $lodbt $cdbt
185
 
        }
186
 
 
187
 
        error_check_good loc_close [$loc close] 0
188
 
        error_check_good lodb_close [$lodb close] 0
189
 
        error_check_good loenv_close [$loenv close] 0
190
 
 
191
 
        error_check_good cc_close [$cc close] 0
192
 
        error_check_good cdb_close [$cdb close] 0
193
 
        error_check_good clientenv_close [$clientenv close] 0
194
 
        
195
 
        close $did
196
 
 
197
 
        replclose $testdir/MSGQUEUEDIR
198
 
}