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

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


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new cfae726428c [cherry-pick][test](doc) add some `data-admin` example in 
doris's doc to regression test (#43240) (#43566)
cfae726428c is described below

commit cfae726428cfc1725ca5071a6e8b63244e2d0cdb
Author: yagagagaga <zhangminkefromflyd...@gmail.com>
AuthorDate: Tue Nov 12 10:55:54 2024 +0800

    [cherry-pick][test](doc) add some `data-admin` example in doris's doc to 
regression test (#43240) (#43566)
    
    (cherry picked from commit 72b4daa9b461b14f1ea179f62543d2336f6ea5b2)
    
    ### What problem does this PR solve?
    
    Issue Number: close #xxx
    
    Related PR: #43240
    
    Problem Summary:
---
 .../doc/admin-manual/data-admin/backup.md.groovy   | 93 ++++++++++++++++++++
 .../admin-manual/data-admin/recyclebin.md.groovy   | 49 +++++++++++
 .../doc/admin-manual/data-admin/restore.md.groovy  | 99 ++++++++++++++++++++++
 3 files changed, 241 insertions(+)

diff --git 
a/regression-test/suites/doc/admin-manual/data-admin/backup.md.groovy 
b/regression-test/suites/doc/admin-manual/data-admin/backup.md.groovy
new file mode 100644
index 00000000000..4c7f6406a2a
--- /dev/null
+++ b/regression-test/suites/doc/admin-manual/data-admin/backup.md.groovy
@@ -0,0 +1,93 @@
+// 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.
+
+import org.junit.jupiter.api.Assertions;
+
+suite("docs/admin-manual/data-admin/backup.md", "p0,nonConcurrent") {
+    try {
+        multi_sql """
+            CREATE DATABASE IF NOT EXISTS example_db;
+            USE example_db;
+            DROP TABLE IF EXISTS example_tbl;
+            CREATE TABLE IF NOT EXISTS example_db.example_tbl(
+                a INT
+            ) PARTITION BY RANGE(a) (
+                PARTITION p1 VALUES LESS THAN (1),
+                PARTITION p2 VALUES LESS THAN (2)
+            ) DISTRIBUTED BY HASH(a) BUCKETS 1
+            PROPERTIES (
+                "replication_num" = "1"
+            );
+            INSERT INTO example_tbl VALUES (1);
+            DROP TABLE IF EXISTS example_tbl2;
+            CREATE TABLE example_tbl2 LIKE example_tbl;
+            INSERT INTO example_tbl2 SELECT * FROM example_tbl;
+        """
+
+        def uuid = UUID.randomUUID().hashCode().abs()
+        def syncer = getSyncer()
+        /*
+         CREATE REPOSITORY `example_repo`
+         WITH HDFS
+         ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/"
+         PROPERTIES
+         (
+         "fs.defaultFS"="hdfs://hdfs_host:port",
+         "hadoop.username" = "hadoop"
+         );
+         */
+        syncer.createHdfsRepository("example_repo")
+
+        /*
+        CREATE REPOSITORY `s3_repo`
+        WITH S3
+        ON LOCATION "s3://bucket_name/test"
+        PROPERTIES
+        (
+            "AWS_ENDPOINT" = "http://xxxx.xxxx.com";,
+            "AWS_ACCESS_KEY" = "xxxx",
+            "AWS_SECRET_KEY"="xxx",
+            "AWS_REGION" = "xxx"
+        );
+         */
+        syncer.createS3Repository("s3_repo")
+        sql """
+            BACKUP SNAPSHOT example_db.snapshot_label1${uuid}
+            TO example_repo
+            ON (example_tbl)
+            PROPERTIES ("type" = "full");
+        """
+        syncer.waitSnapshotFinish("example_db")
+
+        sql """
+            BACKUP SNAPSHOT example_db.snapshot_label2${uuid}
+            TO example_repo
+            ON
+            (
+               example_tbl PARTITION (p1,p2),
+               example_tbl2
+            );
+        """
+        syncer.waitSnapshotFinish("example_db")
+
+        sql """show BACKUP"""
+        sql """SHOW SNAPSHOT ON example_repo WHERE SNAPSHOT = 
"snapshot_label1${uuid}";"""
+
+    } catch (Throwable t) {
+        Assertions.fail("examples in docs/admin-manual/data-admin/backup.md 
failed to exec, please fix it", t)
+    }
+}
diff --git 
a/regression-test/suites/doc/admin-manual/data-admin/recyclebin.md.groovy 
b/regression-test/suites/doc/admin-manual/data-admin/recyclebin.md.groovy
new file mode 100644
index 00000000000..529584f207f
--- /dev/null
+++ b/regression-test/suites/doc/admin-manual/data-admin/recyclebin.md.groovy
@@ -0,0 +1,49 @@
+// 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.
+
+import org.junit.jupiter.api.Assertions;
+
+suite("docs/admin-manual/data-admin/recyclebin.md", "p0,nonConcurrent") {
+    try {
+        multi_sql """
+            CREATE DATABASE IF NOT EXISTS example_db;
+            USE example_db;
+            DROP TABLE IF EXISTS example_tbl;
+            CREATE TABLE IF NOT EXISTS example_db.example_tbl(
+                a INT
+            ) PARTITION BY RANGE(a) (
+                PARTITION p1 VALUES LESS THAN (1),
+                PARTITION p2 VALUES LESS THAN (2)
+            ) DISTRIBUTED BY HASH(a) BUCKETS 1
+            PROPERTIES (
+                "replication_num" = "1"
+            );
+            INSERT INTO example_tbl VALUES (1);
+            
+            ALTER TABLE example_tbl DROP PARTITION p1;
+            DROP TABLE example_tbl;
+            DROP DATABASE example_db;
+        """
+
+        sql """RECOVER DATABASE example_db;"""
+        sql """RECOVER TABLE example_db.example_tbl;"""
+        sql """RECOVER PARTITION p1 FROM example_tbl;"""
+
+    } catch (Throwable t) {
+        Assertions.fail("examples in 
docs/admin-manual/data-admin/recyclebin.md failed to exec, please fix it", t)
+    }
+}
diff --git 
a/regression-test/suites/doc/admin-manual/data-admin/restore.md.groovy 
b/regression-test/suites/doc/admin-manual/data-admin/restore.md.groovy
new file mode 100644
index 00000000000..f36d225854b
--- /dev/null
+++ b/regression-test/suites/doc/admin-manual/data-admin/restore.md.groovy
@@ -0,0 +1,99 @@
+// 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.
+
+import org.junit.jupiter.api.Assertions;
+
+suite("docs/admin-manual/data-admin/restore.md", "p0,nonConcurrent") {
+    try {
+        multi_sql """
+            CREATE DATABASE IF NOT EXISTS example_db1;
+            USE example_db1;
+            DROP TABLE IF EXISTS backup_tbl;
+            CREATE TABLE IF NOT EXISTS example_db1.backup_tbl(
+                a INT
+            ) PARTITION BY RANGE(a) (
+                PARTITION p1 VALUES LESS THAN (1),
+                PARTITION p2 VALUES LESS THAN (2)
+            ) DISTRIBUTED BY HASH(a) BUCKETS 1
+            PROPERTIES (
+                "replication_num" = "1"
+            );
+            INSERT INTO backup_tbl VALUES (1);
+            DROP TABLE IF EXISTS backup_tbl2;
+            CREATE TABLE backup_tbl2 LIKE backup_tbl;
+            INSERT INTO backup_tbl2 SELECT * FROM backup_tbl;
+        """
+
+        def uuid = UUID.randomUUID().hashCode().abs()
+        def syncer = getSyncer()
+        syncer.createS3Repository("example_repo")
+        sql """
+            BACKUP SNAPSHOT example_db1.snapshot_1${uuid}
+            TO example_repo
+            ON (backup_tbl)
+            PROPERTIES ("type" = "full");
+        """
+        syncer.waitSnapshotFinish("example_db1")
+        sql """
+            BACKUP SNAPSHOT example_db1.snapshot_2${uuid}
+            TO example_repo
+            ON (backup_tbl, backup_tbl2)
+            PROPERTIES ("type" = "full");
+        """
+        syncer.waitSnapshotFinish("example_db1")
+
+        multi_sql """
+            truncate table backup_tbl;
+            truncate table backup_tbl2;
+        """
+
+        var timestamp = syncer.getSnapshotTimestamp("example_repo", 
"snapshot_1${uuid}")
+        sql """
+            RESTORE SNAPSHOT example_db1.`snapshot_1${uuid}`
+            FROM `example_repo`
+            ON ( `backup_tbl` )
+            PROPERTIES
+            (
+                "backup_timestamp"="${timestamp}",
+                "replication_num" = "1"
+            );
+        """
+        syncer.waitAllRestoreFinish("example_db1")
+
+        var timestamp2 = syncer.getSnapshotTimestamp("example_repo", 
"snapshot_2${uuid}")
+        sql """
+            RESTORE SNAPSHOT example_db1.`snapshot_2${uuid}`
+            FROM `example_repo`
+            ON
+            (
+                `backup_tbl` PARTITION (`p1`, `p2`),
+                `backup_tbl2` AS `new_tbl`
+            )
+            PROPERTIES
+            (
+                "backup_timestamp"="${timestamp2}",
+                "replication_num" = "1"
+            );
+        """
+        syncer.waitAllRestoreFinish("example_db1")
+
+        sql """SHOW RESTORE"""
+
+    } catch (Throwable t) {
+        Assertions.fail("examples in docs/admin-manual/data-admin/restore.md 
failed to exec, please fix it", t)
+    }
+}


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

Reply via email to