Skip to content

Commit b2c8d42

Browse files
gyang94codex
andcommitted
[test] Stabilize cluster health test setup
Wait for leader initialization of all tables created by the merge-engine test before teardown deletes the schemas needed by KV recovery. Retry the initial cluster health assertions against one response until the cluster is GREEN before stopping a tablet server. This allows prior table deletion and leader activation to settle without racing a second health query. Fixes #4722 Co-Authored-By: Codex <noreply@openai.com> AI-Model: gpt-6 AI-Contributed/Feature: 0/0 AI-Contributed/UT: 31/31
1 parent 1831d26 commit b2c8d42

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

‎fluss-client/src/test/java/org/apache/fluss/client/admin/FlussAdminITCase.java‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
import static org.apache.fluss.row.encode.KvValueLayout.PLAIN;
126126
import static org.apache.fluss.testutils.DataTestUtils.row;
127127
import static org.apache.fluss.testutils.InternalRowAssert.assertThatRow;
128+
import static org.apache.fluss.testutils.common.CommonTestUtils.retry;
128129
import static org.apache.fluss.testutils.common.CommonTestUtils.waitUntil;
129130
import static org.assertj.core.api.Assertions.assertThat;
130131
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -2644,6 +2645,22 @@ void testCreateTableWithAggregateEngineAndWalChangelog() throws Exception {
26442645
.build();
26452646
admin.createTable(tablePath6, tableDescriptor6, false).get();
26462647
assertThat(admin.tableExists(tablePath6).get()).isTrue();
2648+
2649+
// Finish leader initialization before teardown deletes the schemas needed by KV recovery.
2650+
for (TablePath tablePath :
2651+
Arrays.asList(
2652+
DEFAULT_TABLE_PATH,
2653+
tablePath2,
2654+
tablePath3,
2655+
tablePath4,
2656+
tablePath5,
2657+
tablePath6)) {
2658+
TableInfo tableInfo = admin.getTableInfo(tablePath).get();
2659+
for (int bucket = 0; bucket < tableInfo.getNumBuckets(); bucket++) {
2660+
FLUSS_CLUSTER_EXTENSION.waitAndGetLeaderReplica(
2661+
new TableBucket(tableInfo.getTableId(), bucket));
2662+
}
2663+
}
26472664
}
26482665

26492666
// ==================== Table Statistics Tests ====================
@@ -2905,10 +2922,16 @@ void testClusterHealthDuringRollingUpgrade() throws Exception {
29052922
waitAllReplicasReady(tableId, 3);
29062923

29072924
// Phase 1: Cluster is healthy — status should be GREEN.
2908-
ClusterHealth health = admin.getClusterHealth().get();
2909-
assertThat(health.getStatus()).isEqualTo(ClusterHealthStatus.GREEN);
2910-
assertThat(health.getNumReplicas()).isEqualTo(health.getInSyncReplicas());
2911-
assertThat(health.getNumLeaderReplicas()).isEqualTo(health.getActiveLeaderReplicas());
2925+
// Wait for previous table deletions and coordinator-side leader activation to settle.
2926+
retry(
2927+
Duration.ofMinutes(1),
2928+
() -> {
2929+
ClusterHealth health = admin.getClusterHealth().get();
2930+
assertThat(health.getStatus()).isEqualTo(ClusterHealthStatus.GREEN);
2931+
assertThat(health.getNumReplicas()).isEqualTo(health.getInSyncReplicas());
2932+
assertThat(health.getNumLeaderReplicas())
2933+
.isEqualTo(health.getActiveLeaderReplicas());
2934+
});
29122935

29132936
// Phase 2: Stop one tablet server (simulate server crash during rolling upgrade).
29142937
int stoppedServerId = 0;

0 commit comments

Comments
 (0)