You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2024/03/19 08:51:54 UTC

(camel) branch milvus-improvements-test-infra created (now e2dc7bd9f2a)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch milvus-improvements-test-infra
in repository https://gitbox.apache.org/repos/asf/camel.git


      at e2dc7bd9f2a Camel-Milvus Test Infra: Improved options

This branch includes the following new commits:

     new e2dc7bd9f2a Camel-Milvus Test Infra: Improved options

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(camel) 01/01: Camel-Milvus Test Infra: Improved options

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch milvus-improvements-test-infra
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e2dc7bd9f2acfc9e452f13f5e775a0a6cd62c398
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 19 09:38:15 2024 +0100

    Camel-Milvus Test Infra: Improved options
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../camel/component/milvus/MilvusTestSupport.java  |  7 ++----
 .../test/infra/milvus/common/MilvusProperties.java |  4 ++++
 .../services/MilvusLocalContainerService.java      | 26 ++++++++++++++++++++++
 .../infra/milvus/services/MilvusRemoteService.java | 10 +++++++++
 .../test/infra/milvus/services/MilvusService.java  |  4 ++++
 .../milvus/services/MilvusServiceFactory.java      | 10 +++++++++
 6 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/components/camel-milvus/src/test/java/org/apache/camel/component/milvus/MilvusTestSupport.java b/components/camel-milvus/src/test/java/org/apache/camel/component/milvus/MilvusTestSupport.java
index c2b59bc8d6a..e6ad879f4e2 100644
--- a/components/camel-milvus/src/test/java/org/apache/camel/component/milvus/MilvusTestSupport.java
+++ b/components/camel-milvus/src/test/java/org/apache/camel/component/milvus/MilvusTestSupport.java
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.component.milvus;
 
-import java.net.URL;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.test.infra.milvus.services.MilvusService;
 import org.apache.camel.test.infra.milvus.services.MilvusServiceFactory;
@@ -34,10 +32,9 @@ public class MilvusTestSupport extends CamelTestSupport {
     protected CamelContext createCamelContext() throws Exception {
         CamelContext context = super.createCamelContext();
 
-        URL url = new URL(MILVUS.getMilvusEndpointUrl());
         MilvusComponent component = context.getComponent(Milvus.SCHEME, MilvusComponent.class);
-        component.getConfiguration().setHost(url.getHost());
-        component.getConfiguration().setPort(url.getPort());
+        component.getConfiguration().setHost(MILVUS.getMilvusHost());
+        component.getConfiguration().setPort(MILVUS.getMilvusPort());
 
         return context;
     }
diff --git a/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/common/MilvusProperties.java b/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/common/MilvusProperties.java
index b4e82b6ea1f..745053d6343 100644
--- a/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/common/MilvusProperties.java
+++ b/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/common/MilvusProperties.java
@@ -19,6 +19,10 @@ package org.apache.camel.test.infra.milvus.common;
 
 public final class MilvusProperties {
     public static final String MILVUS_ENDPOINT_URL = "milvus.endpoint.url";
+
+    public static final String MILVUS_ENDPOINT_HOST = "milvus.endpoint.host";
+
+    public static final String MILVUS_ENDPOINT_PORT = "milvus.endpoint.port";
     public static final String MILVUS_CONTAINER = "milvus.container";
 
     private MilvusProperties() {
diff --git a/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusLocalContainerService.java b/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusLocalContainerService.java
index 3f0a5a087eb..2003351895c 100644
--- a/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusLocalContainerService.java
+++ b/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusLocalContainerService.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.test.infra.milvus.services;
 
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.time.Duration;
 
 import org.apache.camel.test.infra.common.LocalPropertyResolver;
@@ -52,6 +54,8 @@ public class MilvusLocalContainerService implements MilvusService, ContainerServ
     @Override
     public void registerProperties() {
         System.setProperty(MilvusProperties.MILVUS_ENDPOINT_URL, getMilvusEndpointUrl());
+        System.setProperty(MilvusProperties.MILVUS_ENDPOINT_HOST, getMilvusHost());
+        System.setProperty(MilvusProperties.MILVUS_ENDPOINT_PORT, String.valueOf(getMilvusPort()));
     }
 
     @Override
@@ -78,4 +82,26 @@ public class MilvusLocalContainerService implements MilvusService, ContainerServ
     public String getMilvusEndpointUrl() {
         return container.getEndpoint();
     }
+
+    @Override
+    public String getMilvusHost() {
+        URL url = null;
+        try {
+            url = new URL(container.getEndpoint());
+        } catch (MalformedURLException e) {
+            throw new RuntimeException(e);
+        }
+        return url.getHost();
+    }
+
+    @Override
+    public int getMilvusPort() {
+        URL url = null;
+        try {
+            url = new URL(container.getEndpoint());
+        } catch (MalformedURLException e) {
+            throw new RuntimeException(e);
+        }
+        return url.getPort();
+    }
 }
diff --git a/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusRemoteService.java b/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusRemoteService.java
index 34b76ae5558..d9191820ba0 100644
--- a/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusRemoteService.java
+++ b/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusRemoteService.java
@@ -39,4 +39,14 @@ public class MilvusRemoteService implements MilvusService {
     public String getMilvusEndpointUrl() {
         return System.getProperty(MilvusProperties.MILVUS_ENDPOINT_URL);
     }
+
+    @Override
+    public String getMilvusHost() {
+        return System.getProperty(MilvusProperties.MILVUS_ENDPOINT_HOST);
+    }
+
+    @Override
+    public int getMilvusPort() {
+        return Integer.parseInt(System.getProperty(MilvusProperties.MILVUS_ENDPOINT_PORT));
+    }
 }
diff --git a/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusService.java b/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusService.java
index d61d0791f93..4f81f633738 100644
--- a/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusService.java
+++ b/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusService.java
@@ -24,4 +24,8 @@ import org.apache.camel.test.infra.common.services.TestService;
 public interface MilvusService extends TestService {
 
     String getMilvusEndpointUrl();
+
+    String getMilvusHost();
+
+    int getMilvusPort();
 }
diff --git a/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusServiceFactory.java b/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusServiceFactory.java
index 51ca99ad080..c174ea5959a 100644
--- a/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusServiceFactory.java
+++ b/test-infra/camel-test-infra-milvus/src/test/java/org/apache/camel/test/infra/milvus/services/MilvusServiceFactory.java
@@ -34,6 +34,16 @@ public final class MilvusServiceFactory {
         public String getMilvusEndpointUrl() {
             return getService().getMilvusEndpointUrl();
         }
+
+        @Override
+        public String getMilvusHost() {
+            return getService().getMilvusHost();
+        }
+
+        @Override
+        public int getMilvusPort() {
+            return getService().getMilvusPort();
+        }
     }
 
     public static SimpleTestServiceBuilder<MilvusService> builder() {