File: rpl_multi_source_perfschema.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (356 lines) | stat: -rw-r--r-- 18,001 bytes parent folder | download
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
#
# WL#1697: Multi source Replication
#
# This test verifies that the replication performance schema tables work fine
# with multi-source replication.
# General idea of the test:
# 1) test the count of the rows in all the tables are fine.
# 2) count decreases or increases with channels
# 3) Joins could be made without error
#
# Note: we do not test exclusively the correctness of each field of all
# channels. The tests to test the correctness of individual channel (i.e default)
# are present in rpl_perfschema_* tests.

#Skip on group replication runs
--source include/not_group_replication_plugin.inc
--source include/have_binlog_format_mixed.inc
--source include/not_have_privilege_checks_user.inc
# Test requires master-info-repository=TABLE, relay-log-info-repository=TABLE
--source include/have_slave_repository_type_table.inc
--echo #
--echo # Set up masters server_1 and server_3 with server_2 being a slave.
--echo #
--let $rpl_topology= 1->2,3->2
--let $rpl_multi_source= 1
--source include/rpl_init.inc

--echo #
--echo # Test case 1: Create multiple sources and make sure that
--echo # number of sources= number of rows in all the performance schema tables.
--echo # On master, where replication is not setup, it shall show 0 rows.
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc

--let $num= `select count(*) from performance_schema.replication_connection_configuration`
--let $assert_text= Number of rows = 0 on master for repliation_connection_configuration table.
--let $assert_cond= $num = 0;
--source include/assert.inc

--let $num= `select count(*) from performance_schema.replication_connection_status`
--let $assert_text= Number of rows = 0 on master for repliation_connection_status table.
--let $assert_cond= $num= 0;
--source include/assert.inc

--let $num= `select count(*) from performance_schema.replication_applier_configuration`
--let $assert_text= Number of rows = 0 on master for repliation_applier_configuration table.
--let $assert_cond= $num = 0;
--source include/assert.inc

--let $num= `select count(*) from performance_schema.replication_applier_status`
--let $assert_text= Number of rows = 0 on master for repliation_applier_status table.
--let $assert_cond= $num = 0;
--source include/assert.inc

--let $num= `select count(*) from performance_schema.replication_applier_status_by_coordinator`
--let $assert_text= Number of rows = 0 on master for replication_applier_status_by coordinator table.
--let $assert_cond= $num = 0;
--source include/assert.inc

--let $num= `select count(*) from performance_schema.replication_applier_status_by_worker`
--let $assert_text= Number of rows = 0 on master for replication_applier_status_by_worker table.
--let $assert_cond= "$num" = 0;
--source include/assert.inc

--echo #
--echo # Test case 2: On the slave,  number of rows should be zero for a non existent channel
--echo #
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc

--let $num= `select count(*) from performance_schema.replication_connection_configuration where channel_name="non_existent"`
--let $assert_text= Number of rows= 0 on slave for a non existent channel for repliation_connection_configuration table.
--let $assert_cond= $num = 0;
--source include/assert.inc

--let $num= `select count(*) from performance_schema.replication_connection_status where channel_name="non_existent"`
--let $assert_text= Number of rows= 0 on slave for a non existent channel for repliation_connection_status table.
--let $assert_cond= $num = 0;
--source include/assert.inc

--let $num= `select count(*) from performance_schema.replication_applier_configuration where channel_name="non_existent"`
--let $assert_text= Number of rows= 0 on slave for a non existent channel for repliation_applier_configuration table.
--let $assert_cond= $num= 0;
--source include/assert.inc

--let $num= `select count(*) from performance_schema.replication_applier_status where channel_name="non_existent"`
--let $assert_text= Number of rows= 0 on slave for a non existent channel for repliation_applier_status table.
--let $assert_cond= $num = 0;
--source include/assert.inc

--let $num= `select count(*) from performance_schema.replication_applier_status_by_coordinator where channel_name="non_existent"`
--let $assert_text= Number of rows= 0 on slave for a non existent channel for repliation_applier_status_by_coordinaotor table.
--let $assert_cond= $num= 0;
--source include/assert.inc

--let $num= `select count(*) from performance_schema.replication_applier_status_by_worker where channel_name="non_existent"`
--let $assert_text= Number of rows= 0 on slave for a non existent channel for replication_applier_status_by_worker table.
--let $assert_cond= "$num"= 0;
--source include/assert.inc

