1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 2007,2008 Oracle. All rights reserved. 4# 5# $Id: repmgr001.tcl,v 12.3 2008/01/08 20:58:53 bostic Exp $ 6# 7# TEST repmgr001 8# TEST Check repmgr stats. 9# TEST 10# TEST Run for btree only because access method shouldn't matter. 11# TEST 12proc repmgr001 { method { niter 20 } { tnum "001" } args } { 13 14 source ./include.tcl 15 16 if { $is_windows9x_test == 1 } { 17 puts "Skipping replication test on Win9x platform." 18 return 19 } 20 21 # Skip for all methods except btree. 22 if { $checking_valid_methods } { 23 return btree 24 } 25 if { [is_btree $method] == 0 } { 26 puts "Rep$tnum: skipping for non-btree method $method." 27 return 28 } 29 30 set args [convert_args $method $args] 31 32 puts "Rep$tnum ($method): Test of repmgr stats" 33 repmgr001_sub $method $niter $tnum $args 34} 35 36proc repmgr001_sub { method niter tnum largs } { 37 global testdir rep_verbose 38 39 set verbargs "" 40 if { $rep_verbose == 1 } { 41 set verbargs " -verbose {rep on} " 42 } 43 44 env_cleanup $testdir 45 set ports [available_ports 2] 46 47 set masterdir $testdir/MASTERDIR 48 set clientdir $testdir/CLIENTDIR 49 50 file mkdir $masterdir 51 file mkdir $clientdir 52 53 # Open a master. 54 puts "\tRepmgr$tnum.a: Start a master." 55 set ma_envcmd "berkdb_env_noerr -create $verbargs -errpfx MASTER \ 56 -home $masterdir -txn -rep" 57 set masterenv [eval $ma_envcmd] 58 $masterenv repmgr -ack all -nsites 2 \ 59 -local [list localhost [lindex $ports 0]] \ 60 -start master 61 62 # Open a client 63 puts "\tRepmgr$tnum.b: Start a client." 64 set cl_envcmd "berkdb_env_noerr -create $verbargs -errpfx CLIENT \ 65 -home $clientdir -txn -rep" 66 set clientenv [eval $cl_envcmd] 67 $clientenv repmgr -ack all -nsites 2 \ 68 -local [list localhost [lindex $ports 1]] \ 69 -remote [list localhost [lindex $ports 0]] \ 70 -start client 71 await_startup_done $clientenv 72 73 puts "\tRepmgr$tnum.c: Run some transactions at master." 74 eval rep_test $method $masterenv NULL $niter 0 0 0 0 $largs 75 76 error_check_good perm_no_failed_stat \ 77 [stat_field $masterenv repmgr_stat "Acknowledgement failures"] 0 78 79 error_check_good no_connections_dropped \ 80 [stat_field $masterenv repmgr_stat "Connections dropped"] 0 81 82 $clientenv close 83 84 # Just do a few transactions (i.e., 3 of them), because each one is 85 # expected to time out, and if we did many the test would take a long 86 # time (with no benefit). 87 # 88 puts "\tRepmgr$tnum.d: Run transactions with no client." 89 eval rep_test $method $masterenv NULL 3 $niter $niter 0 0 $largs 90 91 error_check_bad perm_failed_stat \ 92 [stat_field $masterenv repmgr_stat "Acknowledgement failures"] 0 93 94 error_check_good connections_dropped \ 95 [stat_field $masterenv repmgr_stat "Connections dropped"] 1 96 97 # Bring the client back up, and down, a couple times, to test resetting 98 # of stats. 99 # 100 puts "\tRepmgr$tnum.e: Shut down client (pause), check dropped connection." 101 set clientenv [eval $cl_envcmd] 102 $clientenv repmgr -ack all -nsites 2 \ 103 -local [list localhost [lindex $ports 1]] \ 104 -remote [list localhost [lindex $ports 0]] \ 105 -start client 106 await_startup_done $clientenv 107 $clientenv close 108 109 # Wait a moment for the dust to settle. 110 tclsleep 5 111 112 error_check_good connections_dropped \ 113 [stat_field $masterenv repmgr_stat "Connections dropped"] 2 114 $masterenv repmgr_stat -clear 115 116 puts "\tRepmgr$tnum.e: Shut down, pause, check dropped connection (reset)." 117 set clientenv [eval $cl_envcmd] 118 $clientenv repmgr -ack all -nsites 2 \ 119 -local [list localhost [lindex $ports 1]] \ 120 -remote [list localhost [lindex $ports 0]] \ 121 -start client 122 await_startup_done $clientenv 123 $clientenv close 124 tclsleep 5 125 126 error_check_good connections_dropped \ 127 [stat_field $masterenv repmgr_stat "Connections dropped"] 1 128 129 $masterenv close 130} 131