1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 2007-2009 Oracle. All rights reserved. 4# 5# $Id$ 6# 7# TEST repmgr007 8# TEST Basic repmgr client shutdown/restart test. 9# TEST 10# TEST Start an appointed master site and two clients. Shutdown and 11# TEST restart each client, processing transactions after each restart. 12# TEST Verify all expected transactions are replicated. 13# TEST 14# TEST Run for btree only because access method shouldn't matter. 15# TEST 16proc repmgr007 { method { niter 100 } { tnum "007" } args } { 17 18 source ./include.tcl 19 20 if { $is_freebsd_test == 1 } { 21 puts "Skipping replication manager test on FreeBSD platform." 22 return 23 } 24 25 if { $is_windows9x_test == 1 } { 26 puts "Skipping replication test on Win9x platform." 27 return 28 } 29 30 # Skip for all methods except btree. 31 if { $checking_valid_methods } { 32 return btree 33 } 34 if { [is_btree $method] == 0 } { 35 puts "Repmgr$tnum: skipping for non-btree method $method." 36 return 37 } 38 39 set args [convert_args $method $args] 40 41 puts "Repmgr$tnum ($method): repmgr client shutdown/restart test." 42 repmgr007_sub $method $niter $tnum $args 43} 44 45proc repmgr007_sub { method niter tnum largs } { 46 global testdir 47 global rep_verbose 48 global verbose_type 49 set nsites 3 50 51 set verbargs "" 52 if { $rep_verbose == 1 } { 53 set verbargs " -verbose {$verbose_type on} " 54 } 55 56 env_cleanup $testdir 57 set ports [available_ports $nsites] 58 59 set masterdir $testdir/MASTERDIR 60 set clientdir $testdir/CLIENTDIR 61 set clientdir2 $testdir/CLIENTDIR2 62 63 file mkdir $masterdir 64 file mkdir $clientdir 65 file mkdir $clientdir2 66 67 # Use different connection retry timeout values to handle any 68 # collisions from starting sites at the same time by retrying 69 # at different times. 70 71 # Open a master. 72 puts "\tRepmgr$tnum.a: Start a master." 73 set ma_envcmd "berkdb_env_noerr -create $verbargs \ 74 -errpfx MASTER -home $masterdir -txn -rep -thread" 75 set masterenv [eval $ma_envcmd] 76 $masterenv repmgr -ack all -nsites $nsites \ 77 -timeout {conn_retry 20000000} \ 78 -local [list localhost [lindex $ports 0]] \ 79 -start master 80 81 # Open first client 82 puts "\tRepmgr$tnum.b: Start first client." 83 set cl_envcmd "berkdb_env_noerr -create $verbargs \ 84 -errpfx CLIENT -home $clientdir -txn -rep -thread" 85 set clientenv [eval $cl_envcmd] 86 $clientenv repmgr -ack all -nsites $nsites \ 87 -timeout {conn_retry 10000000} \ 88 -local [list localhost [lindex $ports 1]] \ 89 -remote [list localhost [lindex $ports 0]] \ 90 -remote [list localhost [lindex $ports 2]] \ 91 -start client 92 await_startup_done $clientenv 93 94 # Open second client 95 puts "\tRepmgr$tnum.c: Start second client." 96 set cl2_envcmd "berkdb_env_noerr -create $verbargs \ 97 -errpfx CLIENT2 -home $clientdir2 -txn -rep -thread" 98 set clientenv2 [eval $cl2_envcmd] 99 $clientenv2 repmgr -ack all -nsites $nsites \ 100 -timeout {conn_retry 5000000} \ 101 -local [list localhost [lindex $ports 2]] \ 102 -remote [list localhost [lindex $ports 0]] \ 103 -remote [list localhost [lindex $ports 1]] \ 104 -start client 105 await_startup_done $clientenv2 106 107 # 108 # Use of -ack all guarantees replication complete before repmgr send 109 # function returns and rep_test finishes. 110 # 111 puts "\tRepmgr$tnum.d: Run first set of transactions at master." 112 set start 0 113 eval rep_test $method $masterenv NULL $niter $start 0 0 $largs 114 incr start $niter 115 116 puts "\tRepmgr$tnum.e: Shut down first client, wait and restart it." 117 error_check_good client_close [$clientenv close] 0 118 tclsleep 5 119 # Open -recover to clear env region, including startup_done value. 120 set clientenv [eval $cl_envcmd -recover] 121 $clientenv repmgr -ack all -nsites $nsites \ 122 -timeout {conn_retry 10000000} \ 123 -local [list localhost [lindex $ports 1]] \ 124 -remote [list localhost [lindex $ports 0]] \ 125 -remote [list localhost [lindex $ports 2]] \ 126 -start client 127 await_startup_done $clientenv 128 129 puts "\tRepmgr$tnum.f: Run second set of transactions at master." 130 eval rep_test $method $masterenv NULL $niter $start 0 0 $largs 131 incr start $niter 132 133 puts "\tRepmgr$tnum.g: Verifying client database contents." 134 rep_verify $masterdir $masterenv $clientdir $clientenv 1 1 1 135 rep_verify $masterdir $masterenv $clientdir2 $clientenv2 1 1 1 136 137 puts "\tRepmgr$tnum.h: Shut down second client, wait and restart it." 138 error_check_good client_close [$clientenv2 close] 0 139 tclsleep 5 140 # Open -recover to clear env region, including startup_done value. 141 set clientenv2 [eval $cl2_envcmd -recover] 142 $clientenv2 repmgr -ack all -nsites $nsites \ 143 -timeout {conn_retry 5000000} \ 144 -local [list localhost [lindex $ports 2]] \ 145 -remote [list localhost [lindex $ports 0]] \ 146 -remote [list localhost [lindex $ports 1]] \ 147 -start client 148 await_startup_done $clientenv2 149 150 puts "\tRepmgr$tnum.i: Run third set of transactions at master." 151 eval rep_test $method $masterenv NULL $niter $start 0 0 $largs 152 153 puts "\tRepmgr$tnum.j: Verifying client database contents." 154 rep_verify $masterdir $masterenv $clientdir $clientenv 1 1 1 155 rep_verify $masterdir $masterenv $clientdir2 $clientenv2 1 1 1 156 157 error_check_good client2_close [$clientenv2 close] 0 158 error_check_good client_close [$clientenv close] 0 159 error_check_good masterenv_close [$masterenv close] 0 160} 161