--echo #
--echo #  Test case 3: Rows on multi sourced slave, shall be 2. In workers table it should be
--echo #               2*@@global.replica_parallel_workers
USE performance_schema;

--let $assert_text= there shall be 2 rows for replication_connection_configuration
--let $assert_cond= [select count(*) from performance_schema.replication_connection_configuration] = 2;
--source include/assert.inc

--let $assert_text= there shall be 2 rows for replication_connection_status
--let $assert_cond= [select count(*) from performance_schema.replication_connection_status] = 2;
--source include/assert.inc

--let $assert_text= there shall be 2 rows for replication_applier_configuration
--let $assert_cond= [select count(*) from performance_schema.replication_applier_configuration] = 2 ;
--source include/assert.inc

--let $assert_text= there shall be 2 rows for replication_applier_status
--let $assert_cond= [select count(*) from performance_schema.replication_applier_status] = 2;
--source include/assert.inc

# Post Bug#20001173 fix in case of Single Threaded Slave(STS) mode SQL
# thread's status will be reported as part of
# performance_schema.replication_applier_status_by_worker table.
--let $w_rows= `select @@global.replica_parallel_workers`
if ($w_rows != 0)
{
  --let $assert_text= there shall be 2 rows for replication_connection_configuration
  --let $assert_cond= [select count(*) from performance_schema.replication_applier_status_by_coordinator] = 2;
  --source include/assert.inc
}

if ($w_rows == 0)
{
  --let $assert_text= there shall be 2 rows for replication_connection_configuration
  --let $assert_cond= [select count(*) from performance_schema.replication_applier_status_by_worker] = 2;
  --source include/assert.inc
}

# Post Bug#20001173 fix in case of Single Threaded Slave(STS) mode SQL
# thread's status will be reported as part of
# performance_schema.replication_applier_status_by_worker table.
# SQL thread will have the corresponding worker_id as 0.
--let $pfs_w_rows= `select count(*) from performance_schema.replication_applier_status_by_worker where worker_id != 0`
--let $w_rows= `select 2*@@global.replica_parallel_workers`
--let $assert_text= there shall be 2*global.replica_parallel_workers rows for 2 configured channels.
--let $assert_cond= "$pfs_w_rows" = "$w_rows"
--source include/assert.inc


--echo #
--echo # Test case 4: Verify that selects work on named channels
--echo #              Do this verification by comparing with some known data
--echo #
#check that port value returned by channel_3 is same as SERVER_MYPORT_3
--let $channel_3_port= `select port from performance_schema.replication_connection_configuration where channel_name="channel_3"`
--let $assert_text= pfs query shall return the correct query value of the channel_3 port.
--let $assert_cond= "$channel_3_port"= "$SERVER_MYPORT_3"
--source include/assert.inc

--let $service_state= `select service_state from performance_schema.replication_connection_status where channel_name="channel_3"`
--let $assert_text= service state of receiver thread shall be ON.
--let $assert_cond= "ON" = "$service_state"
--source include/assert.inc

let $sss_value=query_get_value(SHOW SLAVE STATUS FOR CHANNEL 'channel_3', SQL_Delay, 1);
let $ps_value= query_get_value(select Desired_Delay from performance_schema.replication_applier_configuration where channel_name = "channel_3", Desired_Delay, 1);
let $assert_text= Value returned by SSS and PS table for Desired_Delay should be same.;
let $assert_cond= "$sss_value" = "$ps_value";
--source include/assert.inc

--let $service_state= `select service_state from performance_schema.replication_applier_status where channel_name="channel_3"`
--let $assert_text= service state shall be ON
--let $assert_cond= "ON" = "$service_state"
--source include/assert.inc

# Post Bug#20001173 fix in case of Single Threaded Slave(STS) mode SQL
# thread's status will be reported as part of
# performance_schema.replication_applier_status_by_worker table.
--let $service_state= `select service_state from performance_schema.replication_applier_status_by_worker where channel_name="channel_3"`
--let $assert_text= service state of coordinator shall be ON
--let $assert_cond= "ON" = "$service_state"
--source include/assert.inc

if ( `select @@GLOBAL.replica_parallel_workers > 0`)
{
  --let $service_state= `select service_state from performance_schema.replication_applier_status_by_worker where channel_name="channel_3" and worker_id= 1`
  --let $assert_text= service state of worker thread shall be ON
  --let $assert_cond= "ON" = "$service_state"
  --let $include_silent= 1
  --source include/assert.inc
  --let $include_silent= 0
}


