1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 2001,2008 Oracle. All rights reserved. 4# 5# $Id: rep071.tcl,v 12.5 2008/01/08 20:58:53 bostic Exp $ 6# 7# TEST rep071 8# TEST Test of multiple simultaneous client env handles and 9# TEST upgrading/downgrading. Tests use of temp db handle 10# TEST internally. 11# TEST 12# TEST Open a master and 2 handles to the same client env. 13# TEST Run rep_test. 14# TEST Close master and upgrade client to master using one env handle. 15# TEST Run rep_test again, and then downgrade back to client. 16# 17proc rep071 { method { niter 10 } { tnum "071" } args } { 18 19 source ./include.tcl 20 if { $is_windows9x_test == 1 } { 21 puts "Skipping replication test on Win 9x platform." 22 return 23 } 24 25 # Run for btree only. 26 if { $checking_valid_methods } { 27 set test_methods { btree } 28 return $test_methods 29 } 30 if { [is_btree $method] == 0 } { 31 puts "Rep$tnum: Skipping for method $method." 32 return 33 } 34 35 # We can't open two envs on HP-UX, so just skip the 36 # whole test since that is at the core of it. 37 if { $is_hp_test == 1 } { 38 puts "Rep$tnum: Skipping for HP-UX." 39 return 40 } 41 # This test depends on copying logs, so can't be run with 42 # in-memory logging. 43 global mixed_mode_logging 44 if { $mixed_mode_logging > 0 } { 45 puts "Rep$tnum: Skipping for mixed-mode logging." 46 return 47 } 48 49 set args [convert_args $method $args] 50 51 # Run the body of the test with and without recovery. 52 foreach r $test_recopts { 53 puts "Rep$tnum ($method $r):\ 54 Replication backup and synchronizing." 55 rep071_sub $method $niter $tnum $r $args 56 } 57} 58 59proc rep071_sub { method niter tnum recargs largs } { 60 global testdir 61 global util_path 62 global rep_verbose 63 global verbose_type 64 65 set verbargs "" 66 if { $rep_verbose == 1 } { 67 set verbargs " -verbose {$verbose_type on} " 68 } 69 70 env_cleanup $testdir 71 72 replsetup $testdir/MSGQUEUEDIR 73 74 set masterdir $testdir/MASTERDIR 75 set clientdir $testdir/CLIENTDIR 76 77 file mkdir $masterdir 78 file mkdir $clientdir 79 80 # Open a master. 81 repladd 1 82 set ma_envcmd "berkdb_env_noerr -create -txn nosync $verbargs \ 83 -home $masterdir -errpfx MASTER \ 84 -rep_transport \[list 1 replsend\]" 85 set masterenv [eval $ma_envcmd $recargs -rep_master] 86 87 # Open a client 88 repladd 2 89 set cl_envcmd "berkdb_env_noerr -create -txn nosync $verbargs \ 90 -home $clientdir -errpfx CLIENT \ 91 -rep_transport \[list 2 replsend\]" 92 set clientenv [eval $cl_envcmd $recargs -rep_client] 93 error_check_good clenv [is_valid_env $clientenv] TRUE 94 # 95 # Open a 2nd client handle to the same client env. 96 # This handle needs to be a full client handle so just 97 # use the same env command for both. 98 # 99 set 2ndclientenv [eval $cl_envcmd -rep_client -errpfx 2ND] 100 error_check_good cl2env [is_valid_env $2ndclientenv] TRUE 101 102 # Bring the clients online by processing the startup messages. 103 set envlist "{$masterenv 1} {$clientenv 2}" 104 process_msgs $envlist 105 106 # Run a modified test001 in the master (and update client). 107 puts "\tRep$tnum.a: Running rep_test in replicated env." 108 eval rep_test $method $masterenv NULL $niter 0 0 0 0 $largs 109 process_msgs $envlist 110 111 puts "\tRep$tnum.b: Downgrade master and upgrade client." 112 error_check_good master_close [$masterenv rep_start -client] 0 113 error_check_good client_close [$clientenv rep_start -master] 0 114 115 puts "\tRep$tnum.b: Run rep_test." 116 eval rep_test $method $clientenv NULL $niter 0 0 0 0 $largs 117 process_msgs $envlist 118 119 puts "\tRep$tnum.c: Downgrade back to client and upgrade master" 120 # 121 # The act of upgrading and downgrading an env, with another 122 # handle open had issues with open internal db handles. 123 # So, the existence of the 2nd client env handle is needed 124 # even though we're not doing anything active with that handle. 125 # 126 error_check_good client_close [$clientenv rep_start -client] 0 127 error_check_good master_close [$masterenv rep_start -master] 0 128 129 puts "\tRep$tnum.d: Run rep_test in master." 130 eval rep_test $method $masterenv NULL $niter 0 0 0 0 $largs 131 process_msgs $envlist 132 133 error_check_good master_close [$masterenv close] 0 134 error_check_good clientenv_close [$clientenv close] 0 135 error_check_good clientenv_close [$2ndclientenv close] 0 136 replclose $testdir/MSGQUEUEDIR 137} 138