1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 2001-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Replication rename and forced-upgrade 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.
17
proc rep001 { method { niter 1000 } { tnum "01" } args } {
20
puts "Rep0$tnum: Replication sanity test."
23
rep001_sub $method $niter $tnum $envargs $args
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
31
proc rep001_sub { method niter tnum envargs largs } {
38
replsetup $testdir/MSGQUEUEDIR
40
set masterdir $testdir/MASTERDIR
41
set clientdir $testdir/CLIENTDIR
46
if { [is_record_based $method] == 1 } {
47
set checkfunc test001_recno.check
49
set checkfunc test001.check
55
[eval {berkdb_env -create -lock_max 2500 -log_max 1000000} \
56
$envargs {-home $masterdir -txn -rep_master -rep_transport \
58
error_check_good master_env [is_valid_env $masterenv] TRUE
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
66
# Bring the client online by processing the startup messages.
71
incr nproced [replprocessqueue $masterenv 1]
72
incr nproced [replprocessqueue $clientenv 2]
74
if { $nproced == 0 } {
79
# Open a test database on the master (so we can test having handles
80
# open across an upgrade).
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
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
98
incr nproced [replprocessqueue $masterenv 1]
99
incr nproced [replprocessqueue $clientenv 2]
101
if { $nproced == 0 } {
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.
113
# Verify the database in the client dir.
114
puts "\tRep0$tnum.c: Verifying client database contents."
115
set testdir [get_home $masterenv]
119
open_and_dump_file test0$tnum.db $clientenv $t1 \
120
$checkfunc dump_file_direction "-first" "-next"
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
131
incr nproced [replprocessqueue $masterenv 1]
132
incr nproced [replprocessqueue $clientenv 2]
134
if { $nproced == 0 } {
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
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
151
incr nproced [replprocessqueue $newmasterenv 2]
153
if { $nproced == 0 } {
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
169
incr nproced [replprocessqueue $newclientenv 1]
170
incr nproced [replprocessqueue $newmasterenv 2]
172
if { $nproced == 0 } {
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
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
189
incr nproced [replprocessqueue $newclientenv 1]
190
incr nproced [replprocessqueue $newmasterenv 2]
192
if { $nproced == 0 } {
197
# Test put to the database handle we opened back when the new master
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
208
incr nproced [replprocessqueue $newclientenv 1]
209
incr nproced [replprocessqueue $newmasterenv 2]
211
if { $nproced == 0 } {
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
225
# Verify the database in the client dir.
226
puts "\tRep0$tnum.j: Verifying new client database contents."
227
set testdir [get_home $newmasterenv]
231
open_and_dump_file test0$tnum.db $newclientenv $t1 \
232
$checkfunc dump_file_direction "-first" "-next"
234
if { [string compare [convert_method $method] -recno] != 0 } {
237
error_check_good diff_files($t2,$t3) [filecmp $t2 $t3] 0
240
error_check_good newmasterenv_close [$newmasterenv close] 0
241
error_check_good newclientenv_close [$newclientenv close] 0
243
if { [lsearch $envargs "-encrypta*"] !=-1 } {
246
error_check_good verify \
247
[verify_dir $clientdir "\tRep0$tnum.k: " 0 0 1] 0
248
replclose $testdir/MSGQUEUEDIR