1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2009, 2013 Oracle and/or its affiliates. All rights reserved.
#
# TEST repmgr109
# TEST Test repmgr's internal juggling of peer EID's.
# TEST
# TEST Set up master and 2 clients, A and B.
# TEST Add a third client (C), with two processes.
# TEST The first process will be configured to know about A.
# TEST The second process will know about B, and set that as peer,
# TEST but when it joins the env site B will have to be shuffled
# TEST into a later position in the list, because A is already first.
# This whole test is highly dependent upon the internal implementation structure
# of repmgr's multi-process support. If that implementation changes, this test
# may become irrelevant, irrational, and inconsequential. If that happens, it
# makes sense to simply discard this test.
proc repmgr109 { } {
foreach initial_action {true false} {
foreach while_active {true false} {
repmgr109_sub $initial_action $while_active
}
}
}
proc repmgr109_sub { {a_too false} {while_active true} } {
source ./include.tcl
if {$a_too} {
set part1 "shuffle with peer reassignment"
} else {
set part1 "shuffle"
}
if {$while_active} {
set part2 "while active"
} else {
set part2 "while not active"
}
set tnum "109"
puts "Repmgr$tnum: ($part1, then peer change $part2)"
env_cleanup $testdir
foreach {mport aport bport cport} [available_ports 4] {}
file mkdir [set dirm $testdir/M]
file mkdir [set dira $testdir/A]
file mkdir [set dirb $testdir/B]
file mkdir [set dirc $testdir/C]
set dbc {{repmgr_set_ack_policy DB_REPMGR_ACKS_ALL}}
make_dbconfig $dirm $dbc
make_dbconfig $dira $dbc
make_dbconfig $dirb $dbc
make_dbconfig $dirc $dbc
puts "\tRepmgr$tnum.a: Create a master and first two clients."
set cmds {
"home $dirm"
"local $mport"
"output $testdir/moutput"
"open_env"
"start master"
}
set m [open_site_prog [subst $cmds]]
set cmds {
"home $dira"
"local $aport"
"output $testdir/aoutput"
"remote 127.0.0.1 $mport"
"open_env"
"start client"
}
set a [open_site_prog [subst $cmds]]
set cmds {
"home $dirb"
"local $bport"
"output $testdir/boutput"
"remote 127.0.0.1 $mport"
"open_env"
"start client"
}
set b [open_site_prog [subst $cmds]]
set aenv [berkdb_env -home $dira]
await_startup_done $aenv
set benv [berkdb_env -home $dirb]
await_startup_done $benv
# Now it gets interesting.
puts "\tRepmgr$tnum.b: Create client C, with two processes."
if {$a_too} {
set peer_flag "-p"
} else {
set peer_flag ""
}
set cmds {
"home $dirc"
"local $cport"
"output $testdir/c1output"
"remote $peer_flag 127.0.0.1 $aport"
"remote 127.0.0.1 $mport"
"open_env"
}
set c1 [open_site_prog [subst $cmds]]
set cmds {
"home $dirc"
"local $cport"
"output $testdir/c2output"
"remote -p 127.0.0.1 $bport"
"remote 127.0.0.1 $aport"
"open_env"
}
set c2 [open_site_prog [subst $cmds]]
puts $c1 "start client"
gets $c1
set cenv [berkdb_env -home $dirc]
await_startup_done $cenv
puts "\tRepmgr$tnum.c: Check resulting statistics."
# Make sure we used B, not A, as the c2c peer.
set requests_at_A [repmgr109_get_request_count $aenv]
set requests_at_B [repmgr109_get_request_count $benv]
error_check_good no_requests_at_A $requests_at_A 0
error_check_bad some_requests_at_B $requests_at_B 0
# Check that site list order is what we expect.
set sl [$cenv repmgr_site_list]
error_check_good site_list [lindex $sl 0 2] $aport
error_check_good site_list [lindex $sl 1 2] $mport
error_check_good site_list [lindex $sl 2 2] $bport
# Give client C a reason to send another request: shut it down, and
# create some new transactions at the master.
#
puts $c2 "exit"
gets $c2
close $c2
puts $c1 "exit"
gets $c1
close $c1
puts $m "open_db test.db"
puts $m "put k1 v1"
puts $m "put k2 v2"
puts $m "echo done"
gets $m
# Change peer setting at C.
#
puts "\tRepmgr$tnum.d: Start client C again."
if { $while_active } {
set cmds {
"home $dirc"
"output $testdir/c1output2"
"open_env"
"remote 127.0.0.1 $bport"
"remote -p 127.0.0.1 $aport"
"start client"
}
} else {
set cmds {
"home $dirc"
"output $testdir/c1output2"
"remote 127.0.0.1 $bport"
"remote -p 127.0.0.1 $aport"
"open_env"
"start client"
}
}
set c [open_site_prog [subst $cmds]]
# Wait for restarted client to catch up with master.
set menv [berkdb_env -home $dirm]
set seq 0
set cond {
incr seq
puts $m "put newkey$seq newdata$seq"
puts $m "echo done"
gets $m
set log_end [next_expected_lsn $menv]
set client_log_end [next_expected_lsn $cenv]
expr [string compare $client_log_end $log_end] == 0
}
await_condition {[eval $cond]}
# Make sure client B has not serviced any more requests, and that
# instead now client A has serviced some.
error_check_good no_addl_reqs \
[repmgr109_get_request_count $benv] $requests_at_B
error_check_bad some_requests_at_A [repmgr109_get_request_count $aenv] 0
$cenv close
$benv close
$aenv close
$menv close
close $c
close $a
close $b
close $m
}
proc repmgr109_get_request_count { env } {
stat_field $env rep_stat "Client service requests"
}
|