gnodet-bot commented on code in PR #31030:
URL: https://github.com/apache/camel/pull/31030#discussion_r4721454875
##########
components/camel-ai/camel-milvus/src/main/java/org/apache/camel/component/milvus/MilvusEndpoint.java:
##########
@@ -185,14 +186,55 @@ public void doStop() throws Exception {
}
private MilvusClient createClient() {
+ return new MilvusServiceClient(createConnectParam());
+ }
+ ConnectParam createConnectParam() {
ConnectParam.Builder parameters =
ConnectParam.newBuilder().withHost(configuration.getHost())
.withPort(configuration.getPort()).withConnectTimeout(configuration.getTimeout(),
TimeUnit.MILLISECONDS);
if (configuration.getToken() != null) {
parameters.withToken(configuration.getToken());
}
- return new MilvusServiceClient(parameters.build());
+ parameters.withSecure(configuration.isSecure());
Review Comment:
💡 **Note:** `withSecure()` is deprecated in the Milvus SDK since v2.3.6 (TLS
is now auto-detected from cert paths and from `https` URIs in
`ConnectParam.verify()`). It still works in 2.6.x, so there is no urgency, but
when upgrading to Milvus SDK v3+ this call can be dropped — the cert path
settings already imply `secure=true` via `verify()`.
##########
components/camel-ai/camel-milvus/src/test/java/org/apache/camel/component/milvus/MilvusConnectParamTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.milvus;
+
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import io.milvus.client.MilvusServiceClient;
+import io.milvus.param.ConnectParam;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * The TLS options of the endpoint reach the ConnectParam of the Milvus SDK.
No Milvus server is needed.
+ */
+public class MilvusConnectParamTest extends CamelTestSupport {
+
+ @Test
+ public void plaintextByDefault() {
+ ConnectParam param =
connectParam("milvus:test?host=milvus.example.com&port=19531&token=user:secret");
+
+ assertThat(param.getHost()).isEqualTo("milvus.example.com");
+ assertThat(param.getPort()).isEqualTo(19531);
+ assertThat(param.isSecure()).isFalse();
+ assertThat(param.getServerPemPath()).isNull();
+ assertThat(param.getServerName()).isNull();
+ assertThat(param.getCaPemPath()).isNull();
+ assertThat(param.getClientPemPath()).isNull();
+ assertThat(param.getClientKeyPath()).isNull();
+ }
+
+ @Test
+ public void secure() {
+ ConnectParam param =
connectParam("milvus:test?host=milvus.example.com&secure=true");
+
+ assertThat(param.isSecure()).isTrue();
+ assertThat(param.getServerPemPath()).isNull();
+ assertThat(param.getCaPemPath()).isNull();
+ }
+
+ @Test
+ public void serverPemPath() {
Review Comment:
💡 **Suggestion:** The docs say *"The file options connect with TLS also when
`secure` is not set"*, but all cert-path tests pass `secure=true` explicitly.
Consider adding a test variant without `secure=true` to validate the documented
implicit TLS behaviour, e.g.:
```suggestion
public void serverPemPath() {
ConnectParam param =
connectParam("milvus:test?host=milvus.example.com&serverPemPath=/certs/server.pem");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]