Skip to content

Commit cfae726

Browse files
authored
[cherry-pick][test](doc) add some data-admin example in doris's doc to regression test (#43240) (#43566)
(cherry picked from commit 72b4daa) ### What problem does this PR solve? Issue Number: close #xxx Related PR: #43240 Problem Summary:
1 parent 4c224bb commit cfae726

File tree

3 files changed

+241
-0
lines changed

3 files changed

+241
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
import org.junit.jupiter.api.Assertions;
19+
20+
suite("docs/admin-manual/data-admin/backup.md", "p0,nonConcurrent") {
21+
try {
22+
multi_sql """
23+
CREATE DATABASE IF NOT EXISTS example_db;
24+
USE example_db;
25+
DROP TABLE IF EXISTS example_tbl;
26+
CREATE TABLE IF NOT EXISTS example_db.example_tbl(
27+
a INT
28+
) PARTITION BY RANGE(a) (
29+
PARTITION p1 VALUES LESS THAN (1),
30+
PARTITION p2 VALUES LESS THAN (2)
31+
) DISTRIBUTED BY HASH(a) BUCKETS 1
32+
PROPERTIES (
33+
"replication_num" = "1"
34+
);
35+
INSERT INTO example_tbl VALUES (1);
36+
DROP TABLE IF EXISTS example_tbl2;
37+
CREATE TABLE example_tbl2 LIKE example_tbl;
38+
INSERT INTO example_tbl2 SELECT * FROM example_tbl;
39+
"""
40+
41+
def uuid = UUID.randomUUID().hashCode().abs()
42+
def syncer = getSyncer()
43+
/*
44+
CREATE REPOSITORY `example_repo`
45+
WITH HDFS
46+
ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/"
47+
PROPERTIES
48+
(
49+
"fs.defaultFS"="hdfs://hdfs_host:port",
50+
"hadoop.username" = "hadoop"
51+
);
52+
*/
53+
syncer.createHdfsRepository("example_repo")
54+
55+
/*
56+
CREATE REPOSITORY `s3_repo`
57+
WITH S3
58+
ON LOCATION "s3://bucket_name/test"
59+
PROPERTIES
60+
(
61+
"AWS_ENDPOINT" = "http://xxxx.xxxx.com",
62+
"AWS_ACCESS_KEY" = "xxxx",
63+
"AWS_SECRET_KEY"="xxx",
64+
"AWS_REGION" = "xxx"
65+
);
66+
*/
67+
syncer.createS3Repository("s3_repo")
68+
sql """
69+
BACKUP SNAPSHOT example_db.snapshot_label1${uuid}
70+
TO example_repo
71+
ON (example_tbl)
72+
PROPERTIES ("type" = "full");
73+
"""
74+
syncer.waitSnapshotFinish("example_db")
75+
76+
sql """
77+
BACKUP SNAPSHOT example_db.snapshot_label2${uuid}
78+
TO example_repo
79+
ON
80+
(
81+
example_tbl PARTITION (p1,p2),
82+
example_tbl2
83+
);
84+
"""
85+
syncer.waitSnapshotFinish("example_db")
86+
87+
sql """show BACKUP"""
88+
sql """SHOW SNAPSHOT ON example_repo WHERE SNAPSHOT = "snapshot_label1${uuid}";"""
89+
90+
} catch (Throwable t) {
91+
Assertions.fail("examples in docs/admin-manual/data-admin/backup.md failed to exec, please fix it", t)
92+
}
93+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
import org.junit.jupiter.api.Assertions;
19+
20+
suite("docs/admin-manual/data-admin/recyclebin.md", "p0,nonConcurrent") {
21+
try {
22+
multi_sql """
23+
CREATE DATABASE IF NOT EXISTS example_db;
24+
USE example_db;
25+
DROP TABLE IF EXISTS example_tbl;
26+
CREATE TABLE IF NOT EXISTS example_db.example_tbl(
27+
a INT
28+
) PARTITION BY RANGE(a) (
29+
PARTITION p1 VALUES LESS THAN (1),
30+
PARTITION p2 VALUES LESS THAN (2)
31+
) DISTRIBUTED BY HASH(a) BUCKETS 1
32+
PROPERTIES (
33+
"replication_num" = "1"
34+
);
35+
INSERT INTO example_tbl VALUES (1);
36+
37+
ALTER TABLE example_tbl DROP PARTITION p1;
38+
DROP TABLE example_tbl;
39+
DROP DATABASE example_db;
40+
"""
41+
42+
sql """RECOVER DATABASE example_db;"""
43+
sql """RECOVER TABLE example_db.example_tbl;"""
44+
sql """RECOVER PARTITION p1 FROM example_tbl;"""
45+
46+
} catch (Throwable t) {
47+
Assertions.fail("examples in docs/admin-manual/data-admin/recyclebin.md failed to exec, please fix it", t)
48+
}
49+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
import org.junit.jupiter.api.Assertions;
19+
20+
suite("docs/admin-manual/data-admin/restore.md", "p0,nonConcurrent") {
21+
try {
22+
multi_sql """
23+
CREATE DATABASE IF NOT EXISTS example_db1;
24+
USE example_db1;
25+
DROP TABLE IF EXISTS backup_tbl;
26+
CREATE TABLE IF NOT EXISTS example_db1.backup_tbl(
27+
a INT
28+
) PARTITION BY RANGE(a) (
29+
PARTITION p1 VALUES LESS THAN (1),
30+
PARTITION p2 VALUES LESS THAN (2)
31+
) DISTRIBUTED BY HASH(a) BUCKETS 1
32+
PROPERTIES (
33+
"replication_num" = "1"
34+
);
35+
INSERT INTO backup_tbl VALUES (1);
36+
DROP TABLE IF EXISTS backup_tbl2;
37+
CREATE TABLE backup_tbl2 LIKE backup_tbl;
38+
INSERT INTO backup_tbl2 SELECT * FROM backup_tbl;
39+
"""
40+
41+
def uuid = UUID.randomUUID().hashCode().abs()
42+
def syncer = getSyncer()
43+
syncer.createS3Repository("example_repo")
44+
sql """
45+
BACKUP SNAPSHOT example_db1.snapshot_1${uuid}
46+
TO example_repo
47+
ON (backup_tbl)
48+
PROPERTIES ("type" = "full");
49+
"""
50+
syncer.waitSnapshotFinish("example_db1")
51+
sql """
52+
BACKUP SNAPSHOT example_db1.snapshot_2${uuid}
53+
TO example_repo
54+
ON (backup_tbl, backup_tbl2)
55+
PROPERTIES ("type" = "full");
56+
"""
57+
syncer.waitSnapshotFinish("example_db1")
58+
59+
multi_sql """
60+
truncate table backup_tbl;
61+
truncate table backup_tbl2;
62+
"""
63+
64+
var timestamp = syncer.getSnapshotTimestamp("example_repo", "snapshot_1${uuid}")
65+
sql """
66+
RESTORE SNAPSHOT example_db1.`snapshot_1${uuid}`
67+
FROM `example_repo`
68+
ON ( `backup_tbl` )
69+
PROPERTIES
70+
(
71+
"backup_timestamp"="${timestamp}",
72+
"replication_num" = "1"
73+
);
74+
"""
75+
syncer.waitAllRestoreFinish("example_db1")
76+
77+
var timestamp2 = syncer.getSnapshotTimestamp("example_repo", "snapshot_2${uuid}")
78+
sql """
79+
RESTORE SNAPSHOT example_db1.`snapshot_2${uuid}`
80+
FROM `example_repo`
81+
ON
82+
(
83+
`backup_tbl` PARTITION (`p1`, `p2`),
84+
`backup_tbl2` AS `new_tbl`
85+
)
86+
PROPERTIES
87+
(
88+
"backup_timestamp"="${timestamp2}",
89+
"replication_num" = "1"
90+
);
91+
"""
92+
syncer.waitAllRestoreFinish("example_db1")
93+
94+
sql """SHOW RESTORE"""
95+
96+
} catch (Throwable t) {
97+
Assertions.fail("examples in docs/admin-manual/data-admin/restore.md failed to exec, please fix it", t)
98+
}
99+
}

0 commit comments

Comments
 (0)