~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to mysql-test/extra/rpl_tests/rpl_test_framework.inc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ==== Purpose ====
 
2
#
 
3
# Auxiliary file used by suite/rpl/t/rpl_test_framework.test
 
4
#
 
5
# The purpose is to check that the sync chain generated in
 
6
# rpl_change_topology.inc (invoked from rpl_init.inc) is correct. This
 
7
# is done in two ways:
 
8
#  (1) Print the sync chain.
 
9
#  (2) Execute a statement and verify that it replicates to all slaves.
 
10
#
 
11
#
 
12
# ==== Implementation ====
 
13
#
 
14
# Does this:
 
15
# (1) Set up a given replication topology (rpl_init.inc)
 
16
# (2) Print $rpl_sync_chain
 
17
# (3) Execute "DELETE FROM t1" and then "INSERT INTO t1" on the master
 
18
# (4) Sync and compare all servers.
 
19
# (5) Clean up the replication topology (rpl_end.inc)
 
20
#
 
21
# (Technical detail: Since DELETE FROM t1 is not executed at the end,
 
22
# some servers may have rows left in t1 from a previous invocation of
 
23
# rpl_test_framework.inc.  Therefore, this file will only work in
 
24
# statement mode where "DELETE FROM t1" removes rows that exist on
 
25
# slave but not on master.)
 
26
#
 
27
#
 
28
# ==== Usage ====
 
29
#
 
30
# --let $rpl_server_count= <number>
 
31
# --let $rpl_topology= <topology specification>
 
32
# --let $masters= <list of masters>
 
33
# [--let $rpl_diff_servers= <list of servers>]
 
34
# --source extra/rpl_tests/rpl_test_framework.inc
 
35
#
 
36
# Parameters:
 
37
#   $next_number
 
38
#     The INSERT statement will insert $next_number into t1, and
 
39
#     $next_number will increase by 1.
 
40
#
 
41
#   $rpl_server_count, $rpl_topology:
 
42
#     See include/rpl_init.inc
 
43
#
 
44
#   $masters
 
45
#     This should be a list of numbers, each identifying a server.
 
46
#     The DELETE and INSERT statements will be executed on all servers
 
47
#     in the list.
 
48
#
 
49
#   $rpl_diff_servers
 
50
#     See include/rpl_diff.inc
 
51
 
 
52
--source include/rpl_init.inc
 
53
--source include/rpl_generate_sync_chain.inc
 
54
--echo rpl_sync_chain= '$rpl_sync_chain'
 
55
 
 
56
--inc $next_number
 
57
 
 
58
# Iterate over masters
 
59
while ($masters)
 
60
{
 
61
  --let $master_i= `SELECT SUBSTRING_INDEX('$masters', ',', 1)`
 
62
  --let $masters= `SELECT SUBSTRING('$masters', LENGTH('$master_i') + 2)`
 
63
 
 
64
  # Connect to master and execute statement
 
65
  --let $rpl_connection_name= server_$master_i
 
66
  --source include/rpl_connection.inc
 
67
  DELETE FROM t1;
 
68
  --eval INSERT INTO t1 VALUES ($next_number)
 
69
}
 
70
 
 
71
--source include/rpl_sync.inc
 
72
 
 
73
# Compare all servers.
 
74
--let $diff_tables= server_$rpl_server_count:t1
 
75
--let $server_i= $rpl_server_count
 
76
--dec $server_i
 
77
while ($server_i)
 
78
{
 
79
  --let $diff_tables= server_$server_i:t1,$diff_tables
 
80
  --dec $server_i
 
81
}
 
82
--source include/diff_tables.inc
 
83
 
 
84
--let $diff_servers=
 
85
--let $masters=
 
86
--source include/rpl_end.inc