Skip to content

Commit 7af3f05

Browse files
committed
ci: test cluster with nginx.
1 parent cb7e94c commit 7af3f05

4 files changed

Lines changed: 38 additions & 76 deletions

File tree

databend-jdbc/src/main/java/com/databend/jdbc/DatabendConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ int streamingLoad(String sql, InputStream inputStream, long fileSize) throws SQL
11111111
String str = new String(bytes, StandardCharsets.UTF_8);
11121112
try {
11131113
session = SESSION_JSON_CODEC.fromJson(str);
1114-
} catch(JsonProcessingException e) {
1114+
} catch(Exception e) {
11151115
throw new RuntimeException(e);
11161116
}
11171117
if (session != null) {

databend-jdbc/src/test/java/com/databend/jdbc/TestMultiHost.java

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
import java.util.List;
1515

1616
public class TestMultiHost {
17-
private final String DEFAULT_JDBC_URL = "jdbc:databend://localhost:8000,localhost:8002,localhost:8003/default";
18-
private final String RANDOM_JDBC_URL = "jdbc:databend://localhost:8000,localhost:8002,localhost:8003/default?load_balancing_policy=random";
19-
private final String ROUND_ROBIN_JDBC_URL = "jdbc:databend://localhost:8000,localhost:8002,localhost:8003/default?load_balancing_policy=round_robin";
20-
private final String FAIL_OVER_JDBC_URL = "jdbc:databend://localhost:7222,localhost:7223,localhost:7224,localhost:8000/default?load_balancing_policy=round_robin&max_failover_retry=4";
21-
private final String AUTO_DISCOVERY_JDBC_URL = "jdbc:databend://localhost:8000/default?load_balancing_policy=round_robin&auto_discovery=true";
22-
private final String UNSUPPORT_AUTO_DISCOVERY_JDBC_URL = "jdbc:databend://localhost:8000/default?load_balancing_policy=round_robin&auto_discovery=true&enable_mock=true";
17+
private final String DEFAULT_JDBC_URL = "jdbc:databend://localhost:8001,localhost:8002,localhost:8003/default";
18+
private final String RANDOM_JDBC_URL = "jdbc:databend://localhost:8001,localhost:8002,localhost:8003/default?load_balancing_policy=random";
19+
private final String ROUND_ROBIN_JDBC_URL = "jdbc:databend://localhost:8001,localhost:8002,localhost:8003/default?load_balancing_policy=round_robin";
20+
private final String FAIL_OVER_JDBC_URL = "jdbc:databend://localhost:7222,localhost:7223,localhost:7224,localhost:8001/default?load_balancing_policy=round_robin&max_failover_retry=4";
21+
private final String AUTO_DISCOVERY_JDBC_URL = "jdbc:databend://localhost:8001/default?load_balancing_policy=round_robin&auto_discovery=true";
22+
private final String UNSUPPORT_AUTO_DISCOVERY_JDBC_URL = "jdbc:databend://localhost:8001/default?load_balancing_policy=round_robin&auto_discovery=true&enable_mock=true";
2323

2424

2525
private Connection createConnection(String url)
@@ -31,7 +31,7 @@ private Connection createConnection(String url)
3131
public void testDefaultLoadBalancing()
3232
throws SQLException {
3333
// try to connect with three nodes 1000 times and count for each node
34-
int node8000 = 0;
34+
int node8001 = 0;
3535
int node8002 = 0;
3636
int node8003 = 0;
3737
int unknown = 0;
@@ -41,8 +41,9 @@ public void testDefaultLoadBalancing()
4141
statement.execute("select value from system.configs where name = 'http_handler_port';");
4242
ResultSet r = statement.getResultSet();
4343
r.next();
44-
if (r.getInt(1) == 8000) {
45-
node8000++;
44+
45+
if (r.getInt(1) == 8001) {
46+
node8001++;
4647
} else if (r.getInt(1) == 8002) {
4748
node8002++;
4849
} else if (r.getInt(1) == 8003) {
@@ -52,7 +53,7 @@ public void testDefaultLoadBalancing()
5253
}
5354
}
5455
}
55-
Assert.assertEquals(node8000, 100);
56+
Assert.assertEquals(node8001, 100);
5657
Assert.assertEquals(node8002, 0);
5758
Assert.assertEquals(node8003, 0);
5859
Assert.assertEquals(unknown, 0);
@@ -62,7 +63,7 @@ public void testDefaultLoadBalancing()
6263
public void testRandomLoadBalancing()
6364
throws SQLException {
6465
// try to connect with three nodes 1000 times and count for each node
65-
int node8000 = 0;
66+
int node8001 = 0;
6667
int node8002 = 0;
6768
int node8003 = 0;
6869
int unknown = 0;
@@ -72,8 +73,8 @@ public void testRandomLoadBalancing()
7273
statement.execute("select value from system.configs where name = 'http_handler_port';");
7374
ResultSet r = statement.getResultSet();
7475
r.next();
75-
if (r.getInt(1) == 8000) {
76-
node8000++;
76+
if (r.getInt(1) == 8001) {
77+
node8001++;
7778
} else if (r.getInt(1) == 8002) {
7879
node8002++;
7980
} else if (r.getInt(1) == 8003) {
@@ -83,16 +84,16 @@ public void testRandomLoadBalancing()
8384
}
8485
}
8586
}
86-
Assert.assertTrue(node8000 > 0 && node8002 > 0 && node8003 > 0);
87+
Assert.assertTrue(node8001 > 0 && node8002 > 0 && node8003 > 0);
8788
Assert.assertEquals(unknown, 0);
88-
Assert.assertEquals(node8000 + node8002 + node8003, 100);
89+
Assert.assertEquals(node8001 + node8002 + node8003, 100);
8990
}
9091

9192
@Test(groups = {"IT", "MULTI_HOST"})
9293
public void testRoundRobinLoadBalancing()
9394
throws SQLException {
9495
// try to connect with three nodes 1000 times and count for each node
95-
int node8000 = 0;
96+
int node8001 = 0;
9697
int node8002 = 0;
9798
int node8003 = 0;
9899
int unknown = 0;
@@ -104,8 +105,8 @@ public void testRoundRobinLoadBalancing()
104105
statement.execute("select value from system.configs where name = 'http_handler_port';");
105106
ResultSet r = statement.getResultSet();
106107
r.next();
107-
if (r.getInt(1) == 8000) {
108-
node8000++;
108+
if (r.getInt(1) == 8001) {
109+
node8001++;
109110
} else if (r.getInt(1) == 8002) {
110111
node8002++;
111112
} else if (r.getInt(1) == 8003) {
@@ -116,11 +117,11 @@ public void testRoundRobinLoadBalancing()
116117
}
117118
}
118119
}
119-
Assert.assertEquals(node8000, 30);
120+
Assert.assertEquals(node8001, 30);
120121
Assert.assertEquals(node8002, 30);
121122
Assert.assertEquals(node8003, 30);
122123
Assert.assertEquals(unknown, 0);
123-
Assert.assertEquals(node8000 + node8002 + node8003, 90);
124+
Assert.assertEquals(node8001 + node8002 + node8003, 90);
124125
}
125126

