|
15 | 15 | // specific language governing permissions and limitations
|
16 | 16 | // under the License.
|
17 | 17 |
|
| 18 | +/* |
| 19 | +Build the basic information. When conceiving upgrade and downgrade test cases, you should firmly grasp the object |
| 20 | +representation of the function in the FE meta. |
| 21 | +Taking MTMV as an example, the main function points are creation, refresh, and rewriting, and the involved entities |
| 22 | +are the base table and MTMV. |
| 23 | +1.When creating an MTMV, check if the rewriting meets the expectations. |
| 24 | +2.When refreshing an MTMV, check if the rewriting meets the expectations. |
| 25 | +3.When deleting an MTMV, check if the rewriting meets the expectations. |
| 26 | +4.When deleting a base table, check if the rewriting meets the expectations; then trigger a refresh and check if the |
| 27 | +rewriting meets the expectations. |
| 28 | +5.When deleting a partition of a base table, check if the rewriting meets the expectations; then trigger a refresh and |
| 29 | +check if the rewriting meets the expectations. |
| 30 | +6.Design a slightly more complex scenario. For example: Build an MTMV with two base tables. When deleting one of the |
| 31 | +base tables, check if the refresh of the MTMV meets the expectations and if the rewriting meets the expectations; |
| 32 | +create an MTMV with the undeleted base table and check if it can be created and refreshed normally, and if the |
| 33 | +corresponding rewriting meets the expectations. |
| 34 | + */ |
18 | 35 | suite("test_upgrade_downgrade_prepare_olap_mtmv","p0,mtmv,restart_fe") {
|
19 | 36 | String suiteName = "mtmv_up_down_olap"
|
| 37 | + String dbName = context.config.getDbNameByFile(context.file) |
20 | 38 | String mvName = "${suiteName}_mtmv"
|
21 | 39 | String tableName = "${suiteName}_table"
|
22 | 40 | String tableName2 = "${suiteName}_table2"
|
@@ -68,4 +86,123 @@ suite("test_upgrade_downgrade_prepare_olap_mtmv","p0,mtmv,restart_fe") {
|
68 | 86 | SELECT a.* FROM ${tableName} a inner join ${tableName2} b on a.user_id=b.user_id;
|
69 | 87 | """
|
70 | 88 | waitingMTMVTaskFinishedByMvName(mvName)
|
| 89 | + |
| 90 | + |
| 91 | + String dropTableName1 = """${suiteName}_DropTableName1""" |
| 92 | + String dropTableName2 = """${suiteName}_DropTableName2""" |
| 93 | + String dropTableName4 = """${suiteName}_DropTableName4""" |
| 94 | + String dropMtmvName1 = """${suiteName}_dropMtmvName1""" |
| 95 | + String dropMtmvName2 = """${suiteName}_dropMtmvName2""" |
| 96 | + String dropMtmvName3 = """${suiteName}_dropMtmvName3""" |
| 97 | + |
| 98 | + sql """drop materialized view if exists ${dropMtmvName1};""" |
| 99 | + sql """drop materialized view if exists ${dropMtmvName2};""" |
| 100 | + sql """drop materialized view if exists ${dropMtmvName3};""" |
| 101 | + sql """drop table if exists `${dropTableName1}`""" |
| 102 | + sql """drop table if exists `${dropTableName2}`""" |
| 103 | + sql """drop table if exists `${dropTableName4}`""" |
| 104 | + |
| 105 | + |
| 106 | + sql """ |
| 107 | + CREATE TABLE `${dropTableName1}` ( |
| 108 | + `user_id` LARGEINT NOT NULL COMMENT '\"用户id\"', |
| 109 | + `date` DATE NOT NULL COMMENT '\"数据灌入日期时间\"', |
| 110 | + `num` SMALLINT NOT NULL COMMENT '\"数量\"' |
| 111 | + ) ENGINE=OLAP |
| 112 | + DUPLICATE KEY(`user_id`, `date`, `num`) |
| 113 | + COMMENT 'OLAP' |
| 114 | + PARTITION BY RANGE(`date`) |
| 115 | + (PARTITION p201701_1000 VALUES [('0000-01-01'), ('2017-02-01')), |
| 116 | + PARTITION p201702_2000 VALUES [('2017-02-01'), ('2017-03-01')), |
| 117 | + PARTITION p201703_3000 VALUES [('2017-03-01'), ('2017-04-01')), |
| 118 | + PARTITION p201704_4000 VALUES [('2017-04-01'), ('2017-05-01')), |
| 119 | + PARTITION p201705_5000 VALUES [('2017-05-01'), ('2017-06-01')), |
| 120 | + PARTITION p201706_6000 VALUES [('2017-06-01'), ('2017-07-01')), |
| 121 | + PARTITION p201707_7000 VALUES [('2017-07-01'), ('2017-08-01')), |
| 122 | + PARTITION p201708_8000 VALUES [('2017-08-01'), ('2017-09-01')), |
| 123 | + PARTITION p201709_9000 VALUES [('2017-09-01'), ('2017-10-01')), |
| 124 | + PARTITION p201710_1000 VALUES [('2017-10-01'), ('2017-11-01')), |
| 125 | + PARTITION p201711_1100 VALUES [('2017-11-01'), ('2017-12-01')), |
| 126 | + PARTITION p201712_1200 VALUES [('2017-12-01'), ('2018-01-01'))) |
| 127 | + DISTRIBUTED BY HASH(`user_id`) BUCKETS 2 |
| 128 | + PROPERTIES ('replication_num' = '1') ; |
| 129 | + """ |
| 130 | + sql """ |
| 131 | + insert into ${dropTableName1} values(1,"2017-01-15",1),(2,"2017-02-15",2),(3,"2017-03-15",3),(4,"2017-04-15",4),(5,"2017-05-15",5),(6,"2017-06-15",6),(7,"2017-07-15",7),(8,"2017-08-15",8),(9,"2017-09-15",9),(10,"2017-10-15",10),(11,"2017-11-15",11),(12,"2017-12-15",12); |
| 132 | + """ |
| 133 | + |
| 134 | + sql """ |
| 135 | + CREATE TABLE `${dropTableName2}` ( |
| 136 | + `user_id` LARGEINT NOT NULL COMMENT '\"用户id\"', |
| 137 | + `date` DATE NOT NULL COMMENT '\"数据灌入日期时间\"', |
| 138 | + `num` SMALLINT NOT NULL COMMENT '\"数量\"' |
| 139 | + ) ENGINE=OLAP |
| 140 | + DUPLICATE KEY(`user_id`, `date`, `num`) |
| 141 | + COMMENT 'OLAP' |
| 142 | + PARTITION BY RANGE(`date`) |
| 143 | + (PARTITION p201701_1000 VALUES [('0000-01-01'), ('2017-02-01')), |
| 144 | + PARTITION p201702_2000 VALUES [('2017-02-01'), ('2017-03-01')), |
| 145 | + PARTITION p201703_3000 VALUES [('2017-03-01'), ('2017-04-01')), |
| 146 | + PARTITION p201704_4000 VALUES [('2017-04-01'), ('2017-05-01')), |
| 147 | + PARTITION p201705_5000 VALUES [('2017-05-01'), ('2017-06-01')), |
| 148 | + PARTITION p201706_6000 VALUES [('2017-06-01'), ('2017-07-01')), |
| 149 | + PARTITION p201707_7000 VALUES [('2017-07-01'), ('2017-08-01')), |
| 150 | + PARTITION p201708_8000 VALUES [('2017-08-01'), ('2017-09-01')), |
| 151 | + PARTITION p201709_9000 VALUES [('2017-09-01'), ('2017-10-01')), |
| 152 | + PARTITION p201710_1000 VALUES [('2017-10-01'), ('2017-11-01')), |
| 153 | + PARTITION p201711_1100 VALUES [('2017-11-01'), ('2017-12-01')), |
| 154 | + PARTITION p201712_1200 VALUES [('2017-12-01'), ('2018-01-01'))) |
| 155 | + DISTRIBUTED BY HASH(`user_id`) BUCKETS 2 |
| 156 | + PROPERTIES ('replication_num' = '1') ; |
| 157 | + """ |
| 158 | + sql """ |
| 159 | + insert into ${dropTableName2} values(1,"2017-01-15",1),(2,"2017-02-15",2),(3,"2017-03-15",3),(4,"2017-04-15",4),(5,"2017-05-15",5),(6,"2017-06-15",6),(7,"2017-07-15",7),(8,"2017-08-15",8),(9,"2017-09-15",9),(10,"2017-10-15",10),(11,"2017-11-15",11),(12,"2017-12-15",12); |
| 160 | + """ |
| 161 | + |
| 162 | + sql """ |
| 163 | + CREATE TABLE `${dropTableName4}` ( |
| 164 | + `user_id` LARGEINT NOT NULL COMMENT '\"用户id\"', |
| 165 | + `age` SMALLINT NOT NULL COMMENT '\"年龄\"' |
| 166 | + ) ENGINE=OLAP |
| 167 | + DUPLICATE KEY(`user_id`, `age`) |
| 168 | + COMMENT 'OLAP' |
| 169 | + DISTRIBUTED BY HASH(`user_id`) BUCKETS 2 |
| 170 | + PROPERTIES ('replication_num' = '1') ; |
| 171 | + """ |
| 172 | + sql """ |
| 173 | + insert into ${dropTableName4} values(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11),(12,12); |
| 174 | + """ |
| 175 | + |
| 176 | + |
| 177 | + sql """ |
| 178 | + CREATE MATERIALIZED VIEW ${dropMtmvName1} |
| 179 | + REFRESH AUTO ON MANUAL |
| 180 | + partition by(`date`) |
| 181 | + DISTRIBUTED BY RANDOM BUCKETS 2 |
| 182 | + PROPERTIES ('replication_num' = '1') |
| 183 | + AS |
| 184 | + SELECT a.* FROM ${dropTableName1} a inner join ${dropTableName4} b on a.user_id=b.user_id; |
| 185 | + """ |
| 186 | + waitingMTMVTaskFinishedByMvName(dropMtmvName1) |
| 187 | + |
| 188 | + sql """ |
| 189 | + CREATE MATERIALIZED VIEW ${dropMtmvName2} |
| 190 | + REFRESH AUTO ON MANUAL |
| 191 | + partition by(`date`) |
| 192 | + DISTRIBUTED BY RANDOM BUCKETS 2 |
| 193 | + PROPERTIES ('replication_num' = '1') |
| 194 | + AS |
| 195 | + SELECT a.* FROM ${dropTableName2} a inner join ${dropTableName4} b on a.user_id=b.user_id; |
| 196 | + """ |
| 197 | + waitingMTMVTaskFinishedByMvName(dropMtmvName2) |
| 198 | + |
| 199 | + def state_mtmv1 = sql """select State,RefreshState,SyncWithBaseTables from mv_infos('database'='${dbName}') where Name = '${dropMtmvName1}';""" |
| 200 | + assertTrue(state_mtmv1[0][0] == "NORMAL") |
| 201 | + assertTrue(state_mtmv1[0][1] == "SUCCESS") |
| 202 | + assertTrue(state_mtmv1[0][2] == true) |
| 203 | + def state_mtmv2 = sql """select State,RefreshState,SyncWithBaseTables from mv_infos('database'='${dbName}') where Name = '${dropMtmvName2}';""" |
| 204 | + assertTrue(state_mtmv2[0][0] == "NORMAL") |
| 205 | + assertTrue(state_mtmv2[0][1] == "SUCCESS") |
| 206 | + assertTrue(state_mtmv2[0][2] == true) |
| 207 | + |
71 | 208 | }
|
0 commit comments