From 3817091baebf9aee22fadbe3354ae7cd797ecd79 Mon Sep 17 00:00:00 2001 From: Vallish Date: Tue, 3 Dec 2024 16:44:07 +0000 Subject: [PATCH] add more testcases for recover table --- .../recover2/test_ds_tbl_drop_recover2.out | 77 +++++++++++++ .../recover3/test_ds_tbl_drop_recover3.out | 77 +++++++++++++ .../recover2/test_ds_tbl_drop_recover2.groovy | 101 ++++++++++++++++++ .../recover3/test_ds_tbl_drop_recover3.groovy | 90 ++++++++++++++++ 4 files changed, 345 insertions(+) create mode 100644 regression-test/data/db_sync/table/recover2/test_ds_tbl_drop_recover2.out create mode 100644 regression-test/data/db_sync/table/recover3/test_ds_tbl_drop_recover3.out create mode 100644 regression-test/suites/db_sync/table/recover2/test_ds_tbl_drop_recover2.groovy create mode 100644 regression-test/suites/db_sync/table/recover3/test_ds_tbl_drop_recover3.groovy diff --git a/regression-test/data/db_sync/table/recover2/test_ds_tbl_drop_recover2.out b/regression-test/data/db_sync/table/recover2/test_ds_tbl_drop_recover2.out new file mode 100644 index 00000000..75dd0ac9 --- /dev/null +++ b/regression-test/data/db_sync/table/recover2/test_ds_tbl_drop_recover2.out @@ -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 + diff --git a/regression-test/data/db_sync/table/recover3/test_ds_tbl_drop_recover3.out b/regression-test/data/db_sync/table/recover3/test_ds_tbl_drop_recover3.out new file mode 100644 index 00000000..75dd0ac9 --- /dev/null +++ b/regression-test/data/db_sync/table/recover3/test_ds_tbl_drop_recover3.out @@ -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 + diff --git a/regression-test/suites/db_sync/table/recover2/test_ds_tbl_drop_recover2.groovy b/regression-test/suites/db_sync/table/recover2/test_ds_tbl_drop_recover2.groovy new file mode 100644 index 00000000..1d677d57 --- /dev/null +++ b/regression-test/suites/db_sync/table/recover2/test_ds_tbl_drop_recover2.groovy @@ -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") +} diff --git a/regression-test/suites/db_sync/table/recover3/test_ds_tbl_drop_recover3.groovy b/regression-test/suites/db_sync/table/recover3/test_ds_tbl_drop_recover3.groovy new file mode 100644 index 00000000..32efed44 --- /dev/null +++ b/regression-test/suites/db_sync/table/recover3/test_ds_tbl_drop_recover3.groovy @@ -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") +}