From 977372d376411867e21dc6800cf342f678f2fd3c Mon Sep 17 00:00:00 2001 From: dmchen Date: Wed, 12 Feb 2025 06:50:37 +0000 Subject: [PATCH] feat/TS-5805-force-assign-leader-fix-cases --- source/libs/parser/inc/sql.y | 2 +- tests/army/cluster/arbitrator_restart.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 796ee76606..341a699288 100755 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -863,7 +863,7 @@ cmd ::= KILL COMPACT NK_INTEGER(A). /************************************************ merge/redistribute/ vgroup ******************************************/ cmd ::= BALANCE VGROUP. { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } -cmd ::= BALANCE VGROUP FORCE. { pCxt->pRootNode = createAssignLeaderStmt(pCxt); } +cmd ::= BALANCE LEADER FORCE. { pCxt->pRootNode = createAssignLeaderStmt(pCxt); } cmd ::= BALANCE VGROUP LEADER on_vgroup_id(A). { pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &A); } cmd ::= BALANCE VGROUP LEADER DATABASE db_name(A). { pCxt->pRootNode = createBalanceVgroupLeaderDBNameStmt(pCxt, &A); } diff --git a/tests/army/cluster/arbitrator_restart.py b/tests/army/cluster/arbitrator_restart.py index 21b7a5b82b..4a80aa1c5a 100644 --- a/tests/army/cluster/arbitrator_restart.py +++ b/tests/army/cluster/arbitrator_restart.py @@ -46,14 +46,17 @@ class TDTestCase(TBase): while count < 100: tdSql.query("show arbgroups;") - if tdSql.getData(0, 4) == 1: + if tdSql.getData(0, 4) == True: break tdLog.info("wait 1 seconds for is sync") time.sleep(1) count += 1 - + if count == 100: + tdLog.exit("arbgroup sync failed") + return + sc.dnodeStop(2) sc.dnodeStop(3) @@ -70,8 +73,11 @@ class TDTestCase(TBase): time.sleep(1) count += 1 - - tdSql.execute("BALANCE VGROUP FORCE;") + if count == 100: + tdLog.exit("wait candidate failed") + return + + tdSql.execute("BALANCE LEADER FORCE;") count = 0 while count < 100: @@ -84,6 +90,9 @@ class TDTestCase(TBase): time.sleep(1) count += 1 + if count == 100: + tdLog.exit("assign leader failed") + return tdSql.execute("INSERT INTO d0 VALUES (NOW, 10.3, 219, 0.31);") @@ -101,6 +110,9 @@ class TDTestCase(TBase): time.sleep(1) count += 1 + if count == 100: + tdLog.exit("arbgroup sync failed") + return def stop(self): tdSql.close()