126127
@Test(groups = {"IT", "MULTI_HOST"})
@@ -161,7 +162,7 @@ public void testRoundRobinTransaction()
161162
public void testFailOver()
162163
throws SQLException {
163164
// try connect with three nodes 1000 times and count for each node
164-
int node8000 = 0;
165+
int node8001 = 0;
165166
int node8002 = 0;
166167
int node8003 = 0;
167168
int unknown = 0;
@@ -173,8 +174,8 @@ public void testFailOver()
173174
statement.execute("select value from system.configs where name = 'http_handler_port';");
174175
ResultSet r = statement.getResultSet();
175176
r.next();
176-
if (r.getInt(1) == 8000) {
177-
node8000++;
177+
if (r.getInt(1) == 8001) {
178+
node8001++;
178179
} else if (r.getInt(1) == 8002) {
179180
node8002++;
180181
} else if (r.getInt(1) == 8003) {
@@ -186,16 +187,16 @@ public void testFailOver()
186187
}
187188
}
188189

189-
Assert.assertEquals(node8000, 90);
190+
Assert.assertEquals(node8001, 90);
190191
Assert.assertEquals(unknown, 0);
191-
Assert.assertEquals(node8000 + node8002 + node8003, 90);
192+
Assert.assertEquals(node8001 + node8002 + node8003, 90);
192193
}
193194

194195
@Test(groups = {"IT", "MULTI_HOST"})
195196
public void testAutoDiscovery()
196197
throws SQLException {
197198
// try connect with three nodes 1000 times and count for each node
198-
int node8000 = 0;
199+
int node8001 = 0;
199200
int node8002 = 0;
200201
int node8003 = 0;
201202
int unknown = 0;
@@ -207,8 +208,8 @@ public void testAutoDiscovery()
207208
statement.execute("select value from system.configs where name = 'http_handler_port';");
208209
ResultSet r = statement.getResultSet();
209210
r.next();
210-
if (r.getInt(1) == 8000) {
211-
node8000++;
211+
if (r.getInt(1) == 8001) {
212+
node8001++;
212213
} else if (r.getInt(1) == 8002) {
213214
node8002++;
214215
} else if (r.getInt(1) == 8003) {
@@ -220,11 +221,11 @@ public void testAutoDiscovery()
220221
}
221222
}
222223

223-
Assert.assertEquals(node8000, 31);
224+
Assert.assertEquals(node8001, 31);
224225
Assert.assertEquals(node8002, 30);
225226
Assert.assertEquals(node8003, 29);
226227
Assert.assertEquals(unknown, 0);
227-
Assert.assertEquals(node8000 + node8002 + node8003, 90);
228+
Assert.assertEquals(node8001 + node8002 + node8003, 90);
228229
}
229230

