Quellcode durchsuchen

modify testcases (#723)

Signed-off-by: yongpengli-z <yongpeng.li@zilliz.com>
yongpengli-z vor 1 Jahr
Ursprung
Commit
674dad8f50

+ 3 - 3
tests/milvustest/pom.xml

@@ -84,13 +84,13 @@
         <dependency>
             <groupId>io.milvus</groupId>
             <artifactId>milvus-sdk-java</artifactId>
-            <version>2.2.6</version>
+            <version>2.2.15</version>
         </dependency>
-        <dependency>
+<!--        <dependency>
             <groupId>com.google.protobuf</groupId>
             <artifactId>protobuf-java</artifactId>
             <version>3.19.2</version>
-        </dependency>
+        </dependency>-->
         <!--Allure-->
         <dependency>
             <groupId>io.qameta.allure</groupId>

+ 6 - 6
tests/milvustest/src/main/java/com/zilliz/milvustest/common/CommonFunction.java

@@ -474,21 +474,21 @@ public class CommonFunction {
       case IVF_PQ:
         extraParm = "{\"nlist\":128, \"m\":16, \"nbits\":8}";
         break;
-      case ANNOY:
+      /*case ANNOY:
         extraParm = "{\"n_trees\":16}";
-        break;
+        break;*/
       case HNSW:
         extraParm = "{\"M\":16,\"efConstruction\":64}";
         break;
-      case RHNSW_FLAT:
+     /* case RHNSW_FLAT:
         extraParm = "{\"M\":16,\"efConstruction\":64}";
         break;
       case RHNSW_PQ:
         extraParm = "{\"M\":16,\"efConstruction\":64, \"PQM\":16}";
-        break;
-      case RHNSW_SQ:
+        break;*/
+    /*  case RHNSW_SQ:
         extraParm = "{\"M\":16,\"efConstruction\":64}";
-        break;
+        break;*/
       case BIN_IVF_FLAT:
         extraParm = "";
       default:

+ 8 - 8
tests/milvustest/src/test/java/com/zilliz/milvustest/index/CreateIndexTest.java

@@ -47,10 +47,10 @@ public class CreateIndexTest extends BaseTest {
       {IndexType.IVF_SQ8},
       {IndexType.IVF_PQ},
       {IndexType.HNSW},
-      {IndexType.ANNOY},
+   /*   {IndexType.ANNOY},
       {IndexType.RHNSW_FLAT},
       {IndexType.RHNSW_PQ},
-      {IndexType.RHNSW_SQ},
+      {IndexType.RHNSW_SQ},*/
       {IndexType.DISKANN}
     };
   }
@@ -69,10 +69,10 @@ public class CreateIndexTest extends BaseTest {
   public Object[][] providerBinaryMetricType() {
     return new Object[][] {
       {MetricType.HAMMING},
-      {MetricType.JACCARD},
+      {MetricType.JACCARD}/*,
       {MetricType.SUBSTRUCTURE},
       {MetricType.SUPERSTRUCTURE},
-      {MetricType.TANIMOTO}
+      {MetricType.TANIMOTO}*/
     };
   }
 
@@ -142,11 +142,11 @@ public class CreateIndexTest extends BaseTest {
   @Issue("https://github.com/milvus-io/milvus-sdk-java/issues/321")
   @Test(description = "Create index for collection Async", dataProvider = "BinaryIndex")
   public void createBinaryIndexAsync(IndexType indexType, MetricType metricType) {
-    if (indexType.equals(IndexType.BIN_IVF_FLAT)
+   /* if (indexType.equals(IndexType.BIN_IVF_FLAT)
         && (metricType.equals(MetricType.SUBSTRUCTURE)
             || metricType.equals(MetricType.SUPERSTRUCTURE))) {
       return;
-    }
+    }*/
     R<RpcStatus> rpcStatusR =
         milvusClient.createIndex(
             CreateIndexParam.newBuilder()
@@ -172,11 +172,11 @@ public class CreateIndexTest extends BaseTest {
   @Issue("https://github.com/milvus-io/milvus-sdk-java/issues/321")
   @Test(description = "Create index for collection sync", dataProvider = "BinaryIndex")
   public void createBinaryIndexSync(IndexType indexType, MetricType metricType) {
-    if (indexType.equals(IndexType.BIN_IVF_FLAT)
+    /*if (indexType.equals(IndexType.BIN_IVF_FLAT)
         && (metricType.equals(MetricType.SUBSTRUCTURE)
             || metricType.equals(MetricType.SUPERSTRUCTURE))) {
       return;
-    }
+    }*/
     R<RpcStatus> rpcStatusR =
         milvusClient.createIndex(
             CreateIndexParam.newBuilder()

+ 51 - 6
tests/milvustest/src/test/java/com/zilliz/milvustest/index/IndexLoadTest.java

@@ -48,11 +48,11 @@ public class IndexLoadTest extends BaseTest {
                 {IndexType.IVF_FLAT},
                 {IndexType.IVF_SQ8},
                 {IndexType.IVF_PQ},
-                {IndexType.HNSW},
+                {IndexType.HNSW}/*,
                 {IndexType.ANNOY},
                 {IndexType.RHNSW_FLAT},
                 {IndexType.RHNSW_PQ},
-                {IndexType.RHNSW_SQ}
+                {IndexType.RHNSW_SQ}*/
         };
     }
 
@@ -71,10 +71,10 @@ public class IndexLoadTest extends BaseTest {
     public Object[][] providerBinaryMetricType() {
         return new Object[][] {
                 {MetricType.HAMMING},
-                {MetricType.JACCARD},
+                {MetricType.JACCARD}/*,
                 {MetricType.SUBSTRUCTURE},
                 {MetricType.SUPERSTRUCTURE},
-                {MetricType.TANIMOTO}
+                {MetricType.TANIMOTO}*/
         };
     }
 
@@ -162,11 +162,11 @@ public class IndexLoadTest extends BaseTest {
     @Severity(SeverityLevel.NORMAL)
     @Test(description = "Test create/drop index when collection is loaded for binary vector", dataProvider = "BinaryIndex",groups = {"Smoke"})
     public void createIndexAfterLoadBinaryCollection(IndexType indexType, MetricType metricType) {
-        if (indexType.equals(IndexType.BIN_IVF_FLAT)
+      /*  if (indexType.equals(IndexType.BIN_IVF_FLAT)
                 && (metricType.equals(MetricType.SUBSTRUCTURE)
                 || metricType.equals(MetricType.SUPERSTRUCTURE))) {
             return;
-        }
+        }*/
         // 1. create index params
         CreateIndexParam createIndexParams = CreateIndexParam.newBuilder()
                 .withCollectionName(binaryCollection)
@@ -234,4 +234,49 @@ public class IndexLoadTest extends BaseTest {
         Assert.assertEquals(rpcStatusR7.getStatus().intValue(), 0);
         Assert.assertEquals(rpcStatusR7.getData().getMsg(), "Success");
     }
+
+    @Test
+    public void repeatCreateIndex(){
+        String collection = CommonFunction.createNewCollection();
+        // 1. create index params
+        CreateIndexParam createIndexParams = CreateIndexParam.newBuilder()
+                .withCollectionName(collection)
+                .withFieldName(CommonData.defaultVectorField)
+                .withMetricType(MetricType.L2)
+                .withIndexType(IndexType.HNSW)
+                .withExtraParam(CommonFunction.provideExtraParam(IndexType.HNSW))
+                .withSyncMode(Boolean.TRUE)
+                .withSyncWaitingTimeout(30L)
+                .withSyncWaitingInterval(500L)
+                .build();
+        // 2. create index
+        R<RpcStatus> rpcStatusR = milvusClient.createIndex(createIndexParams);
+        System.out.println("Create index" + rpcStatusR);
+        Assert.assertEquals(rpcStatusR.getStatus().intValue(), 0);
+        Assert.assertEquals(rpcStatusR.getData().getMsg(), "Success");
+        // 3. load collection
+        R<RpcStatus> rpcStatusR2 = milvusClient.loadCollection(
+                LoadCollectionParam.newBuilder()
+                        .withCollectionName(collection)
+                        .withSyncLoad(Boolean.TRUE)
+                        .build());
+        System.out.println("Load collection " + rpcStatusR);
+        Assert.assertEquals(rpcStatusR2.getStatus().intValue(), 0);
+        Assert.assertEquals(rpcStatusR2.getData().getMsg(), "Success");
+        // repeat createIndex
+        CreateIndexParam createIndexParams2 = CreateIndexParam.newBuilder()
+                .withCollectionName(collection)
+                .withFieldName(CommonData.defaultVectorField)
+                .withMetricType(MetricType.L2)
+                .withIndexType(IndexType.IVF_FLAT)
+                .withExtraParam(CommonFunction.provideExtraParam(IndexType.IVF_FLAT))
+                .withSyncMode(Boolean.TRUE)
+                .withSyncWaitingTimeout(30L)
+                .withSyncWaitingInterval(500L)
+                .build();
+        R<RpcStatus> rpcStatusR3 = milvusClient.createIndex(createIndexParams2);
+        System.out.println("Create index" + rpcStatusR2);
+        Assert.assertEquals(rpcStatusR3.getStatus().intValue(), 0);
+        Assert.assertEquals(rpcStatusR3.getData().getMsg(), "Success");
+    }
 }

+ 8 - 8
tests/milvustest/src/test/java/com/zilliz/milvustest/query/QueryAsyncTest.java

@@ -102,11 +102,11 @@ public class QueryAsyncTest extends BaseTest {
       {IndexType.IVF_FLAT},
       {IndexType.IVF_SQ8},
       {IndexType.IVF_PQ},
-      {IndexType.HNSW},
+      {IndexType.HNSW}/*,
       {IndexType.ANNOY},
       {IndexType.RHNSW_FLAT},
       {IndexType.RHNSW_PQ},
-      {IndexType.RHNSW_SQ}
+      {IndexType.RHNSW_SQ}*/
     };
   }
 
@@ -129,10 +129,10 @@ public class QueryAsyncTest extends BaseTest {
   public Object[][] providerBinaryMetricType() {
     return new Object[][] {
       {MetricType.HAMMING},
-      {MetricType.JACCARD},
+      {MetricType.JACCARD}/*,
       {MetricType.SUBSTRUCTURE},
       {MetricType.SUPERSTRUCTURE},
-      {MetricType.TANIMOTO}
+      {MetricType.TANIMOTO}*/
     };
   }
 
@@ -807,12 +807,12 @@ public class QueryAsyncTest extends BaseTest {
   @Severity(SeverityLevel.CRITICAL)
   public void stringPKAndBinaryVectorQueryUsingEachIndex(
           IndexType indexType, MetricType metricType) throws ExecutionException, InterruptedException {
-    boolean b =
+   /* boolean b =
             metricType.equals(MetricType.SUBSTRUCTURE) || metricType.equals(MetricType.SUPERSTRUCTURE);
 
     if (indexType.equals(IndexType.BIN_IVF_FLAT) && b) {
       return;
-    }
+    }*/
     String stringPKAndBinaryCollection = CommonFunction.createStringPKAndBinaryCollection();
     // create index
     R<RpcStatus> rpcStatusR =
@@ -857,9 +857,9 @@ public class QueryAsyncTest extends BaseTest {
     R<QueryResults> queryResultsR = rListenableFuture.get();
     QueryResultsWrapper wrapperQuery = new QueryResultsWrapper(queryResultsR.getData());
     Assert.assertEquals(queryResultsR.getStatus().intValue(), 0);
-    if (b) {
+/*    if (b) {
       return;
-    }
+    }*/
     System.out.println(wrapperQuery.getFieldWrapper("book_name").getFieldData());
     System.out.println(wrapperQuery.getFieldWrapper("book_content").getFieldData());
     Assert.assertTrue(wrapperQuery.getFieldWrapper("book_name").getFieldData().size() > 10);

+ 8 - 11
tests/milvustest/src/test/java/com/zilliz/milvustest/query/QueryTest.java

@@ -110,11 +110,11 @@ public class QueryTest extends BaseTest {
       {IndexType.IVF_FLAT},
       {IndexType.IVF_SQ8},
       {IndexType.IVF_PQ},
-      {IndexType.HNSW},
+      {IndexType.HNSW}/*,
       {IndexType.ANNOY},
       {IndexType.RHNSW_FLAT},
       {IndexType.RHNSW_PQ},
-      {IndexType.RHNSW_SQ}
+      {IndexType.RHNSW_SQ}*/
     };
   }
 
@@ -137,10 +137,10 @@ public class QueryTest extends BaseTest {
   public Object[][] providerBinaryMetricType() {
     return new Object[][] {
       {MetricType.HAMMING},
-      {MetricType.JACCARD},
+      {MetricType.JACCARD}/*,
       {MetricType.SUBSTRUCTURE},
       {MetricType.SUPERSTRUCTURE},
-      {MetricType.TANIMOTO}
+      {MetricType.TANIMOTO}*/
     };
   }
 
@@ -818,12 +818,12 @@ public class QueryTest extends BaseTest {
   @Severity(SeverityLevel.CRITICAL)
   public void stringPKAndBinaryVectorQueryUsingEachIndex(
       IndexType indexType, MetricType metricType) {
-    boolean b =
+   /* boolean b =
         metricType.equals(MetricType.SUBSTRUCTURE) || metricType.equals(MetricType.SUPERSTRUCTURE);
 
     if (indexType.equals(IndexType.BIN_IVF_FLAT) && b) {
       return;
-    }
+    }*/
     String stringPKAndBinaryCollection = CommonFunction.createStringPKAndBinaryCollection();
     // create index
     R<RpcStatus> rpcStatusR =
@@ -867,9 +867,9 @@ public class QueryTest extends BaseTest {
     R<QueryResults> queryResultsR = milvusClient.query(queryParam);
     QueryResultsWrapper wrapperQuery = new QueryResultsWrapper(queryResultsR.getData());
     Assert.assertEquals(queryResultsR.getStatus().intValue(), 0);
-    if (b) {
+/*    if (b) {
       return;
-    }
+    }*/
     System.out.println(wrapperQuery.getFieldWrapper("book_name").getFieldData());
     System.out.println(wrapperQuery.getFieldWrapper("book_content").getFieldData());
     Assert.assertTrue(wrapperQuery.getFieldWrapper("book_name").getFieldData().size() > 10);
@@ -1121,9 +1121,6 @@ public class QueryTest extends BaseTest {
     QueryResultsWrapper wrapperQuery = new QueryResultsWrapper(queryResultsR.getData());
     Assert.assertEquals(queryResultsR.getStatus().intValue(), 0);
     Assert.assertTrue(wrapperQuery.getFieldWrapper("json_field").getFieldData().size()>=4);
-    JSONObject jsonObject = (JSONObject) wrapperQuery.getRowRecord(0).get("json_field");
-    String string_field = jsonObject.getString("string_field");
-    Assert.assertTrue(string_field.contains("Str"));
 
   }
 

+ 10 - 10
tests/milvustest/src/test/java/com/zilliz/milvustest/search/SearchAsyncTest.java

@@ -102,11 +102,11 @@ public class SearchAsyncTest extends BaseTest {
       {IndexType.IVF_FLAT},
       {IndexType.IVF_SQ8},
       {IndexType.IVF_PQ},
-      {IndexType.HNSW},
+      {IndexType.HNSW}/*,
       {IndexType.ANNOY},
       {IndexType.RHNSW_FLAT},
       {IndexType.RHNSW_PQ},
-      {IndexType.RHNSW_SQ}
+      {IndexType.RHNSW_SQ}*/
     };
   }
 
@@ -129,10 +129,10 @@ public class SearchAsyncTest extends BaseTest {
   public Object[][] providerBinaryMetricType() {
     return new Object[][] {
       {MetricType.HAMMING},
-      {MetricType.JACCARD},
+      {MetricType.JACCARD}/*,
       {MetricType.SUBSTRUCTURE},
       {MetricType.SUPERSTRUCTURE},
-      {MetricType.TANIMOTO}
+      {MetricType.TANIMOTO}*/
     };
   }
 
@@ -1655,11 +1655,11 @@ public class SearchAsyncTest extends BaseTest {
       dataProvider = "BinaryIndex")
   public void stringPKAndBinaryVectorSearchAsyncWithEachIndex(
       IndexType indexType, MetricType metricType) {
-    boolean b =
-        metricType.equals(MetricType.SUBSTRUCTURE) || metricType.equals(MetricType.SUPERSTRUCTURE);
-    if (indexType.equals(IndexType.BIN_IVF_FLAT) && b) {
+    /*boolean b =
+        metricType.equals(MetricType.SUBSTRUCTURE) || metricType.equals(MetricType.SUPERSTRUCTURE);*/
+   /* if (indexType.equals(IndexType.BIN_IVF_FLAT) && b) {
       return;
-    }
+    }*/
     String stringPKAndBinaryCollection = CommonFunction.createStringPKAndBinaryCollection();
     // create index
     R<RpcStatus> rpcStatusR =
@@ -1710,9 +1710,9 @@ public class SearchAsyncTest extends BaseTest {
     ListenableFuture<R<SearchResults>> rListenableFuture = milvusClient.searchAsync(searchParam);
     try {
       Assert.assertEquals(rListenableFuture.get().getStatus().intValue(), 0);
-      if (b) {
+    /*  if (b) {
         return;
-      }
+      }*/
       SearchResultsWrapper searchResultsWrapper =
           new SearchResultsWrapper(rListenableFuture.get().getData().getResults());
       Assert.assertEquals(searchResultsWrapper.getFieldData("book_name", 0).size(), 2);

+ 8 - 8
tests/milvustest/src/test/java/com/zilliz/milvustest/search/SearchTest.java

@@ -129,11 +129,11 @@ public class SearchTest extends BaseTest {
       {IndexType.IVF_FLAT},
       {IndexType.IVF_SQ8},
       {IndexType.IVF_PQ},
-      {IndexType.HNSW},
+      {IndexType.HNSW}/*,
       {IndexType.ANNOY},
       {IndexType.RHNSW_FLAT},
       {IndexType.RHNSW_PQ},
-      {IndexType.RHNSW_SQ}
+      {IndexType.RHNSW_SQ}*/
     };
   }
 
@@ -156,10 +156,10 @@ public class SearchTest extends BaseTest {
   public Object[][] providerBinaryMetricType() {
     return new Object[][] {
       {MetricType.HAMMING},
-      {MetricType.JACCARD},
+      {MetricType.JACCARD}/*,
       {MetricType.SUBSTRUCTURE},
       {MetricType.SUPERSTRUCTURE},
-      {MetricType.TANIMOTO}
+      {MetricType.TANIMOTO}*/
     };
   }
 
@@ -1519,12 +1519,12 @@ public class SearchTest extends BaseTest {
       description = "String PK and Binary vector search with each index",
       dataProvider = "BinaryIndex")
   public void stringPKAndBinaryVectorSearchWithEachIndex(
-      IndexType indexType, MetricType metricType) {
+      IndexType indexType, MetricType metricType) {/*
     boolean b = metricType.equals(MetricType.SUBSTRUCTURE) || metricType.equals(MetricType.SUPERSTRUCTURE);
 
     if(indexType.equals(IndexType.BIN_IVF_FLAT)&& b){
       return;
-    }
+    }*/
     String stringPKAndBinaryCollection = CommonFunction.createStringPKAndBinaryCollection();
     // create index
     R<RpcStatus> rpcStatusR =
@@ -1575,9 +1575,9 @@ public class SearchTest extends BaseTest {
     R<SearchResults> searchResultsR = milvusClient.search(searchParam);
     System.out.println(searchResultsR.getData().getResults());
     Assert.assertEquals(searchResultsR.getStatus().intValue(), 0);
-    if (b){
+  /*  if (b){
       return ;
-    }
+    }*/
     SearchResultsWrapper searchResultsWrapper =
         new SearchResultsWrapper(searchResultsR.getData().getResults());
     Assert.assertEquals(searchResultsWrapper.getFieldData("book_name", 0).size(), 2);