This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new df43b671dee [case](regression) Backup & restore with view (#29573)
df43b671dee is described below

commit df43b671deec0569eb5d5a4425cb1c1f470fecda
Author: walter <w41te...@gmail.com>
AuthorDate: Sun Jan 7 00:03:22 2024 +0800

    [case](regression) Backup & restore with view (#29573)
---
 .../backup_restore/test_backup_restore_with.out    | 39 +++++++++
 .../backup_restore/test_backup_restore_with.groovy | 96 ++++++++++++++++++++++
 2 files changed, 135 insertions(+)

diff --git a/regression-test/data/backup_restore/test_backup_restore_with.out 
b/regression-test/data/backup_restore/test_backup_restore_with.out
new file mode 100644
index 00000000000..465e5d40ac9
--- /dev/null
+++ b/regression-test/data/backup_restore/test_backup_restore_with.out
@@ -0,0 +1,39 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1      1
+2      2
+3      3
+4      4
+5      5
+6      6
+7      7
+8      8
+9      9
+10     10
+
+-- !sql --
+6      6
+7      7
+8      8
+9      9
+10     10
+
+-- !sql --
+1      1
+2      2
+3      3
+4      4
+5      5
+6      6
+7      7
+8      8
+9      9
+10     10
+
+-- !sql --
+6      6
+7      7
+8      8
+9      9
+10     10
+
diff --git 
a/regression-test/suites/backup_restore/test_backup_restore_with.groovy 
b/regression-test/suites/backup_restore/test_backup_restore_with.groovy
new file mode 100644
index 00000000000..1589827be00
--- /dev/null
+++ b/regression-test/suites/backup_restore/test_backup_restore_with.groovy
@@ -0,0 +1,96 @@
+// 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_with_view", "backup_restore") {
+    String suiteName = "backup_restore_with_view"
+    String dbName = "${suiteName}_db"
+    String repoName = "${suiteName}_repo"
+    String snapshotName = "${suiteName}_snapshot"
+    String tableName = "${suiteName}_table"
+    String viewName = "${suiteName}_view"
+
+    def syncer = getSyncer()
+    syncer.createS3Repository(repoName)
+    sql "CREATE DATABASE IF NOT EXISTS ${dbName}"
+
+    int numRows = 10;
+    sql "DROP TABLE IF EXISTS ${dbName}.${tableName} FORCE"
+    sql "DROP VIEW IF EXISTS ${dbName}.${viewName}"
+    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(",")}"
+
+    sql """CREATE VIEW ${dbName}.${viewName} (id, count)
+        AS
+        SELECT * FROM ${dbName}.${tableName} WHERE count > 5
+        """
+
+    qt_sql "SELECT * FROM ${dbName}.${tableName} ORDER BY id ASC"
+    qt_sql "SELECT * FROM ${dbName}.${viewName} ORDER BY id ASC"
+
+    sql """
+        BACKUP SNAPSHOT ${dbName}.${snapshotName}
+        TO `${repoName}`
+    """
+
+    while (!syncer.checkSnapshotFinish(dbName)) {
+        Thread.sleep(3000)
+    }
+
+    def snapshot = syncer.getSnapshotTimestamp(repoName, snapshotName)
+    assertTrue(snapshot != null)
+
+    sql "DROP TABLE ${dbName}.${tableName} FORCE"
+    sql "DROP VIEW ${dbName}.${viewName}"
+
+    sql """
+        RESTORE SNAPSHOT ${dbName}.${snapshotName}
+        FROM `${repoName}`
+        PROPERTIES
+        (
+            "backup_timestamp" = "${snapshot}",
+            "reserve_replica" = "true"
+        )
+    """
+
+    while (!syncer.checkAllRestoreFinish(dbName)) {
+        Thread.sleep(3000)
+    }
+
+    qt_sql "SELECT * FROM ${dbName}.${tableName} ORDER BY id ASC"
+    qt_sql "SELECT * FROM ${dbName}.${viewName} ORDER BY id ASC"
+
+    sql "DROP TABLE ${dbName}.${tableName} FORCE"
+    sql "DROP VIEW ${dbName}.${viewName}"
+    sql "DROP DATABASE ${dbName} FORCE"
+    sql "DROP REPOSITORY `${repoName}`"
+}
+


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to