~ubuntu-branches/ubuntu/saucy/db/saucy-proposed

« back to all changes in this revision

Viewing changes to test/tcl/repmgr030.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2010-11-05 15:02:09 UTC
  • mfrom: (13.1.12 sid)
  • Revision ID: james.westby@ubuntu.com-20101105150209-ppvyn0619pu014xo
Tags: 5.1.19-1ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Pass --build/--host to configure to support cross-building, and don't
    override CC.
  - Disable the Java build when cross-building, for now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See the file LICENSE for redistribution information.
 
2
#
 
3
# Copyright (c) 2007, 2010 Oracle and/or its affiliates.  All rights reserved.
 
4
#
 
5
# $Id$
 
6
#
 
7
# TEST  repmgr030
 
8
# TEST  repmgr multiple client-to-client peer test.
 
9
# 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.
 
16
# TEST
 
17
# TEST  Run for btree only because access method shouldn't matter.
 
18
# TEST
 
19
proc repmgr030 { { niter 100 } { tnum "030" } args } {
 
20
 
 
21
        source ./include.tcl
 
22
 
 
23
        if { $is_freebsd_test == 1 } {
 
24
                puts "Skipping replication manager test on FreeBSD platform."
 
25
                return
 
26
        }
 
27
 
 
28
        set method "btree"
 
29
        set args [convert_args $method $args]
 
30
 
 
31
        puts "Repmgr$tnum ($method): repmgr multiple c2c peer test."
 
32
        repmgr030_sub $method $niter $tnum $args
 
33
}
 
34
 
 
35
proc repmgr030_sub { method niter tnum largs } {
 
36
        global testdir
 
37
        global rep_verbose
 
38
        global verbose_type
 
39
        set nsites 4
 
40
 
 
41
        set verbargs ""
 
42
        if { $rep_verbose == 1 } {
 
43
                set verbargs " -verbose {$verbose_type on} "
 
44
        }
 
45
 
 
46
        env_cleanup $testdir
 
47
        set ports [available_ports $nsites]
 
48
        set omethod [convert_method $method]
 
49
 
 
50
        set masterdir $testdir/MASTERDIR
 
51
        set clientdir $testdir/CLIENTDIR
 
52
        set clientdir2 $testdir/CLIENTDIR2
 
53
        set clientdir3 $testdir/CLIENTDIR3
 
54
 
 
55
        file mkdir $masterdir
 
56
        file mkdir $clientdir
 
57
        file mkdir $clientdir2
 
58
        file mkdir $clientdir3
 
59
 
 
60
        # Use different connection retry timeout values to handle any
 
61
        # collisions from starting sites at the same time by retrying
 
62
        # at different times.
 
63
 
 
64
        # Open a master.
 
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]] \
 
72
            -start master
 
73
 
 
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]] \
 
86
            -start client
 
87
        await_startup_done $clientenv
 
88
 
 
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]] \
 
98
            -start client
 
99
        await_startup_done $clientenv2
 
100
 
 
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] \
 
110
            -start client
 
111
        await_startup_done $clientenv3
 
112
 
 
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
 
116
        # current master.
 
117
 
 
118
        puts "\tRepmgr$tnum.c: Configure third client for delayed sync."
 
119
        $clientenv3 rep_config {delayclient on}
 
120
 
 
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
 
126
 
 
127
        puts "\tRepmgr$tnum.e: Run some transactions at master."
 
128
        eval rep_test $method $masterenv NULL $niter 0 0 0 $largs
 
129
 
 
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
 
133
 
 
134
        puts "\tRepmgr$tnum.g: Run some more transactions at new master."
 
135
        eval rep_test $method $clientenv NULL $niter $niter 0 0 $largs
 
136
 
 
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.
 
140
        tclsleep 1
 
141
 
 
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
 
145
 
 
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
 
149
 
 
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
 
153
}