From 47c163eb5ef565ed70a053563412fec30b12e3e7 Mon Sep 17 00:00:00 2001 From: Lchangliang <915311741@qq.com> Date: Sun, 10 Jul 2022 09:52:38 +0800 Subject: [PATCH] fix schema change test --- be/src/olap/compaction.cpp | 8 +-- be/src/olap/snapshot_manager.cpp | 3 +- .../test_partition_schema_change.out | 33 ++++++++++ .../test_agg_keys_schema_change.groovy | 51 +++++++++++++++- .../test_agg_mv_schema_change.groovy | 50 ++++++++++++++- .../test_agg_rollup_schema_change.groovy | 51 +++++++++++++++- .../test_agg_vals_schema_change.groovy | 51 +++++++++++++++- .../test_dup_keys_schema_change.groovy | 50 ++++++++++++++- .../test_dup_mv_schema_change.groovy | 50 ++++++++++++++- .../test_dup_rollup_schema_change.groovy | 49 ++++++++++++++- .../test_dup_vals_schema_change.groovy | 49 ++++++++++++++- .../test_partition_schema_change.sql | 44 +++++++++++++ .../test_uniq_keys_schema_change.groovy | 61 ++++++++++++++++--- .../test_uniq_mv_schema_change.groovy | 49 ++++++++++++++- .../test_uniq_rollup_schema_change.groovy | 49 ++++++++++++++- .../test_uniq_vals_schema_change.groovy | 49 ++++++++++++++- 16 files changed, 650 insertions(+), 47 deletions(-) create mode 100644 regression-test/data/schema_change/test_partition_schema_change.out create mode 100644 regression-test/suites/schema_change/test_partition_schema_change.sql diff --git a/be/src/olap/compaction.cpp b/be/src/olap/compaction.cpp index f29ed77f7a0d235..e06e5a9b00da4f7 100644 --- a/be/src/olap/compaction.cpp +++ b/be/src/olap/compaction.cpp @@ -145,9 +145,9 @@ Status Compaction::do_compaction_impl(int64_t permits) { LOG(INFO) << "start " << merge_type << compaction_name() << ". tablet=" << _tablet->full_name() << ", output_version=" << _output_version << ", permits: " << permits; // get cur schema if rowset schema exist, rowset schema must be newer than tablet schema - const TabletSchema* cur_tablet_schema = &_tablet->tablet_schema(); + const TabletSchema cur_tablet_schema = _tablet->tablet_schema(); - RETURN_NOT_OK(construct_output_rowset_writer(cur_tablet_schema)); + RETURN_NOT_OK(construct_output_rowset_writer(&cur_tablet_schema)); RETURN_NOT_OK(construct_input_rowset_readers()); TRACE("prepare finished"); @@ -157,10 +157,10 @@ Status Compaction::do_compaction_impl(int64_t permits) { Status res; if (use_vectorized_compaction) { - res = Merger::vmerge_rowsets(_tablet, compaction_type(), cur_tablet_schema, + res = Merger::vmerge_rowsets(_tablet, compaction_type(), &cur_tablet_schema, _input_rs_readers, _output_rs_writer.get(), &stats); } else { - res = Merger::merge_rowsets(_tablet, compaction_type(), cur_tablet_schema, + res = Merger::merge_rowsets(_tablet, compaction_type(), &cur_tablet_schema, _input_rs_readers, _output_rs_writer.get(), &stats); } diff --git a/be/src/olap/snapshot_manager.cpp b/be/src/olap/snapshot_manager.cpp index 3765008a407f51e..436769bc3a2da05 100644 --- a/be/src/olap/snapshot_manager.cpp +++ b/be/src/olap/snapshot_manager.cpp @@ -232,7 +232,8 @@ Status SnapshotManager::_rename_rowset_id(const RowsetMetaPB& rs_meta_pb, context.tablet_schema_hash = org_rowset_meta->tablet_schema_hash(); context.rowset_type = org_rowset_meta->rowset_type(); context.tablet_path = new_tablet_path; - context.tablet_schema = &tablet_schema; + context.tablet_schema = + org_rowset_meta->tablet_schema() ? org_rowset_meta->tablet_schema() : &tablet_schema; context.rowset_state = org_rowset_meta->rowset_state(); context.version = org_rowset_meta->version(); context.oldest_write_timestamp = org_rowset_meta->oldest_write_timestamp(); diff --git a/regression-test/data/schema_change/test_partition_schema_change.out b/regression-test/data/schema_change/test_partition_schema_change.out new file mode 100644 index 000000000000000..5c568d5ecda5e0d --- /dev/null +++ b/regression-test/data/schema_change/test_partition_schema_change.out @@ -0,0 +1,33 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !test_partition_schema_change -- +0 + +-- !test_partition_schema_change_2 -- +0 + +-- !test_partition_schema_change_3 -- +1 + +-- !test_partition_schema_change_4 -- +1 + +-- !test_partition_schema_change_5 -- +1 + +-- !test_partition_schema_change_6 -- +1 2017-01-02 Beijing 10 1 2017-01-02T00:00 1 30 20 +1 2017-02-02 Beijing 10 1 2017-02-02T00:00 1 30 20 +1 2017-03-02 Beijing 10 1 2017-03-02T00:00 1 30 20 + +-- !test_partition_schema_change_7 -- +0 + +-- !test_partition_schema_change_8 -- +1 + +-- !test_partition_schema_change_9 -- +1 2017-01-02 Beijing 10 1 2017-01-02T00:00 1 30 20 1 +1 2017-02-02 Beijing 10 1 2017-02-02T00:00 1 30 20 1 +2 2017-02-03 Beijing 10 1 2017-02-02T00:00 1 30 20 2 +1 2017-03-02 Beijing 10 1 2017-03-02T00:00 1 30 20 1 + diff --git a/regression-test/suites/schema_change/test_agg_keys_schema_change.groovy b/regression-test/suites/schema_change/test_agg_keys_schema_change.groovy index 96308a9b6d30bfa..13594474f746a25 100644 --- a/regression-test/suites/schema_change/test_agg_keys_schema_change.groovy +++ b/regression-test/suites/schema_change/test_agg_keys_schema_change.groovy @@ -21,6 +21,42 @@ suite ("test_agg_keys_schema_change") { def tableName = "schema_change_agg_keys_regression_test" try { + + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } + sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ CREATE TABLE ${tableName} ( @@ -151,10 +187,13 @@ suite ("test_agg_keys_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -173,9 +212,12 @@ suite ("test_agg_keys_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -203,9 +245,12 @@ suite ("test_agg_keys_schema_change") { int rowCount = 0 for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString() diff --git a/regression-test/suites/schema_change/test_agg_mv_schema_change.groovy b/regression-test/suites/schema_change/test_agg_mv_schema_change.groovy index a6b104ab70df8c0..d13c66ebdf4c534 100644 --- a/regression-test/suites/schema_change/test_agg_mv_schema_change.groovy +++ b/regression-test/suites/schema_change/test_agg_mv_schema_change.groovy @@ -22,6 +22,41 @@ suite ("test_agg_mv_schema_change") { def tableName = "schema_change_agg_mv_regression_test" try { + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } + sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ CREATE TABLE ${tableName} ( @@ -131,10 +166,13 @@ suite ("test_agg_mv_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -154,9 +192,12 @@ suite ("test_agg_mv_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -184,9 +225,12 @@ suite ("test_agg_mv_schema_change") { int rowCount = 0 for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString() diff --git a/regression-test/suites/schema_change/test_agg_rollup_schema_change.groovy b/regression-test/suites/schema_change/test_agg_rollup_schema_change.groovy index 232635b483e3cf8..c77cb5e946930b1 100644 --- a/regression-test/suites/schema_change/test_agg_rollup_schema_change.groovy +++ b/regression-test/suites/schema_change/test_agg_rollup_schema_change.groovy @@ -22,6 +22,42 @@ suite ("test_agg_rollup_schema_change") { def tableName = "schema_change_agg_rollup_regression_test" try { + + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } + sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ CREATE TABLE ${tableName} ( @@ -131,10 +167,13 @@ suite ("test_agg_rollup_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -154,9 +193,12 @@ suite ("test_agg_rollup_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -184,9 +226,12 @@ suite ("test_agg_rollup_schema_change") { int rowCount = 0 for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString() diff --git a/regression-test/suites/schema_change/test_agg_vals_schema_change.groovy b/regression-test/suites/schema_change/test_agg_vals_schema_change.groovy index d83f0e4c739abfe..304f3e4033c9050 100644 --- a/regression-test/suites/schema_change/test_agg_vals_schema_change.groovy +++ b/regression-test/suites/schema_change/test_agg_vals_schema_change.groovy @@ -21,6 +21,42 @@ suite ("test_agg_vals_schema_change") { def tableName = "schema_change_agg_vals_regression_test" try { + + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } + sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ @@ -147,10 +183,13 @@ suite ("test_agg_vals_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -170,9 +209,12 @@ suite ("test_agg_vals_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -199,9 +241,12 @@ suite ("test_agg_vals_schema_change") { int rowCount = 0 for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString() diff --git a/regression-test/suites/schema_change/test_dup_keys_schema_change.groovy b/regression-test/suites/schema_change/test_dup_keys_schema_change.groovy index 22763baf2613ff2..6711429d5a5f667 100644 --- a/regression-test/suites/schema_change/test_dup_keys_schema_change.groovy +++ b/regression-test/suites/schema_change/test_dup_keys_schema_change.groovy @@ -21,6 +21,41 @@ suite ("test_dup_keys_schema_change") { def tableName = "schema_change_dup_keys_regression_test" try { + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } + sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ @@ -147,10 +182,13 @@ suite ("test_dup_keys_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -170,9 +208,12 @@ suite ("test_dup_keys_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -201,9 +242,12 @@ suite ("test_dup_keys_schema_change") { int rowCount = 0 for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString() diff --git a/regression-test/suites/schema_change/test_dup_mv_schema_change.groovy b/regression-test/suites/schema_change/test_dup_mv_schema_change.groovy index e290833bb4502f9..810d75d7b8a1d0e 100644 --- a/regression-test/suites/schema_change/test_dup_mv_schema_change.groovy +++ b/regression-test/suites/schema_change/test_dup_mv_schema_change.groovy @@ -21,6 +21,41 @@ suite ("test_dup_mv_schema_change") { def tableName = "schema_change_dup_mv_regression_test" try { + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } + sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ @@ -162,10 +197,13 @@ suite ("test_dup_mv_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -185,9 +223,12 @@ suite ("test_dup_mv_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -216,9 +257,12 @@ suite ("test_dup_mv_schema_change") { int rowCount = 0 for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString() diff --git a/regression-test/suites/schema_change/test_dup_rollup_schema_change.groovy b/regression-test/suites/schema_change/test_dup_rollup_schema_change.groovy index dc3e2fb531d0500..6c1e8c2e42dd4f5 100644 --- a/regression-test/suites/schema_change/test_dup_rollup_schema_change.groovy +++ b/regression-test/suites/schema_change/test_dup_rollup_schema_change.groovy @@ -21,6 +21,40 @@ suite ("test_dup_rollup_schema_change") { def tableName = "schema_change_dup_rollup_regression_test" try { + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ @@ -162,10 +196,13 @@ suite ("test_dup_rollup_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -185,9 +222,12 @@ suite ("test_dup_rollup_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -217,8 +257,11 @@ suite ("test_dup_rollup_schema_change") { for (String[] tablet in tablets) { String tablet_id = tablet[0] StringBuilder sb = new StringBuilder(); + backend_id = tablet[2] sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString() diff --git a/regression-test/suites/schema_change/test_dup_vals_schema_change.groovy b/regression-test/suites/schema_change/test_dup_vals_schema_change.groovy index ecf0c7f7dbd35e3..e10e0724cebe117 100644 --- a/regression-test/suites/schema_change/test_dup_vals_schema_change.groovy +++ b/regression-test/suites/schema_change/test_dup_vals_schema_change.groovy @@ -21,6 +21,40 @@ suite ("test_dup_vals_schema_change") { def tableName = "schema_change_dup_vals_regression_test" try { + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ @@ -137,10 +171,13 @@ suite ("test_dup_vals_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -160,9 +197,12 @@ suite ("test_dup_vals_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -189,9 +229,12 @@ suite ("test_dup_vals_schema_change") { int rowCount = 0 for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString() diff --git a/regression-test/suites/schema_change/test_partition_schema_change.sql b/regression-test/suites/schema_change/test_partition_schema_change.sql new file mode 100644 index 000000000000000..58925efc3b5cff4 --- /dev/null +++ b/regression-test/suites/schema_change/test_partition_schema_change.sql @@ -0,0 +1,44 @@ +DROP TABLE IF EXISTS example_range_tbl; +CREATE TABLE example_range_tbl +( + `user_id` LARGEINT NOT NULL COMMENT "用户id", + `date` DATE NOT NULL COMMENT "数据灌入日期时间", + `city` VARCHAR(20) COMMENT "用户所在城市", + `age` SMALLINT COMMENT "用户年龄", + `sex` TINYINT COMMENT "用户性别", + `last_visit_date` DATETIME REPLACE DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次访问时间", + `cost` BIGINT SUM DEFAULT "0" COMMENT "用户总消费", + `max_dwell_time` INT MAX DEFAULT "0" COMMENT "用户最大停留时间", + `min_dwell_time` INT MIN DEFAULT "99999" COMMENT "用户最小停留时间" +) +ENGINE=OLAP +AGGREGATE KEY(`user_id`, `date`, `city`, `age`, `sex`) +PARTITION BY RANGE(`date`) +( + PARTITION `p201701` VALUES LESS THAN ("2017-02-01"), + PARTITION `p201702` VALUES LESS THAN ("2017-03-01"), + PARTITION `p201703` VALUES LESS THAN ("2017-04-01") +) +DISTRIBUTED BY HASH(`user_id`) BUCKETS 1 +PROPERTIES +( + "replication_num" = "1" +); + +INSERT INTO example_range_tbl VALUES + (1, '2017-01-02', 'Beijing', 10, 1, "2017-01-02 00:00:00", 1, 30, 20); + +INSERT INTO example_range_tbl VALUES + (1, '2017-02-02', 'Beijing', 10, 1, "2017-02-02 00:00:00", 1, 30, 20); + +INSERT INTO example_range_tbl VALUES + (1, '2017-03-02', 'Beijing', 10, 1, "2017-03-02 00:00:00", 1, 30, 20); + +select * from example_range_tbl order by `date`; + +ALTER table example_range_tbl ADD COLUMN new_column INT MAX default "1"; + +INSERT INTO example_range_tbl VALUES + (2, '2017-02-03', 'Beijing', 10, 1, "2017-02-02 00:00:00", 1, 30, 20, 2); + +select * from example_range_tbl order by `date`; \ No newline at end of file diff --git a/regression-test/suites/schema_change/test_uniq_keys_schema_change.groovy b/regression-test/suites/schema_change/test_uniq_keys_schema_change.groovy index b8eb3b91cb72e80..568df986f528e3e 100644 --- a/regression-test/suites/schema_change/test_uniq_keys_schema_change.groovy +++ b/regression-test/suites/schema_change/test_uniq_keys_schema_change.groovy @@ -21,10 +21,44 @@ suite ("test_uniq_keys_schema_change") { def tableName = "schema_change_uniq_keys_regression_test" try { + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ - CREATE TABLE ${tableName} ( + CREATE TABLE schema_change_uniq_keys_regression_test ( `user_id` LARGEINT NOT NULL COMMENT "用户id", `date` DATE NOT NULL COMMENT "数据灌入日期时间", `city` VARCHAR(20) COMMENT "用户所在城市", @@ -40,23 +74,23 @@ suite ("test_uniq_keys_schema_change") { PROPERTIES ( "replication_num" = "1" ); """ - sql """ INSERT INTO ${tableName} VALUES + sql """ INSERT INTO schema_change_uniq_keys_regression_test VALUES (1, '2017-10-01', 'Beijing', 10, 1, '2020-01-01', '2020-01-01', '2020-01-01', 1, 30, 20) """ - sql """ INSERT INTO ${tableName} VALUES + sql """ INSERT INTO schema_change_uniq_keys_regression_test VALUES (1, '2017-10-01', 'Beijing', 10, 1, '2020-01-02', '2020-01-02', '2020-01-02', 1, 31, 19) """ - sql """ INSERT INTO ${tableName} VALUES + sql """ INSERT INTO schema_change_uniq_keys_regression_test VALUES (2, '2017-10-01', 'Beijing', 10, 1, '2020-01-02', '2020-01-02', '2020-01-02', 1, 31, 21) """ - sql """ INSERT INTO ${tableName} VALUES + sql """ INSERT INTO schema_change_uniq_keys_regression_test VALUES (2, '2017-10-01', 'Beijing', 10, 1, '2020-01-03', '2020-01-03', '2020-01-03', 1, 32, 20) """ def result = sql """ - select count(*) from ${tableName} + select count(*) from schema_change_uniq_keys_regression_test """ assertTrue(result.size() == 1) assertTrue(result[0].size() == 1) @@ -148,10 +182,13 @@ suite ("test_uniq_keys_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -171,9 +208,12 @@ suite ("test_uniq_keys_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -200,9 +240,12 @@ suite ("test_uniq_keys_schema_change") { int rowCount = 0 for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString() diff --git a/regression-test/suites/schema_change/test_uniq_mv_schema_change.groovy b/regression-test/suites/schema_change/test_uniq_mv_schema_change.groovy index 4ea38950f4991f0..19070173f35a4b6 100644 --- a/regression-test/suites/schema_change/test_uniq_mv_schema_change.groovy +++ b/regression-test/suites/schema_change/test_uniq_mv_schema_change.groovy @@ -21,6 +21,40 @@ suite ("test_uniq_mv_schema_change") { def tableName = "schema_change_uniq_mv_regression_test" try { + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ @@ -152,10 +186,13 @@ suite ("test_uniq_mv_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -175,9 +212,12 @@ suite ("test_uniq_mv_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -204,9 +244,12 @@ suite ("test_uniq_mv_schema_change") { int rowCount = 0 for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString() diff --git a/regression-test/suites/schema_change/test_uniq_rollup_schema_change.groovy b/regression-test/suites/schema_change/test_uniq_rollup_schema_change.groovy index 7cd897324b85c6b..317e099b2cc6266 100644 --- a/regression-test/suites/schema_change/test_uniq_rollup_schema_change.groovy +++ b/regression-test/suites/schema_change/test_uniq_rollup_schema_change.groovy @@ -21,6 +21,40 @@ suite ("test_uniq_rollup_schema_change") { def tableName = "schema_change_uniq_rollup_regression_test" try { + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ @@ -164,10 +198,13 @@ suite ("test_uniq_rollup_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -187,9 +224,12 @@ suite ("test_uniq_rollup_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -216,9 +256,12 @@ suite ("test_uniq_rollup_schema_change") { int rowCount = 0 for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString() diff --git a/regression-test/suites/schema_change/test_uniq_vals_schema_change.groovy b/regression-test/suites/schema_change/test_uniq_vals_schema_change.groovy index 5bd842bc6f0fa83..3c5ff5b3a73ac3e 100644 --- a/regression-test/suites/schema_change/test_uniq_vals_schema_change.groovy +++ b/regression-test/suites/schema_change/test_uniq_vals_schema_change.groovy @@ -21,6 +21,40 @@ suite ("test_uniq_vals_schema_change") { def tableName = "schema_change_uniq_vals_regression_test" try { + String[][] backends = sql """ show backends; """ + assertTrue(backends.size() > 0) + String backend_id; + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + for (String[] backend in backends) { + backendId_to_backendIP.put(backend[0], backend[2]) + backendId_to_backendHttpPort.put(backend[0], backend[5]) + } + + backend_id = backendId_to_backendIP.keySet()[0] + StringBuilder showConfigCommand = new StringBuilder(); + showConfigCommand.append("curl -X GET http://") + showConfigCommand.append(backendId_to_backendIP.get(backend_id)) + showConfigCommand.append(":") + showConfigCommand.append(backendId_to_backendHttpPort.get(backend_id)) + showConfigCommand.append("/api/show_config") + logger.info(showConfigCommand.toString()) + def process = showConfigCommand.toString().execute() + int code = process.waitFor() + String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream()))); + String out = process.getText() + logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) + assertEquals(code, 0) + def configList = parseJson(out.trim()) + assert configList instanceof List + + boolean disableAutoCompaction = true + for (Object ele in (List) configList) { + assert ele instanceof List + if (((List) ele)[0] == "disable_auto_compaction") { + disableAutoCompaction = Boolean.parseBoolean(((List) ele)[2]) + } + } sql """ DROP TABLE IF EXISTS ${tableName} """ sql """ @@ -138,10 +172,13 @@ suite ("test_uniq_vals_schema_change") { String[][] tablets = sql """ show tablets from ${tableName}; """ for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] logger.info("run compaction:" + tablet_id) StringBuilder sb = new StringBuilder(); sb.append("curl -X POST http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run?tablet_id=") sb.append(tablet_id) sb.append("&compact_type=cumulative") @@ -161,9 +198,12 @@ suite ("test_uniq_vals_schema_change") { do { Thread.sleep(1000) String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/run_status?tablet_id=") sb.append(tablet_id) @@ -190,9 +230,12 @@ suite ("test_uniq_vals_schema_change") { int rowCount = 0 for (String[] tablet in tablets) { String tablet_id = tablet[0] + backend_id = tablet[2] StringBuilder sb = new StringBuilder(); sb.append("curl -X GET http://") - sb.append(context.config.beHttpAddress) + sb.append(backendId_to_backendIP.get(backend_id)) + sb.append(":") + sb.append(backendId_to_backendHttpPort.get(backend_id)) sb.append("/api/compaction/show?tablet_id=") sb.append(tablet_id) String command = sb.toString()