--echo #
--echo #  Stop the slave on channel_1 and verify that rows are still instact
--echo #
--let $rpl_channel_name= 'channel_1'
--source include/stop_slave.inc

--echo #
--echo # Test case 5: Verify that selects work on named channels even
--echo #              after a channel is stopped. test that service state is OFF
--echo #

--let $channel_1_port= `select port from performance_schema.replication_connection_configuration where channel_name="channel_1"`
--let $assert_text=  After stop slave for channel, replication_connection_configuration is intact
--let $assert_cond= "$channel_1_port"= "$SERVER_MYPORT_1"
--source include/assert.inc

--let $service_state= `select service_state from performance_schema.replication_connection_status where channel_name="channel_1"`
--let $assert_text=  After stop slave for channel, service state is OFF for connection_status table.
--let $assert_cond= "OFF" = "$service_state"
--source include/assert.inc

--let $service_state= `select service_state from performance_schema.replication_applier_status where channel_name="channel_1"`
--let $assert_text=  After stop slave for channel, service state is OFF for applier_status table.
--let $assert_cond= "OFF" = "$service_state"
--source include/assert.inc

# Post Bug#20001173 fix in case of Single Threaded Slave(STS) mode SQL
# thread's status will be reported as part of
# performance_schema.replication_applier_status_by_worker table.
--let $service_state= `select service_state from performance_schema.replication_applier_status_by_worker where channel_name="channel_1"`
--let $assert_text=  After stop slave for channel, service state is OFF by replication_applier_status_by_worker table.
--let $assert_cond= "OFF" = "$service_state"
--source include/assert.inc

if ( `select @@GLOBAL.replica_parallel_workers > 0`)
{
  --let $service_state= `select service_state from performance_schema.replication_applier_status_by_worker where channel_name="channel_1" and worker_id= 1`
  --let $assert_text= service state of worker thread shall be OFF
  --let $assert_cond= "OFF" = "$service_state"
  --let $include_silent= 1
  --source include/assert.inc
  --let $include_silent= 0
}


--echo #
--echo #  Test case 6): Do a sanity check that joins can be performed as replication tables
--echo #                 contain multiple rows now.
# Post Bug#20001173 fix in case of Single Threaded Slave(STS) mode SQL
# thread's status will be reported as part of
# performance_schema.replication_applier_status_by_worker table.
--let $w_rows= `select @@global.replica_parallel_workers`
if ($w_rows != 0)
{
  --disable_query_log
  --replace_column 3 # 4 # 6 # 7 # 13 #
  --query_vertical(select connection_status.CHANNEL_NAME, GROUP_NAME, SOURCE_UUID, connection_status.THREAD_ID, connection_status.SERVICE_STATE, COUNT_RECEIVED_HEARTBEATS, LAST_HEARTBEAT_TIMESTAMP, RECEIVED_TRANSACTION_SET, connection_status.LAST_ERROR_NUMBER, connection_status.LAST_ERROR_MESSAGE, connection_status.LAST_ERROR_TIMESTAMP, coordinator_status.CHANNEL_NAME, coordinator_status.THREAD_ID, coordinator_status.SERVICE_STATE, coordinator_status.LAST_ERROR_NUMBER, coordinator_status.LAST_ERROR_MESSAGE, coordinator_status.LAST_ERROR_TIMESTAMP from replication_connection_status connection_status, replication_applier_status_by_coordinator coordinator_status where connection_status.channel_name= coordinator_status.channel_name)
  --enable_query_log
}

if ($w_rows == 0)
{
  --disable_query_log
  --replace_column 3 # 4 # 6 # 7 # 13 #
  --query_vertical(select connection_status.CHANNEL_NAME, GROUP_NAME, SOURCE_UUID, connection_status.THREAD_ID, connection_status.SERVICE_STATE, COUNT_RECEIVED_HEARTBEATS, LAST_HEARTBEAT_TIMESTAMP, RECEIVED_TRANSACTION_SET, connection_status.LAST_ERROR_NUMBER, connection_status.LAST_ERROR_MESSAGE, connection_status.LAST_ERROR_TIMESTAMP, worker_status.CHANNEL_NAME, worker_status.THREAD_ID, worker_status.SERVICE_STATE, worker_status.LAST_ERROR_NUMBER, worker_status.LAST_ERROR_MESSAGE, worker_status.LAST_ERROR_TIMESTAMP from replication_connection_status connection_status, replication_applier_status_by_worker worker_status where connection_status.channel_name= worker_status.channel_name and worker_status.worker_id=0)
  --enable_query_log
}