230231
@Test(groups = {"IT", "MULTI_HOST"})
@@ -247,13 +248,13 @@ public void testUnSupportedAutoDiscovery()
247248

248249
@Test(groups = {"UNIT"})
249250
public void testAutoDiscoveryUriParsing() throws SQLException {
250-
DatabendDriverUri uri = DatabendDriverUri.create("jdbc:databend://localhost:8000?ssl=true", null);
251-
DatabendDriverUri uri2 = DatabendDriverUri.create("jdbc:databend://127.0.0.1:8000,127.0.0.1:8002,127.0.0.1:8003?ssl=true", null);
251+
DatabendDriverUri uri = DatabendDriverUri.create("jdbc:databend://localhost:8001?ssl=true", null);
252+
DatabendDriverUri uri2 = DatabendDriverUri.create("jdbc:databend://127.0.0.1:8001,127.0.0.1:8002,127.0.0.1:8003?ssl=true", null);
252253
List<URI> uris2 = uri2.getNodes().getUris();
253254

254255
DatabendNodes nodes = uri.getNodes();
255256
List<DiscoveryNode> discoveryNodes = new ArrayList<>();
256-
discoveryNodes.add(DiscoveryNode.create("127.0.0.1:8000"));
257+
discoveryNodes.add(DiscoveryNode.create("127.0.0.1:8001"));
257258
discoveryNodes.add(DiscoveryNode.create("127.0.0.1:8002"));
258259
discoveryNodes.add(DiscoveryNode.create("127.0.0.1:8003"));
259260
List<URI> uris = nodes.parseURI(discoveryNodes);

scripts/ci/nginx_rr.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ events {
44

55
http {
66
upstream backend {
7-
server 127.0.0.1:8000;
7+
server 127.0.0.1:8001;
88
server 127.0.0.1:8002;
99
server 127.0.0.1:8003;
1010
}
1111

1212
server {
13-
listen 8010;
13+
listen 8000;
1414

1515
location / {
1616
proxy_pass http://backend;

scripts/deploy/config/databend-query-node-1.toml

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ clickhouse_http_handler_port = 8124
2525

2626
# Databend Query HTTP Handler.
2727
http_handler_host = "0.0.0.0"
28-
http_handler_port = 8000
28+
http_handler_port = 8001
2929

3030
# Databend Query FlightSQL Handler.
3131
flight_sql_handler_host = "0.0.0.0"
@@ -50,22 +50,12 @@ auth_type = "no_password"
5050
name = "default"
5151
auth_type = "no_password"
5252

53-
# [[query.users]]
54-
# name = "admin"
55-
# auth_type = "no_password"
56-
5753
[[query.users]]
5854
name = "databend"
5955
auth_type = "double_sha1_password"
6056
# echo -n "databend" | sha1sum | cut -d' ' -f1 | xxd -r -p | sha1sum
6157
auth_string = "3081f32caef285c232d066033c89a78d88a6d8a5"
6258

63-
# [[query.users]]
64-
# name = "datafuselabs"
65-
# auth_type = "sha256_password"
66-
# # echo -n "datafuselabs" | sha256sum
67-
# auth_string = "6db1a2f5da402b43c066fcadcbf78f04260b3236d9035e44dd463f21e29e6f3b"
68-
6959
# This for test
7060
[[query.udfs]]
7161
name = "ping"
@@ -107,35 +97,6 @@ type = "fs"
10797
[storage.fs]
10898
data_path = "./.databend/stateless_test_data"
10999

110-
# To use S3-compatible object storage, uncomment this block and set your values.
111-
# [storage.s3]
112-
# bucket = "<your-bucket-name>"
113-
# endpoint_url = "<your-endpoint>"
114-
# access_key_id = "<your-key-id>"
115-
# secret_access_key = "<your-account-key>"
116-
# enable_virtual_host_style = false
117-
118-
# To use Azure Blob storage, uncomment this block and set your values.
119-
# [storage.azblob]
120-
# endpoint_url = "https://<your-storage-account-name>.blob.core.windows.net"
121-
# container = "<your-azure-storage-container-name>"
122-
# account_name = "<your-storage-account-name>"
123-
# account_key = "<your-account-key>"
124-
125-
# To use OBS object storage, uncomment this block and set your values.
126-
# [storage.obs]
127-
# bucket = "<your-bucket-name>"
128-
# endpoint_url = "<your-endpoint>"
129-
# access_key_id = "<your-key-id>"
130-
# secret_access_key = "<your-account-key>"
131-
132-
# To use OSS object storage, uncomment this block and set your values.
133-
# [storage.oss]
134-
# bucket = "<your-bucket-name>"
135-
# endpoint_url = "<your-endpoint>"
136-
# access_key_id = "<your-key-id>"
137-
# access_key_secret = "<your-account-key>"
138-
139100
# Cache config.
140101
[cache]
141102
# Type of storage to keep the table data cache

0 commit comments

Comments
 (0)