2
0
Эх сурвалжийг харах

Upgrade dependencies (#434)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 2 жил өмнө
parent
commit
7f277afb3d

+ 6 - 2
.github/mergify.yml

@@ -1,7 +1,9 @@
 pull_request_rules:
   - name: Test passed for code changed
     conditions:
-      - base=master
+      - or:
+        - base=master
+        - base~=2\.\d
       - "status-success=Build and test"
     actions:
       label:
@@ -10,7 +12,9 @@ pull_request_rules:
 
   - name: Remove ci-passed when code check failed
     conditions:
-      - base=master
+      - or:
+        - base=master
+        - base~=2\.\d
       - "check-failure=Build and test"
     actions:
       label:

+ 1 - 1
.github/workflows/java_sdk_ci_test.yaml

@@ -3,7 +3,7 @@ name: Java sdk CI test
 on:
   workflow_dispatch:
   push:
-    branches: [ master ]
+  pull_request:
 
 jobs:
   build:

+ 0 - 2
.github/workflows/maven.yml

@@ -5,9 +5,7 @@ name: Java CI with Maven
 
 on:
   push:
-    branches: [ master ]
   pull_request:
-    branches: [ master ]
 
 jobs:
   build:

+ 2 - 2
docker-compose.yml

@@ -31,7 +31,7 @@ services:
 
   standalone:
     container_name: milvus-javasdk-test-standalone
-    image: milvusdb/milvus:master-20230119-e96af4e5
+    image: milvusdb/milvus:master-20230203-787ce7c1
     command: ["milvus", "run", "standalone"]
     environment:
       ETCD_ENDPOINTS: etcd:2379
@@ -75,7 +75,7 @@ services:
 
   standaloneslave:
     container_name: milvus-javasdk-test-slave-standalone
-    image: milvusdb/milvus:master-20230119-e96af4e5
+    image: milvusdb/milvus:master-20230203-787ce7c1
     command: ["milvus", "run", "standalone"]
     environment:
       ETCD_ENDPOINTS: etcdslave:2379

+ 15 - 4
pom.xml

@@ -64,9 +64,9 @@
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <grpc.version>1.38.0</grpc.version>
-        <protobuf.version>3.12.0</protobuf.version>
-        <protoc.version>3.12.0</protoc.version>
+        <grpc.version>1.47.1</grpc.version>
+        <protobuf.version>3.19.6</protobuf.version>
+        <protoc.version>3.19.6</protoc.version>
         <commons-collections4.version>4.3</commons-collections4.version>
         <maven.compiler.source>1.8</maven.compiler.source>
         <maven.compiler.target>1.8</maven.compiler.target>
@@ -79,7 +79,7 @@
         <junit.version>4.13.1</junit.version>
         <junit.jupiter.version>5.7.0</junit.jupiter.version>
         <lombok.version>1.18.22</lombok.version>
-        <okhttp.version>3.14.9</okhttp.version>
+        <okhttp.version>4.9.2</okhttp.version>
         <plexus.version>3.0.20</plexus.version>
         <maven.source.plugin.version>3.1.0</maven.source.plugin.version>
         <maven.javadoc.plugin.version>3.1.1</maven.javadoc.plugin.version>
@@ -91,6 +91,7 @@
         <junit.platform.version>1.1.0</junit.platform.version>
         <junit.jupiter.engine.version>5.1.0</junit.jupiter.engine.version>
         <jackson.version>2.12.7.1</jackson.version>
+        <gson.version>2.9.0</gson.version>
     </properties>
 
     <dependencyManagement>
@@ -191,6 +192,16 @@
             <artifactId>plexus-utils</artifactId>
             <version>${plexus.version}</version>
         </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>${gson.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jetbrains.kotlin</groupId>
+            <artifactId>kotlin-stdlib</artifactId>
+            <version>1.4.10</version>
+        </dependency>
     </dependencies>
 
     <profiles>

+ 1 - 1
src/main/milvus-proto

@@ -1 +1 @@
-Subproject commit 4ebfc4f769740e30bacd2952f982fc84c6b05af3
+Subproject commit d8cfcb4d86bd0720258351b4b4641778e30cb62e

+ 12 - 6
src/test/java/io/milvus/client/MilvusClientDockerTest.java

@@ -849,7 +849,7 @@ class MilvusClientDockerTest {
     // this case can be executed when the milvus image of version 2.1 is published.
     @Test
     void testCredential() {
-        String collectionName = "aa";
+        String randomCollectionName = generator.generate(10);
         // collection schema
         String field1Name = "long_field";
         String field2Name = "vec_field";
@@ -871,7 +871,7 @@ class MilvusClientDockerTest {
 
         // create collection
         CreateCollectionParam createParam = CreateCollectionParam.newBuilder()
-                .withCollectionName(collectionName)
+                .withCollectionName(randomCollectionName)
                 .withDescription("test")
                 .withFieldTypes(fieldsSchema)
                 .build();
@@ -880,7 +880,7 @@ class MilvusClientDockerTest {
 
         // create index
         CreateIndexParam indexParam = CreateIndexParam.newBuilder()
-                .withCollectionName(collectionName)
+                .withCollectionName(randomCollectionName)
                 .withFieldName(field2Name)
                 .withIndexType(IndexType.IVF_FLAT)
                 .withIndexName("xxx")
@@ -894,16 +894,16 @@ class MilvusClientDockerTest {
         R<RpcStatus> createIndexR = client.createIndex(indexParam);
 
         client.getIndexState(GetIndexStateParam.newBuilder()
-                .withCollectionName(collectionName)
+                .withCollectionName(randomCollectionName)
                 .withIndexName(indexParam.getIndexName())
                 .build());
 
         R<RpcStatus> dropIndexR = client.dropIndex(DropIndexParam.newBuilder()
-                .withCollectionName(collectionName)
+                .withCollectionName(randomCollectionName)
                 .withIndexName(indexParam.getIndexName())
                 .build());
 
-        client.dropCollection(DropCollectionParam.newBuilder().withCollectionName(collectionName).build());
+        client.dropCollection(DropCollectionParam.newBuilder().withCollectionName(randomCollectionName).build());
     }
 
     @Test
@@ -1108,6 +1108,8 @@ class MilvusClientDockerTest {
             System.out.println("The result of No." + i + " target vector(ID = " + queryIds.get(i) + "):");
             System.out.println(scores);
         }
+
+        client.dropCollection(DropCollectionParam.newBuilder().withCollectionName(randomCollectionName).build());
     }
 
     private static void testIndex(String collectionName, String fieldName,
@@ -1189,6 +1191,8 @@ class MilvusClientDockerTest {
                 testIndex(randomCollectionName, field2Name, type, metric, indexTypes.get(type), Boolean.FALSE);
             }
         }
+
+        client.dropCollection(DropCollectionParam.newBuilder().withCollectionName(randomCollectionName).build());
     }
 
     @Test
@@ -1241,5 +1245,7 @@ class MilvusClientDockerTest {
             testIndex(randomCollectionName, field2Name, IndexType.BIN_IVF_FLAT, metric, "{\"nlist\":128}", Boolean.TRUE);
             testIndex(randomCollectionName, field2Name, IndexType.BIN_IVF_FLAT, metric, "{\"nlist\":128}", Boolean.FALSE);
         }
+
+        client.dropCollection(DropCollectionParam.newBuilder().withCollectionName(randomCollectionName).build());
     }
 }

+ 91 - 55
src/test/java/io/milvus/client/MilvusServiceClientTest.java

@@ -68,53 +68,72 @@ class MilvusServiceClientTest {
         return new MilvusServiceClient(connectParam);
     }
 
+    private <T, P> void invokeFunc(Method testFunc, MilvusServiceClient client, T param, int ret, boolean equalRet) {
+        try {
+            R<P> resp = (R<P>) testFunc.invoke(client, param);
+            if (equalRet) {
+                assertEquals(ret, resp.getStatus());
+            } else {
+                assertNotEquals(ret, resp.getStatus());
+            }
+        } catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
+            e.printStackTrace();
+            System.out.println(e.getMessage());
+            fail();
+        }
+    }
+
     @SuppressWarnings("unchecked")
     private <T, P> void testFuncByName(String funcName, T param) {
+        // start mock server
+        MockMilvusServer server = startServer();
+        MilvusServiceClient client = startClient();
         try {
             Class<?> clientClass = MilvusServiceClient.class;
             Method testFunc = clientClass.getMethod(funcName, param.getClass());
 
-            // start mock server
-            MockMilvusServer server = startServer();
-            MilvusServiceClient client = startClient();
-
             // test return ok with correct input
-            R<P> resp = (R<P>) testFunc.invoke(client, param);
-            assertEquals(R.Status.Success.getCode(), resp.getStatus());
+            invokeFunc(testFunc, client, param, R.Status.Success.getCode(), true);
 
             // stop mock server
             server.stop();
 
             // test return error without server
-            resp = (R<P>) testFunc.invoke(client, param);
-            assertNotEquals(R.Status.Success.getCode(), resp.getStatus());
+            invokeFunc(testFunc, client, param, R.Status.Success.getCode(), false);
 
             // test return error when client channel is shutdown
             client.close();
-            resp = (R<P>) testFunc.invoke(client, param);
-            assertEquals(R.Status.ClientNotConnected.getCode(), resp.getStatus());
-        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
-            System.out.println(e.toString());
+            invokeFunc(testFunc, client, param, R.Status.ClientNotConnected.getCode(), true);
+        } catch (NoSuchMethodException | SecurityException e) {
+            e.printStackTrace();
+            System.out.println(e.getMessage());
+            fail();
+        } finally {
+            server.stop();
+            client.close();
         }
     }
 
     @SuppressWarnings("unchecked")
     private <T, P> void testAsyncFuncByName(String funcName, T param) {
+        // start mock server
+        MockMilvusServer server = startServer();
+        MilvusServiceClient client = startClient();
+
         try {
             Class<?> clientClass = MilvusServiceClient.class;
             Method testFunc = clientClass.getMethod(funcName, param.getClass());
 
-            // start mock server
-            MockMilvusServer server = startServer();
-            MilvusServiceClient client = startClient();
-
             // test return ok with correct input
             try {
                 ListenableFuture<R<P>> respFuture = (ListenableFuture<R<P>>) testFunc.invoke(client, param);
                 R<P> response = respFuture.get();
                 assertEquals(R.Status.Success.getCode(), response.getStatus());
-            } catch (InterruptedException | ExecutionException e) {
+            } catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException |
+                    InterruptedException | ExecutionException e) {
                 e.printStackTrace();
+                System.out.println(e.getMessage());
+                fail();
             }
 
             // stop mock server
@@ -133,11 +152,19 @@ class MilvusServiceClientTest {
                 ListenableFuture<R<P>> respFuture = (ListenableFuture<R<P>>) testFunc.invoke(client, param);
                 R<P> response = respFuture.get();
                 assertEquals(R.Status.ClientNotConnected.getCode(), response.getStatus());
-            } catch (InterruptedException | ExecutionException e) {
+            } catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException |
+                    InterruptedException | ExecutionException e) {
                 e.printStackTrace();
+                System.out.println(e.getMessage());
+                fail();
             }
-        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
-            System.out.println(e.toString());
+        } catch (NoSuchMethodException | SecurityException e) {
+            e.printStackTrace();
+            System.out.println(e.getMessage());
+            fail();
+        } finally {
+            server.stop();
+            client.close();
         }
     }
 
