Skip to content

Commit 2b8d319

Browse files
committed
fixed some tests
1 parent d793e65 commit 2b8d319

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

client-v2/src/test/java/com/clickhouse/client/insert/InsertTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ protected Client.Builder newClient() {
8989
.compressClientRequest(useClientCompression)
9090
.useHttpCompression(useHttpCompression)
9191
.setDefaultDatabase(ClickHouseServerForTest.getDatabase())
92+
.serverSetting(ServerSettings.WAIT_END_OF_QUERY, "1")
9293
.useNewImplementation(System.getProperty("client.tests.useNewImplementation", "true").equals("true"));
9394
}
9495

client-v2/src/test/java/com/clickhouse/client/metadata/MetadataTests.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
import com.clickhouse.client.ClickHouseProtocol;
99
import com.clickhouse.client.ClickHouseRequest;
1010
import com.clickhouse.client.ClickHouseResponse;
11+
import com.clickhouse.client.ClickHouseServerForTest;
1112
import com.clickhouse.client.api.Client;
13+
import com.clickhouse.client.api.enums.Protocol;
14+
import com.clickhouse.client.api.internal.ServerSettings;
1215
import com.clickhouse.client.api.metadata.DefaultColumnToMethodMatchingStrategy;
1316
import com.clickhouse.client.api.metadata.TableSchema;
1417
import com.clickhouse.data.ClickHouseColumn;
@@ -27,22 +30,17 @@ public class MetadataTests extends BaseIntegrationTest {
2730

2831
@BeforeMethod(groups = { "integration" })
2932
public void setUp() {
30-
ClickHouseNode node = getServer(ClickHouseProtocol.HTTP);
31-
client = new Client.Builder()
32-
.addEndpoint(node.getBaseUri() + "default")
33-
.setUsername("default")
34-
.setPassword("")
35-
.build();
33+
client = newClient().build();
3634
}
3735

3836
@Test(groups = { "integration" })
3937
public void testGetTableSchema() {
4038
prepareDataSet("describe_table");
4139

42-
TableSchema schema = client.getTableSchema("describe_table", "default");
40+
TableSchema schema = client.getTableSchema("describe_table", ClickHouseServerForTest.getDatabase());
4341

4442
Assert.assertEquals(schema.getTableName(), "describe_table");
45-
Assert.assertEquals(schema.getDatabaseName(), "default");
43+
Assert.assertEquals(schema.getDatabaseName(), ClickHouseServerForTest.getDatabase());
4644

4745
Assert.assertEquals(schema.getColumns().size(), 2);
4846

@@ -54,10 +52,10 @@ public void testGetTableSchema() {
5452
private void prepareDataSet(String tableName) {
5553

5654
try {
57-
String sql = "CREATE TABLE IF NOT EXISTS default." + tableName + " (param1 UInt32, param2 UInt16) ENGINE = Memory";
55+
String sql = "CREATE TABLE IF NOT EXISTS " + tableName + " (param1 UInt32, param2 UInt16) ENGINE = Memory";
5856
client.execute(sql).get();
5957

60-
sql = "INSERT INTO default." + tableName + " VALUES (1, 2), (3, 4), (5, 6)";
58+
sql = "INSERT INTO " + tableName + " VALUES (1, 2), (3, 4), (5, 6)";
6159
client.execute(sql).get();
6260
} catch (Exception e) {
6361
Assert.fail("Failed to prepare data set", e);
@@ -87,4 +85,16 @@ public Object[][] testMatchingNormalizationData() {
8785

8886
};
8987
}
88+
89+
protected Client.Builder newClient() {
90+
ClickHouseNode node = getServer(ClickHouseProtocol.HTTP);
91+
boolean isSecure = isCloud();
92+
return new Client.Builder()
93+
.addEndpoint(Protocol.HTTP, node.getHost(), node.getPort(), isSecure)
94+
.setUsername("default")
95+
.setPassword(ClickHouseServerForTest.getPassword())
96+
.setDefaultDatabase(ClickHouseServerForTest.getDatabase())
97+
.serverSetting(ServerSettings.WAIT_END_OF_QUERY, "1")
98+
.useNewImplementation(System.getProperty("client.tests.useNewImplementation", "true").equals("true"));
99+
}
90100
}

client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ public QueryTests(boolean useServerCompression, boolean useHttpCompression, bool
114114
@BeforeMethod(groups = {"integration"})
115115
public void setUp() {
116116
ClickHouseNode node = getServer(ClickHouseProtocol.HTTP);
117-
boolean isSecure = isCloud();
118117
client = newClient().build();
119118

120119
delayForProfiler(0);
@@ -1932,6 +1931,7 @@ protected Client.Builder newClient() {
19321931
.useHttpCompression(useHttpCompression)
19331932
.allowBinaryReaderToReuseBuffers(usePreallocatedBuffers)
19341933
.setDefaultDatabase(ClickHouseServerForTest.getDatabase())
1934+
.serverSetting(ServerSettings.WAIT_END_OF_QUERY, "1")
19351935
.useNewImplementation(System.getProperty("client.tests.useNewImplementation", "true").equals("true"));
19361936
}
19371937

jdbc-v2/src/test/java/com/clickhouse/jdbc/JdbcIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public Connection getJdbcConnection(Properties properties) throws SQLException {
4646
}
4747

4848
protected static String getDatabase() {
49-
return ClickHouseServerForTest.isCloud() ? ClickHouseServerForTest.getDatabase() : "default";
49+
return ClickHouseServerForTest.getDatabase();
5050
}
5151

5252
protected boolean runQuery(String query) {

0 commit comments

Comments
 (0)