Skip to content

Commit

Permalink
add more testcases for recover table
Browse files Browse the repository at this point in the history
  • Loading branch information
Vallishp committed Dec 3, 2024
1 parent c1a2e56 commit 3817091
Show file tree
Hide file tree
Showing 4 changed files with 345 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !target_sql_content_2 --
0 0
0 1
0 2
10 0
10 1
10 2
11 0
11 1
11 2
12 0
12 1
12 2
13 0
13 1
13 2
14 0
14 1
14 2
15 0
15 1
15 2
16 0
16 1
16 2
17 0
17 1
17 2
18 0
18 1
18 2
19 0
19 1
19 2
20 0
20 1
20 2

-- !sql_source_content_2 --
0 0
0 1
0 2
10 0
10 1
10 2
11 0
11 1
11 2
12 0
12 1
12 2
13 0
13 1
13 2
14 0
14 1
14 2
15 0
15 1
15 2
16 0
16 1
16 2
17 0
17 1
17 2
18 0
18 1
18 2
19 0
19 1
19 2
20 0
20 1
20 2

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !target_sql_content_2 --
0 0
0 1
0 2
10 0
10 1
10 2
11 0
11 1
11 2
12 0
12 1
12 2
13 0
13 1
13 2
14 0
14 1
14 2
15 0
15 1
15 2
16 0
16 1
16 2
17 0
17 1
17 2
18 0
18 1
18 2
19 0
19 1
19 2
20 0
20 1
20 2

-- !sql_source_content_2 --
0 0
0 1
0 2
10 0
10 1
10 2
11 0
11 1
11 2
12 0
12 1
12 2
13 0
13 1
13 2
14 0
14 1
14 2
15 0
15 1
15 2
16 0
16 1
16 2
17 0
17 1
17 2
18 0
18 1
18 2
19 0
19 1
19 2
20 0
20 1
20 2

Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// 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_tbl_drop_recover2") {
def helper = new GroovyShell(new Binding(['suite': delegate]))
.evaluate(new File("${context.config.suitePath}/../common", "helper.groovy"))

def tableName = "tbl_recover" + helper.randomSuffix()
def test_num = 0
def insert_num = 3
def opPartitonName = "less"

def exist = { res -> Boolean
return res.size() != 0
}
def notExist = { res -> Boolean
return res.size() == 0
}

helper.ccrJobDelete()

sql """
CREATE TABLE if NOT EXISTS ${tableName}_1
(
`test` INT,
`id` INT
)
ENGINE=OLAP
UNIQUE KEY(`test`, `id`)
PARTITION BY RANGE(`id`)
(
PARTITION `${opPartitonName}_0` VALUES LESS THAN ("0"),
PARTITION `${opPartitonName}_1` VALUES LESS THAN ("1000")
)
DISTRIBUTED BY HASH(id) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"binlog.enable" = "true"
)
"""



for (int index = 0; index < insert_num; index++) {
sql """
INSERT INTO ${tableName}_1 VALUES (${test_num}, ${index})
"""
}

sql """
DROP TABLE ${tableName}_1
"""
helper.enableDbBinlog()
helper.ccrJobCreate()
int interations = 10;
for(int t = 0; t <= interations; t += 1){
/* first iteration already deleted */
sql """
DROP TABLE if exists ${tableName}_1
"""

assertTrue(helper.checkShowTimesOf(""" SHOW TABLES LIKE "${tableName}_1" """, notExist, 60, "sql")) // check recovered in local
assertTrue(helper.checkShowTimesOf(""" SHOW TABLES LIKE "${tableName}_1" """, notExist, 60, "target"))

sql """
RECOVER TABLE ${tableName}_1
"""
assertTrue(helper.checkShowTimesOf(""" SHOW TABLES LIKE "${tableName}_1" """, exist, 60, "sql")) // check recovered in local
assertTrue(helper.checkShowTimesOf(""" SHOW TABLES LIKE "${tableName}_1" """, exist, 60, "target")) // check recovered in target

assertTrue(helper.checkRestoreFinishTimesOf("${tableName}_1", 60))

test_num = t + 10;
for (int index = 0; index < insert_num; index++) {
sql """
INSERT INTO ${tableName}_1 VALUES (${test_num}, ${index})
"""
}
// need check restore,
assertTrue(helper.checkRestoreFinishTimesOf("${tableName}_1", 60))
// check in remote available.
assertTrue(helper.checkSelectTimesOf("SELECT * FROM ${tableName}_1 WHERE test=${test_num}",
insert_num, 30))

}
order_qt_target_sql_content_2("SELECT * FROM ${tableName}_1")
qt_sql_source_content_2("SELECT * FROM ${tableName}_1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// 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_tbl_drop_recover3") {
def helper = new GroovyShell(new Binding(['suite': delegate]))
.evaluate(new File("${context.config.suitePath}/../common", "helper.groovy"))

def tableName = "tbl_recover" + helper.randomSuffix()
def test_num = 0
def insert_num = 3
def opPartitonName = "less"

def exist = { res -> Boolean
return res.size() != 0
}
def notExist = { res -> Boolean
return res.size() == 0
}

helper.ccrJobDelete()

sql """
CREATE TABLE if NOT EXISTS ${tableName}_1
(
`test` INT,
`id` INT
)
ENGINE=OLAP
UNIQUE KEY(`test`, `id`)
PARTITION BY RANGE(`id`)
(
PARTITION `${opPartitonName}_0` VALUES LESS THAN ("0"),
PARTITION `${opPartitonName}_1` VALUES LESS THAN ("1000")
)
DISTRIBUTED BY HASH(id) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"binlog.enable" = "true"
)
"""



for (int index = 0; index < insert_num; index++) {
sql """
INSERT INTO ${tableName}_1 VALUES (${test_num}, ${index})
"""
}

sql """
DROP TABLE ${tableName}_1
"""
helper.enableDbBinlog()
helper.ccrJobCreate()
int interations = 10;
for(int t = 0; t <= interations; t += 1){
/* first iteration already deleted */
sql """
DROP TABLE if exists ${tableName}_1
"""
sql """
RECOVER TABLE ${tableName}_1
"""
test_num = t + 10;
for (int index = 0; index < insert_num; index++) {
sql """
INSERT INTO ${tableName}_1 VALUES (${test_num}, ${index})
"""
}
}
// before validate, lets see restore is ok or not in target.
assertTrue(helper.checkRestoreFinishTimesOf("${tableName}_1", 60))
assertTrue(helper.checkSelectTimesOf("SELECT * FROM ${tableName}_1",36, 30))

order_qt_target_sql_content_2("SELECT * FROM ${tableName}_1")
qt_sql_source_content_2("SELECT * FROM ${tableName}_1")
}

0 comments on commit 3817091

Please sign in to comment.