github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/shardddl3/run.sh (about) 1 #!/bin/bash 2 3 set -eu 4 5 cur=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 6 source $cur/../_utils/test_prepare 7 WORK_DIR=$TEST_DIR/$TEST_NAME 8 source $cur/../_utils/shardddl_lib.sh 9 10 function DM_071_CASE() { 11 run_sql_source1 "alter table ${shardddl1}.${tb1} default character set utf8mb4 collate utf8mb4_bin;" 12 run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,'aaa');" 13 run_sql_source2 "insert into ${shardddl1}.${tb1} values(2,'bbb');" 14 run_sql_source2 "insert into ${shardddl1}.${tb2} values(3,'ccc');" 15 16 run_sql_source2 "alter table ${shardddl1}.${tb1} default character set utf8mb4 collate utf8mb4_bin;" 17 run_sql_source1 "insert into ${shardddl1}.${tb1} values(4,'ddd');" 18 run_sql_source2 "insert into ${shardddl1}.${tb1} values(5,'eee');" 19 run_sql_source2 "insert into ${shardddl1}.${tb2} values(6,'fff');" 20 21 run_sql_source2 "alter table ${shardddl1}.${tb2} default character set utf8mb4 collate utf8mb4_bin;" 22 run_sql_source1 "insert into ${shardddl1}.${tb1} values(7,'ggg');" 23 run_sql_source2 "insert into ${shardddl1}.${tb1} values(8,'hhh');" 24 run_sql_source2 "insert into ${shardddl1}.${tb2} values(9,'iii');" 25 26 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 27 } 28 29 function DM_071() { 30 run_case 071 "double-source-pessimistic" \ 31 "run_sql_source1 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"; \ 32 run_sql_source2 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"; \ 33 run_sql_source2 \"create table ${shardddl1}.${tb2} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"" \ 34 "clean_table" "pessimistic" 35 36 # schema comparer doesn't support to compare/diff charset now 37 # run_case 071 "double-source-optimistic" \ 38 # "run_sql_source1 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"; \ 39 # run_sql_source2 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"; \ 40 # run_sql_source2 \"create table ${shardddl1}.${tb2} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"" \ 41 # "clean_table" "optimistic" 42 } 43 44 function DM_073_CASE() { 45 run_sql_source1 "alter table ${shardddl1}.${tb1} convert to character set utf8mb4 collate utf8mb4_bin;" 46 run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,'aaa');" 47 run_sql_source2 "insert into ${shardddl1}.${tb1} values(2,'bbb');" 48 run_sql_source2 "insert into ${shardddl1}.${tb2} values(3,'ccc');" 49 50 run_sql_source2 "alter table ${shardddl1}.${tb1} convert to character set utf8mb4 collate utf8mb4_bin;" 51 run_sql_source1 "insert into ${shardddl1}.${tb1} values(4,'ddd');" 52 run_sql_source2 "insert into ${shardddl1}.${tb1} values(5,'eee');" 53 run_sql_source2 "insert into ${shardddl1}.${tb2} values(6,'fff');" 54 55 run_sql_source2 "alter table ${shardddl1}.${tb2} convert to character set utf8mb4 collate utf8mb4_bin;" 56 run_sql_source1 "insert into ${shardddl1}.${tb1} values(7,'ggg');" 57 run_sql_source2 "insert into ${shardddl1}.${tb1} values(8,'hhh');" 58 run_sql_source2 "insert into ${shardddl1}.${tb2} values(9,'iii');" 59 60 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 61 } 62 63 function DM_073() { 64 run_case 073 "double-source-pessimistic" \ 65 "run_sql_source1 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"; \ 66 run_sql_source2 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"; \ 67 run_sql_source2 \"create table ${shardddl1}.${tb2} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"" \ 68 "clean_table" "pessimistic" 69 70 # schema comparer doesn't support to compare/diff charset now 71 # run_case 073 "double-source-optimistic" \ 72 # "run_sql_source1 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"; \ 73 # run_sql_source2 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"; \ 74 # run_sql_source2 \"create table ${shardddl1}.${tb2} (a int primary key, b varchar(10)) default character set utf8 collate utf8_bin;\"" \ 75 # "clean_table" "optimistic" 76 } 77 78 function DM_076_CASE() { 79 run_sql_source1 "alter table ${shardddl1}.${tb1} add primary key(id);" 80 run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,1);" 81 82 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 83 } 84 85 function DM_076() { 86 run_case 076 "single-source-pessimistic" \ 87 "run_sql_source1 \"create table ${shardddl1}.${tb1} (a int unique, id int);\"" \ 88 "clean_table" "pessimistic" 89 run_case 076 "single-source-optimistic" \ 90 "run_sql_source1 \"create table ${shardddl1}.${tb1} (a int unique, id int);\"" \ 91 "clean_table" "optimistic" 92 } 93 94 function DM_077_CASE() { 95 run_sql_source1 "alter table ${shardddl1}.${tb1} drop primary key;" 96 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 97 "query-status test" \ 98 "Unsupported drop primary key" 1 99 } 100 101 function DM_077() { 102 run_sql_tidb "create database if not exists ${shardddl};" 103 run_sql_tidb "create table ${shardddl}.${tb} (id int, primary key(id) clustered);" 104 run_case 077 "single-source-pessimistic" "run_sql_source1 \"create table ${shardddl1}.${tb1} (id int primary key);\"" "clean_table" "" 105 run_sql_tidb "create table ${shardddl}.${tb} (id int, primary key(id) clustered);" 106 run_case 077 "single-source-optimistic" "run_sql_source1 \"create table ${shardddl1}.${tb1} (id int primary key);\"" "clean_table" "" 107 } 108 109 function DM_078_CASE() { 110 run_sql_source1 "insert into ${shardddl1}.${tb1} values (1, 1, 'wer'), (2, 2, NULL);" 111 run_sql_source1 "alter table ${shardddl1}.${tb1} add primary key(a);" 112 run_sql_source1 "insert into ${shardddl1}.${tb1} values (3, 3, 'wer'), (4, 4, NULL);" 113 114 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 115 } 116 117 function DM_078() { 118 run_case 078 "single-source-pessimistic" "run_sql_source1 \"create table ${shardddl1}.${tb1} (id int unique, a int, b varchar(10));\"" "clean_table" "" 119 run_case 078 "single-source-optimistic" "run_sql_source1 \"create table ${shardddl1}.${tb1} (id int unique, a int, b varchar(10));\"" "clean_table" "" 120 } 121 122 function DM_079_CASE() { 123 run_sql_source1 "insert into ${shardddl1}.${tb1} values (1, 'wer'), (2, NULL);" 124 run_sql_source1 "alter table ${shardddl1}.${tb1} drop primary key;" 125 run_sql_source1 "insert into ${shardddl1}.${tb1} values (0, 'wer'), (0, NULL);" 126 127 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 128 "query-status test" \ 129 "Unsupported drop primary key" 1 130 } 131 132 function DM_079() { 133 run_case 079 "single-source-pessimistic" "run_sql_source1 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10));\"" "clean_table" "" 134 run_case 079 "single-source-optimistic" "run_sql_source1 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10));\"" "clean_table" "" 135 } 136 137 function DM_080_CASE() { 138 run_sql_source1 "alter table ${shardddl1}.${tb1} add unique key idx_a(a);" 139 run_sql_source1 "alter table ${shardddl1}.${tb1} add unique key idx_b(b);" 140 run_sql_source1 "alter table ${shardddl1}.${tb1} add unique key idx_ab(a,b);" 141 run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,1,'aaa');" 142 run_sql_source2 "insert into ${shardddl1}.${tb1} values(2,1,'aaa');" 143 run_sql_source2 "alter table ${shardddl1}.${tb1} add unique key idx_a(a);" 144 run_sql_source2 "alter table ${shardddl1}.${tb1} add unique key idx_b(b);" 145 run_sql_source2 "alter table ${shardddl1}.${tb1} add unique key idx_ab(a,b);" 146 run_sql_source1 "insert into ${shardddl1}.${tb1} values(3,2,'bbb');" 147 run_sql_source2 "insert into ${shardddl1}.${tb1} values(4,2,'bbb');" 148 run_sql_source2 "insert into ${shardddl1}.${tb2} values(5,2,'bbb');" 149 run_sql_source2 "alter table ${shardddl1}.${tb2} add unique key idx_a(a);" 150 run_sql_source2 "alter table ${shardddl1}.${tb2} add unique key idx_b(b);" 151 run_sql_source2 "alter table ${shardddl1}.${tb2} add unique key idx_ab(a,b);" 152 run_sql_source1 "insert into ${shardddl1}.${tb1} values(6,3,'ccc');" 153 run_sql_source2 "insert into ${shardddl1}.${tb1} values(7,3,'ccc');" 154 run_sql_source2 "insert into ${shardddl1}.${tb2} values(8,3,'ccc');" 155 run_sql_tidb_with_retry "select count(1) from ${shardddl}.${tb};" "count(1): 3" 156 } 157 158 function DM_080() { 159 run_case 080 "double-source-pessimistic" \ 160 "run_sql_source1 \"create table ${shardddl1}.${tb1} (id int primary key, a int, b varchar(10));\"; \ 161 run_sql_source2 \"create table ${shardddl1}.${tb1} (id int primary key, a int, b varchar(10));\"; \ 162 run_sql_source2 \"create table ${shardddl1}.${tb2} (id int primary key, a int, b varchar(10));\"" \ 163 "clean_table" "pessimistic" 164 165 # currently not support optimistic 166 #run_case 080 "double-source-optimistic" \ 167 #"run_sql_source1 \"create table ${shardddl1}.${tb1} (id int primary key, a int, b varchar(10));\"; \ 168 # run_sql_source2 \"create table ${shardddl1}.${tb1} (id int primary key, a int, b varchar(10));\"; \ 169 # run_sql_source2 \"create table ${shardddl1}.${tb2} (id int primary key, a int, b varchar(10));\"" \ 170 #"clean_table" "optimistic" 171 } 172 173 function DM_081_CASE() { 174 run_sql_source1 "alter table ${shardddl1}.${tb1} add unique key idx_a(a);" 175 run_sql_source1 "alter table ${shardddl1}.${tb1} add unique key idx_b(b);" 176 run_sql_source1 "alter table ${shardddl1}.${tb1} add unique key idx_ab(a,b);" 177 run_sql_source2 "alter table ${shardddl1}.${tb1} add unique key idx_a(a);" 178 run_sql_source2 "alter table ${shardddl1}.${tb1} add unique key idx_b(b);" 179 run_sql_source2 "alter table ${shardddl1}.${tb1} add unique key idx_ab(a,b);" 180 run_sql_source2 "alter table ${shardddl1}.${tb2} add unique key idx_a(a);" 181 run_sql_source2 "alter table ${shardddl1}.${tb2} add unique key idx_b(b);" 182 run_sql_source2 "alter table ${shardddl1}.${tb2} add unique key idx_ab(a,b);" 183 184 run_sql_source1 "alter table ${shardddl1}.${tb1} drop index idx_a;" 185 run_sql_source1 "alter table ${shardddl1}.${tb1} drop index idx_b;" 186 run_sql_source1 "alter table ${shardddl1}.${tb1} drop index idx_ab;" 187 run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,1,'aaa');" 188 run_sql_source2 "insert into ${shardddl1}.${tb1} values(2,1,'aaa');" 189 run_sql_source2 "alter table ${shardddl1}.${tb1} drop index idx_a;" 190 run_sql_source2 "alter table ${shardddl1}.${tb1} drop index idx_b;" 191 run_sql_source2 "alter table ${shardddl1}.${tb1} drop index idx_ab;" 192 run_sql_source1 "insert into ${shardddl1}.${tb1} values(3,2,'bbb');" 193 run_sql_source2 "insert into ${shardddl1}.${tb1} values(4,2,'bbb');" 194 run_sql_source2 "insert into ${shardddl1}.${tb2} values(5,2,'bbb');" 195 run_sql_source2 "alter table ${shardddl1}.${tb2} drop index idx_a;" 196 run_sql_source2 "alter table ${shardddl1}.${tb2} drop index idx_b;" 197 run_sql_source2 "alter table ${shardddl1}.${tb2} drop index idx_ab;" 198 run_sql_source1 "insert into ${shardddl1}.${tb1} values(6,3,'ccc');" 199 run_sql_source2 "insert into ${shardddl1}.${tb1} values(7,3,'ccc');" 200 run_sql_source2 "insert into ${shardddl1}.${tb2} values(8,3,'ccc');" 201 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 202 } 203 204 function DM_081() { 205 run_case 081 "double-source-pessimistic" \ 206 "run_sql_source1 \"create table ${shardddl1}.${tb1} (id int primary key, a int, b varchar(10));\"; \ 207 run_sql_source2 \"create table ${shardddl1}.${tb1} (id int primary key, a int, b varchar(10));\"; \ 208 run_sql_source2 \"create table ${shardddl1}.${tb2} (id int primary key, a int, b varchar(10));\"" \ 209 "clean_table" "pessimistic" 210 211 # currently not support optimistic 212 # run_case 081 "double-source-optimistic" \ 213 #"run_sql_source1 \"create table ${shardddl1}.${tb1} (id int primary key, a int, b varchar(10));\"; \ 214 # run_sql_source2 \"create table ${shardddl1}.${tb1} (id int primary key, a int, b varchar(10));\"; \ 215 # run_sql_source2 \"create table ${shardddl1}.${tb2} (id int primary key, a int, b varchar(10));\"" \ 216 #"clean_table" "optimistic" 217 } 218 219 function DM_082_CASE() { 220 run_sql_source1 "alter table ${shardddl1}.${tb1} rename index a to c;" 221 run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,'aaa');" 222 run_sql_source2 "insert into ${shardddl1}.${tb1} values(2,'bbb');" 223 run_sql_source2 "insert into ${shardddl1}.${tb2} values(3,'ccc');" 224 run_sql_source2 "alter table ${shardddl1}.${tb1} rename index a to c;" 225 run_sql_source1 "insert into ${shardddl1}.${tb1} values(4,'ddd');" 226 run_sql_source2 "insert into ${shardddl1}.${tb1} values(5,'eee');" 227 run_sql_source2 "insert into ${shardddl1}.${tb2} values(6,'fff');" 228 run_sql_source2 "alter table ${shardddl1}.${tb2} rename index a to c;" 229 run_sql_source1 "insert into ${shardddl1}.${tb1} values(7,'ggg');" 230 run_sql_source2 "insert into ${shardddl1}.${tb1} values(8,'hhh');" 231 run_sql_source2 "insert into ${shardddl1}.${tb2} values(9,'iii');" 232 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 233 } 234 235 function DM_082() { 236 run_case 082 "double-source-pessimistic" \ 237 "run_sql_source1 \"create table ${shardddl1}.${tb1} (a int unique key, b varchar(10));\"; \ 238 run_sql_source2 \"create table ${shardddl1}.${tb1} (a int unique key, b varchar(10));\"; \ 239 run_sql_source2 \"create table ${shardddl1}.${tb2} (a int unique key, b varchar(10));\"" \ 240 "clean_table" "pessimistic" 241 242 # currently not support optimistic 243 # run_case 082 "double-source-optimistic" \ 244 #"run_sql_source1 \"create table ${shardddl1}.${tb1} (a int unique key, b varchar(10));\"; \ 245 # run_sql_source2 \"create table ${shardddl1}.${tb1} (a int unique key, b varchar(10));\"; \ 246 # run_sql_source2 \"create table ${shardddl1}.${tb2} (a int unique key, b varchar(10));\"" \ 247 #"clean_table" "optimistic" 248 } 249 250 function DM_085_CASE() { 251 run_sql_source2 "alter table ${shardddl1}.${tb1} alter index a visible;" 252 run_sql_source2 "insert into ${shardddl1}.${tb1} values(1,'aaa');" 253 run_sql_source2 "insert into ${shardddl1}.${tb2} values(2,'bbb');" 254 run_sql_source2 "insert into ${shardddl1}.${tb3} values(3,'ccc');" 255 run_sql_source2 "alter table ${shardddl1}.${tb2} alter index a visible;" 256 run_sql_source2 "insert into ${shardddl1}.${tb1} values(4,'ddd');" 257 run_sql_source2 "insert into ${shardddl1}.${tb2} values(5,'eee');" 258 run_sql_source2 "insert into ${shardddl1}.${tb3} values(6,'fff');" 259 run_sql_source2 "alter table ${shardddl1}.${tb3} alter index a visible;" 260 run_sql_source2 "insert into ${shardddl1}.${tb1} values(7,'ggg');" 261 run_sql_source2 "insert into ${shardddl1}.${tb2} values(8,'hhh');" 262 run_sql_source2 "insert into ${shardddl1}.${tb3} values(9,'iii');" 263 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 264 } 265 266 function DM_085() { 267 # `ALTER INDEX` not supported in MySQL 5.7, but we setup the second MySQL 8.0 in CI now. 268 run_case 085 "single-source-pessimistic-2" \ 269 "run_sql_source2 \"create table ${shardddl1}.${tb1} (a int unique key, b varchar(10));\"; \ 270 run_sql_source2 \"create table ${shardddl1}.${tb2} (a int unique key, b varchar(10));\"; \ 271 run_sql_source2 \"create table ${shardddl1}.${tb3} (a int unique key, b varchar(10));\"" \ 272 "clean_table" "pessimistic" 273 274 run_case 085 "single-source-optimistic-2" \ 275 "run_sql_source2 \"create table ${shardddl1}.${tb1} (a int unique key, b varchar(10));\"; \ 276 run_sql_source2 \"create table ${shardddl1}.${tb2} (a int unique key, b varchar(10));\"; \ 277 run_sql_source2 \"create table ${shardddl1}.${tb3} (a int unique key, b varchar(10));\"" \ 278 "clean_table" "optimistic" 279 } 280 281 function DM_086_CASE() { 282 run_sql_source2 "alter table ${shardddl1}.${tb1} alter index a visible;" 283 run_sql_source2 "insert into ${shardddl1}.${tb1} values(1,'aaa');" 284 run_sql_source2 "insert into ${shardddl1}.${tb2} values(2,'bbb');" 285 run_sql_source2 "insert into ${shardddl1}.${tb3} values(3,'ccc');" 286 run_sql_source2 "alter table ${shardddl1}.${tb2} alter index a invisible;" 287 run_sql_source2 "insert into ${shardddl1}.${tb1} values(4,'ddd');" 288 run_sql_source2 "insert into ${shardddl1}.${tb2} values(5,'eee');" 289 run_sql_source2 "insert into ${shardddl1}.${tb3} values(6,'fff');" 290 run_sql_source2 "alter table ${shardddl1}.${tb3} alter index a visible;" 291 run_sql_source2 "insert into ${shardddl1}.${tb1} values(7,'ggg');" 292 run_sql_source2 "insert into ${shardddl1}.${tb2} values(8,'hhh');" 293 run_sql_source2 "insert into ${shardddl1}.${tb3} values(9,'iii');" 294 295 if [[ "$1" = "pessimistic" ]]; then 296 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 297 "query-status test" \ 298 "detect inconsistent DDL sequence from source" 1 299 else 300 # schema comparer for optimistic shard DDL can't diff visible/invisible now. 301 # may this needs to be failed? 302 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 303 fi 304 } 305 306 function DM_086() { 307 # `ALTER INDEX` not supported in MySQL 5.7, but we setup the second MySQL 8.0 in CI now. 308 run_case 086 "single-source-pessimistic-2" \ 309 "run_sql_source2 \"create table ${shardddl1}.${tb1} (a int unique key, b varchar(10));\"; \ 310 run_sql_source2 \"create table ${shardddl1}.${tb2} (a int unique key, b varchar(10));\"; \ 311 run_sql_source2 \"create table ${shardddl1}.${tb3} (a int unique key, b varchar(10));\"" \ 312 "clean_table" "pessimistic" 313 314 run_case 086 "single-source-optimistic-2" \ 315 "run_sql_source2 \"create table ${shardddl1}.${tb1} (a int unique key, b varchar(10));\"; \ 316 run_sql_source2 \"create table ${shardddl1}.${tb2} (a int unique key, b varchar(10));\"; \ 317 run_sql_source2 \"create table ${shardddl1}.${tb3} (a int unique key, b varchar(10));\"" \ 318 "clean_table" "optimistic" 319 } 320 321 function DM_094_CASE() { 322 # here we run ddl to make sure we flush first check point in syncer 323 # otherwise the worker may dump again when restart 324 run_sql_source1 "alter table ${shardddl1}.${tb1} add column col int;" 325 run_sql_source1 "alter table ${shardddl1}.${tb2} add column col int;" 326 run_sql_source2 "alter table ${shardddl1}.${tb1} add column col int;" 327 run_sql_source2 "alter table ${shardddl1}.${tb2} add column col int;" 328 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 329 330 run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,1);" 331 run_sql_source2 "insert into ${shardddl1}.${tb1} values(2,2);" 332 run_sql_source2 "insert into ${shardddl1}.${tb2} values(3,3);" 333 run_sql_source1 "insert into ${shardddl1}.${tb2} values(4,4);" 334 335 run_sql_source1 "alter table ${shardddl1}.${tb1} add column new_col1 int;" 336 run_sql_source2 "alter table ${shardddl1}.${tb1} add column new_col1 int;" 337 338 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 339 "stop-task test" \ 340 "\"result\": true" 3 341 342 run_sql_source1 "alter table ${shardddl1}.${tb2} add column new_col1 int;" 343 run_sql_source2 "alter table ${shardddl1}.${tb2} add column new_col1 int;" 344 345 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 346 "start-task $cur/conf/double-source-$1.yaml" \ 347 "\"result\": true" 3 348 349 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 350 } 351 352 function DM_094() { 353 run_case 094 "double-source-pessimistic" "init_table 111 112 211 212" "clean_table" "pessimistic" 354 run_case 094 "double-source-optimistic" "init_table 111 112 211 212" "clean_table" "optimistic" 355 } 356 357 function DM_095_CASE() { 358 # here we run ddl to make sure we flush first check point in syncer 359 # otherwise the worker may dump again when restart 360 run_sql_source1 "alter table ${shardddl1}.${tb1} add column col int;" 361 run_sql_source1 "alter table ${shardddl1}.${tb2} add column col int;" 362 run_sql_source2 "alter table ${shardddl1}.${tb1} add column col int;" 363 run_sql_source2 "alter table ${shardddl1}.${tb2} add column col int;" 364 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 365 366 run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,1);" 367 run_sql_source2 "insert into ${shardddl1}.${tb1} values(2,2);" 368 run_sql_source2 "insert into ${shardddl1}.${tb2} values(3,3);" 369 run_sql_source1 "insert into ${shardddl1}.${tb2} values(4,4);" 370 371 run_sql_source1 "alter table ${shardddl1}.${tb1} add column new_col1 int;" 372 run_sql_source2 "alter table ${shardddl1}.${tb1} add column new_col1 int;" 373 374 # do not check pause result because we may pause when auto resume in optimistic 375 # then pause-task "result": true may not 3 376 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 377 "pause-task test" 378 379 run_sql_source1 "alter table ${shardddl1}.${tb2} add column new_col1 int;" 380 run_sql_source2 "alter table ${shardddl1}.${tb2} add column new_col1 int;" 381 382 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 383 "resume-task test" \ 384 "\"result\": true" 3 385 386 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 387 } 388 389 function DM_095() { 390 run_case 095 "double-source-pessimistic" "init_table 111 112 211 212" "clean_table" "pessimistic" 391 run_case 095 "double-source-optimistic" "init_table 111 112 211 212" "clean_table" "optimistic" 392 } 393 394 function DM_096_CASE() { 395 # here we run ddl to make sure we flush first check point in syncer 396 # otherwise the worker may dump again when restart 397 run_sql_source1 "alter table ${shardddl1}.${tb1} add column col int;" 398 run_sql_source1 "alter table ${shardddl1}.${tb2} add column col int;" 399 run_sql_source2 "alter table ${shardddl1}.${tb1} add column col int;" 400 run_sql_source2 "alter table ${shardddl1}.${tb2} add column col int;" 401 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 402 403 run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,1);" 404 run_sql_source2 "insert into ${shardddl1}.${tb1} values(2,2);" 405 run_sql_source2 "insert into ${shardddl1}.${tb2} values(3,3);" 406 run_sql_source1 "insert into ${shardddl1}.${tb2} values(4,4);" 407 408 run_sql_source1 "alter table ${shardddl1}.${tb1} add column new_col1 int;" 409 run_sql_source2 "alter table ${shardddl1}.${tb1} add column new_col1 int;" 410 411 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 412 "pause-task test" 413 414 run_sql_source1 "alter table ${shardddl1}.${tb2} add column new_col1 int;" 415 run_sql_source2 "alter table ${shardddl1}.${tb2} add column new_col1 int;" 416 417 # TODO: uncomment after we support update-task 418 # run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 419 # "update-task $cur/conf/double-source-$1.yaml" \ 420 # "\"result\": true" 1 421 422 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 423 "resume-task test" \ 424 "\"result\": true" 3 425 426 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 427 } 428 429 function DM_096() { 430 run_case 096 "double-source-pessimistic" "init_table 111 112 211 212" "clean_table" "pessimistic" 431 run_case 096 "double-source-optimistic" "init_table 111 112 211 212" "clean_table" "optimistic" 432 } 433 434 function DM_097_CASE() { 435 # here we run ddl to make sure we flush first check point in syncer 436 # otherwise the worker may dump again when restart 437 run_sql_source1 "alter table ${shardddl1}.${tb1} add column col int;" 438 run_sql_source1 "alter table ${shardddl1}.${tb2} add column col int;" 439 run_sql_source2 "alter table ${shardddl1}.${tb1} add column col int;" 440 run_sql_source2 "alter table ${shardddl1}.${tb2} add column col int;" 441 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 442 443 run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,1);" 444 run_sql_source2 "insert into ${shardddl1}.${tb1} values(2,2);" 445 run_sql_source2 "insert into ${shardddl1}.${tb2} values(3,3);" 446 run_sql_source1 "insert into ${shardddl1}.${tb2} values(4,4);" 447 448 run_sql_source1 "alter table ${shardddl1}.${tb1} add column new_col1 int;" 449 run_sql_source2 "alter table ${shardddl1}.${tb1} add column new_col1 int;" 450 451 kill_process dm-master 452 check_master_port_offline 1 453 454 run_sql_source1 "alter table ${shardddl1}.${tb2} add column new_col1 int;" 455 run_sql_source2 "alter table ${shardddl1}.${tb2} add column new_col1 int;" 456 457 run_dm_master $WORK_DIR/master $MASTER_PORT $cur/conf/dm-master.toml 458 check_rpc_alive $cur/../bin/check_master_online 127.0.0.1:$MASTER_PORT 459 460 # Task may be paused by error because master has restarted 461 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 462 "resume-task test" 463 464 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 465 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 466 "query-status test" \ 467 "\"stage\": \"Running\"" 3 468 } 469 470 function DM_097() { 471 run_case 097 "double-source-pessimistic" "init_table 111 112 211 212" "clean_table" "pessimistic" 472 run_case 097 "double-source-optimistic" "init_table 111 112 211 212" "clean_table" "optimistic" 473 } 474 475 function DM_098_CASE() { 476 # here we run ddl to make sure we flush first check point in syncer 477 # otherwise the worker may dump again when restart 478 run_sql_source1 "alter table ${shardddl1}.${tb1} add column col int;" 479 run_sql_source1 "alter table ${shardddl1}.${tb2} add column col int;" 480 run_sql_source2 "alter table ${shardddl1}.${tb1} add column col int;" 481 run_sql_source2 "alter table ${shardddl1}.${tb2} add column col int;" 482 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 483 484 run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,1);" 485 run_sql_source2 "insert into ${shardddl1}.${tb1} values(2,2);" 486 run_sql_source2 "insert into ${shardddl1}.${tb2} values(3,3);" 487 run_sql_source1 "insert into ${shardddl1}.${tb2} values(4,4);" 488 489 run_sql_source1 "alter table ${shardddl1}.${tb1} add column new_col1 int;" 490 491 kill_process dm-worker1 492 check_port_offline $WORKER1_PORT 20 493 494 run_sql_source2 "alter table ${shardddl1}.${tb1} add column new_col1 int;" 495 run_sql_source1 "alter table ${shardddl1}.${tb2} add column new_col1 int;" 496 497 run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml 498 check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT 499 500 run_sql_source2 "alter table ${shardddl1}.${tb2} add column new_col1 int;" 501 502 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 503 } 504 505 function DM_098() { 506 run_case 098 "double-source-pessimistic" "init_table 111 112 211 212" "clean_table" "pessimistic" 507 } 508 509 function run() { 510 init_cluster 511 init_database 512 start=71 513 end=98 514 except=(072 074 075 083 084 087 088 089 090 091 092 093) 515 for i in $(seq -f "%03g" ${start} ${end}); do 516 if [[ ${except[@]} =~ $i ]]; then 517 continue 518 fi 519 DM_${i} 520 sleep 1 521 done 522 } 523 524 cleanup_data $shardddl 525 cleanup_data $shardddl1 526 cleanup_data $shardddl2 527 # also cleanup dm processes in case of last run failed 528 cleanup_process $* 529 run $* 530 cleanup_process $* 531 532 echo "[$(date)] <<<<<< test case $TEST_NAME success! >>>>>>"