Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.apache.flink.types.Row;
import org.apache.flink.util.CloseableIterator;

import com.alibaba.fluss.client.Connection;
import com.alibaba.fluss.client.ConnectionFactory;
import com.alibaba.fluss.server.testutils.FlussClusterExtension;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -74,7 +76,9 @@ public class FlussSinkITCase extends AbstractTestBase {
protected TableEnvironment tBatchEnv;

@BeforeEach
void before() {
void before() throws Exception {
waitForFlussClusterReady();

// open a catalog so that we can get table from the catalog
String bootstrapServers = FLUSS_CLUSTER_EXTENSION.getBootstrapServers();

Expand All @@ -94,6 +98,27 @@ void before() {
tBatchEnv.useDatabase(DEFAULT_DB);
}

private void waitForFlussClusterReady() throws Exception {
int maxRetries = 30;
int retryIntervalMs = 1000;
Exception lastException = null;

for (int i = 0; i < maxRetries; i++) {
try (Connection connection =
ConnectionFactory.createConnection(FLUSS_CLUSTER_EXTENSION.getClientConfig())) {
// Connection successful, cluster is ready
return;
} catch (Exception e) {
lastException = e;
Thread.sleep(retryIntervalMs);
}
}

throw new IllegalStateException(
"Failed to connect to Fluss cluster after " + maxRetries + " attempts",
lastException);
}

@AfterEach
void after() {
tBatchEnv.useDatabase(BUILTIN_DATABASE);
Expand Down
Loading