mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-03 04:19:18 +08:00
Remove useless test files
Signed-off-by: zw <zw@milvus.io>
This commit is contained in:
parent
ba1af004a9
commit
f4744c7d2e
@ -9,12 +9,12 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
|
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.10" level="project" />
|
||||||
<orderEntry type="library" name="Maven: commons-cli:commons-cli:1.4" level="project" />
|
<orderEntry type="library" name="Maven: commons-cli:commons-cli:1.4" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.testng:testng:6.14.3" level="project" />
|
<orderEntry type="library" name="Maven: org.testng:testng:6.14.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.beust:jcommander:1.72" level="project" />
|
<orderEntry type="library" name="Maven: com.beust:jcommander:1.72" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.apache-extras.beanshell:bsh:2.0b6" level="project" />
|
<orderEntry type="library" name="Maven: org.apache-extras.beanshell:bsh:2.0b6" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.47" level="project" />
|
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.68" level="project" />
|
||||||
<orderEntry type="library" name="Maven: junit:junit:4.13" level="project" />
|
<orderEntry type="library" name="Maven: junit:junit:4.13" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: io.milvus:milvus-sdk-java:0.8.0-SNAPSHOT" level="project" />
|
<orderEntry type="library" name="Maven: io.milvus:milvus-sdk-java:0.8.0-SNAPSHOT" level="project" />
|
||||||
|
@ -1,205 +0,0 @@
|
|||||||
package com;
|
|
||||||
|
|
||||||
import io.milvus.client.MilvusClient;
|
|
||||||
import io.milvus.client.Response;
|
|
||||||
import io.milvus.client.ShowPartitionsResponse;
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class Partition {
|
|
||||||
int dimension = 128;
|
|
||||||
|
|
||||||
public List<List<Float>> gen_vectors(Integer nb) {
|
|
||||||
List<List<Float>> xb = new LinkedList<>();
|
|
||||||
Random random = new Random();
|
|
||||||
for (int i = 0; i < nb; ++i) {
|
|
||||||
LinkedList<Float> vector = new LinkedList<>();
|
|
||||||
for (int j = 0; j < dimension; j++) {
|
|
||||||
vector.add(random.nextFloat());
|
|
||||||
}
|
|
||||||
xb.add(vector);
|
|
||||||
}
|
|
||||||
return xb;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------- create partition cases in ---------------------------------
|
|
||||||
|
|
||||||
// create partition
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_create_partition(MilvusClient client, String tableName) {
|
|
||||||
String partitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
String tag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition partition = new io.milvus.client.Partition.Builder(tableName, partitionName, tag).build();
|
|
||||||
Response createpResponse = client.createPartition(partition);
|
|
||||||
assert (createpResponse.ok());
|
|
||||||
// show partitions
|
|
||||||
List<io.milvus.client.Partition> partitions = client.showPartitions(tableName).getPartitionList();
|
|
||||||
System.out.println(partitions);
|
|
||||||
List<String> partitionNames = new ArrayList<>();
|
|
||||||
for (int i=0; i<partitions.size(); ++i) {
|
|
||||||
partitionNames.add(partitions.get(i).getPartitionName());
|
|
||||||
}
|
|
||||||
Assert.assertTrue(partitionNames.contains(partitionName));
|
|
||||||
}
|
|
||||||
|
|
||||||
// create partition, partition existed
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_create_partition_name_existed(MilvusClient client, String tableName) {
|
|
||||||
String partitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
String tag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition partition = new io.milvus.client.Partition.Builder(tableName, partitionName, tag).build();
|
|
||||||
Response createpResponse = client.createPartition(partition);
|
|
||||||
assert (createpResponse.ok());
|
|
||||||
String newTag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition newPartition = new io.milvus.client.Partition.Builder(tableName, partitionName, newTag).build();
|
|
||||||
Response newCreatepResponse = client.createPartition(newPartition);
|
|
||||||
assert (!newCreatepResponse.ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
// create partition, tag name existed
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_create_partition_tag_name_existed(MilvusClient client, String tableName) {
|
|
||||||
String partitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
String tag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition partition = new io.milvus.client.Partition.Builder(tableName, partitionName, tag).build();
|
|
||||||
Response createpResponse = client.createPartition(partition);
|
|
||||||
assert (createpResponse.ok());
|
|
||||||
io.milvus.client.Partition newPartition = new io.milvus.client.Partition.Builder(tableName, partitionName, tag).build();
|
|
||||||
Response newCreatepResponse = client.createPartition(newPartition);
|
|
||||||
assert (!newCreatepResponse.ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------- drop partition cases in ---------------------------------
|
|
||||||
|
|
||||||
// drop a partition created before, drop by partition name
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_drop_partition(MilvusClient client, String tableName) {
|
|
||||||
String partitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
String tag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition partition = new io.milvus.client.Partition.Builder(tableName, partitionName, tag).build();
|
|
||||||
Response createpResponse = client.createPartition(partition);
|
|
||||||
assert (createpResponse.ok());
|
|
||||||
Response response = client.dropPartition(partitionName);
|
|
||||||
assert (response.ok());
|
|
||||||
// show partitions
|
|
||||||
int length = client.showPartitions(tableName).getPartitionList().size();
|
|
||||||
Assert.assertEquals(length, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// drop a partition repeat created before, drop by partition name
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_drop_partition_repeat(MilvusClient client, String tableName) throws InterruptedException {
|
|
||||||
String partitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
String tag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition partition = new io.milvus.client.Partition.Builder(tableName, partitionName, tag).build();
|
|
||||||
Response createpResponse = client.createPartition(partition);
|
|
||||||
assert (createpResponse.ok());
|
|
||||||
Response response = client.dropPartition(partitionName);
|
|
||||||
assert (response.ok());
|
|
||||||
Thread.currentThread().sleep(2000);
|
|
||||||
Response newResponse = client.dropPartition(partitionName);
|
|
||||||
assert (!newResponse.ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
// drop a partition created before, drop by tag
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_drop_partition_with_tag(MilvusClient client, String tableName) {
|
|
||||||
String partitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
String tag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition partition = new io.milvus.client.Partition.Builder(tableName, partitionName, tag).build();
|
|
||||||
Response createpResponse = client.createPartition(partition);
|
|
||||||
assert (createpResponse.ok());
|
|
||||||
Response response = client.dropPartition(tableName, tag);
|
|
||||||
assert (response.ok());
|
|
||||||
// show partitions
|
|
||||||
int length = client.showPartitions(tableName).getPartitionList().size();
|
|
||||||
Assert.assertEquals(length, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// drop a partition not created before
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_drop_partition_not_existed(MilvusClient client, String tableName) {
|
|
||||||
String partitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
String tag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition partition = new io.milvus.client.Partition.Builder(tableName, partitionName, tag).build();
|
|
||||||
Response createpResponse = client.createPartition(partition);
|
|
||||||
assert(createpResponse.ok());
|
|
||||||
String newPartitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
Response response = client.dropPartition(newPartitionName);
|
|
||||||
assert(!response.ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
// drop a partition not created before
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_drop_partition_tag_not_existed(MilvusClient client, String tableName) {
|
|
||||||
String partitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
String tag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition partition = new io.milvus.client.Partition.Builder(tableName, partitionName, tag).build();
|
|
||||||
Response createpResponse = client.createPartition(partition);
|
|
||||||
assert(createpResponse.ok());
|
|
||||||
String newTag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
Response response = client.dropPartition(tableName, newTag);
|
|
||||||
assert(!response.ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------- show partitions cases in ---------------------------------
|
|
||||||
|
|
||||||
// create partition, then show partitions
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_show_partitions(MilvusClient client, String tableName) {
|
|
||||||
String partitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
String tag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition partition = new io.milvus.client.Partition.Builder(tableName, partitionName, tag).build();
|
|
||||||
Response createpResponse = client.createPartition(partition);
|
|
||||||
assert (createpResponse.ok());
|
|
||||||
ShowPartitionsResponse response = client.showPartitions(tableName);
|
|
||||||
assert (response.getResponse().ok());
|
|
||||||
List<String> partitionNames = new ArrayList<>();
|
|
||||||
for (int i=0; i<response.getPartitionList().size(); ++i) {
|
|
||||||
partitionNames.add(response.getPartitionList().get(i).getPartitionName());
|
|
||||||
if (response.getPartitionList().get(i).getPartitionName() == partitionName) {
|
|
||||||
Assert.assertTrue(response.getPartitionList().get(i).getTableName() == tableName);
|
|
||||||
Assert.assertTrue(response.getPartitionList().get(i).getTag() == tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Assert.assertTrue(partitionNames.contains(partitionName));
|
|
||||||
}
|
|
||||||
|
|
||||||
// create multi partition, then show partitions
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_show_partitions_multi(MilvusClient client, String tableName) {
|
|
||||||
String partitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
String tag = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition partition = new io.milvus.client.Partition.Builder(tableName, partitionName, tag).build();
|
|
||||||
Response createpResponse = client.createPartition(partition);
|
|
||||||
assert (createpResponse.ok());
|
|
||||||
String newPartitionName = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
String tagNew = RandomStringUtils.randomAlphabetic(10);
|
|
||||||
io.milvus.client.Partition newPartition = new io.milvus.client.Partition.Builder(tableName, newPartitionName, tagNew).build();
|
|
||||||
Response newCreatepResponse = client.createPartition(newPartition);
|
|
||||||
assert (newCreatepResponse.ok());
|
|
||||||
ShowPartitionsResponse response = client.showPartitions(tableName);
|
|
||||||
assert (response.getResponse().ok());
|
|
||||||
List<String> partitionNames = response.getPartitionNameList();
|
|
||||||
// for (int i=0; i<response.getPartitionList().size(); ++i) {
|
|
||||||
// partitionNames.add(response.getPartitionList().get(i).getPartitionName());
|
|
||||||
// if (response.getPartitionList().get(i).getPartitionName() == newPartitionName) {
|
|
||||||
// Assert.assertTrue(response.getPartitionList().get(i).getTableName() == tableName);
|
|
||||||
// Assert.assertTrue(response.getPartitionList().get(i).getTag() == tagNew);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
System.out.println(partitionNames);
|
|
||||||
Assert.assertTrue(partitionNames.contains(partitionName));
|
|
||||||
Assert.assertTrue(partitionNames.contains(newPartitionName));
|
|
||||||
List<String> tagNames = response.getPartitionTagList();
|
|
||||||
Assert.assertTrue(tagNames.contains(tag));
|
|
||||||
Assert.assertTrue(tagNames.contains(tagNew));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
package com;
|
|
||||||
|
|
||||||
|
|
||||||
import io.milvus.client.*;
|
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TestTable {
|
|
||||||
int index_file_size = 50;
|
|
||||||
int dimension = 128;
|
|
||||||
|
|
||||||
@Test(dataProvider = "ConnectInstance", dataProviderClass = MainClass.class)
|
|
||||||
public void test_create_table(MilvusClient client, String tableName){
|
|
||||||
TableSchema tableSchema = new TableSchema.Builder(tableName, dimension)
|
|
||||||
.withIndexFileSize(index_file_size)
|
|
||||||
.withMetricType(MetricType.L2)
|
|
||||||
.build();
|
|
||||||
Response res = client.createTable(tableSchema);
|
|
||||||
assert(res.ok());
|
|
||||||
Assert.assertEquals(res.ok(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
|
|
||||||
public void test_create_table_disconnect(MilvusClient client, String tableName){
|
|
||||||
TableSchema tableSchema = new TableSchema.Builder(tableName, dimension)
|
|
||||||
.withIndexFileSize(index_file_size)
|
|
||||||
.withMetricType(MetricType.L2)
|
|
||||||
.build();
|
|
||||||
Response res = client.createTable(tableSchema);
|
|
||||||
assert(!res.ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "ConnectInstance", dataProviderClass = MainClass.class)
|
|
||||||
public void test_create_table_repeatably(MilvusClient client, String tableName){
|
|
||||||
TableSchema tableSchema = new TableSchema.Builder(tableName, dimension)
|
|
||||||
.withIndexFileSize(index_file_size)
|
|
||||||
.withMetricType(MetricType.L2)
|
|
||||||
.build();
|
|
||||||
Response res = client.createTable(tableSchema);
|
|
||||||
Assert.assertEquals(res.ok(), true);
|
|
||||||
Response res_new = client.createTable(tableSchema);
|
|
||||||
Assert.assertEquals(res_new.ok(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "ConnectInstance", dataProviderClass = MainClass.class)
|
|
||||||
public void test_create_table_wrong_params(MilvusClient client, String tableName){
|
|
||||||
Integer dimension = 0;
|
|
||||||
TableSchema tableSchema = new TableSchema.Builder(tableName, dimension)
|
|
||||||
.withIndexFileSize(index_file_size)
|
|
||||||
.withMetricType(MetricType.L2)
|
|
||||||
.build();
|
|
||||||
Response res = client.createTable(tableSchema);
|
|
||||||
System.out.println(res.toString());
|
|
||||||
Assert.assertEquals(res.ok(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "ConnectInstance", dataProviderClass = MainClass.class)
|
|
||||||
public void test_show_tables(MilvusClient client, String tableName){
|
|
||||||
Integer tableNum = 10;
|
|
||||||
ShowTablesResponse res = null;
|
|
||||||
for (int i = 0; i < tableNum; ++i) {
|
|
||||||
String tableNameNew = tableName+"_"+Integer.toString(i);
|
|
||||||
TableSchema tableSchema = new TableSchema.Builder(tableNameNew, dimension)
|
|
||||||
.withIndexFileSize(index_file_size)
|
|
||||||
.withMetricType(MetricType.L2)
|
|
||||||
.build();
|
|
||||||
client.createTable(tableSchema);
|
|
||||||
List<String> tableNames = client.showTables().getTableNames();
|
|
||||||
Assert.assertTrue(tableNames.contains(tableNameNew));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
|
|
||||||
public void test_show_tables_without_connect(MilvusClient client, String tableName){
|
|
||||||
ShowTablesResponse res = client.showTables();
|
|
||||||
assert(!res.getResponse().ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_drop_table(MilvusClient client, String tableName) throws InterruptedException {
|
|
||||||
Response res = client.dropTable(tableName);
|
|
||||||
assert(res.ok());
|
|
||||||
Thread.currentThread().sleep(1000);
|
|
||||||
List<String> tableNames = client.showTables().getTableNames();
|
|
||||||
Assert.assertFalse(tableNames.contains(tableName));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_drop_table_not_existed(MilvusClient client, String tableName) throws InterruptedException {
|
|
||||||
Response res = client.dropTable(tableName+"_");
|
|
||||||
assert(!res.ok());
|
|
||||||
List<String> tableNames = client.showTables().getTableNames();
|
|
||||||
Assert.assertTrue(tableNames.contains(tableName));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
|
|
||||||
public void test_drop_table_without_connect(MilvusClient client, String tableName) throws InterruptedException {
|
|
||||||
Response res = client.dropTable(tableName);
|
|
||||||
assert(!res.ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_describe_table(MilvusClient client, String tableName) throws InterruptedException {
|
|
||||||
DescribeTableResponse res = client.describeTable(tableName);
|
|
||||||
assert(res.getResponse().ok());
|
|
||||||
TableSchema tableSchema = res.getTableSchema().get();
|
|
||||||
Assert.assertEquals(tableSchema.getDimension(), dimension);
|
|
||||||
Assert.assertEquals(tableSchema.getTableName(), tableName);
|
|
||||||
Assert.assertEquals(tableSchema.getIndexFileSize(), index_file_size);
|
|
||||||
Assert.assertEquals(tableSchema.getMetricType().name(), tableName.substring(0,2));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
|
|
||||||
public void test_describe_table_without_connect(MilvusClient client, String tableName) throws InterruptedException {
|
|
||||||
DescribeTableResponse res = client.describeTable(tableName);
|
|
||||||
assert(!res.getResponse().ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_has_table_not_existed(MilvusClient client, String tableName) throws InterruptedException {
|
|
||||||
HasTableResponse res = client.hasTable(tableName+"_");
|
|
||||||
assert(res.getResponse().ok());
|
|
||||||
Assert.assertFalse(res.hasTable());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
|
|
||||||
public void test_has_table_without_connect(MilvusClient client, String tableName) throws InterruptedException {
|
|
||||||
HasTableResponse res = client.hasTable(tableName);
|
|
||||||
assert(!res.getResponse().ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_has_table(MilvusClient client, String tableName) throws InterruptedException {
|
|
||||||
HasTableResponse res = client.hasTable(tableName);
|
|
||||||
assert(res.getResponse().ok());
|
|
||||||
Assert.assertTrue(res.hasTable());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package com;
|
|
||||||
|
|
||||||
import io.milvus.client.*;
|
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class TestTableCount {
|
|
||||||
int index_file_size = 50;
|
|
||||||
int dimension = 128;
|
|
||||||
|
|
||||||
public List<List<Float>> gen_vectors(Integer nb) {
|
|
||||||
List<List<Float>> xb = new ArrayList<>();
|
|
||||||
Random random = new Random();
|
|
||||||
for (int i = 0; i < nb; ++i) {
|
|
||||||
ArrayList<Float> vector = new ArrayList<>();
|
|
||||||
for (int j = 0; j < dimension; j++) {
|
|
||||||
vector.add(random.nextFloat());
|
|
||||||
}
|
|
||||||
xb.add(vector);
|
|
||||||
}
|
|
||||||
return xb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_table_count_no_vectors(MilvusClient client, String tableName) {
|
|
||||||
Assert.assertEquals(client.getTableRowCount(tableName).getTableRowCount(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_table_count_table_not_existed(MilvusClient client, String tableName) {
|
|
||||||
GetTableRowCountResponse res = client.getTableRowCount(tableName+"_");
|
|
||||||
assert(!res.getResponse().ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
|
|
||||||
public void test_table_count_without_connect(MilvusClient client, String tableName) {
|
|
||||||
GetTableRowCountResponse res = client.getTableRowCount(tableName+"_");
|
|
||||||
assert(!res.getResponse().ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_table_count(MilvusClient client, String tableName) throws InterruptedException {
|
|
||||||
int nb = 10000;
|
|
||||||
List<List<Float>> vectors = gen_vectors(nb);
|
|
||||||
// Add vectors
|
|
||||||
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();;
|
|
||||||
client.insert(insertParam);
|
|
||||||
Thread.currentThread().sleep(2000);
|
|
||||||
Assert.assertEquals(client.getTableRowCount(tableName).getTableRowCount(), nb);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
|
|
||||||
public void test_table_count_multi_tables(MilvusClient client, String tableName) throws InterruptedException {
|
|
||||||
int nb = 10000;
|
|
||||||
List<List<Float>> vectors = gen_vectors(nb);
|
|
||||||
Integer tableNum = 10;
|
|
||||||
GetTableRowCountResponse res = null;
|
|
||||||
for (int i = 0; i < tableNum; ++i) {
|
|
||||||
String tableNameNew = tableName + "_" + Integer.toString(i);
|
|
||||||
TableSchema tableSchema = new TableSchema.Builder(tableNameNew, dimension)
|
|
||||||
.withIndexFileSize(index_file_size)
|
|
||||||
.withMetricType(MetricType.L2)
|
|
||||||
.build();
|
|
||||||
client.createTable(tableSchema);
|
|
||||||
// Add vectors
|
|
||||||
InsertParam insertParam = new InsertParam.Builder(tableNameNew, vectors).build();
|
|
||||||
client.insert(insertParam);
|
|
||||||
}
|
|
||||||
Thread.currentThread().sleep(1000);
|
|
||||||
for (int i = 0; i < tableNum; ++i) {
|
|
||||||
String tableNameNew = tableName + "_" + Integer.toString(i);
|
|
||||||
res = client.getTableRowCount(tableNameNew);
|
|
||||||
Assert.assertEquals(res.getTableRowCount(), nb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user