|
| 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 | +// The "binlog.*" properties configure CCR binlog. A key under "binlog." other than binlog.enable, |
| 19 | +// binlog.ttl_seconds, binlog.max_bytes and binlog.max_history_nums is rejected instead of being |
| 20 | +// ignored, and binlog.enable accepts only true or false, in any case. |
| 21 | +suite("test_binlog_property_validation") { |
| 22 | + sql "DROP TABLE IF EXISTS test_binlog_property_validation_tbl" |
| 23 | + |
| 24 | + test { |
| 25 | + sql """ |
| 26 | + CREATE TABLE test_binlog_property_validation_tbl ( |
| 27 | + k1 INT NOT NULL, |
| 28 | + v1 INT |
| 29 | + ) |
| 30 | + DUPLICATE KEY(k1) |
| 31 | + DISTRIBUTED BY HASH(k1) BUCKETS 1 |
| 32 | + PROPERTIES ( |
| 33 | + "replication_num" = "1", |
| 34 | + "binlog.ttl_second" = "3600" |
| 35 | + ) |
| 36 | + """ |
| 37 | + exception "Unknown binlog property: binlog.ttl_second" |
| 38 | + } |
| 39 | + test { |
| 40 | + sql """ |
| 41 | + CREATE TABLE test_binlog_property_validation_tbl ( |
| 42 | + k1 INT NOT NULL, |
| 43 | + v1 INT |
| 44 | + ) |
| 45 | + DUPLICATE KEY(k1) |
| 46 | + DISTRIBUTED BY HASH(k1) BUCKETS 1 |
| 47 | + PROPERTIES ( |
| 48 | + "replication_num" = "1", |
| 49 | + "binlog.enable" = "yes" |
| 50 | + ) |
| 51 | + """ |
| 52 | + exception "Invalid binlog enable value: yes" |
| 53 | + } |
| 54 | + |
| 55 | + sql """ |
| 56 | + CREATE TABLE test_binlog_property_validation_tbl ( |
| 57 | + k1 INT NOT NULL, |
| 58 | + v1 INT |
| 59 | + ) |
| 60 | + DUPLICATE KEY(k1) |
| 61 | + DISTRIBUTED BY HASH(k1) BUCKETS 1 |
| 62 | + PROPERTIES ( |
| 63 | + "replication_num" = "1", |
| 64 | + "binlog.enable" = "False" |
| 65 | + ) |
| 66 | + """ |
| 67 | + order_qt_table_binlog_enable """ |
| 68 | + SELECT TABLE_NAME, PROPERTY_NAME, PROPERTY_VALUE |
| 69 | + FROM information_schema.table_properties |
| 70 | + WHERE TABLE_CATALOG = 'internal' |
| 71 | + AND TABLE_SCHEMA = '${context.dbName}' |
| 72 | + AND TABLE_NAME = 'test_binlog_property_validation_tbl' |
| 73 | + AND PROPERTY_NAME = 'binlog.enable' |
| 74 | + """ |
| 75 | + |
| 76 | + // The unknown key used to fail with "Nothing is changed", and "yes" used to be read as false, |
| 77 | + // which turned binlog off on a table that had it on. |
| 78 | + test { |
| 79 | + sql """ALTER TABLE test_binlog_property_validation_tbl SET ("binlog.ttl_second" = "3600")""" |
| 80 | + exception "Unknown binlog property: binlog.ttl_second" |
| 81 | + } |
| 82 | + test { |
| 83 | + sql """ALTER TABLE test_binlog_property_validation_tbl SET ("binlog.enable" = "yes")""" |
| 84 | + exception "Invalid binlog enable value: yes" |
| 85 | + } |
| 86 | + |
| 87 | + sql "DROP DATABASE IF EXISTS test_binlog_property_validation_db" |
| 88 | + test { |
| 89 | + sql """CREATE DATABASE test_binlog_property_validation_db PROPERTIES ("binlog.ttl_second" = "3600")""" |
| 90 | + exception "Unknown binlog property: binlog.ttl_second" |
| 91 | + } |
| 92 | + sql "CREATE DATABASE test_binlog_property_validation_db" |
| 93 | + // Database properties are stored as given, so these used to be persisted as they were. |
| 94 | + test { |
| 95 | + sql """ALTER DATABASE test_binlog_property_validation_db SET PROPERTIES ("binlog.max_byte" = "1024")""" |
| 96 | + exception "Unknown binlog property: binlog.max_byte" |
| 97 | + } |
| 98 | + test { |
| 99 | + sql """ALTER DATABASE test_binlog_property_validation_db SET PROPERTIES ("binlog.enable" = "1")""" |
| 100 | + exception "Invalid binlog enable value: 1" |
| 101 | + } |
| 102 | + order_qt_database_binlog_properties """ |
| 103 | + SELECT SCHEMA_NAME, PROPERTY_NAME, PROPERTY_VALUE |
| 104 | + FROM information_schema.database_properties |
| 105 | + WHERE SCHEMA_NAME = 'test_binlog_property_validation_db' |
| 106 | + AND PROPERTY_NAME LIKE 'binlog.%' |
| 107 | + """ |
| 108 | +} |
0 commit comments