1# See the file LICENSE for redistribution information. 2# 3# Copyright (c)-2009 Oracle. All rights reserved. 4# 5# TEST repmgr030 6# TEST Subordinate connections and processes should not trigger elections. 7 8proc repmgr030 { } { 9 source ./include.tcl 10 11 set tnum "030" 12 puts "Repmgr$tnum: Subordinate\ 13 connections and processes should not trigger elections." 14 15 env_cleanup $testdir 16 17 foreach {mport cport} [available_ports 2] {} 18 file mkdir [set mdir $testdir/MASTER] 19 file mkdir [set cdir $testdir/CLIENT] 20 21 make_dbconfig $mdir [set dbconfig {{rep_set_nsites 3}}] 22 make_dbconfig $cdir $dbconfig 23 24 puts "\tRepmgr$tnum.a: Set up a pair of sites, two processes each." 25 set cmds { 26 "home $mdir" 27 "local $mport" 28 "output $testdir/m1output" 29 "open_env" 30 "start master" 31 } 32 set m1 [open_site_prog [subst $cmds]] 33 34 set cmds { 35 "home $mdir" 36 "local $mport" 37 "output $testdir/m2output" 38 "open_env" 39 "start master" 40 } 41 set m2 [open_site_prog [subst $cmds]] 42 43 # Force subordinate client process to be the one to inform master of its 44 # address, to be sure there's a connection. This shouldn't be 45 # necessary, but it's hard to verify this in a test. 46 # 47 set cmds { 48 "home $cdir" 49 "local $cport" 50 "output $testdir/c1output" 51 "open_env" 52 "start client" 53 } 54 set c1 [open_site_prog [subst $cmds]] 55 56 set cmds { 57 "home $cdir" 58 "local $cport" 59 "output $testdir/c2output" 60 "remote localhost $mport" 61 "open_env" 62 "start client" 63 } 64 set c2 [open_site_prog [subst $cmds]] 65 66 set cenv [berkdb_env -home $cdir] 67 await_startup_done $cenv 68 69 puts "\tRepmgr$tnum.b: Stop master's subordinate process (pause)." 70 close $m2 71 72 # Pause to let client notice the connection loss. 73 tclsleep 3 74 75 # The client main process is still running, but it shouldn't care about 76 # a connection loss to the master's subordinate process. 77 78 puts "\tRepmgr$tnum.c:\ 79 Stop client's main process, then master's main process (pause)." 80 close $c1 81 tclsleep 2 82 close $m1 83 tclsleep 3 84 85 # If the client main process were still running, it would have reacted 86 # to the loss of the master by calling for an election. However, with 87 # only the client subordinate process still running, he cannot call for 88 # an election. So, we should see no elections ever having been 89 # started. 90 # 91 set election_count [stat_field $cenv rep_stat "Elections held"] 92 puts "\tRepmgr$tnum.d: Check election count ($election_count)." 93 error_check_good no_elections $election_count 0 94 95 $cenv close 96 close $c2 97} 98