fix(iotdb): recognize JDBC rpc_compress option
This commit is contained in:
1 parent
997d217cb2
commit
9962796a04
3 files changed
+54
-2
No files matched your search
@@ -35,7 +35,9 @@ The following URL parameters are supported:
|
|||||||
- `time_zone`
|
- `time_zone`
|
||||||
- `connect_retry_max`
|
- `connect_retry_max`
|
||||||
- `connect_timeout_ms`
|
- `connect_timeout_ms`
|
||||||
- `enable_compression=true`
|
- `enable_compression=true` (also accepts `rpc_compression` and the IoTDB JDBC
|
||||||
|
alias `rpc_compress`; when conflicting aliases are present, they take
|
||||||
|
precedence in that order)
|
||||||
- `node_urls=host1:6667,host2:6667` for cluster sessions
|
- `node_urls=host1:6667,host2:6667` for cluster sessions
|
||||||
- `ssl=true` and `insecure_skip_verify=true`
|
- `ssl=true` and `insecure_skip_verify=true`
|
||||||
|
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ func parseConnectionConfig(params connectParams) (connectionConfig, error) {
|
|||||||
}
|
}
|
||||||
config.ConnectTimeoutMS = parsed
|
config.ConnectTimeoutMS = parsed
|
||||||
}
|
}
|
||||||
config.EnableCompression = queryBool(query, "enable_compression", "rpc_compression")
|
config.EnableCompression = queryBool(query, "enable_compression", "rpc_compression", "rpc_compress")
|
||||||
config.NodeURLs = parseNodeURLs(firstQueryValue(query, "node_urls", "nodes"))
|
config.NodeURLs = parseNodeURLs(firstQueryValue(query, "node_urls", "nodes"))
|
||||||
if len(config.NodeURLs) == 0 {
|
if len(config.NodeURLs) == 0 {
|
||||||
config.NodeURLs = []string{net.JoinHostPort(config.Host, strconv.Itoa(config.Port))}
|
config.NodeURLs = []string{net.JoinHostPort(config.Host, strconv.Itoa(config.Port))}
|
||||||
|
|||||||
@@ -70,6 +70,56 @@ func TestParseConnectionConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseConnectionConfigCompressionAliases(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
connectionString string
|
||||||
|
urlParams string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{name: "default disabled"},
|
||||||
|
{name: "documented enabled", urlParams: "enable_compression=true", want: true},
|
||||||
|
{name: "documented disabled", urlParams: "enable_compression=false"},
|
||||||
|
{name: "existing alias enabled", urlParams: "rpc_compression=true", want: true},
|
||||||
|
{name: "existing alias disabled", urlParams: "rpc_compression=false"},
|
||||||
|
{name: "JDBC alias enabled in URL parameters", urlParams: "rpc_compress=true", want: true},
|
||||||
|
{name: "JDBC alias false", urlParams: "rpc_compress=false"},
|
||||||
|
{
|
||||||
|
name: "JDBC alias enabled in connection string",
|
||||||
|
connectionString: "jdbc:iotdb://localhost:6667/?rpc_compress=true",
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "URL parameters override same connection string key",
|
||||||
|
connectionString: "jdbc:iotdb://localhost:6667/?rpc_compress=true",
|
||||||
|
urlParams: "rpc_compress=false",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "documented option takes precedence",
|
||||||
|
urlParams: "enable_compression=false&rpc_compression=true&rpc_compress=true",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "existing alias takes precedence over JDBC alias",
|
||||||
|
urlParams: "rpc_compression=false&rpc_compress=true",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
config, err := parseConnectionConfig(connectParams{
|
||||||
|
ConnectionString: test.connectionString,
|
||||||
|
URLParams: test.urlParams,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if config.EnableCompression != test.want {
|
||||||
|
t.Fatalf("EnableCompression = %t, want %t", config.EnableCompression, test.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestBundledTimeZoneDatabase(t *testing.T) {
|
func TestBundledTimeZoneDatabase(t *testing.T) {
|
||||||
dataSet, err := client.NewIoTDBRpcDataSet(
|
dataSet, err := client.NewIoTDBRpcDataSet(
|
||||||
"", nil, nil, nil, true, false, 0, 0, nil, 0, nil, 0, nil,
|
"", nil, nil, nil, true, false, 0, 0, nil, 0, nil, 0, nil,
|
||||||
|
|||||||
Reference in new issue
Block a user