|
| 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_group_commit_timeout", "nonConcurrent") { |
| 19 | + def tableName = "test_group_commit_timeout" |
| 20 | + sql """ |
| 21 | + CREATE TABLE if not exists ${tableName} ( |
| 22 | + `id` int(11) NOT NULL, |
| 23 | + `name` varchar(100) NULL, |
| 24 | + `score` int(11) NULL default "-1" |
| 25 | + ) ENGINE=OLAP |
| 26 | + DUPLICATE KEY(`id`) |
| 27 | + DISTRIBUTED BY HASH(`id`) BUCKETS 1 |
| 28 | + PROPERTIES ( |
| 29 | + "replication_num" = "1", |
| 30 | + "group_commit_interval_ms" = "300000" |
| 31 | + ); |
| 32 | + """ |
| 33 | + |
| 34 | + def query_timeout = sql """show variables where variable_name = 'query_timeout';""" |
| 35 | + def insert_timeout = sql """show variables where variable_name = 'insert_timeout';""" |
| 36 | + logger.info("query_timeout: ${query_timeout}, insert_timeout: ${insert_timeout}") |
| 37 | + |
| 38 | + long start = System.currentTimeMillis() |
| 39 | + try { |
| 40 | + sql "SET global query_timeout = 5" |
| 41 | + sql "SET global insert_timeout = 5" |
| 42 | + |
| 43 | + sql "set group_commit = sync_mode" |
| 44 | + sql "insert into ${tableName} values(1, 'a', 10)" |
| 45 | + assertTrue(false) |
| 46 | + } catch (Exception e) { |
| 47 | + long end = System.currentTimeMillis() |
| 48 | + logger.info("failed " + e.getMessage()) |
| 49 | + assertTrue(e.getMessage().contains("FragmentMgr cancel worker going to cancel timeout instance")) |
| 50 | + assertTrue(end - start <= 60000) |
| 51 | + } finally { |
| 52 | + sql "SET global query_timeout = ${query_timeout[0][1]}" |
| 53 | + sql "SET global insert_timeout = ${insert_timeout[0][1]}" |
| 54 | + } |
| 55 | +} |
0 commit comments