From 44fd6515eafa47227b85c76101642789a21fb8be Mon Sep 17 00:00:00 2001 From: Yongqiang YANG Date: Wed, 6 Aug 2025 09:26:41 +0800 Subject: [PATCH] [fix](case) remove global variable declarations in compaction test [files - Add 'def' declaration for tabletId variables in for loops - Add 'def result = null' declaration before using result variables - Fix global variable issues in compaction1-11 test files - Ensure proper local variable scope in Groovy test scripts --- .../compaction1/test_schema_change_with_compaction1.groovy | 1 + .../compaction10/test_schema_change_with_compaction10.groovy | 3 ++- .../compaction11/test_schema_change_with_compaction11.groovy | 2 +- .../compaction2/test_schema_change_with_compaction2.groovy | 1 + .../compaction3/test_schema_change_with_compaction3.groovy | 5 +++-- .../compaction4/test_schema_change_with_compaction4.groovy | 5 +++-- .../compaction5/test_schema_change_with_compaction5.groovy | 5 +++-- .../compaction6/test_schema_change_with_compaction6.groovy | 5 +++-- .../compaction7/test_schema_change_with_compaction7.groovy | 5 +++-- .../compaction8/test_schema_change_with_compaction8.groovy | 1 + .../compaction9/test_schema_change_with_compaction9.groovy | 5 +++-- 11 files changed, 24 insertions(+), 14 deletions(-) diff --git a/regression-test/suites/cloud_p1/schema_change/compaction1/test_schema_change_with_compaction1.groovy b/regression-test/suites/cloud_p1/schema_change/compaction1/test_schema_change_with_compaction1.groovy index 90c273ce4e2772..58b7459204977f 100644 --- a/regression-test/suites/cloud_p1/schema_change/compaction1/test_schema_change_with_compaction1.groovy +++ b/regression-test/suites/cloud_p1/schema_change/compaction1/test_schema_change_with_compaction1.groovy @@ -123,6 +123,7 @@ suite('test_schema_change_with_compaction1', 'p1,nonConcurrent') { DebugPoint.disableDebugPoint(injectBe.Host, injectBe.HttpPort.toInteger(), NodeType.BE, injectName) } int max_try_time = 3000 + def result = null while (max_try_time--){ result = getJobState("date") if (result == "FINISHED" || result == "CANCELLED") { diff --git a/regression-test/suites/cloud_p1/schema_change/compaction10/test_schema_change_with_compaction10.groovy b/regression-test/suites/cloud_p1/schema_change/compaction10/test_schema_change_with_compaction10.groovy index 2e9ad0628d4d53..db3da9aa044241 100644 --- a/regression-test/suites/cloud_p1/schema_change/compaction10/test_schema_change_with_compaction10.groovy +++ b/regression-test/suites/cloud_p1/schema_change/compaction10/test_schema_change_with_compaction10.groovy @@ -127,8 +127,9 @@ suite('test_schema_change_with_compaction10', 'docker') { GetDebugPoint().disableDebugPointForAllBEs(injectName) } int max_try_time = 3000 + def result = null while (max_try_time--){ - def result = getJobState("date") + result = getJobState("date") if (result == "FINISHED" || result == "CANCELLED") { sleep(3000) break diff --git a/regression-test/suites/cloud_p1/schema_change/compaction11/test_schema_change_with_compaction11.groovy b/regression-test/suites/cloud_p1/schema_change/compaction11/test_schema_change_with_compaction11.groovy index 2f7268b962442f..4c1c772da37c93 100644 --- a/regression-test/suites/cloud_p1/schema_change/compaction11/test_schema_change_with_compaction11.groovy +++ b/regression-test/suites/cloud_p1/schema_change/compaction11/test_schema_change_with_compaction11.groovy @@ -115,7 +115,7 @@ suite('test_schema_change_with_compaction11', 'docker') { // cu compaction - tabletId = array[0].TabletId + def tabletId = array[0].TabletId logger.info("run compaction:" + tabletId) (code, out, err) = be_run_cumulative_compaction(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Run compaction: code=" + code + ", out=" + out + ", err=" + err) diff --git a/regression-test/suites/cloud_p1/schema_change/compaction2/test_schema_change_with_compaction2.groovy b/regression-test/suites/cloud_p1/schema_change/compaction2/test_schema_change_with_compaction2.groovy index 4c4b153af8c792..58f54f9769213f 100644 --- a/regression-test/suites/cloud_p1/schema_change/compaction2/test_schema_change_with_compaction2.groovy +++ b/regression-test/suites/cloud_p1/schema_change/compaction2/test_schema_change_with_compaction2.groovy @@ -143,6 +143,7 @@ suite('test_schema_change_with_compaction2', 'p1,nonConcurrent') { DebugPoint.disableDebugPoint(injectBe.Host, injectBe.HttpPort.toInteger(), NodeType.BE, injectName) } int max_try_time = 3000 + def result = null while (max_try_time--){ result = getJobState("date") if (result == "FINISHED") { diff --git a/regression-test/suites/cloud_p1/schema_change/compaction3/test_schema_change_with_compaction3.groovy b/regression-test/suites/cloud_p1/schema_change/compaction3/test_schema_change_with_compaction3.groovy index 49911063e81571..7f11ad99ac5abe 100644 --- a/regression-test/suites/cloud_p1/schema_change/compaction3/test_schema_change_with_compaction3.groovy +++ b/regression-test/suites/cloud_p1/schema_change/compaction3/test_schema_change_with_compaction3.groovy @@ -143,7 +143,7 @@ suite('test_schema_change_with_compaction3', 'p1,nonConcurrent') { // cu compaction for (int i = 0; i < array.size(); i++) { - tabletId = array[i].TabletId + def tabletId = array[i].TabletId logger.info("run compaction:" + tabletId) (code, out, err) = be_run_cumulative_compaction(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Run compaction: code=" + code + ", out=" + out + ", err=" + err) @@ -153,7 +153,7 @@ suite('test_schema_change_with_compaction3', 'p1,nonConcurrent') { running = true do { Thread.sleep(100) - tabletId = array[i].TabletId + def tabletId = array[i].TabletId (code, out, err) = be_get_compaction_status(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err) assertEquals(code, 0) @@ -170,6 +170,7 @@ suite('test_schema_change_with_compaction3', 'p1,nonConcurrent') { DebugPoint.disableDebugPoint(injectBe.Host, injectBe.HttpPort.toInteger(), NodeType.BE, injectName) } int max_try_time = 3000 + def result = null while (max_try_time--){ result = getJobState("date") if (result == "FINISHED" || result == "CANCELLED") { diff --git a/regression-test/suites/cloud_p1/schema_change/compaction4/test_schema_change_with_compaction4.groovy b/regression-test/suites/cloud_p1/schema_change/compaction4/test_schema_change_with_compaction4.groovy index 8ca086facd1a2b..915b2fd95c3926 100644 --- a/regression-test/suites/cloud_p1/schema_change/compaction4/test_schema_change_with_compaction4.groovy +++ b/regression-test/suites/cloud_p1/schema_change/compaction4/test_schema_change_with_compaction4.groovy @@ -143,7 +143,7 @@ suite('test_schema_change_with_compaction4', 'p1,nonConcurrent') { // cu compaction for (int i = 0; i < array.size(); i++) { - tabletId = array[i].TabletId + def tabletId = array[i].TabletId logger.info("run compaction:" + tabletId) (code, out, err) = be_run_cumulative_compaction(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Run compaction: code=" + code + ", out=" + out + ", err=" + err) @@ -153,7 +153,7 @@ suite('test_schema_change_with_compaction4', 'p1,nonConcurrent') { running = true do { Thread.sleep(100) - tabletId = array[i].TabletId + def tabletId = array[i].TabletId (code, out, err) = be_get_compaction_status(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err) assertEquals(code, 0) @@ -170,6 +170,7 @@ suite('test_schema_change_with_compaction4', 'p1,nonConcurrent') { DebugPoint.disableDebugPoint(injectBe.Host, injectBe.HttpPort.toInteger(), NodeType.BE, injectName) } int max_try_time = 3000 + def result = null while (max_try_time--){ result = getJobState("date") if (result == "FINISHED" || result == "CANCELLED") { diff --git a/regression-test/suites/cloud_p1/schema_change/compaction5/test_schema_change_with_compaction5.groovy b/regression-test/suites/cloud_p1/schema_change/compaction5/test_schema_change_with_compaction5.groovy index 8af620ea6479b4..ddd639b5fd1fc1 100644 --- a/regression-test/suites/cloud_p1/schema_change/compaction5/test_schema_change_with_compaction5.groovy +++ b/regression-test/suites/cloud_p1/schema_change/compaction5/test_schema_change_with_compaction5.groovy @@ -143,7 +143,7 @@ suite('test_schema_change_with_compaction5', 'docker') { // cu compaction for (int i = 0; i < array.size(); i++) { - tabletId = array[i].TabletId + def tabletId = array[i].TabletId logger.info("run compaction:" + tabletId) (code, out, err) = be_run_cumulative_compaction(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Run compaction: code=" + code + ", out=" + out + ", err=" + err) @@ -153,7 +153,7 @@ suite('test_schema_change_with_compaction5', 'docker') { running = true do { Thread.sleep(100) - tabletId = array[i].TabletId + def tabletId = array[i].TabletId (code, out, err) = be_get_compaction_status(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err) assertEquals(code, 0) @@ -172,6 +172,7 @@ suite('test_schema_change_with_compaction5', 'docker') { GetDebugPoint().disableDebugPointForAllBEs(injectName) } int max_try_time = 3000 + def result = null while (max_try_time--){ result = getJobState("date") if (result == "FINISHED" || result == "CANCELLED") { diff --git a/regression-test/suites/cloud_p1/schema_change/compaction6/test_schema_change_with_compaction6.groovy b/regression-test/suites/cloud_p1/schema_change/compaction6/test_schema_change_with_compaction6.groovy index 4321a23f7b7fb3..31a5760c62db46 100644 --- a/regression-test/suites/cloud_p1/schema_change/compaction6/test_schema_change_with_compaction6.groovy +++ b/regression-test/suites/cloud_p1/schema_change/compaction6/test_schema_change_with_compaction6.groovy @@ -148,7 +148,7 @@ suite('test_schema_change_with_compaction6', 'docker') { // cu compaction for (int i = 0; i < array.size(); i++) { - tabletId = array[i].TabletId + def tabletId = array[i].TabletId logger.info("run compaction:" + tabletId) (code, out, err) = be_run_cumulative_compaction(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Run compaction: code=" + code + ", out=" + out + ", err=" + err) @@ -158,7 +158,7 @@ suite('test_schema_change_with_compaction6', 'docker') { running = true do { Thread.sleep(100) - tabletId = array[i].TabletId + def tabletId = array[i].TabletId (code, out, err) = be_get_compaction_status(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err) assertEquals(code, 0) @@ -175,6 +175,7 @@ suite('test_schema_change_with_compaction6', 'docker') { GetDebugPoint().disableDebugPointForAllBEs(injectName) } int max_try_time = 3000 + def result = null while (max_try_time--){ result = getJobState("date") if (result == "FINISHED" || result == "CANCELLED") { diff --git a/regression-test/suites/cloud_p1/schema_change/compaction7/test_schema_change_with_compaction7.groovy b/regression-test/suites/cloud_p1/schema_change/compaction7/test_schema_change_with_compaction7.groovy index df53518d2671cc..44a564a7bc4cf1 100644 --- a/regression-test/suites/cloud_p1/schema_change/compaction7/test_schema_change_with_compaction7.groovy +++ b/regression-test/suites/cloud_p1/schema_change/compaction7/test_schema_change_with_compaction7.groovy @@ -142,7 +142,7 @@ suite('test_schema_change_with_compaction7', 'p1,nonConcurrent') { // cu compaction for (int i = 0; i < array.size(); i++) { - tabletId = array[i].TabletId + def tabletId = array[i].TabletId logger.info("run compaction:" + tabletId) (code, out, err) = be_run_cumulative_compaction(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Run compaction: code=" + code + ", out=" + out + ", err=" + err) @@ -152,7 +152,7 @@ suite('test_schema_change_with_compaction7', 'p1,nonConcurrent') { running = true do { Thread.sleep(100) - tabletId = array[i].TabletId + def tabletId = array[i].TabletId (code, out, err) = be_get_compaction_status(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err) assertEquals(code, 0) @@ -168,6 +168,7 @@ suite('test_schema_change_with_compaction7', 'p1,nonConcurrent') { DebugPoint.disableDebugPoint(injectBe.Host, injectBe.HttpPort.toInteger(), NodeType.BE, injectName) } int max_try_time = 3000 + def result = null while (max_try_time--){ result = getJobState("date") if (result == "FINISHED" || result == "CANCELLED") { diff --git a/regression-test/suites/cloud_p1/schema_change/compaction8/test_schema_change_with_compaction8.groovy b/regression-test/suites/cloud_p1/schema_change/compaction8/test_schema_change_with_compaction8.groovy index 74437afa490f01..3350608fedfd88 100644 --- a/regression-test/suites/cloud_p1/schema_change/compaction8/test_schema_change_with_compaction8.groovy +++ b/regression-test/suites/cloud_p1/schema_change/compaction8/test_schema_change_with_compaction8.groovy @@ -143,6 +143,7 @@ suite('test_schema_change_with_compaction8', 'p1,nonConcurrent') { DebugPoint.disableDebugPoint(injectBe.Host, injectBe.HttpPort.toInteger(), NodeType.BE, injectName) } int max_try_time = 3000 + def result = null while (max_try_time--){ result = getJobState("date") if (result == "FINISHED") { diff --git a/regression-test/suites/cloud_p1/schema_change/compaction9/test_schema_change_with_compaction9.groovy b/regression-test/suites/cloud_p1/schema_change/compaction9/test_schema_change_with_compaction9.groovy index ad33e537d4920b..27f4e857007b02 100644 --- a/regression-test/suites/cloud_p1/schema_change/compaction9/test_schema_change_with_compaction9.groovy +++ b/regression-test/suites/cloud_p1/schema_change/compaction9/test_schema_change_with_compaction9.groovy @@ -144,7 +144,7 @@ suite('test_schema_change_with_compaction9', 'docker') { // cu compaction for (int i = 0; i < array.size(); i++) { - tabletId = array[i].TabletId + def tabletId = array[i].TabletId logger.info("run compaction:" + tabletId) (code, out, err) = be_run_cumulative_compaction(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Run compaction: code=" + code + ", out=" + out + ", err=" + err) @@ -154,7 +154,7 @@ suite('test_schema_change_with_compaction9', 'docker') { running = true do { Thread.sleep(100) - tabletId = array[i].TabletId + def tabletId = array[i].TabletId (code, out, err) = be_get_compaction_status(injectBe.Host, injectBe.HttpPort, tabletId) logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err) assertEquals(code, 0) @@ -174,6 +174,7 @@ suite('test_schema_change_with_compaction9', 'docker') { GetDebugPoint().disableDebugPointForAllBEs(injectName) } int max_try_time = 3000 + def result = null while (max_try_time--){ result = getJobState("date") if (result == "FINISHED" || result == "CANCELLED") {