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

« back to all changes in this revision

Viewing changes to libdb/test/rep001.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) 2001-2002
4
 
#       Sleepycat Software.  All rights reserved.
5
 
#
6
 
# $Id$
7
 
#
8
 
# TEST  rep001
9
 
# TEST  Replication rename and forced-upgrade test.
10
 
# TEST
11
 
# TEST  Run a modified version of test001 in a replicated master environment;
12
 
# TEST  verify that the database on the client is correct.
13
 
# TEST  Next, remove the database, close the master, upgrade the 
14
 
# TEST  client, reopen the master, and make sure the new master can correctly
15
 
# TEST  run test001 and propagate it in the other direction.
16
 
 
17
 
proc rep001 { method { niter 1000 } { tnum "01" } args } {
18
 
        global passwd
19
 
 
20
 
        puts "Rep0$tnum: Replication sanity test."
21
 
 
22
 
        set envargs ""
23
 
        rep001_sub $method $niter $tnum $envargs $args
24
 
 
25
 
        puts "Rep0$tnum: Replication and security sanity test."
26
 
        append envargs " -encryptaes $passwd "
27
 
        append args " -encrypt "
28
 
        rep001_sub $method $niter $tnum $envargs $args
29
 
}
30
 
 
31
 
proc rep001_sub { method niter tnum envargs largs } {
32
 
        source ./include.tcl
33
 
        global testdir
34
 
        global encrypt
35
 
 
36
 
        env_cleanup $testdir
37
 
 
38
 
        replsetup $testdir/MSGQUEUEDIR
39
 
 
40
 
        set masterdir $testdir/MASTERDIR
41
 
        set clientdir $testdir/CLIENTDIR
42
 
 
43
 
        file mkdir $masterdir
44
 
        file mkdir $clientdir
45
 
 
46
 
        if { [is_record_based $method] == 1 } {
47
 
                set checkfunc test001_recno.check
48
 
        } else {
49
 
                set checkfunc test001.check
50
 
        }
51
 
 
52
 
        # Open a master.
53
 
        repladd 1
54
 
        set masterenv \
55
 
            [eval {berkdb_env -create -lock_max 2500 -log_max 1000000} \
56
 
            $envargs {-home $masterdir -txn -rep_master -rep_transport \
57
 
            [list 1 replsend]}]
58
 
        error_check_good master_env [is_valid_env $masterenv] TRUE
59
 
 
60
 
        # Open a client
61
 
        repladd 2
62
 
        set clientenv [eval {berkdb_env -create} $envargs -txn -lock_max 2500 \
63
 
            {-home $clientdir -rep_client -rep_transport [list 2 replsend]}]
64
 
        error_check_good client_env [is_valid_env $clientenv] TRUE
65
 
 
66
 
        # Bring the client online by processing the startup messages.
67
 
        set donenow 0
68
 
        while { 1 } {
69
 
                set nproced 0
70
 
 
71
 
                incr nproced [replprocessqueue $masterenv 1]
72
 
                incr nproced [replprocessqueue $clientenv 2]
73
 
 
74
 
                if { $nproced == 0 } {
75
 
                        break
76
 
                }
77
 
        }
78
 
 
79
 
        # Open a test database on the master (so we can test having handles
80
 
        # open across an upgrade).
81
 
        puts "\tRep0$tnum.a:\
82
 
            Opening test database for post-upgrade client logging test."
83
 
        set master_upg_db [berkdb_open \
84
 
            -create -auto_commit -btree -env $masterenv rep0$tnum-upg.db]
85
 
        set puttxn [$masterenv txn]
86
 
        error_check_good master_upg_db_put \
87
 
            [$master_upg_db put -txn $puttxn hello world] 0
88
 
        error_check_good puttxn_commit [$puttxn commit] 0
89
 
        error_check_good master_upg_db_close [$master_upg_db close] 0
90
 
 
91
 
        # Run a modified test001 in the master (and update client).
92
 
        puts "\tRep0$tnum.b: Running test001 in replicated env."
93
 
        eval test001 $method $niter 0 $tnum 1 -env $masterenv $largs
94
 
        set donenow 0
95
 
        while { 1 } {
96
 
                set nproced 0
97
 
 
98
 
                incr nproced [replprocessqueue $masterenv 1]
99
 
                incr nproced [replprocessqueue $clientenv 2]
100
 
 
101
 
                if { $nproced == 0 } {
102
 
                        break
103
 
                }
104
 
        }
105
 
 
106
 
        # Open the cross-upgrade database on the client and check its contents.
107
 
        set client_upg_db [berkdb_open \
108
 
             -create -auto_commit -btree -env $clientenv rep0$tnum-upg.db]
109
 
        error_check_good client_upg_db_get [$client_upg_db get hello] \
110
 
             [list [list hello world]]
111
 
        # !!! We use this handle later.  Don't close it here.
112
 
 
113
 
        # Verify the database in the client dir.
114
 
        puts "\tRep0$tnum.c: Verifying client database contents."
115
 
        set testdir [get_home $masterenv]
116
 
        set t1 $testdir/t1
117
 
        set t2 $testdir/t2
118
 
        set t3 $testdir/t3
119
 
        open_and_dump_file test0$tnum.db $clientenv $t1 \
120
 
            $checkfunc dump_file_direction "-first" "-next"
121
 
 
122
 
        # Remove the file (and update client).
123
 
        puts "\tRep0$tnum.d: Remove the file on the master and close master."
124
 
        error_check_good remove \
125
 
            [$masterenv dbremove -auto_commit test0$tnum.db] 0
126
 
        error_check_good masterenv_close [$masterenv close] 0
127
 
        set donenow 0
128
 
        while { 1 } {
129
 
                set nproced 0
130
 
 
131
 
                incr nproced [replprocessqueue $masterenv 1]
132
 
                incr nproced [replprocessqueue $clientenv 2]
133
 
 
134
 
                if { $nproced == 0 } {
135
 
                        break
136
 
                }
137
 
        }
138
 
 
139
 
        # Don't get confused in Tcl.
140
 
        puts "\tRep0$tnum.e: Upgrade client."
141
 
        set newmasterenv $clientenv
142
 
        error_check_good upgrade_client [$newmasterenv rep_start -master] 0
143
 
 
144
 
        # Run test001 in the new master
145
 
        puts "\tRep0$tnum.f: Running test001 in new master."
146
 
        eval test001 $method $niter 0 $tnum 1 -env $newmasterenv $largs
147
 
        set donenow 0
148
 
        while { 1 } {
149
 
                set nproced 0
150
 
 
151
 
                incr nproced [replprocessqueue $newmasterenv 2]
152
 
 
153
 
                if { $nproced == 0 } {
154
 
                        break
155
 
                }
156
 
        }
157
 
 
158
 
        puts "\tRep0$tnum.g: Reopen old master as client and catch up."
159
 
        # Throttle master so it can't send everything at once
160
 
        $newmasterenv rep_limit 0 [expr 64 * 1024]
161
 
        set newclientenv [eval {berkdb_env -create -recover} $envargs \
162
 
            -txn -lock_max 2500 \
163
 
            {-home $masterdir -rep_client -rep_transport [list 1 replsend]}]
164
 
        error_check_good newclient_env [is_valid_env $newclientenv] TRUE
165
 
        set donenow 0
166
 
        while { 1 } {
167
 
                set nproced 0
168
 
 
169
 
                incr nproced [replprocessqueue $newclientenv 1]
170
 
                incr nproced [replprocessqueue $newmasterenv 2]
171
 
 
172
 
                if { $nproced == 0 } {
173
 
                        break
174
 
                }
175
 
        }
176
 
        set stats [$newmasterenv rep_stat]
177
 
        set nthrottles [getstats $stats {Transmission limited}]
178
 
        error_check_bad nthrottles $nthrottles -1
179
 
        error_check_bad nthrottles $nthrottles 0
180
 
 
181
 
        # Run a modified test001 in the new master (and update client).
182
 
        puts "\tRep0$tnum.h: Running test001 in new master."
183
 
        eval test001 $method \
184
 
            $niter $niter $tnum 1 -env $newmasterenv $largs
185
 
        set donenow 0
186
 
        while { 1 } {
187
 
                set nproced 0
188
 
 
189
 
                incr nproced [replprocessqueue $newclientenv 1]
190
 
                incr nproced [replprocessqueue $newmasterenv 2]
191
 
 
192
 
                if { $nproced == 0 } {
193
 
                        break
194
 
                }
195
 
        }
196
 
 
197
 
        # Test put to the database handle we opened back when the new master
198
 
        # was a client.
199
 
        puts "\tRep0$tnum.i: Test put to handle opened before upgrade."
200
 
        set puttxn [$newmasterenv txn]
201
 
        error_check_good client_upg_db_put \
202
 
            [$client_upg_db put -txn $puttxn hello there] 0
203
 
        error_check_good puttxn_commit [$puttxn commit] 0
204
 
        set donenow 0
205
 
        while { 1 } {
206
 
                set nproced 0
207
 
 
208
 
                incr nproced [replprocessqueue $newclientenv 1]
209
 
                incr nproced [replprocessqueue $newmasterenv 2]
210
 
 
211
 
                if { $nproced == 0 } {
212
 
                        break
213
 
                }
214
 
        }
215
 
 
216
 
        # Close the new master's handle for the upgrade-test database;  we
217
 
        # don't need it.  Then check to make sure the client did in fact
218
 
        # update the database.
219
 
        error_check_good client_upg_db_close [$client_upg_db close] 0
220
 
        set newclient_upg_db [berkdb_open -env $newclientenv rep0$tnum-upg.db]
221
 
        error_check_good newclient_upg_db_get [$newclient_upg_db get hello] \
222
 
            [list [list hello there]]
223
 
        error_check_good newclient_upg_db_close [$newclient_upg_db close] 0
224
 
 
225
 
        # Verify the database in the client dir.
226
 
        puts "\tRep0$tnum.j: Verifying new client database contents."
227
 
        set testdir [get_home $newmasterenv]
228
 
        set t1 $testdir/t1
229
 
        set t2 $testdir/t2
230
 
        set t3 $testdir/t3
231
 
        open_and_dump_file test0$tnum.db $newclientenv $t1 \
232
 
            $checkfunc dump_file_direction "-first" "-next"
233
 
 
234
 
        if { [string compare [convert_method $method] -recno] != 0 } {
235
 
                filesort $t1 $t3
236
 
        }
237
 
        error_check_good diff_files($t2,$t3) [filecmp $t2 $t3] 0
238
 
 
239
 
 
240
 
        error_check_good newmasterenv_close [$newmasterenv close] 0
241
 
        error_check_good newclientenv_close [$newclientenv close] 0
242
 
 
243
 
        if { [lsearch $envargs "-encrypta*"] !=-1 } {
244
 
                set encrypt 1
245
 
        }
246
 
        error_check_good verify \
247
 
            [verify_dir $clientdir "\tRep0$tnum.k: " 0 0 1] 0
248
 
        replclose $testdir/MSGQUEUEDIR
249
 
}