Browse Source

Open the docker testing (#261)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 3 years ago
parent
commit
ff139fa211
3 changed files with 21 additions and 7 deletions
  1. 1 0
      .gitignore
  2. 12 6
      docker-compose.yml
  3. 8 1
      src/test/java/io/milvus/client/MilvusClientDockerTest.java

+ 1 - 0
.gitignore

@@ -24,5 +24,6 @@ hs_err_pid*
 
 .idea/
 target/
+volumes/
 *.iml
 

+ 12 - 6
docker-compose.yml

@@ -2,15 +2,21 @@ version: '3.5'
 
 services:
   etcd:
-    container_name: milvus-test-etcd
+    container_name: milvus-javasdk-test-etcd
     image: quay.io/coreos/etcd:v3.5.0
     volumes:
       - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd
-    command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
+    command: etcd -listen-peer-urls=http://127.0.0.1:2380 -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 -initial-advertise-peer-urls=http://127.0.0.1:2380 --initial-cluster default=http://127.0.0.1:2380 --data-dir /etcd
+    ports:
+      - "2379:2379"
+      - "2380:2380"
+      - "4001:4001"
 
   minio:
-    container_name: milvus-test-minio
+    container_name: milvus-javasdk-test-minio
     image: minio/minio:RELEASE.2020-12-03T00-03-10Z
+    ports:
+      - "9000:9000"
     environment:
       MINIO_ACCESS_KEY: minioadmin
       MINIO_SECRET_KEY: minioadmin
@@ -18,14 +24,14 @@ services:
       - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_data
     command: minio server /minio_data
     healthcheck:
-      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
+      test: [ "CMD", "curl", "-f", "http://localhost:9000/minio/health/live" ]
       interval: 30s
       timeout: 20s
       retries: 3
 
   standalone:
-    container_name: milvus-test-standalone
-    image: milvusdb/milvus:v2.0.0-rc7-20211011-d567b21
+    container_name: milvus-javasdk-test-standalone
+    image: milvusdb/milvus:v2.0.0
     command: ["milvus", "run", "standalone"]
     environment:
       ETCD_ENDPOINTS: etcd:2379

+ 8 - 1
src/test/java/io/milvus/client/MilvusClientDockerTest.java

@@ -55,7 +55,7 @@ public class MilvusClientDockerTest {
     private static MilvusClient client;
     private static RandomStringGenerator generator;
     private static final int dimension = 128;
-    private static final Boolean useDockerCompose = Boolean.FALSE;
+    private static final Boolean useDockerCompose = Boolean.TRUE;
 
     private static void startDockerContainer() {
         if (!useDockerCompose) {
@@ -73,6 +73,11 @@ public class MilvusClientDockerTest {
             if (status != 0) {
                 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");
         } catch (Throwable t) {
             logger.error("Failed to execute docker compose up", t);
         }
@@ -88,6 +93,8 @@ public class MilvusClientDockerTest {
         String bashCommand = "docker-compose down";
 
         try {
+            logger.debug("Milvus service stopping...");
+            TimeUnit.SECONDS.sleep(5);
             logger.debug(bashCommand);
             Process pro = runtime.exec(bashCommand);
             int status = pro.waitFor();