-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip overwritten tables in partial snapshot (#241)
- Loading branch information
Showing
3 changed files
with
178 additions
and
0 deletions.
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
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
149 changes: 149 additions & 0 deletions
149
...ession-test/suites/cross_ds/table/drop/alter_create/test_cds_tbl_alter_drop_create.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,149 @@ | ||
// 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_cds_tbl_alter_drop_create") { | ||
def helper = new GroovyShell(new Binding(['suite': delegate])) | ||
.evaluate(new File("${context.config.suitePath}/../common", "helper.groovy")) | ||
|
||
if (!helper.is_version_supported([30003, 20108, 20016])) { | ||
// at least doris 3.0.3, 2.1.8 and doris 2.0.16 | ||
def version = helper.upstream_version() | ||
logger.info("skip this suite because version is not supported, upstream version ${version}") | ||
return | ||
} | ||
|
||
def oldTableName = "tbl_old_" + helper.randomSuffix() | ||
def newTableName = "tbl_new_" + helper.randomSuffix() | ||
|
||
def exist = { res -> Boolean | ||
return res.size() != 0 | ||
} | ||
def notExist = { res -> Boolean | ||
return res.size() == 0 | ||
} | ||
|
||
logger.info("=== Create a fake table ===") | ||
sql """ | ||
CREATE TABLE if NOT EXISTS ${oldTableName}_fake | ||
( | ||
`test` INT, | ||
`id` INT | ||
) | ||
ENGINE=OLAP | ||
UNIQUE KEY(`test`, `id`) | ||
PARTITION BY RANGE(`id`) | ||
( | ||
PARTITION `p1` VALUES LESS THAN ("0"), | ||
PARTITION `p2` VALUES LESS THAN ("100"), | ||
PARTITION `p3` VALUES LESS THAN ("200"), | ||
PARTITION `p4` VALUES LESS THAN ("300"), | ||
PARTITION `p5` VALUES LESS THAN ("1000") | ||
) | ||
DISTRIBUTED BY HASH(id) BUCKETS AUTO | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1", | ||
"binlog.enable" = "true" | ||
) | ||
""" | ||
|
||
helper.enableDbBinlog() | ||
helper.ccrJobDelete() | ||
helper.ccrJobCreate() | ||
|
||
assertTrue(helper.checkRestoreFinishTimesOf("${oldTableName}_fake", 60)) | ||
|
||
logger.info(" ==== create table and drop ==== ") | ||
|
||
def first_job_progress = helper.get_job_progress() | ||
|
||
helper.ccrJobPause() | ||
|
||
sql """ | ||
CREATE TABLE if NOT EXISTS ${oldTableName} | ||
( | ||
`test` INT, | ||
`id` INT | ||
) | ||
ENGINE=OLAP | ||
UNIQUE KEY(`test`, `id`) | ||
PARTITION BY RANGE(`id`) | ||
( | ||
PARTITION `p1` VALUES LESS THAN ("0"), | ||
PARTITION `p2` VALUES LESS THAN ("100"), | ||
PARTITION `p3` VALUES LESS THAN ("200"), | ||
PARTITION `p4` VALUES LESS THAN ("300"), | ||
PARTITION `p5` VALUES LESS THAN ("1000") | ||
) | ||
DISTRIBUTED BY HASH(id) BUCKETS AUTO | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1", | ||
"binlog.enable" = "true" | ||
) | ||
""" | ||
|
||
sql "INSERT INTO ${oldTableName} VALUES (1, 100), (100, 1), (2, 200), (200, 2)" | ||
sql "ALTER TABLE ${oldTableName} ADD COLUMN `new_col` INT KEY DEFAULT \"0\"" | ||
|
||
assertTrue(helper.checkShowTimesOf(""" | ||
SHOW ALTER TABLE COLUMN | ||
FROM ${context.dbName} | ||
WHERE TableName = "${oldTableName}" AND State = "FINISHED" | ||
""", | ||
exist, 30)) | ||
|
||
sql "INSERT INTO ${oldTableName} VALUES (5, 500, 1)" | ||
sql "DROP TABLE ${oldTableName} FORCE" | ||
sql "INSERT INTO ${oldTableName}_fake VALUES (5, 500)" | ||
|
||
logger.info("create table ${oldTableName} again ") | ||
|
||
sql """ | ||
CREATE TABLE if NOT EXISTS ${oldTableName} | ||
( | ||
`test` INT, | ||
`id` INT | ||
) | ||
ENGINE=OLAP | ||
UNIQUE KEY(`test`, `id`) | ||
PARTITION BY RANGE(`id`) | ||
( | ||
PARTITION `p1` VALUES LESS THAN ("0"), | ||
PARTITION `p2` VALUES LESS THAN ("100"), | ||
PARTITION `p3` VALUES LESS THAN ("200"), | ||
PARTITION `p4` VALUES LESS THAN ("300"), | ||
PARTITION `p5` VALUES LESS THAN ("1000") | ||
) | ||
DISTRIBUTED BY HASH(id) BUCKETS AUTO | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1", | ||
"binlog.enable" = "true" | ||
) | ||
""" | ||
|
||
sql "INSERT INTO ${oldTableName} VALUES (1, 100), (100, 1), (2, 200), (200, 2)" | ||
sql "INSERT INTO ${oldTableName}_fake VALUES (1, 100), (100, 1), (2, 200), (200, 2)" | ||
|
||
helper.ccrJobResume() | ||
|
||
assertTrue(helper.checkSelectTimesOf("SELECT * FROM ${oldTableName}_fake", 5, 60)) | ||
assertTrue(helper.checkSelectTimesOf("SELECT * FROM ${oldTableName}", 4, 60)) | ||
assertTrue(helper.checkShowTimesOf("SHOW TABLES LIKE \"${oldTableName}\"", exist, 60, "target")) | ||
|
||
// no fullsync are triggered | ||
def last_job_progress = helper.get_job_progress() | ||
assertTrue(last_job_progress.full_sync_start_at == first_job_progress.full_sync_start_at) | ||
} |