forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test](doc) add some
data-admin
example in doris's doc to regressio…
…n test (apache#43240) ### What problem does this PR solve? <!-- You need to clearly describe your PR in this part: 1. What problem was fixed (it's best to include specific error reporting information). How it was fixed. 2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be. 3. What features were added. Why this function was added. 4. Which codes were refactored and why this part of the code was refactored. 5. Which functions were optimized and what is the difference before and after the optimization. The description of the PR needs to enable reviewers to quickly and clearly understand the logic of the code modification. --> <!-- If there are related issues, please fill in the issue number. - If you want the issue to be closed after the PR is merged, please use "close apache#12345". Otherwise, use "ref apache#12345" --> Issue Number: close #xxx <!-- If this PR is followup a preivous PR, for example, fix the bug that introduced by a related PR, link the PR here --> Related PR: #xxx Problem Summary: ### Check List (For Committer) - Test <!-- At least one of them must be included. --> - [x] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No colde files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [x] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [x] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#1214 --> - Release note <!-- bugfix, feat, behavior changed need a release note --> <!-- Add one line release note for this PR. --> None ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
- Loading branch information
1 parent
99d0748
commit 72b4daa
Showing
3 changed files
with
241 additions
and
0 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
regression-test/suites/doc/admin-manual/data-admin/backup.md.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,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) | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
regression-test/suites/doc/admin-manual/data-admin/recyclebin.md.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,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) | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
regression-test/suites/doc/admin-manual/data-admin/restore.md.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,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) | ||
} | ||
} |