Skip to content

Commit 3226918

Browse files
committed
Change ping logic & create database on init
1 parent 63e9da7 commit 3226918

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

flink-connector-clickhouse-base/src/test/java/org/apache/flink/connector/test/FlinkClusterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public class FlinkClusterTests {
99
@BeforeAll
10-
static void setup() throws Exception {
10+
static void setUp() throws Exception {
1111
EmbeddedFlinkClusterForTests.setUp();
1212
ClickHouseServerForTests.setUp();
1313
}

flink-connector-clickhouse-base/src/test/java/org/apache/flink/connector/test/embedded/clickhouse/ClickHouseServerForTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static void initConfiguration() {
4646
}
4747
isSSL = ClickHouseTestHelpers.isCloud();
4848
}
49-
public static void setUp() throws InterruptedException {
49+
public static void setUp() throws InterruptedException, ExecutionException {
5050
if (!isCloud) {
5151
db = new ClickHouseContainer(ClickHouseTestHelpers.CLICKHOUSE_DOCKER_IMAGE).withPassword("test_password").withEnv("CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT", "1");
5252
db.start();
@@ -58,7 +58,11 @@ public static void setUp() throws InterruptedException {
5858
int counter = 0;
5959
while (counter < 5) {
6060
isLive = ClickHouseTestHelpers.ping(isCloud, host, port, isSSL, username, password);
61-
if (isLive) return;
61+
if (isLive) {
62+
String createDatabase = String.format("CREATE DATABASE IF NOT EXISTS `%s`", database);
63+
executeSql(createDatabase);
64+
return;
65+
}
6266
Thread.sleep(2000);
6367
counter++;
6468
}

0 commit comments

Comments
 (0)