@@ -402,46 +429,55 @@ class MilvusServiceClientTest {
         MockMilvusServer server = startServer();
         MilvusServiceClient client = startClient();
 
-        final String collectionName = "collection1";
-        GetCollectionStatisticsParam param = GetCollectionStatisticsParam.newBuilder()
-                .withCollectionName(collectionName)
-                .withFlush(Boolean.TRUE)
-                .build();
-
-        // test return ok with correct input
-        final long segmentID = 2021L;
-        mockServerImpl.setFlushResponse(FlushResponse.newBuilder()
-                .putCollSegIDs(collectionName, LongArray.newBuilder().addData(segmentID).build())
-                .build());
-        mockServerImpl.setGetFlushStateResponse(GetFlushStateResponse.newBuilder()
-                .setFlushed(false)
-                .build());
+        try {
+            final String collectionName = "collection1";
+            GetCollectionStatisticsParam param = GetCollectionStatisticsParam.newBuilder()
+                    .withCollectionName(collectionName)
+                    .withFlush(Boolean.TRUE)
+                    .build();
 
-        new Thread(() -> {
-            try {
-                TimeUnit.SECONDS.sleep(1);
-            } catch (InterruptedException e) {
-                System.out.println(e.toString());
-            }
+            // test return ok with correct input
+            final long segmentID = 2021L;
+            mockServerImpl.setFlushResponse(FlushResponse.newBuilder()
+                    .putCollSegIDs(collectionName, LongArray.newBuilder().addData(segmentID).build())
+                    .build());
             mockServerImpl.setGetFlushStateResponse(GetFlushStateResponse.newBuilder()
-                    .setFlushed(true)
+                    .setFlushed(false)
                     .build());
-        }, "RefreshFlushState").start();
 
-        R<GetCollectionStatisticsResponse> resp = client.getCollectionStatistics(param);
-        assertEquals(R.Status.Success.getCode(), resp.getStatus());
+            new Thread(() -> {
+                try {
+                    TimeUnit.SECONDS.sleep(1);
+                } catch (InterruptedException e) {
+                    System.out.println(e.toString());
+                }
+                mockServerImpl.setGetFlushStateResponse(GetFlushStateResponse.newBuilder()
+                        .setFlushed(true)
+                        .build());
+            }, "RefreshFlushState").start();
 
-        // stop mock server
-        server.stop();
+            R<GetCollectionStatisticsResponse> resp = client.getCollectionStatistics(param);
+            assertEquals(R.Status.Success.getCode(), resp.getStatus());
 
-        // test return error without server
-        resp = client.getCollectionStatistics(param);
-        assertNotEquals(R.Status.Success.getCode(), resp.getStatus());
+            // stop mock server
+            server.stop();
 
-        // test return error when client channel is shutdown
-        client.close();
-        resp = client.getCollectionStatistics(param);
-        assertEquals(R.Status.ClientNotConnected.getCode(), resp.getStatus());
+            // test return error without server
+            resp = client.getCollectionStatistics(param);
+            assertNotEquals(R.Status.Success.getCode(), resp.getStatus());
+
+            // test return error when client channel is shutdown
+            client.close();
+            resp = client.getCollectionStatistics(param);
+            assertEquals(R.Status.ClientNotConnected.getCode(), resp.getStatus());
+        } catch (Exception e) {
+            e.printStackTrace();
+            System.out.println(e.getMessage());
+            fail();
+        } finally {
+            server.stop();
+            client.close();
+        }
     }
 
     @Test
@@ -1929,7 +1965,7 @@ class MilvusServiceClientTest {
         );
 
         // float vector metric type is illegal
-        List<List<Float>> vectors2 = Arrays.asList(vector2);
+        List<List<Float>> vectors2 = Collections.singletonList(vector2);
         assertThrows(ParamException.class, () -> SearchParam.newBuilder()
                 .withCollectionName("collection1")
                 .withPartitionNames(partitions)
@@ -1944,7 +1980,7 @@ class MilvusServiceClientTest {
         );
 
         // binary vector metric type is illegal
-        List<ByteBuffer> binVectors2 = Arrays.asList(buf2);
+        List<ByteBuffer> binVectors2 = Collections.singletonList(buf2);
         assertThrows(ParamException.class, () -> SearchParam.newBuilder()
                 .withCollectionName("collection1")
                 .withPartitionNames(partitions)