--echo #
--echo # Test case 7: Delete channel_3 and count the number of rows in each table.
--echo #
--let $rpl_channel_name= 'channel_3'
--source include/stop_slave.inc
RESET SLAVE ALL FOR CHANNEL 'channel_3';

--let $assert_text= there shall be 1 in replication connection_configuration table after a channel is deleted.
--let $assert_cond= [select count(*) from performance_schema.replication_connection_configuration] = 1;
--source include/assert.inc

--let $assert_text= there shall be 1 in replication connection_status table after a channel is deleted.
--let $assert_cond= [select count(*) from performance_schema.replication_connection_status] = 1;
--source include/assert.inc

--let $assert_text= there shall be 1 in replication applier_config table after a channel is deleted.
--let $assert_cond= [select count(*) from performance_schema.replication_applier_configuration] = 1 ;
--source include/assert.inc

--let $assert_text= there shall be 1 in replication applier_status table after a channel is deleted.
--let $assert_cond= [select count(*) from performance_schema.replication_applier_status] = 1;
--source include/assert.inc

# Post Bug#20001173 fix in case of Single Threaded Slave(STS) mode SQL
# thread's status will be reported as part of
# performance_schema.replication_applier_status_by_worker table.
# SQL thread will have the corresponding worker_id as 0.
--let $w_rows= `select @@global.replica_parallel_workers`

if ($w_rows == 0)
{
  --let $assert_text= there shall be 1 applier after a channel is deleted.
  --let $assert_cond= [select count(*) from performance_schema.replication_applier_status_by_worker where worker_id=0] = 1;
  --source include/assert.inc
  --let $pfs_w_rows= `select count(*) from performance_schema.replication_applier_status_by_worker where worker_id !=0`
  --let $w_rows= `select @@global.replica_parallel_workers`
  --let $assert_text= there shall be global.replica_parallel_workers rows after a channel is deleted.
  --let $assert_cond= "$pfs_w_rows" = "$w_rows"
  --source include/assert.inc
}
if ($w_rows != 0)
{
  --let $assert_text= there shall be 1 applier after a channel is deleted.
  --let $assert_cond= [select count(*) from performance_schema.replication_applier_status_by_coordinator] = 1;
  --source include/assert.inc
  --let $pfs_w_rows= `select count(*) from performance_schema.replication_applier_status_by_worker`
  --let $w_rows= `select @@global.replica_parallel_workers`
  --let $assert_text= there shall be global.replica_parallel_workers rows after a channel is deleted.
  --let $assert_cond= "$pfs_w_rows" = "$w_rows"
  --source include/assert.inc
}



--echo #
--echo #  Test case 8: Do a complete delete and see if the number of rows are zero
--echo #
RESET SLAVE ALL;


--let $assert_text= there shall be 0 rows after all channels are deleted.
--let $assert_cond= [select count(*) from performance_schema.replication_connection_configuration] = 0;
--source include/assert.inc

--let $assert_text= there shall be 0 rows after all channels are deleted.
--let $assert_cond= [select count(*) from performance_schema.replication_connection_status] = 0;
--source include/assert.inc

--let $assert_text= there shall be 0 rows after all channels are deleted.
--let $assert_cond= [select count(*) from performance_schema.replication_applier_configuration] = 0 ;
--source include/assert.inc

--let $assert_text= there shall be 0 rows after all channels are deleted.
--let $assert_cond= [select count(*) from performance_schema.replication_applier_status] = 0;
--source include/assert.inc

--let $assert_text= there shall be 0 rows after all channels are deleted.
--let $assert_cond= [select count(*) from performance_schema.replication_applier_status_by_coordinator] = 0;
--source include/assert.inc

--let $pfs_w_rows= `select count(*) from performance_schema.replication_applier_status_by_worker`
--let $w_rows= `select @@global.replica_parallel_workers`
--let $assert_text= there shall be global.replica_parallel_workers rows after a channel is deleted.

--let $assert_text= there shall be 0 rows after all channels are deleted.
--let $assert_cond= "$pfs_w_rows" = "0"
--source include/assert.inc

--let $rpl_skip_sync= 1
--let $rpl_skip_delete_channels= 1
--let $rpl_only_running_threads= 1
--let $rpl_group_replication= 1
--source include/rpl_end.inc