|
| 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.apache.doris.regression.suite.ClusterOptions |
| 19 | +import org.codehaus.groovy.runtime.IOGroovyMethods |
| 20 | + |
| 21 | +suite('test_expanding_node_balance', 'docker') { |
| 22 | + if (!isCloudMode()) { |
| 23 | + return; |
| 24 | + } |
| 25 | + |
| 26 | + def clusterOptions = [ |
| 27 | + new ClusterOptions(), |
| 28 | + new ClusterOptions(), |
| 29 | + new ClusterOptions(), |
| 30 | + ] |
| 31 | + |
| 32 | + for (options in clusterOptions) { |
| 33 | + options.feConfigs += [ |
| 34 | + 'cloud_cluster_check_interval_second=1', |
| 35 | + 'cloud_tablet_rebalancer_interval_second=20', |
| 36 | + 'sys_log_verbose_modules=org', |
| 37 | + 'heartbeat_interval_second=1', |
| 38 | + 'rehash_tablet_after_be_dead_seconds=3600', |
| 39 | + 'cloud_warm_up_for_rebalance_type=peer_read_async_warmup', |
| 40 | + // disable Auto Analysis Job Executor |
| 41 | + 'auto_check_statistics_in_minutes=60', |
| 42 | + ] |
| 43 | + options.cloudMode = true |
| 44 | + options.setFeNum(1) |
| 45 | + options.setBeNum(1) |
| 46 | + options.enableDebugPoints() |
| 47 | + } |
| 48 | + |
| 49 | + |
| 50 | + def testCase = { command, expectCost -> |
| 51 | + sql """ |
| 52 | + CREATE TABLE `fact_sales` ( |
| 53 | + `order_id` varchar(255) NOT NULL, |
| 54 | + `order_line_id` varchar(255) NOT NULL, |
| 55 | + `order_date` date NOT NULL, |
| 56 | + `time_of_day` varchar(50) NOT NULL, |
| 57 | + `season` varchar(50) NOT NULL, |
| 58 | + `month` int NOT NULL, |
| 59 | + `location_id` varchar(255) NOT NULL, |
| 60 | + `region` varchar(100) NOT NULL, |
| 61 | + `product_name` varchar(255) NOT NULL, |
| 62 | + `quantity` int NOT NULL, |
| 63 | + `sales_amount` double NOT NULL, |
| 64 | + `discount_percentage` int NOT NULL, |
| 65 | + `product_id` varchar(255) NOT NULL |
| 66 | + ) ENGINE=OLAP |
| 67 | + DUPLICATE KEY(`order_id`, `order_line_id`) |
| 68 | + DISTRIBUTED BY HASH(`order_id`) BUCKETS 256 |
| 69 | + PROPERTIES ( |
| 70 | + "replication_allocation" = "tag.location.default: 1" |
| 71 | + ) |
| 72 | + """ |
| 73 | + |
| 74 | + cluster.addBackend(15, "compute_cluster") |
| 75 | + |
| 76 | + sql """ |
| 77 | + $command |
| 78 | + """ |
| 79 | + def begin = System.currentTimeMillis(); |
| 80 | + awaitUntil(1000, 10) { |
| 81 | + def showRet = sql_return_maparray """ADMIN SHOW REPLICA DISTRIBUTION FROM fact_sales""" |
| 82 | + logger.info("show result {}", showRet) |
| 83 | + showRet.any { row -> |
| 84 | + Integer.valueOf((String) row.ReplicaNum) == 16 |
| 85 | + } |
| 86 | + } |
| 87 | + def cost = (System.currentTimeMillis() - begin) / 1000; |
| 88 | + log.info("exec command: {}\n time cost: {}s", command, cost) |
| 89 | + assertTrue(cost < expectCost, "cost assert wrong") |
| 90 | + } |
| 91 | + |
| 92 | + docker(clusterOptions[0]) { |
| 93 | + def command = 'admin set frontend config("cloud_min_balance_tablet_num_per_run"="16");' |
| 94 | + // assert < 300s |
| 95 | + testCase(command, 300) |
| 96 | + } |
| 97 | + |
| 98 | + docker(clusterOptions[1]) { |
| 99 | + def command = 'admin set frontend config("cloud_tablet_rebalancer_interval_second"="0");' |
| 100 | + // assert < 50s |
| 101 | + testCase(command, 50) |
| 102 | + } |
| 103 | + |
| 104 | + docker(clusterOptions[2]) { |
| 105 | + GetDebugPoint().enableDebugPointForAllFEs("CloudTabletRebalancer.balanceEnd.tooLong") |
| 106 | + // do nothing |
| 107 | + def command = 'select 1' |
| 108 | + // assert < 50s |
| 109 | + testCase(command, 50) |
| 110 | + } |
| 111 | +} |
0 commit comments