提交 9c88a0f6 编写于 作者: Z zhenwu

Update README.md #27


Former-commit-id: a4d2ec9865156f922eafb592446fc5ccdb1abc6a
上级 fc2dc648
# Requirements
- jdk-1.8
- testng
# How to use this Test Project
1. package and install
```shell
mvn clean install
```
2. start or deploy your milvus server
3. run tests
```shell
java -cp \"target/MilvusSDkJavaTest-1.0-SNAPSHOT.jar:lib/*\" com.MainClass -h 127.0.0.1
```
4. get test report
```shell
firefox test-output/index.html
```
# Contribution getting started
Add test cases under testng framework
\ No newline at end of file
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
<dependency> <dependency>
<groupId>io.milvus</groupId> <groupId>io.milvus</groupId>
<artifactId>milvus-sdk-java</artifactId> <artifactId>milvus-sdk-java</artifactId>
<version>0.1.1-SNAPSHOT</version> <version>0.1.2-SNAPSHOT</version>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
...@@ -134,4 +134,4 @@ ...@@ -134,4 +134,4 @@
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -33,7 +33,7 @@ public class MainClass { ...@@ -33,7 +33,7 @@ public class MainClass {
} }
@DataProvider(name="ConnectInstance") @DataProvider(name="ConnectInstance")
public Object[][] connectInstance(){ public Object[][] connectInstance() throws ConnectFailedException {
MilvusClient client = new MilvusGrpcClient(); MilvusClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder() ConnectParam connectParam = new ConnectParam.Builder()
.withHost(host) .withHost(host)
...@@ -45,7 +45,7 @@ public class MainClass { ...@@ -45,7 +45,7 @@ public class MainClass {
} }
@DataProvider(name="DisConnectInstance") @DataProvider(name="DisConnectInstance")
public Object[][] disConnectInstance(){ public Object[][] disConnectInstance() throws ConnectFailedException {
// Generate connection instance // Generate connection instance
MilvusClient client = new MilvusGrpcClient(); MilvusClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder() ConnectParam connectParam = new ConnectParam.Builder()
...@@ -63,7 +63,7 @@ public class MainClass { ...@@ -63,7 +63,7 @@ public class MainClass {
} }
@DataProvider(name="Table") @DataProvider(name="Table")
public Object[][] provideTable(){ public Object[][] provideTable() throws ConnectFailedException {
Object[][] tables = new Object[2][2]; Object[][] tables = new Object[2][2];
MetricType metricTypes[] = { MetricType.L2, MetricType.IP }; MetricType metricTypes[] = { MetricType.L2, MetricType.IP };
for (Integer i = 0; i < metricTypes.length; ++i) { for (Integer i = 0; i < metricTypes.length; ++i) {
......
package com; package com;
import io.milvus.client.ConnectParam; import io.milvus.client.*;
import io.milvus.client.MilvusClient; import org.testng.Assert;
import io.milvus.client.MilvusGrpcClient;
import io.milvus.client.Response;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
public class TestConnect { public class TestConnect {
@Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class) @Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class)
public void test_connect(String host, String port){ public void test_connect(String host, String port) throws ConnectFailedException {
System.out.println("Host: "+host+", Port: "+port); System.out.println("Host: "+host+", Port: "+port);
MilvusClient client = new MilvusGrpcClient(); MilvusClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder() ConnectParam connectParam = new ConnectParam.Builder()
...@@ -18,31 +16,42 @@ public class TestConnect { ...@@ -18,31 +16,42 @@ public class TestConnect {
.build(); .build();
Response res = client.connect(connectParam); Response res = client.connect(connectParam);
assert(res.ok()); assert(res.ok());
assert(client.connected()); assert(client.isConnected());
} }
@Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class) @Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class)
public void test_connect_repeat(String host, String port){ public void test_connect_repeat(String host, String port) {
MilvusGrpcClient client = new MilvusGrpcClient(); MilvusGrpcClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder() ConnectParam connectParam = new ConnectParam.Builder()
.withHost(host) .withHost(host)
.withPort(port) .withPort(port)
.build(); .build();
client.connect(connectParam); Response res = null;
Response res = client.connect(connectParam); try {
assert(!res.ok()); res = client.connect(connectParam);
assert(client.connected()); res = client.connect(connectParam);
} catch (ConnectFailedException e) {
e.printStackTrace();
}
assert (res.ok());
assert(client.isConnected());
} }
@Test(dataProvider="InvalidConnectArgs") @Test(dataProvider="InvalidConnectArgs")
public void test_connect_invalid_connect_args(String ip, String port) throws InterruptedException { public void test_connect_invalid_connect_args(String ip, String port) {
MilvusClient client = new MilvusGrpcClient(); MilvusClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder() ConnectParam connectParam = new ConnectParam.Builder()
.withHost(ip) .withHost(ip)
.withPort(port) .withPort(port)
.build(); .build();
client.connect(connectParam); Response res = null;
assert(!client.connected()); try {
res = client.connect(connectParam);
} catch (ConnectFailedException e) {
e.printStackTrace();
}
Assert.assertEquals(res, null);
assert(!client.isConnected());
} }
// TODO: MS-615 // TODO: MS-615
...@@ -63,18 +72,18 @@ public class TestConnect { ...@@ -63,18 +72,18 @@ public class TestConnect {
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class) @Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_disconnect(MilvusClient client, String tableName){ public void test_disconnect(MilvusClient client, String tableName){
assert(!client.connected()); assert(!client.isConnected());
} }
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class) @Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_disconnect_repeatably(MilvusClient client, String tableNam){ public void test_disconnect_repeatably(MilvusClient client, String tableName){
Response res = null; Response res = null;
try { try {
res = client.disconnect(); res = client.disconnect();
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
assert(res.ok()); assert(!res.ok());
assert(!client.connected()); assert(!client.isConnected());
} }
} }
...@@ -140,7 +140,7 @@ public class TestIndex { ...@@ -140,7 +140,7 @@ public class TestIndex {
@Test(dataProvider = "Table", dataProviderClass = MainClass.class) @Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_create_index_IVFSQ8H(MilvusClient client, String tableName) throws InterruptedException { public void test_create_index_IVFSQ8H(MilvusClient client, String tableName) throws InterruptedException {
IndexType indexType = IndexType.IVF_SQ8_H; IndexType indexType = IndexType.IVF_SQ8H;
List<List<Float>> vectors = gen_vectors(nb); List<List<Float>> vectors = gen_vectors(nb);
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build(); InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
client.insert(insertParam); client.insert(insertParam);
......
...@@ -71,7 +71,7 @@ public class TestMix { ...@@ -71,7 +71,7 @@ public class TestMix {
} }
@Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class) @Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class)
public void test_connect_threads(String host, String port) throws InterruptedException { public void test_connect_threads(String host, String port) throws ConnectFailedException {
int thread_num = 100; int thread_num = 100;
ForkJoinPool executor = new ForkJoinPool(); ForkJoinPool executor = new ForkJoinPool();
for (int i = 0; i < thread_num; i++) { for (int i = 0; i < thread_num; i++) {
...@@ -82,8 +82,12 @@ public class TestMix { ...@@ -82,8 +82,12 @@ public class TestMix {
.withHost(host) .withHost(host)
.withPort(port) .withPort(port)
.build(); .build();
client.connect(connectParam); try {
assert(client.connected()); client.connect(connectParam);
} catch (ConnectFailedException e) {
e.printStackTrace();
}
assert(client.isConnected());
try { try {
client.disconnect(); client.disconnect();
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -182,7 +186,7 @@ public class TestMix { ...@@ -182,7 +186,7 @@ public class TestMix {
} }
@Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class) @Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class)
public void test_create_insert_delete_threads(String host, String port) throws InterruptedException { public void test_create_insert_delete_threads(String host, String port) {
int thread_num = 100; int thread_num = 100;
List<List<Float>> vectors = gen_vectors(nb,false); List<List<Float>> vectors = gen_vectors(nb,false);
ForkJoinPool executor = new ForkJoinPool(); ForkJoinPool executor = new ForkJoinPool();
...@@ -194,7 +198,12 @@ public class TestMix { ...@@ -194,7 +198,12 @@ public class TestMix {
.withHost(host) .withHost(host)
.withPort(port) .withPort(port)
.build(); .build();
client.connect(connectParam); try {
client.connect(connectParam);
} catch (ConnectFailedException e) {
e.printStackTrace();
}
assert(client.isConnected());
String tableName = RandomStringUtils.randomAlphabetic(10); String tableName = RandomStringUtils.randomAlphabetic(10);
TableSchema tableSchema = new TableSchema.Builder(tableName, dimension) TableSchema tableSchema = new TableSchema.Builder(tableName, dimension)
.withIndexFileSize(index_file_size) .withIndexFileSize(index_file_size)
......
package com; package com;
import io.milvus.client.ConnectParam; import io.milvus.client.*;
import io.milvus.client.MilvusClient;
import io.milvus.client.MilvusGrpcClient;
import io.milvus.client.Response;
import org.testng.annotations.Test; import org.testng.annotations.Test;
public class TestPing { public class TestPing {
@Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class) @Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class)
public void test_server_status(String host, String port){ public void test_server_status(String host, String port) throws ConnectFailedException {
System.out.println("Host: "+host+", Port: "+port); System.out.println("Host: "+host+", Port: "+port);
MilvusClient client = new MilvusGrpcClient(); MilvusClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder() ConnectParam connectParam = new ConnectParam.Builder()
...@@ -16,13 +13,13 @@ public class TestPing { ...@@ -16,13 +13,13 @@ public class TestPing {
.withPort(port) .withPort(port)
.build(); .build();
client.connect(connectParam); client.connect(connectParam);
Response res = client.serverStatus(); Response res = client.getServerStatus();
assert (res.ok()); assert (res.ok());
} }
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class) @Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_server_status_without_connected(MilvusGrpcClient client, String tableName){ public void test_server_status_without_connected(MilvusGrpcClient client, String tableName){
Response res = client.serverStatus(); Response res = client.getServerStatus();
assert (!res.ok()); assert (!res.ok());
} }
} }
\ No newline at end of file
# Requirements
- python 3.6+
- pip install -r requirements.txt
# How to use this Test Project
This project is used to test search accuracy based on the given datasets (https://github.com/erikbern/ann-benchmarks#data-sets)
1. start your milvus server
2. update your test configuration in test.py
3. run command
```shell
python test.py
```
# Contribution getting started
- Follow PEP-8 for naming and black for formatting.
numpy==1.16.3
pymilvus>=0.2.0
scikit-learn==0.19.1
h5py==2.7.1
# Quick start # Requirements
## 运行 - python 3.6+
- pip install -r requirements.txt
### 运行示例: # How to use this Test Project
`python3 main.py --image=registry.zilliz.com/milvus/engine:branch-0.3.1-release --run-count=2 --run-type=performance` This project is used to test performance / accuracy / stability of milvus server
### 运行参数: 1. update your test configuration in suites_*.yaml
2. run command
--image: 容器模式,传入镜像名称,如传入,则运行测试时,会先进行pull image,基于image生成milvus server容器 ```shell
### docker mode:
python main.py --image=milvusdb/milvus:latest --run-count=2 --run-type=performance
--local: 与image参数互斥,本地模式,连接使用本地启动的milvus server进行测试 ### local mode:
python main.py --local --run-count=2 --run-type=performance --ip=127.0.0.1 --port=19530
```
--run-count: 重复运行次数 # Contribution getting started
--suites: 测试集配置文件,默认使用suites.yaml - Follow PEP-8 for naming and black for formatting.
\ No newline at end of file
--run-type: 测试类型,包括性能--performance、准确性测试--accuracy以及稳定性--stability
### 测试集配置文件:
`operations:
insert:
​ [
​ {"table.index_type": "ivf_flat", "server.index_building_threshold": 300, "table.size": 2000000, "table.ni": 100000, "table.dim": 512},
​ ]
build: []
query:
​ [
​ {"dataset": "ip_ivfsq8_1000", "top_ks": [10], "nqs": [10, 100], "server.nprobe": 1, "server.use_blas_threshold": 800},
​ {"dataset": "ip_ivfsq8_1000", "top_ks": [10], "nqs": [10, 100], "server.nprobe": 10, "server.use_blas_threshold": 20},
​ ]`
## 测试结果:
性能:
`INFO:milvus_benchmark.runner:Start warm query, query params: top-k: 1, nq: 1
INFO:milvus_benchmark.client:query run in 19.19s
INFO:milvus_benchmark.runner:Start query, query params: top-k: 64, nq: 10, actually length of vectors: 10
INFO:milvus_benchmark.runner:Start run query, run 1 of 1
INFO:milvus_benchmark.client:query run in 0.2s
INFO:milvus_benchmark.runner:Avarage query time: 0.20
INFO:milvus_benchmark.runner:[[0.2]]`
**│ 10 │ 0.2 │**
准确率:
`INFO:milvus_benchmark.runner:Avarage accuracy: 1.0`
\ No newline at end of file
# Requirements # Requirements
* python 3.6.8 * python 3.6.8+
* pip install -r requirements.txt
# How to use this Test Project # How to use this Test Project
```shell ```shell
pytest . -q -v pytest . --level=1
``` ```
or test connect function only
```shell
pytest test_connect.py --level=1
```
with allure test report with allure test report
```shell ```shell
pytest --alluredir=test_out . -q -v pytest --alluredir=test_out . -q -v
allure serve test_out allure serve test_out
``` ```
# Contribution getting started # Contribution getting started
* Follow PEP-8 for naming and black for formatting. * Follow PEP-8 for naming and black for formatting.
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册