-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test for ccr sync relay create table #220
Open
wyxxxcat
wants to merge
2
commits into
selectdb:dev
Choose a base branch
from
wyxxxcat:ccr_tb_to_tb
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ class Helper { | |
destSpec.put("table", table) | ||
|
||
Map<String, Object> body = Maps.newHashMap() | ||
String name = context.suiteName | ||
String name = context.suiteName + "_" + dbName | ||
if (!table.equals("")) { | ||
name = name + "_" + table | ||
} | ||
|
@@ -67,8 +67,8 @@ class Helper { | |
return gson.toJson(body) | ||
} | ||
|
||
void ccrJobDelete(table = "") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For ccr tasks, it should be able to specify the table and db to perform the operation e.g. create pause |
||
def bodyJson = get_ccr_body "${table}" | ||
void ccrJobDelete(table = "", db = null) { | ||
def bodyJson = get_ccr_body(table, db) | ||
suite.httpTest { | ||
uri "/delete" | ||
endpoint syncerAddress | ||
|
@@ -77,8 +77,8 @@ class Helper { | |
} | ||
} | ||
|
||
void ccrJobCreate(table = "") { | ||
def bodyJson = get_ccr_body "${table}" | ||
void ccrJobCreate(table = "", db = null) { | ||
def bodyJson = get_ccr_body(table, db) | ||
suite.httpTest { | ||
uri "/create_ccr" | ||
endpoint syncerAddress | ||
|
@@ -103,8 +103,8 @@ class Helper { | |
} | ||
} | ||
|
||
void ccrJobPause(table = "") { | ||
def bodyJson = get_ccr_body "${table}" | ||
void ccrJobPause(table = "", db = null) { | ||
def bodyJson = get_ccr_body(table, db) | ||
suite.httpTest { | ||
uri "/pause" | ||
endpoint syncerAddress | ||
|
@@ -113,8 +113,8 @@ class Helper { | |
} | ||
} | ||
|
||
void ccrJobResume(table = "") { | ||
def bodyJson = get_ccr_body "${table}" | ||
void ccrJobResume(table = "", db = null) { | ||
def bodyJson = get_ccr_body(table, db) | ||
suite.httpTest { | ||
uri "/resume" | ||
endpoint syncerAddress | ||
|
@@ -123,8 +123,8 @@ class Helper { | |
} | ||
} | ||
|
||
void ccrJobDesync(table = "") { | ||
def bodyJson = get_ccr_body "${table}" | ||
void ccrJobDesync(table = "", db = null) { | ||
def bodyJson = get_ccr_body(table, db) | ||
suite.httpTest { | ||
uri "/desync" | ||
endpoint syncerAddress | ||
|
120 changes: 120 additions & 0 deletions
120
regression-test/suites/db_sync/table/relay/test_ds_table_relay.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
suite("test_ds_table_relay") { | ||
def helper = new GroovyShell(new Binding(['suite': delegate])) | ||
.evaluate(new File("${context.config.suitePath}/../common", "helper.groovy")) | ||
|
||
def tableName = "test_db_sync_create_table_relay_table_1" | ||
def tableTmpName = "test_db_sync_table_tmp" | ||
|
||
def dbNameOrigin = context.dbName | ||
def dbNameRelay = "TEST_" + context.dbName | ||
def dbNameNew = "TEST_" + "TEST_" + context.dbName | ||
|
||
|
||
def test_num = 0 | ||
def insert_num = 10 | ||
|
||
def exist = { res -> Boolean | ||
return res.size() != 0 | ||
} | ||
|
||
def notExist = { res -> Boolean | ||
return res.size() == 0 | ||
} | ||
|
||
helper.enableDbBinlog() | ||
|
||
sql "CREATE DATABASE IF NOT EXISTS ${dbNameRelay}" | ||
sql "CREATE DATABASE IF NOT EXISTS ${dbNameNew}" | ||
|
||
sql "DROP TABLE IF EXISTS ${dbNameOrigin}.${tableName}" | ||
sql "DROP TABLE IF EXISTS ${dbNameRelay}.${tableName}" | ||
sql "DROP TABLE IF EXISTS ${dbNameNew}.${tableName}" | ||
sql "DROP TABLE IF EXISTS ${dbNameNew}.${tableTmpName}" | ||
|
||
|
||
sql """ | ||
CREATE TABLE if NOT EXISTS ${dbNameOrigin}.${tableName} | ||
( | ||
`test` INT, | ||
`id` INT | ||
) | ||
UNIQUE KEY(`test`, `id`) | ||
DISTRIBUTED BY HASH(id) BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1", | ||
"binlog.enable" = "true" | ||
) | ||
""" | ||
sql """ | ||
CREATE TABLE if NOT EXISTS ${dbNameRelay}.${tableTmpName} | ||
( | ||
`test` INT, | ||
`id` INT | ||
) | ||
UNIQUE KEY(`test`, `id`) | ||
DISTRIBUTED BY HASH(id) BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1", | ||
"binlog.enable" = "true" | ||
) | ||
""" | ||
|
||
helper.ccrJobDelete("", dbNameOrigin) | ||
helper.ccrJobDelete("", dbNameRelay) | ||
helper.ccrJobCreate("", dbNameRelay) | ||
helper.ccrJobCreate("", dbNameOrigin) | ||
|
||
assertTrue(helper.checkRestoreFinishTimesOf("${tableName}", 60)) | ||
|
||
for (int index = 0; index < insert_num; index++) { | ||
sql """ | ||
INSERT INTO ${dbNameOrigin}.${tableName} VALUES (${test_num}, ${index}) | ||
""" | ||
} | ||
for (int index = 0; index < insert_num; index++) { | ||
sql """ | ||
INSERT INTO ${dbNameRelay}.${tableTmpName} VALUES (${test_num}, ${index}) | ||
""" | ||
} | ||
|
||
resultOrigin = sql "select * from ${dbNameOrigin}.${tableName}" | ||
|
||
assertEquals(resultOrigin.size(), insert_num) | ||
|
||
resultOrigin = sql "select * from ${dbNameRelay}.${tableTmpName}" | ||
|
||
assertEquals(resultOrigin.size(), insert_num) | ||
|
||
logger.info("=== Test 1: Check table exist ===") | ||
|
||
assertTrue(helper.checkShowTimesOf(""" select * from ${dbNameRelay}.${tableTmpName} """, exist, 60, "target")) | ||
|
||
assertTrue(helper.checkShowTimesOf(""" select * from ${dbNameNew}.${tableTmpName} """, exist, 60, "target")) | ||
|
||
assertTrue(helper.checkShowTimesOf(""" select * from ${dbNameOrigin}.${tableName} """, exist, 60, "target")) | ||
|
||
assertTrue(helper.checkShowTimesOf(""" select * from ${dbNameRelay}.${tableName} """, exist, 60, "target")) | ||
|
||
logger.info("=== Test 3: Check table not exist ===") | ||
|
||
sql "USE ${dbNameNew}" | ||
|
||
assertTrue(helper.checkShowTimesOf(""" SHOW TABLES LIKE "${tableName}" """, notExist, 60, "sql")) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For db-level synchronization tasks, they should be distinguished by dbname