|
| 1 | +package com.zilliz.milvustestv2.index; |
| 2 | + |
| 3 | +import com.zilliz.milvustestv2.common.BaseTest; |
| 4 | +import com.zilliz.milvustestv2.common.CommonData; |
| 5 | +import com.zilliz.milvustestv2.common.CommonFunction; |
| 6 | +import io.milvus.param.Constant; |
| 7 | +import io.milvus.v2.common.DataType; |
| 8 | +import io.milvus.v2.service.collection.request.DropCollectionReq; |
| 9 | +import io.milvus.v2.service.index.request.AlterIndexReq; |
| 10 | +import io.milvus.v2.service.index.request.DescribeIndexReq; |
| 11 | +import io.milvus.v2.service.index.request.ListIndexesReq; |
| 12 | +import io.milvus.v2.service.index.response.DescribeIndexResp; |
| 13 | +import io.milvus.v2.service.vector.request.DeleteReq; |
| 14 | +import org.testng.Assert; |
| 15 | +import org.testng.annotations.AfterClass; |
| 16 | +import org.testng.annotations.BeforeClass; |
| 17 | +import org.testng.annotations.Test; |
| 18 | + |
| 19 | +import java.util.HashMap; |
| 20 | +import java.util.List; |
| 21 | +import java.util.Map; |
| 22 | + |
| 23 | +public class AlterIndexTest extends BaseTest { |
| 24 | + private String collectionName; |
| 25 | + |
| 26 | + @BeforeClass(alwaysRun = true) |
| 27 | + public void initTest() { |
| 28 | + collectionName = CommonFunction.createNewCollection(CommonData.dim, null, DataType.FloatVector); |
| 29 | + CommonFunction.createIndex(collectionName, DataType.FloatVector); |
| 30 | + } |
| 31 | + |
| 32 | + @AfterClass(alwaysRun = true) |
| 33 | + public void destroyTestData() { |
| 34 | + milvusClientV2.dropCollection(DropCollectionReq.builder() |
| 35 | + .collectionName(collectionName).build()); |
| 36 | + } |
| 37 | + |
| 38 | + @Test(description = "alter index mmap", groups = {"Smoke"}) |
| 39 | + public void alterIndexMMapTest() { |
| 40 | + List<String> strings = milvusClientV2.listIndexes(ListIndexesReq.builder() |
| 41 | + .collectionName(collectionName).build()); |
| 42 | + System.out.println(strings); |
| 43 | + Map<String, String> stringMap = new HashMap<>(); |
| 44 | + stringMap.put(Constant.MMAP_ENABLED, "true"); |
| 45 | + milvusClientV2.alterIndex(AlterIndexReq.builder() |
| 46 | + .indexName(strings.get(0)) |
| 47 | + .collectionName(collectionName) |
| 48 | + .properties(stringMap) |
| 49 | + .build()); |
| 50 | + DescribeIndexResp describeIndexResp = milvusClientV2.describeIndex(DescribeIndexReq.builder() |
| 51 | + .collectionName(collectionName) |
| 52 | + .indexName(strings.get(0)).build()); |
| 53 | + System.out.println(describeIndexResp); |
| 54 | + Assert.assertTrue(describeIndexResp.getIndexDescriptions().get(0).getExtraParams().get(Constant.MMAP_ENABLED).equalsIgnoreCase("true")); |
| 55 | + |
| 56 | + } |
| 57 | + |
| 58 | + |
| 59 | +} |
0 commit comments