Browse Source

Using milvus 2.2.12 for test (#573)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 1 year ago
parent
commit
e8b86a67a7

+ 2 - 2
docker-compose.yml

@@ -31,7 +31,7 @@ services:
 
 
   standalone:
   standalone:
     container_name: milvus-javasdk-test-standalone
     container_name: milvus-javasdk-test-standalone
-    image: milvusdb/milvus:v2.2.11
+    image: milvusdb/milvus:v2.2.12
     command: ["milvus", "run", "standalone"]
     command: ["milvus", "run", "standalone"]
     environment:
     environment:
       ETCD_ENDPOINTS: etcd:2379
       ETCD_ENDPOINTS: etcd:2379
@@ -75,7 +75,7 @@ services:
 
 
   standaloneslave:
   standaloneslave:
     container_name: milvus-javasdk-test-slave-standalone
     container_name: milvus-javasdk-test-slave-standalone
-    image: milvusdb/milvus:v2.2.11
+    image: milvusdb/milvus:v2.2.12
     command: ["milvus", "run", "standalone"]
     command: ["milvus", "run", "standalone"]
     environment:
     environment:
       ETCD_ENDPOINTS: etcdslave:2379
       ETCD_ENDPOINTS: etcdslave:2379

+ 41 - 3
src/test/java/io/milvus/client/MilvusMultiClientDockerTest.java

@@ -72,13 +72,43 @@ class MilvusMultiClientDockerTest {
                 logger.error("Failed to start docker compose, status " + status);
                 logger.error("Failed to start docker compose, status " + status);
             }
             }
 
 
-            // here stop 10 seconds, reason: although milvus container is alive, it is still in initializing,
-            // connection will failed and get error "proxy not health".
-            TimeUnit.SECONDS.sleep(10);
             logger.debug("Milvus service started");
             logger.debug("Milvus service started");
         } catch (Throwable t) {
         } catch (Throwable t) {
             logger.error("Failed to execute docker compose up", t);
             logger.error("Failed to execute docker compose up", t);
         }
         }
+
+        ConnectParam connectParam = connectParamBuilder().withAuthorization("root", "Milvus").build();
+        MilvusServiceClient tempClient = new MilvusServiceClient(connectParam);
+        long waitTime = 0;
+        while (true) {
+            // although milvus container is alive, it is still in initializing,
+            // connection will failed and get error "proxy not health".
+            // check health state for every few seconds, until the server is ready.
+            long checkInterval = 3;
+            try {
+                TimeUnit.SECONDS.sleep(checkInterval);
+            } catch (InterruptedException t) {
+                logger.error("Interrupted", t);
+                break;
+            }
+
+            try{
+                R<CheckHealthResponse> resp = tempClient.checkHealth();
+                if (resp.getData().getIsHealthy()) {
+                    logger.info(String.format("Milvus service is ready after %d seconds", waitTime));
+                    break;
+                }
+                logger.info("Milvus service is not ready, waiting...");
+            } catch (Throwable t) {
+                logger.error("Milvus service is in initialize, not able to connect", t);
+            }
+
+            waitTime += checkInterval;
+            if (waitTime > 120) {
+                logger.error(String.format("Milvus service failed to start within %d seconds", waitTime));
+                break;
+            }
+        }
     }
     }
 
 
     private static void stopDockerContainer() {
     private static void stopDockerContainer() {
@@ -143,6 +173,14 @@ class MilvusMultiClientDockerTest {
         stopDockerContainer();
         stopDockerContainer();
     }
     }
 
 
+    protected static ConnectParam.Builder connectParamBuilder() {
+        return connectParamBuilder("localhost", 19530);
+    }
+
+    private static ConnectParam.Builder connectParamBuilder(String host, int port) {
+        return ConnectParam.newBuilder().withHost(host).withPort(port);
+    }
+
     private static MultiConnectParam.Builder multiConnectParamBuilder() {
     private static MultiConnectParam.Builder multiConnectParamBuilder() {
         ServerAddress serverAddress = ServerAddress.newBuilder().withHost("localhost").withPort(19530).build();
         ServerAddress serverAddress = ServerAddress.newBuilder().withHost("localhost").withPort(19530).build();
         ServerAddress serverSlaveAddress = ServerAddress.newBuilder().withHost("localhost").withPort(19531).withHealthPort(9092).build();
         ServerAddress serverSlaveAddress = ServerAddress.newBuilder().withHost("localhost").withPort(19531).withHealthPort(9092).build();