forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cases](regression-test) Add backup restore operation test
1. restore overwrites an exists table 2. backup & restore with exclude table 3. restore to a new table 4. restore mix exists and new tables 5. restore with alias
- Loading branch information
Showing
8 changed files
with
574 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
regression-test/data/backup_restore/test_backup_restore_alias.out
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,41 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select -- | ||
1 1 | ||
2 2 | ||
3 3 | ||
4 4 | ||
5 5 | ||
6 6 | ||
7 7 | ||
8 8 | ||
9 9 | ||
10 10 | ||
20 21 | ||
123 341 | ||
|
||
-- !select -- | ||
1 1 | ||
2 2 | ||
3 3 | ||
4 4 | ||
5 5 | ||
6 6 | ||
7 7 | ||
8 8 | ||
9 9 | ||
10 10 | ||
20 21 | ||
123 341 | ||
|
||
-- !select -- | ||
1 1 | ||
2 2 | ||
3 3 | ||
4 4 | ||
5 5 | ||
6 6 | ||
7 7 | ||
8 8 | ||
9 9 | ||
10 10 | ||
|
29 changes: 29 additions & 0 deletions
29
regression-test/data/backup_restore/test_backup_restore_exclude.out
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,29 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select -- | ||
1 1 | ||
2 2 | ||
3 3 | ||
4 4 | ||
5 5 | ||
6 6 | ||
7 7 | ||
8 8 | ||
9 9 | ||
10 10 | ||
20 20 | ||
21 21 | ||
|
||
-- !select -- | ||
1 1 | ||
2 2 | ||
3 3 | ||
4 4 | ||
5 5 | ||
6 6 | ||
7 7 | ||
8 8 | ||
9 9 | ||
10 10 | ||
20 20 | ||
21 21 | ||
|
27 changes: 27 additions & 0 deletions
27
regression-test/data/backup_restore/test_backup_restore_multi_tables_overwrite.out
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,27 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select -- | ||
1 1 | ||
2 2 | ||
3 3 | ||
4 4 | ||
5 5 | ||
6 6 | ||
7 7 | ||
8 8 | ||
9 9 | ||
10 10 | ||
20 20 | ||
21 21 | ||
|
||
-- !select -- | ||
1 1 | ||
2 2 | ||
3 3 | ||
4 4 | ||
5 5 | ||
6 6 | ||
7 7 | ||
8 8 | ||
9 9 | ||
10 10 | ||
|
88 changes: 88 additions & 0 deletions
88
regression-test/suites/backup_restore/test_backup_restore_alias.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,88 @@ | ||
// 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_backup_restore_alias", "backup_restore") { | ||
String repoName = "test_backup_restore_alias_repo" | ||
String dbName = "backup_restore_alias_db" | ||
String tableName = "test_backup_restore_alias_table" | ||
String aliasName = "test_backup_restore_alias_table_alias" | ||
|
||
def syncer = getSyncer() | ||
syncer.createS3Repository(repoName) | ||
|
||
sql "CREATE DATABASE IF NOT EXISTS ${dbName}" | ||
sql "DROP TABLE IF EXISTS ${dbName}.${tableName}" | ||
sql """ | ||
CREATE TABLE ${dbName}.${tableName} ( | ||
`id` LARGEINT NOT NULL, | ||
`count` LARGEINT SUM DEFAULT "0") | ||
AGGREGATE KEY(`id`) | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 2 | ||
PROPERTIES | ||
( | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
List<String> values = [] | ||
for (int i = 1; i <= 10; ++i) { | ||
values.add("(${i}, ${i})") | ||
} | ||
sql "INSERT INTO ${dbName}.${tableName} VALUES ${values.join(",")}" | ||
def result = sql "SELECT * FROM ${dbName}.${tableName}" | ||
assertEquals(result.size(), values.size()); | ||
|
||
String snapshotName = "test_backup_restore_snapshot" | ||
sql """ | ||
BACKUP SNAPSHOT ${dbName}.${snapshotName} | ||
TO `${repoName}` | ||
ON (${tableName}) | ||
""" | ||
|
||
while (!syncer.checkSnapshotFinish(dbName)) { | ||
Thread.sleep(3000) | ||
} | ||
|
||
snapshot = syncer.getSnapshotTimestamp(repoName, snapshotName) | ||
assertTrue(snapshot != null) | ||
|
||
sql "INSERT INTO ${dbName}.${tableName} VALUES (20, 21), (123, 341)" | ||
qt_select "SELECT * FROM ${dbName}.${tableName} ORDER BY id" | ||
|
||
sql """ | ||
RESTORE SNAPSHOT ${dbName}.${snapshotName} | ||
FROM `${repoName}` | ||
ON ( `${tableName}` AS `${aliasName}` ) | ||
PROPERTIES | ||
( | ||
"backup_timestamp" = "${snapshot}", | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
while (!syncer.checkAllRestoreFinish(dbName)) { | ||
Thread.sleep(3000) | ||
} | ||
|
||
qt_select "SELECT * FROM ${dbName}.${tableName} ORDER BY id" | ||
qt_select "SELECT * FROM ${dbName}.${aliasName} ORDER BY id" | ||
|
||
sql "DROP TABLE ${dbName}.${tableName} FORCE" | ||
sql "DROP DATABASE ${dbName} FORCE" | ||
sql "DROP REPOSITORY `${repoName}`" | ||
} | ||
|
103 changes: 103 additions & 0 deletions
103
regression-test/suites/backup_restore/test_backup_restore_exclude.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,103 @@ | ||
// 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_backup_restore_exclude", "backup_restore") { | ||
String dbName = "backup_restore_exclude" | ||
String suiteName = "test_backup_restore_exclude" | ||
String repoName = "${suiteName}_repo" | ||
String snapshotName = "${suiteName}_snapshot" | ||
String tableNamePrefix = "${suiteName}_tables" | ||
|
||
def syncer = getSyncer() | ||
syncer.createS3Repository(repoName) | ||
sql "CREATE DATABASE IF NOT EXISTS ${dbName}" | ||
|
||
int numTables = 10; | ||
int numRows = 10; | ||
List<String> tables = [] | ||
for (int i = 0; i < numTables; ++i) { | ||
String tableName = "${tableNamePrefix}_${i}" | ||
tables.add(tableName) | ||
sql "DROP TABLE IF EXISTS ${dbName}.${tableName}" | ||
sql """ | ||
CREATE TABLE ${dbName}.${tableName} ( | ||
`id` LARGEINT NOT NULL, | ||
`count` LARGEINT SUM DEFAULT "0" | ||
) | ||
AGGREGATE KEY(`id`) | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 2 | ||
PROPERTIES | ||
( | ||
"replication_num" = "1" | ||
) | ||
""" | ||
List<String> values = [] | ||
for (int j = 1; j <= numRows; ++j) { | ||
values.add("(${j}, ${j})") | ||
} | ||
sql "INSERT INTO ${dbName}.${tableName} VALUES ${values.join(",")}" | ||
def result = sql "SELECT * FROM ${dbName}.${tableName}" | ||
assertEquals(result.size(), numRows); | ||
} | ||
|
||
def backupExcludeTable = tables.removeLast(); | ||
sql """ | ||
BACKUP SNAPSHOT ${dbName}.${snapshotName} | ||
TO `${repoName}` | ||
EXCLUDE (${backupExcludeTable}) | ||
""" | ||
|
||
while (!syncer.checkSnapshotFinish(dbName)) { | ||
Thread.sleep(3000) | ||
} | ||
|
||
snapshot = syncer.getSnapshotTimestamp(repoName, snapshotName) | ||
assertTrue(snapshot != null) | ||
|
||
// Overwrite exists table. | ||
sql "INSERT INTO ${dbName}.${backupExcludeTable} VALUES (20, 20), (21, 21)" | ||
qt_select "SELECT * FROM ${dbName}.${backupExcludeTable} ORDER BY id" | ||
|
||
def restoreExcludeTable = tables.removeLast() | ||
sql "DROP TABLE ${dbName}.${restoreExcludeTable} FORCE" | ||
|
||
sql """ | ||
RESTORE SNAPSHOT ${dbName}.${snapshotName} | ||
FROM `${repoName}` | ||
EXCLUDE (${restoreExcludeTable}) | ||
PROPERTIES | ||
( | ||
"backup_timestamp" = "${snapshot}", | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
while (!syncer.checkAllRestoreFinish(dbName)) { | ||
Thread.sleep(3000) | ||
} | ||
|
||
qt_select "SELECT * FROM ${dbName}.${backupExcludeTable} ORDER BY id" | ||
for (def tableName in tables) { | ||
result = sql "SELECT * FROM ${dbName}.${tableName}" | ||
assertEquals(result.size(), numRows); | ||
sql "DROP TABLE ${dbName}.${tableName} FORCE" | ||
} | ||
|
||
sql "DROP DATABASE ${dbName} FORCE" | ||
sql "DROP REPOSITORY `${repoName}`" | ||
} | ||
|
101 changes: 101 additions & 0 deletions
101
regression-test/suites/backup_restore/test_backup_restore_multi_tables_overwrite.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,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_backup_restore_multi_tables_overwrite", "backup_restore") { | ||
String dbName = "backup_restore_multi_tables_overwrite_db" | ||
String suiteName = "test_backup_restore_multi_tables_overwrite" | ||
String repoName = "${suiteName}_repo" | ||
String snapshotName = "${suiteName}_snapshot" | ||
String tableNamePrefix = "${suiteName}_tables" | ||
|
||
def syncer = getSyncer() | ||
syncer.createS3Repository(repoName) | ||
sql "CREATE DATABASE IF NOT EXISTS ${dbName}" | ||
|
||
int numTables = 10; | ||
int numRows = 10; | ||
List<String> tables = [] | ||
for (int i = 0; i < numTables; ++i) { | ||
String tableName = "${tableNamePrefix}_${i}" | ||
tables.add(tableName) | ||
sql "DROP TABLE IF EXISTS ${dbName}.${tableName}" | ||
sql """ | ||
CREATE TABLE ${dbName}.${tableName} ( | ||
`id` LARGEINT NOT NULL, | ||
`count` LARGEINT SUM DEFAULT "0" | ||
) | ||
AGGREGATE KEY(`id`) | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 2 | ||
PROPERTIES | ||
( | ||
"replication_num" = "1" | ||
) | ||
""" | ||
List<String> values = [] | ||
for (int j = 1; j <= numRows; ++j) { | ||
values.add("(${j}, ${j})") | ||
} | ||
sql "INSERT INTO ${dbName}.${tableName} VALUES ${values.join(",")}" | ||
def result = sql "SELECT * FROM ${dbName}.${tableName}" | ||
assertEquals(result.size(), numRows); | ||
} | ||
|
||
def backupTables = tables[0..5] | ||
sql """ | ||
BACKUP SNAPSHOT ${dbName}.${snapshotName} | ||
TO `${repoName}` | ||
ON (${backupTables.join(",")}) | ||
""" | ||
|
||
while (!syncer.checkSnapshotFinish(dbName)) { | ||
Thread.sleep(3000) | ||
} | ||
|
||
snapshot = syncer.getSnapshotTimestamp(repoName, snapshotName) | ||
assertTrue(snapshot != null) | ||
|
||
// Overwrite exists table. | ||
def firstTableName = backupTables[0] | ||
sql "INSERT INTO ${dbName}.${firstTableName} VALUES (20, 20), (21, 21)" | ||
qt_select "SELECT * FROM ${dbName}.${firstTableName} ORDER BY id" | ||
|
||
sql """ | ||
RESTORE SNAPSHOT ${dbName}.${snapshotName} | ||
FROM `${repoName}` | ||
ON (${backupTables.join(",")}) | ||
PROPERTIES | ||
( | ||
"backup_timestamp" = "${snapshot}", | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
while (!syncer.checkAllRestoreFinish(dbName)) { | ||
Thread.sleep(3000) | ||
} | ||
|
||
qt_select "SELECT * FROM ${dbName}.${firstTableName} ORDER BY id" | ||
for (def tableName in tables) { | ||
result = sql "SELECT * FROM ${dbName}.${tableName}" | ||
assertEquals(result.size(), numRows); | ||
sql "DROP TABLE ${dbName}.${tableName} FORCE" | ||
} | ||
|
||
sql "DROP DATABASE ${dbName} FORCE" | ||
sql "DROP REPOSITORY `${repoName}`" | ||
} | ||
|
Oops, something went wrong.