This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 2cc901d3b9badeec371c04c4a812835a0e06302b Author: Yongqiang YANG <98214048+dataroar...@users.noreply.github.com> AuthorDate: Fri Jul 19 16:34:45 2024 +0800 [fix](test) use waitForSchemaChangeDone instead of custom sleeping (#38105) --- .../test_alter_table_add_columns.groovy | 22 ++---- .../test_alter_table_drop_column.groovy | 30 +++----- .../test_alter_table_modify_column.groovy | 28 ++----- .../test_schema_change_duplicate.groovy | 86 ++++++---------------- .../schema_change_p2/test_schema_change.groovy | 19 +---- 5 files changed, 49 insertions(+), 136 deletions(-) diff --git a/regression-test/suites/schema_change_p0/test_alter_table_add_columns.groovy b/regression-test/suites/schema_change_p0/test_alter_table_add_columns.groovy index 33484f95bf8..f5da136bdd6 100644 --- a/regression-test/suites/schema_change_p0/test_alter_table_add_columns.groovy +++ b/regression-test/suites/schema_change_p0/test_alter_table_add_columns.groovy @@ -56,26 +56,14 @@ suite("test_alter_table_add_columns") { qt_order """ select * from ${tbName} order by siteid""" // Add one value column light schema change is false - sleep(1000) + sql """ alter table ${tbName} ADD COLUMN (new_k1 INT DEFAULT '1', new_k2 INT DEFAULT '2');""" - def waitSchemaChangeJob = { String tableName /* param */ -> - int tryTimes = 30 - while (tryTimes-- > 0) { - def jobResult = sql """SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """ - def jobState = jobResult[0][9].toString() - if ('cancelled'.equalsIgnoreCase(jobState)) { - logger.info("jobResult:{}", jobResult) - throw new IllegalStateException("${tableName}'s job has been cancelled") - } - if ('finished'.equalsIgnoreCase(jobState)) { - logger.info("jobResult:{}", jobResult) - break - } - sleep(10000) - } + + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${tbName}' ORDER BY createtime DESC LIMIT 1 """ + time 600 } - waitSchemaChangeJob(tbName) qt_sql """ DESC ${tbName}""" sql """ INSERT INTO ${tbName} VALUES diff --git a/regression-test/suites/schema_change_p0/test_alter_table_drop_column.groovy b/regression-test/suites/schema_change_p0/test_alter_table_drop_column.groovy index 163f1267aae..bd600d81698 100644 --- a/regression-test/suites/schema_change_p0/test_alter_table_drop_column.groovy +++ b/regression-test/suites/schema_change_p0/test_alter_table_drop_column.groovy @@ -75,26 +75,12 @@ suite("test_alter_table_drop_column") { exception "Can not drop key column in Unique data model table" } - def waitSchemaChangeJob = { String tableName /* param */ -> - int tryTimes = 30 - while (tryTimes-- > 0) { - def jobResult = sql """SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """ - def jobState = jobResult[0][9].toString() - if ('cancelled'.equalsIgnoreCase(jobState)) { - logger.info("jobResult:{}", jobResult) - throw new IllegalStateException("${tableName}'s job has been cancelled") - } - if ('finished'.equalsIgnoreCase(jobState)) { - logger.info("jobResult:{}", jobResult) - return - } - sleep(10000) - } - assertTrue(false) - } - sql """ alter table ${uniqueTableName} drop COLUMN pv from ${uniqueTableRollupName};""" - waitSchemaChangeJob(uniqueTableName) + + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${uniqueTableName}' ORDER BY createtime DESC LIMIT 1 """ + time 600 + } qt_order """ select * from ${uniqueTableName} order by siteid""" qt_order """ select * from ${uniqueTableName} order by citycode""" @@ -138,7 +124,11 @@ suite("test_alter_table_drop_column") { } sql """ alter table ${aggTableName} drop COLUMN pv from ${aggTableRollupName};""" - waitSchemaChangeJob(aggTableName) + + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${aggTableName}' ORDER BY createtime DESC LIMIT 1 """ + time 600 + } qt_order """ select * from ${aggTableName} order by siteid""" qt_order """ select * from ${aggTableName} order by citycode""" diff --git a/regression-test/suites/schema_change_p0/test_alter_table_modify_column.groovy b/regression-test/suites/schema_change_p0/test_alter_table_modify_column.groovy index 405b28fefe3..3920086bf6c 100644 --- a/regression-test/suites/schema_change_p0/test_alter_table_modify_column.groovy +++ b/regression-test/suites/schema_change_p0/test_alter_table_modify_column.groovy @@ -34,24 +34,6 @@ suite("test_alter_table_modify_column") { assertTrue(false) } - def waitSchemaChangeJob = { String tableName /* param */ -> - int tryTimes = 30 - while (tryTimes-- > 0) { - def jobResult = sql """SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """ - def jobState = jobResult[0][9].toString() - if ('cancelled'.equalsIgnoreCase(jobState)) { - logger.info("jobResult:{}", jobResult) - throw new IllegalStateException("${tableName}'s job has been cancelled") - } - if ('finished'.equalsIgnoreCase(jobState)) { - logger.info("jobResult:{}", jobResult) - return - } - sleep(10000) - } - assertTrue(false) - } - // unique model table def uniqueTableName = "test_alter_table_modify_column_unique" @@ -202,7 +184,10 @@ suite("test_alter_table_modify_column") { } sql """alter table ${dupTableName} modify COLUMN username VARCHAR(32) key DEFAULT 'test' first;""" - waitSchemaChangeJob(dupTableName) + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${dupTableName}' ORDER BY createtime DESC LIMIT 1 """ + time 600 + } sql """ INSERT INTO ${dupTableName} VALUES ("yyy", 4, 4, 4) @@ -210,7 +195,10 @@ suite("test_alter_table_modify_column") { qt_order """select * from ${dupTableName} order by siteid""" sql """alter table ${dupTableName} order by(citycode, siteid, username, pv);""" - waitSchemaChangeJob(dupTableName) + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${dupTableName}' ORDER BY createtime DESC LIMIT 1 """ + time 600 + } sql """ INSERT INTO ${dupTableName} VALUES (5, 5, "zzz", 5) """ diff --git a/regression-test/suites/schema_change_p0/test_schema_change_duplicate.groovy b/regression-test/suites/schema_change_p0/test_schema_change_duplicate.groovy index 007bb196244..6c6660d1055 100644 --- a/regression-test/suites/schema_change_p0/test_schema_change_duplicate.groovy +++ b/regression-test/suites/schema_change_p0/test_schema_change_duplicate.groovy @@ -95,41 +95,21 @@ suite("test_schema_change_duplicate", "p0") { execStreamLoad() sql """ alter table ${tableName3} modify column k4 string NULL""" - sleep(10) - int max_try_num = 60 - while (max_try_num--) { - String res = getJobState(tableName3) - if (res == "FINISHED" || res == "CANCELLED") { - assertEquals("FINISHED", res) - sleep(3000) - break - } else { - execStreamLoad() - if (max_try_num < 1) { - println "test timeout," + "state:" + res - assertEquals("FINISHED",res) - } - } + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 600 } + execStreamLoad(); + sql """ alter table ${tableName3} modify column k2 bigint(11) key NULL""" - sleep(10) - max_try_num = 60 - while (max_try_num--) { - String res = getJobState(tableName3) - if (res == "FINISHED" || res == "CANCELLED") { - assertEquals("FINISHED", res) - sleep(3000) - break - } else { - execStreamLoad() - if (max_try_num < 1) { - println "test timeout," + "state:" + res - assertEquals("FINISHED",res) - } - } + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 600 } + execStreamLoad() + /* sql """ create materialized view view_1 as select k2, k1, k4, k5 from ${tableName3} """ sleep(10) @@ -151,48 +131,28 @@ suite("test_schema_change_duplicate", "p0") { */ sql """ alter table ${tableName3} modify column k5 string NULL""" - sleep(10) - max_try_num = 60 - while (max_try_num--) { - String res = getJobState(tableName3) - if (res == "FINISHED" || res == "CANCELLED") { - assertEquals("FINISHED", res) - sleep(3000) - break - } else { - execStreamLoad() - if (max_try_num < 1) { - println "test timeout," + "state:" + res - assertEquals("FINISHED",res) - } - } + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 600 } + execStreamLoad() + sql """ alter table ${tableName3} add column v14 int NOT NULL default "1" after k13 """ sql """ insert into ${tableName3} values (10001, 2, 3, 4, 5, 6.6, 1.7, 8.8, 'a', 'b', 'c', '2021-10-30', '2021-10-30 00:00:00', 10086) """ sql """ alter table ${tableName3} modify column v14 int NULL default "1" """ - sleep(10) - max_try_num = 6000 - while (max_try_num--) { - String res = getJobState(tableName3) - if (res == "FINISHED" || res == "CANCELLED") { - assertEquals("FINISHED", res) - sleep(3000) - break - } else { - int val = 100000 + max_try_num - sql """ insert into ${tableName3} values (${val}, 2, 3, 4, 5, 6.6, 1.7, 8.8, - 'a', 'b', 'c', '2021-10-30', '2021-10-30 00:00:00', 9527) """ - sleep(10) - if (max_try_num < 1) { - println "test timeout," + "state:" + res - assertEquals("FINISHED",res) - } - } + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 600 } + int val = 100000 + max_try_num + sql """ insert into ${tableName3} values (${val}, 2, 3, 4, 5, 6.6, 1.7, 8.8, +'a', 'b', 'c', '2021-10-30', '2021-10-30 00:00:00', 9527) """ + + sql """ alter table ${tableName3} drop column v14 """ execStreamLoad() diff --git a/regression-test/suites/schema_change_p2/test_schema_change.groovy b/regression-test/suites/schema_change_p2/test_schema_change.groovy index 3897d0d03b6..d6ca29caa03 100644 --- a/regression-test/suites/schema_change_p2/test_schema_change.groovy +++ b/regression-test/suites/schema_change_p2/test_schema_change.groovy @@ -90,24 +90,11 @@ suite("test_schema_change") { sql """ alter table ${tableName} drop column C_NAME""" - def waitSchemaChangeJob = { String tbName /* param */ -> - int tryTimes = 20 - while (tryTimes-- > 0) { - def jobResult = sql """SHOW ALTER TABLE COLUMN WHERE IndexName='${tbName}' ORDER BY createtime DESC LIMIT 1 """ - def jobState = jobResult[0][9].toString() - if ('cancelled'.equalsIgnoreCase(jobState)) { - logger.info("jobResult:{}", jobResult) - throw new IllegalStateException("${tbName}'s job has been cancelled") - } - if ('finished'.equalsIgnoreCase(jobState)) { - logger.info("jobResult:{}", jobResult) - break - } - sleep(60000) - } + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${tableName}' ORDER BY createtime DESC LIMIT 1 """ + time 600 } - waitSchemaChangeJob(tableName) sql """ DESC ${tableName}""" rowCount = sql "select count(*) from ${tableName}" logger.info("rowCount:{}", rowCount) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org