Skip to content

Commit

Permalink
add testcases abort enable mmap (#1043) (#1044)
Browse files Browse the repository at this point in the history
Signed-off-by: yongpengli-z <yongpeng.li@zilliz.com>
  • Loading branch information
yongpengli-z authored Aug 19, 2024
1 parent bb995a5 commit 398414d
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

import com.zilliz.milvustestv2.common.BaseTest;
import com.zilliz.milvustestv2.common.CommonData;
import com.zilliz.milvustestv2.common.CommonFunction;
import io.milvus.grpc.CollectionSchema;
import io.milvus.param.Constant;
import io.milvus.v2.common.DataType;
import io.milvus.v2.service.collection.request.AlterCollectionReq;
import io.milvus.v2.service.collection.request.CreateCollectionReq;
import io.milvus.v2.service.collection.request.DescribeCollectionReq;
import io.milvus.v2.service.collection.request.DropCollectionReq;
import io.milvus.v2.service.collection.response.DescribeCollectionResp;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @Author yongpeng.li
* @Date 2024/2/19 11:11
Expand All @@ -18,6 +30,25 @@ public void describeCollection() {
DescribeCollectionResp describeCollectionResp = milvusClientV2.describeCollection(DescribeCollectionReq.builder()
.collectionName(CommonData.defaultFloatVectorCollection)
.build());
Assert.assertEquals(describeCollectionResp.getVectorFieldNames().get(0),CommonData.fieldFloatVector);
Assert.assertEquals(describeCollectionResp.getVectorFieldNames().get(0), CommonData.fieldFloatVector);
}

@Test(description = "Describe collection when mmap field", groups = {"Smoke"})
public void describeMMapCollection() {
String newCollection = CommonFunction.createNewCollection(CommonData.dim, null, DataType.FloatVector);
Map<String, String> map = new HashMap<String, String>() {{
put(Constant.MMAP_ENABLED, "true");
}};
milvusClientV2.alterCollection(AlterCollectionReq.builder()
.collectionName(newCollection)
.properties(map).build());
DescribeCollectionResp describeCollectionResp = milvusClientV2.describeCollection(DescribeCollectionReq.builder()
.collectionName(newCollection)
.build());
Assert.assertTrue(describeCollectionResp.getProperties().containsKey(Constant.MMAP_ENABLED));
Assert.assertTrue(describeCollectionResp.getProperties().get(Constant.MMAP_ENABLED).equalsIgnoreCase("true"));
milvusClientV2.dropCollection(DropCollectionReq.builder().collectionName(newCollection).build());


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.zilliz.milvustestv2.index;

import com.zilliz.milvustestv2.common.BaseTest;
import com.zilliz.milvustestv2.common.CommonData;
import com.zilliz.milvustestv2.common.CommonFunction;
import io.milvus.param.Constant;
import io.milvus.v2.common.DataType;
import io.milvus.v2.service.collection.request.DropCollectionReq;
import io.milvus.v2.service.index.request.AlterIndexReq;
import io.milvus.v2.service.index.request.DescribeIndexReq;
import io.milvus.v2.service.index.request.ListIndexesReq;
import io.milvus.v2.service.index.response.DescribeIndexResp;
import io.milvus.v2.service.vector.request.DeleteReq;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AlterIndexTest extends BaseTest {
private String collectionName;

@BeforeClass(alwaysRun = true)
public void initTest() {
collectionName = CommonFunction.createNewCollection(CommonData.dim, null, DataType.FloatVector);
CommonFunction.createIndex(collectionName, DataType.FloatVector);
}

@AfterClass(alwaysRun = true)
public void destroyTestData() {
milvusClientV2.dropCollection(DropCollectionReq.builder()
.collectionName(collectionName).build());
}

@Test(description = "alter index mmap", groups = {"Smoke"})
public void alterIndexMMapTest() {
List<String> strings = milvusClientV2.listIndexes(ListIndexesReq.builder()
.collectionName(collectionName).build());
System.out.println(strings);
Map<String, String> stringMap = new HashMap<>();
stringMap.put(Constant.MMAP_ENABLED, "true");
milvusClientV2.alterIndex(AlterIndexReq.builder()
.indexName(strings.get(0))
.collectionName(collectionName)
.properties(stringMap)
.build());
DescribeIndexResp describeIndexResp = milvusClientV2.describeIndex(DescribeIndexReq.builder()
.collectionName(collectionName)
.indexName(strings.get(0)).build());
System.out.println(describeIndexResp);
Assert.assertTrue(describeIndexResp.getIndexDescriptions().get(0).getExtraParams().get(Constant.MMAP_ENABLED).equalsIgnoreCase("true"));

}


}

0 comments on commit 398414d

Please sign in to comment.