1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 2007, 2010 Oracle and/or its affiliates. All rights reserved.
8
# TEST repmgr multiple client-to-client peer test.
10
# TEST Start an appointed master and three clients. The third client
11
# TEST configures the other two clients as peers and delays client
12
# TEST sync. Add some data and confirm that the third client uses first
13
# TEST client as a peer. Close the master so that the first client now
14
# TEST becomes the master. Add some more data and confirm that the
15
# TEST third client now uses the second client as a peer.
17
# TEST Run for btree only because access method shouldn't matter.
19
proc repmgr030 { { niter 100 } { tnum "030" } args } {
23
if { $is_freebsd_test == 1 } {
24
puts "Skipping replication manager test on FreeBSD platform."
29
set args [convert_args $method $args]
31
puts "Repmgr$tnum ($method): repmgr multiple c2c peer test."
32
repmgr030_sub $method $niter $tnum $args
35
proc repmgr030_sub { method niter tnum largs } {
42
if { $rep_verbose == 1 } {
43
set verbargs " -verbose {$verbose_type on} "
47
set ports [available_ports $nsites]
48
set omethod [convert_method $method]
50
set masterdir $testdir/MASTERDIR
51
set clientdir $testdir/CLIENTDIR
52
set clientdir2 $testdir/CLIENTDIR2
53
set clientdir3 $testdir/CLIENTDIR3
57
file mkdir $clientdir2
58
file mkdir $clientdir3
60
# Use different connection retry timeout values to handle any
61
# collisions from starting sites at the same time by retrying
65
puts "\tRepmgr$tnum.a: Start a master."
66
set ma_envcmd "berkdb_env_noerr -create $verbargs \
67
-errpfx MASTER -home $masterdir -txn -rep -thread"
68
set masterenv [eval $ma_envcmd]
69
$masterenv repmgr -ack all -nsites $nsites -pri 100 \
70
-timeout {connection_retry 20000000} \
71
-local [list localhost [lindex $ports 0]] \
74
# Open three clients, setting first two as peers of the third and
75
# configuring third for delayed sync.
76
puts "\tRepmgr$tnum.b: Start three clients, third with two peers."
77
set cl_envcmd "berkdb_env_noerr -create $verbargs \
78
-errpfx CLIENT -home $clientdir -txn -rep -thread"
79
set clientenv [eval $cl_envcmd]
80
$clientenv repmgr -ack all -nsites $nsites -pri 80 \
81
-timeout {connection_retry 10000000} \
82
-local [list localhost [lindex $ports 1]] \
83
-remote [list localhost [lindex $ports 0]] \
84
-remote [list localhost [lindex $ports 2]] \
85
-remote [list localhost [lindex $ports 3]] \
87
await_startup_done $clientenv
89
set cl2_envcmd "berkdb_env_noerr -create $verbargs \
90
-errpfx CLIENT2 -home $clientdir2 -txn -rep -thread"
91
set clientenv2 [eval $cl2_envcmd]
92
$clientenv2 repmgr -ack all -nsites $nsites -pri 50 \
93
-timeout {connection_retry 5000000} \
94
-local [list localhost [lindex $ports 2]] \
95
-remote [list localhost [lindex $ports 0]] \
96
-remote [list localhost [lindex $ports 1]] \
97
-remote [list localhost [lindex $ports 3]] \
99
await_startup_done $clientenv2
101
set cl3_envcmd "berkdb_env_noerr -create $verbargs \
102
-errpfx CLIENT3 -home $clientdir3 -txn -rep -thread"
103
set clientenv3 [eval $cl3_envcmd]
104
$clientenv3 repmgr -ack all -nsites $nsites -pri 50 \
105
-timeout {connection_retry 75000000} \
106
-local [list localhost [lindex $ports 3]] \
107
-remote [list localhost [lindex $ports 0]] \
108
-remote [list localhost [lindex $ports 1] peer] \
109
-remote [list localhost [lindex $ports 2] peer] \
111
await_startup_done $clientenv3
113
# Internally, repmgr does the following to determine the peer
114
# to use: it scans the internal list of remote sites, selecting
115
# the first one that is marked as a peer and that is not the
118
puts "\tRepmgr$tnum.c: Configure third client for delayed sync."
119
$clientenv3 rep_config {delayclient on}
121
puts "\tRepmgr$tnum.d: Check third client used first client as peer."
122
set creqs [stat_field $clientenv rep_stat "Client service requests"]
123
set c2reqs [stat_field $clientenv2 rep_stat "Client service requests"]
124
error_check_good got_client_reqs [expr {$creqs > 0}] 1
125
error_check_good no_client2_reqs [expr {$c2reqs == 0}] 1
127
puts "\tRepmgr$tnum.e: Run some transactions at master."
128
eval rep_test $method $masterenv NULL $niter 0 0 0 $largs
130
puts "\tRepmgr$tnum.f: Shut down master, first client takes over."
131
error_check_good masterenv_close [$masterenv close] 0
132
await_expected_master $clientenv
134
puts "\tRepmgr$tnum.g: Run some more transactions at new master."
135
eval rep_test $method $clientenv NULL $niter $niter 0 0 $largs
137
puts "\tRepmgr$tnum.h: Sync delayed third client."
138
error_check_good rep_sync [$clientenv3 rep_sync] 0
139
# Give sync requests a bit of time to show up in stats.
142
puts "\tRepmgr$tnum.i: Check third client used second client as peer."
143
set c2reqs [stat_field $clientenv2 rep_stat "Client service requests"]
144
error_check_good got_client2_reqs [expr {$c2reqs > 0}] 1
146
puts "\tRepmgr$tnum.j: Verifying client database contents."
147
rep_verify $clientdir $clientenv $clientdir2 $clientenv2 1 1 1
148
rep_verify $clientdir $clientenv $clientdir3 $clientenv3 1 1 1
150
error_check_good client3_close [$clientenv3 close] 0
151
error_check_good client2_close [$clientenv2 close] 0
152
error_check_good client_close [$clientenv close] 0