|
| 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.codehaus.groovy.runtime.IOGroovyMethods |
| 19 | + |
| 20 | +suite ("accept_null") { |
| 21 | + sql """ drop table IF EXISTS detail_tmp;""" |
| 22 | + |
| 23 | + sql """ |
| 24 | + CREATE TABLE `detail_tmp` ( |
| 25 | + `id` VARCHAR(512) NOT NULL, |
| 26 | + `accident_no` VARCHAR(512) NULL, |
| 27 | + `accident_type_name` VARCHAR(512) NULL |
| 28 | + ) ENGINE=OLAP |
| 29 | + UNIQUE KEY(`id`) |
| 30 | + DISTRIBUTED BY HASH(`id`) BUCKETS AUTO |
| 31 | + PROPERTIES ( |
| 32 | + "replication_allocation" = "tag.location.default: 1", |
| 33 | + "min_load_replica_num" = "-1", |
| 34 | + "is_being_synced" = "false", |
| 35 | + "storage_medium" = "hdd", |
| 36 | + "storage_format" = "V2", |
| 37 | + "inverted_index_storage_format" = "V1", |
| 38 | + "enable_unique_key_merge_on_write" = "true", |
| 39 | + "light_schema_change" = "true", |
| 40 | + "disable_auto_compaction" = "false", |
| 41 | + "enable_single_replica_compaction" = "false", |
| 42 | + "group_commit_interval_ms" = "10000", |
| 43 | + "group_commit_data_bytes" = "134217728", |
| 44 | + "enable_mow_light_delete" = "false" |
| 45 | + ); |
| 46 | + """ |
| 47 | + |
| 48 | + sql "insert into detail_tmp(id,accident_type_name,accident_no) select e1,'dd',e1 from (select 1 k1) as t lateral view explode_numbers(100000) tmp1 as e1;" |
| 49 | + sql "delete from detail_tmp where accident_no <100;" |
| 50 | + |
| 51 | + def tablets = sql_return_maparray """ show tablets from detail_tmp; """ |
| 52 | + |
| 53 | + // before full compaction, there are 7 rowsets in all tablets. |
| 54 | + for (def tablet : tablets) { |
| 55 | + int rowsetCount = 0 |
| 56 | + def (code, out, err) = curl("GET", tablet.CompactionStatus) |
| 57 | + logger.info("Show tablets status: code=" + code + ", out=" + out + ", err=" + err) |
| 58 | + assertEquals(code, 0) |
| 59 | + def tabletJson = parseJson(out.trim()) |
| 60 | + assert tabletJson.rowsets instanceof List |
| 61 | + } |
| 62 | + |
| 63 | + // trigger full compactions for all tablets by table id in ${tableName} |
| 64 | + def backendId_to_backendIP = [:] |
| 65 | + def backendId_to_backendHttpPort = [:] |
| 66 | + getBackendIpHttpPort(backendId_to_backendIP, backendId_to_backendHttpPort); |
| 67 | + boolean disableAutoCompaction = true |
| 68 | + for(int i=0;i<backendId_to_backendIP.keySet().size();i++){ |
| 69 | + backend_id = backendId_to_backendIP.keySet()[i] |
| 70 | + def (code, out, err) = show_be_config(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id)) |
| 71 | + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) |
| 72 | + assertEquals(code, 0) |
| 73 | + def configList = parseJson(out.trim()) |
| 74 | + assert configList instanceof List |
| 75 | + |
| 76 | + for (Object ele in (List) configList) { |
| 77 | + assert ele instanceof List<String> |
| 78 | + if (((List<String>) ele)[0] == "disable_auto_compaction") { |
| 79 | + disableAutoCompaction = Boolean.parseBoolean(((List<String>) ele)[2]) |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + for (def tablet : tablets) { |
| 85 | + String tablet_id = tablet.TabletId |
| 86 | + def tablet_info = sql_return_maparray """ show tablet ${tablet_id}; """ |
| 87 | + logger.info("tablet"+tablet_info) |
| 88 | + def table_id = tablet_info[0].TableId |
| 89 | + backend_id = tablet.BackendId |
| 90 | + def times = 1 |
| 91 | + def code, out, err |
| 92 | + do{ |
| 93 | + (code, out, err) = be_run_full_compaction_by_table_id(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), table_id) |
| 94 | + logger.info("Run compaction: code=" + code + ", out=" + out + ", err=" + err) |
| 95 | + ++times |
| 96 | + sleep(2000) |
| 97 | + } while (parseJson(out.trim()).status.toLowerCase()!="success" && times<=10) |
| 98 | + |
| 99 | + def compactJson = parseJson(out.trim()) |
| 100 | + if (compactJson.status.toLowerCase() == "fail") { |
| 101 | + assertEquals(disableAutoCompaction, false) |
| 102 | + logger.info("Compaction was done automatically!") |
| 103 | + } |
| 104 | + if (disableAutoCompaction) { |
| 105 | + assertEquals("success", compactJson.status.toLowerCase()) |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + qt_test "select id,accident_type_name,accident_no,__DORIS_DELETE_SIGN__ From detail_tmp where accident_type_name = 'dd' order by accident_no,id limit 10;" |
| 110 | +} |
0 commit comments