mirror of https://github.com/milvus-io/milvus.git
[skip ci] Test get entity by id (#3417)
* [skip ci] update for Contasts Signed-off-by: zongyufen <zongyufen@foxmail.com> * [skip ci] test get entity by id Signed-off-by: zongyufen <zongyufen@foxmail.com> * [skip ci] test get entity by id Signed-off-by: zongyufen <zongyufen@foxmail.com>pull/3424/head
parent
b0b6aefc21
commit
e89a707d6c
|
@ -32,6 +32,10 @@ public final class Constants {
|
|||
|
||||
public static final List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
|
||||
|
||||
public static final List<Map<String,Object>> defaultFields = Utils.genDefaultFields(dimension,false);
|
||||
|
||||
public static final List<Map<String,Object>> defaultBinaryFields = Utils.genDefaultFields(dimension,true);
|
||||
|
||||
public static final List<Map<String,Object>> defaultEntities = Utils.genDefaultEntities(dimension, nb, vectors);
|
||||
|
||||
public static final List<Map<String,Object>> defaultBinaryEntities = Utils.genDefaultBinaryEntities(dimension, nb, vectorsBinary);
|
||||
|
|
|
@ -3,19 +3,12 @@ package com;
|
|||
import io.milvus.client.*;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestCollectionCount {
|
||||
int segmentRowCount = 5000;
|
||||
int dimension = 128;
|
||||
int nb = 10000;
|
||||
List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
|
||||
List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
|
||||
List<Map<String,Object>> defaultEntities = Utils.genDefaultEntities(dimension,nb,vectors);
|
||||
List<Map<String,Object>> defaultBinaryEntities = Utils.genDefaultBinaryEntities(dimension,nb,vectorsBinary);
|
||||
int dimension = Constants.dimension;
|
||||
int nb = Constants.nb;
|
||||
|
||||
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
public void testCollectionCountNoVectors(MilvusClient client, String collectionName) {
|
||||
|
@ -39,7 +32,7 @@ public class TestCollectionCount {
|
|||
|
||||
InsertParam insertParam =
|
||||
new InsertParam.Builder(collectionName)
|
||||
.withFields(defaultEntities)
|
||||
.withFields(Constants.defaultEntities)
|
||||
.build();
|
||||
InsertResponse insertResponse = client.insert(insertParam);
|
||||
// Insert returns a list of entity ids that you will be using (if you did not supply the yourself) to reference the entities you just inserted
|
||||
|
@ -54,7 +47,7 @@ public class TestCollectionCount {
|
|||
public void testCollectionCountBinary(MilvusClient client, String collectionName) throws InterruptedException {
|
||||
// Add vectors
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName)
|
||||
.withFields(defaultBinaryEntities)
|
||||
.withFields(Constants.defaultBinaryEntities)
|
||||
.build();
|
||||
client.insert(insertParam);
|
||||
client.flush(collectionName);
|
||||
|
@ -75,7 +68,7 @@ public class TestCollectionCount {
|
|||
Assert.assertEquals(cteateRes.ok(), true);
|
||||
// Add vectors
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionNameNew)
|
||||
.withFields(defaultEntities)
|
||||
.withFields(Constants.defaultEntities)
|
||||
.build();
|
||||
InsertResponse insertRes = client.insert(insertParam);
|
||||
Assert.assertEquals(insertRes.ok(), true);
|
||||
|
|
|
@ -1,34 +1,19 @@
|
|||
|
||||
package com;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.milvus.client.*;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestCollectionInfo {
|
||||
int dimension = 128;
|
||||
int nb = 8000;
|
||||
int nList = 1024;
|
||||
int defaultNList = 16384;
|
||||
String indexType = "IVF_SQ8";
|
||||
String defaultIndexType = "FLAT";
|
||||
String metricType = "L2";
|
||||
String indexParam = Utils.setIndexParam(indexType,metricType,nList);
|
||||
List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
|
||||
List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
|
||||
List<Map<String,Object>> defaultEntities = Utils.genDefaultEntities(dimension,nb,vectors);
|
||||
List<Map<String,Object>> defaultBinaryEntities = Utils.genDefaultBinaryEntities(dimension,nb,vectorsBinary);
|
||||
int nb = Constants.nb;
|
||||
|
||||
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
public void testGetEntityIdsAfterDeleteEntities(MilvusClient client, String collectionName) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName)
|
||||
.withFields(defaultEntities)
|
||||
.withFields(Constants.defaultEntities)
|
||||
.build();
|
||||
InsertResponse resInsert = client.insert(insertParam);
|
||||
client.flush(collectionName);
|
||||
|
@ -45,12 +30,12 @@ public class TestCollectionInfo {
|
|||
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
public void testGetEntityIdsAterDeleteEntitiesIndexed(MilvusClient client, String collectionName) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName)
|
||||
.withFields(defaultEntities)
|
||||
.withFields(Constants.defaultEntities)
|
||||
.build();
|
||||
InsertResponse resInsert = client.insert(insertParam);
|
||||
client.flush(collectionName);
|
||||
Index index = new Index.Builder(collectionName, "float_vector")
|
||||
.withParamsInJson(indexParam).build();
|
||||
.withParamsInJson(Constants.indexParam).build();
|
||||
Response createIndexResponse = client.createIndex(index);
|
||||
assert(createIndexResponse.ok());
|
||||
List<Long> idsBefore = resInsert.getEntityIds();
|
||||
|
@ -66,7 +51,7 @@ public class TestCollectionInfo {
|
|||
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
|
||||
public void testGetEntityIdsAfterDeleteEntitiesBinary(MilvusClient client, String collectionName) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName)
|
||||
.withFields(defaultBinaryEntities)
|
||||
.withFields(Constants.defaultBinaryEntities)
|
||||
.build();
|
||||
InsertResponse resInsert = client.insert(insertParam);
|
||||
client.flush(collectionName);
|
||||
|
|
|
@ -3,23 +3,12 @@ package com;
|
|||
import io.milvus.client.*;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestCompact {
|
||||
|
||||
int dimension = 128;
|
||||
int nb = 8000;
|
||||
List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
|
||||
List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
|
||||
List<Map<String,Object>> defaultEntities = Utils.genDefaultEntities(dimension,nb,vectors);
|
||||
List<Map<String,Object>> defaultBinaryEntities = Utils.genDefaultBinaryEntities(dimension,nb,vectorsBinary);
|
||||
|
||||
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
public void testCompactAfterDelete(MilvusClient client, String collectionName) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(defaultEntities).build();
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(Constants.defaultEntities).build();
|
||||
InsertResponse res = client.insert(insertParam);
|
||||
assert(res.getResponse().ok());
|
||||
List<Long> ids = res.getEntityIds();
|
||||
|
@ -37,7 +26,7 @@ public class TestCompact {
|
|||
|
||||
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
|
||||
public void testCompactAfterDeleteBinary(MilvusClient client, String collectionName) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(defaultBinaryEntities).build();
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(Constants.defaultBinaryEntities).build();
|
||||
InsertResponse res = client.insert(insertParam);
|
||||
assert(res.getResponse().ok());
|
||||
List<Long> ids = res.getEntityIds();
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
package com;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import io.milvus.client.*;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestFlush {
|
||||
int segmentRowCount = 50;
|
||||
int dimension = 128;
|
||||
int nb = 8000;
|
||||
int nb = Constants.nb;
|
||||
|
||||
List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
|
||||
List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
|
||||
List<Map<String,Object>> defaultFields = Utils.genDefaultFields(dimension,false);
|
||||
List<Map<String,Object>> defaultEntities = Utils.genDefaultEntities(dimension,nb,vectors);
|
||||
List<Map<String,Object>> defaultBinaryEntities = Utils.genDefaultBinaryEntities(dimension,nb,vectorsBinary);
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
@Test(dataProvider = "ConnectInstance", dataProviderClass = MainClass.class)
|
||||
public void testFlushCollectionNotExisted(MilvusClient client, String collectionName) {
|
||||
String newCollection = "not_existed";
|
||||
Response res = client.flush(newCollection);
|
||||
|
@ -40,39 +26,40 @@ public class TestFlush {
|
|||
assert(res.ok());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
@Test(dataProvider = "ConnectInstance", dataProviderClass = MainClass.class)
|
||||
public void testAddCollectionsFlush(MilvusClient client, String collectionName) {
|
||||
List<String> names = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int collectionNum = 10;
|
||||
for (int i = 0; i < collectionNum; i++) {
|
||||
names.add(RandomStringUtils.randomAlphabetic(10));
|
||||
CollectionMapping collectionSchema = new CollectionMapping.Builder(names.get(i))
|
||||
.withFields(defaultFields)
|
||||
.withFields(Constants.defaultFields)
|
||||
.withParamsInJson(String.format("{\"segment_row_count\": %s}",segmentRowCount))
|
||||
.build();
|
||||
client.createCollection(collectionSchema);
|
||||
InsertParam insertParam = new InsertParam.Builder(names.get(i)).withFields(defaultEntities).build();
|
||||
InsertParam insertParam = new InsertParam.Builder(names.get(i)).withFields(Constants.defaultEntities).build();
|
||||
client.insert(insertParam);
|
||||
System.out.println("Table " + names.get(i) + " created.");
|
||||
}
|
||||
Response res = client.flush(names);
|
||||
assert(res.ok());
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int i = 0; i < collectionNum; i++) {
|
||||
// check row count
|
||||
Assert.assertEquals(client.countEntities(names.get(i)).getCollectionEntityCount(), nb);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
@Test(dataProvider = "ConnectInstance", dataProviderClass = MainClass.class)
|
||||
public void testAddCollectionsFlushAsync(MilvusClient client, String collectionName) throws ExecutionException, InterruptedException {
|
||||
List<String> names = new ArrayList<>();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
names.add(RandomStringUtils.randomAlphabetic(10));
|
||||
CollectionMapping collectionSchema = new CollectionMapping.Builder(names.get(i))
|
||||
.withFields(defaultFields)
|
||||
.withFields(Constants.defaultFields)
|
||||
.withParamsInJson(String.format("{\"segment_row_count\": %s}",segmentRowCount))
|
||||
.build();
|
||||
client.createCollection(collectionSchema);
|
||||
InsertParam insertParam = new InsertParam.Builder(names.get(i)).withFields(defaultEntities).build();
|
||||
InsertParam insertParam = new InsertParam.Builder(names.get(i)).withFields(Constants.defaultEntities).build();
|
||||
client.insert(insertParam);
|
||||
System.out.println("Collection " + names.get(i) + " created.");
|
||||
}
|
||||
|
@ -87,7 +74,7 @@ public class TestFlush {
|
|||
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
public void testAddFlushMultipleTimes(MilvusClient client, String collectionName) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(defaultEntities).build();
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(Constants.defaultEntities).build();
|
||||
client.insert(insertParam);
|
||||
Response res = client.flush(collectionName);
|
||||
assert(res.ok());
|
||||
|
@ -98,7 +85,7 @@ public class TestFlush {
|
|||
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
|
||||
public void testAddFlushMultipleTimesBinary(MilvusClient client, String collectionName) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(defaultBinaryEntities).build();
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(Constants.defaultBinaryEntities).build();
|
||||
client.insert(insertParam);
|
||||
Response res = client.flush(collectionName);
|
||||
assert(res.ok());
|
||||
|
|
|
@ -1,97 +1,89 @@
|
|||
//package com;
|
||||
//
|
||||
//import io.milvus.client.*;
|
||||
//import org.testng.annotations.Test;
|
||||
//
|
||||
//import java.nio.ByteBuffer;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Collections;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//public class TestGetEntityByID {
|
||||
// int dimension = 128;
|
||||
// int nb = 8000;
|
||||
// public List<Long> get_ids = Utils.toListIds(1111);
|
||||
//// List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
|
||||
//// List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
|
||||
// List<Map<String,Object>> defaultEntities = Utils.genDefaultEntities(dimension,nb,false);
|
||||
// List<Map<String,Object>> defaultBinaryEntities = Utils.genDefaultEntities(dimension,nb,true);
|
||||
//
|
||||
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
// public void test_get_vector_by_id_valid(MilvusClient client, String collectionName) {
|
||||
// int get_length = 100;
|
||||
// InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(defaultEntities).build();
|
||||
// InsertResponse resInsert = client.insert(insertParam);
|
||||
// List<Long> ids = resInsert.getEntityIds();
|
||||
// client.flush(collectionName);
|
||||
// GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, get_length));
|
||||
// assert (res.getResponse().ok());
|
||||
package com;
|
||||
|
||||
import io.milvus.client.*;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestGetEntityByID {
|
||||
public List<Long> get_ids = Utils.toListIds(1111);
|
||||
|
||||
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
public void testGetEntitiesByIdValid(MilvusClient client, String collectionName) {
|
||||
int get_length = 100;
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(Constants.defaultEntities).build();
|
||||
InsertResponse resInsert = client.insert(insertParam);
|
||||
List<Long> ids = resInsert.getEntityIds();
|
||||
client.flush(collectionName);
|
||||
GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, get_length));
|
||||
assert (res.getResponse().ok());
|
||||
// assert (res.getValidIds(), ids.subList(0, get_length));
|
||||
// for (int i = 0; i < get_length; i++) {
|
||||
// List<Map<String,Object>> fieldsMap = res.getFieldsMap();
|
||||
// assert (fieldsMap.get(i).get("float_vector").equals(defaultEntities.get(defaultEntities.size()-1).get("values").get("float_vector")));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
// public void test_get_vector_by_id_after_delete(MilvusClient client, String collectionName) {
|
||||
// InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
|
||||
// InsertResponse resInsert = client.insert(insertParam);
|
||||
// List<Long> ids = resInsert.getVectorIds();
|
||||
// Response res_delete = client.deleteEntityByID(collectionName, Collections.singletonList(ids.get(0)));
|
||||
// assert(res_delete.ok());
|
||||
// client.flush(collectionName);
|
||||
// GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, 1));
|
||||
// assert (res.getResponse().ok());
|
||||
// assert (res.getFloatVectors().get(0).size() == 0);
|
||||
// }
|
||||
//
|
||||
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
// public void test_get_vector_by_id_collection_name_not_existed(MilvusClient client, String collectionName) {
|
||||
// String newCollection = "not_existed";
|
||||
// GetEntityByIDResponse res = client.getEntityByID(newCollection, get_ids);
|
||||
// assert(!res.getResponse().ok());
|
||||
// }
|
||||
//
|
||||
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
// public void test_get_vector_id_not_existed(MilvusClient client, String collectionName) {
|
||||
// InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
|
||||
// client.insert(insertParam);
|
||||
// client.flush(collectionName);
|
||||
// GetEntityByIDResponse res = client.getEntityByID(collectionName, get_ids);
|
||||
// assert (res.getFloatVectors().get(0).size() == 0);
|
||||
// }
|
||||
//
|
||||
// // Binary tests
|
||||
// @Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
|
||||
// public void test_get_vector_by_id_valid_binary(MilvusClient client, String collectionName) {
|
||||
// InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
|
||||
// InsertResponse resInsert = client.insert(insertParam);
|
||||
// List<Long> ids = resInsert.getVectorIds();
|
||||
// client.flush(collectionName);
|
||||
// GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, 1));
|
||||
// assert res.getBinaryVectors().get(0).equals(vectorsBinary.get(0).rewind());
|
||||
// }
|
||||
//
|
||||
// @Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
|
||||
// public void test_get_vector_by_id_after_delete_binary(MilvusClient client, String collectionName) {
|
||||
// InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
|
||||
// InsertResponse resInsert = client.insert(insertParam);
|
||||
// List<Long> ids = resInsert.getVectorIds();
|
||||
// Response res_delete = client.deleteEntityByID(collectionName, Collections.singletonList(ids.get(0)));
|
||||
// assert(res_delete.ok());
|
||||
// client.flush(collectionName);
|
||||
// GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, 1));
|
||||
// assert (res.getFloatVectors().get(0).size() == 0);
|
||||
// }
|
||||
//
|
||||
// @Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
|
||||
// public void test_get_vector_id_not_existed_binary(MilvusClient client, String collectionName) {
|
||||
// InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
|
||||
// client.insert(insertParam);
|
||||
// client.flush(collectionName);
|
||||
// GetEntityByIDResponse res = client.getEntityByID(collectionName, get_ids);
|
||||
// assert (res.getFloatVectors().get(0).size() == 0);
|
||||
// }
|
||||
//}
|
||||
for (int i = 0; i < get_length; i++) {
|
||||
List<Map<String,Object>> fieldsMap = res.getFieldsMap();
|
||||
assert (fieldsMap.get(i).get("float_vector").equals(Constants.vectors.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
public void testGetEntityByIdAfterDelete(MilvusClient client, String collectionName) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(Constants.defaultEntities).build();
|
||||
InsertResponse resInsert = client.insert(insertParam);
|
||||
List<Long> ids = resInsert.getEntityIds();
|
||||
Response res_delete = client.deleteEntityByID(collectionName, Collections.singletonList(ids.get(0)));
|
||||
assert(res_delete.ok());
|
||||
client.flush(collectionName);
|
||||
GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, 1));
|
||||
assert (res.getResponse().ok());
|
||||
assert (res.getFieldsMap().size() == 0);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "ConnectInstance", dataProviderClass = MainClass.class)
|
||||
public void testGetEntityByIdCollectionNameNotExisted(MilvusClient client, String collectionName) {
|
||||
String newCollection = "not_existed";
|
||||
GetEntityByIDResponse res = client.getEntityByID(newCollection, get_ids);
|
||||
assert(!res.getResponse().ok());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
||||
public void testGetVectorIdNotExisted(MilvusClient client, String collectionName) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(Constants.defaultEntities).build();
|
||||
client.insert(insertParam);
|
||||
client.flush(collectionName);
|
||||
GetEntityByIDResponse res = client.getEntityByID(collectionName, get_ids);
|
||||
assert (res.getFieldsMap().size() == 0);
|
||||
}
|
||||
|
||||
// Binary tests
|
||||
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
|
||||
public void testGetEntityByIdValidBinary(MilvusClient client, String collectionName) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(Constants.defaultBinaryEntities).build();
|
||||
InsertResponse resInsert = client.insert(insertParam);
|
||||
List<Long> ids = resInsert.getEntityIds();
|
||||
client.flush(collectionName);
|
||||
GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, 1));
|
||||
assert res.getFieldsMap().get(0).get(Constants.binaryFieldName).equals(Constants.vectorsBinary.get(0).rewind());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
|
||||
public void testGetEntityByIdAfterDeleteBinary(MilvusClient client, String collectionName) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(Constants.defaultBinaryEntities).build();
|
||||
InsertResponse resInsert = client.insert(insertParam);
|
||||
List<Long> ids = resInsert.getEntityIds();
|
||||
Response res_delete = client.deleteEntityByID(collectionName, Collections.singletonList(ids.get(0)));
|
||||
assert(res_delete.ok());
|
||||
client.flush(collectionName);
|
||||
GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, 1));
|
||||
assert (res.getFieldsMap().size() == 0);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
|
||||
public void testGetEntityIdNotExistedBinary(MilvusClient client, String collectionName) {
|
||||
InsertParam insertParam = new InsertParam.Builder(collectionName).withFields(Constants.defaultBinaryEntities).build();
|
||||
client.insert(insertParam);
|
||||
client.flush(collectionName);
|
||||
GetEntityByIDResponse res = client.getEntityByID(collectionName, get_ids);
|
||||
assert (res.getFieldsMap().size() == 0);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue