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+ suite(" test_prop_retention_count" ) {
19+ def helper = new GroovyShell (new Binding ([' suite' : delegate]))
20+ .evaluate(new File (" ${ context.config.suitePath} /../common" , " helper.groovy" ))
21+
22+ def dbName = context. dbName
23+ def tableName = " tbl_" + helper. randomSuffix()
24+
25+ def exist = { res -> Boolean
26+ return res. size() != 0
27+ }
28+
29+ sql " DROP TABLE IF EXISTS ${ dbName} .${ tableName} "
30+ target_sql " DROP TABLE IF EXISTS TEST_${ dbName} .${ tableName} "
31+
32+ helper. enableDbBinlog()
33+
34+ sql """
35+ CREATE TABLE ${ tableName} (
36+ k0 DATETIME NOT NULL
37+ )
38+ partition by range (date_trunc(k0, 'day')) ()
39+ PROPERTIES (
40+ "replication_num" = "1",
41+ "partition.retention_count" = "3"
42+ );
43+ """
44+
45+ helper. ccrJobDelete()
46+ helper. ccrJobCreate()
47+
48+ assertTrue (helper. checkRestoreFinishTimesOf(" ${ tableName} " , 30 ))
49+
50+ assertTrue (helper. checkShowTimesOf(" SHOW TABLES LIKE \" ${ tableName} \" " , exist, 60 , " sql" ))
51+
52+ assertTrue (helper. checkShowTimesOf(" SHOW TABLES LIKE \" ${ tableName} \" " , exist, 60 , " target" ))
53+
54+ def target_res = target_sql " SHOW CREATE TABLE ${ tableName} "
55+
56+ assertTrue (target_res[0 ][1 ]. contains(" \" partition.retention_count\" = \" 3\" " ))
57+
58+ target_sql """
59+ insert into ${ tableName} select date_add('2022-01-01 00:00:00', interval number day) from numbers("number" = "100");
60+ """
61+ target_sql """ admin set frontend config ('dynamic_partition_check_interval_seconds' = '1') """
62+ sleep(8000 )
63+ target_res = target_sql " show partitions from ${ tableName} "
64+ assertEquals (target_res. size(), 3 )
65+
66+ target_sql """ admin set frontend config ('dynamic_partition_check_interval_seconds' = '600') """
67+ }
0 commit comments