基于 pytest 编写的 pymilvus-orm 的测试框架。
测试代码:https://github.com/milvus-io/milvus/tree/master/tests/python_client
Milvus 支持4种部署方式,请根据需求选择部署方式,pymilvus_orm 支持任意部署下的 Milvus。
KinD部署提供一键安装部署:最新的Milvus服务和测试客户端。KinD部署非常适合开发/调试测试用例,功能验证等对数据规模要求不大的场景,但并不适合性能或压力等有较大数据规模的场景。
./e2e-k8s.sh
note:默认参数下KinD环境将在执行完测试用例后被自动清理
./e2e-k8s.sh --skip-cleanup
./e2e-k8s.sh --skip-cleanup --skip-test --manual
Note:需要log in到测试客户端的container进行手动执行或调试测试用例
./e2e-k8s.sh --help
kind export logs .
推荐使用 Python 3(>= 3.6) ,与 pymilvus_orm 支持的 python 版本保持一致。
Note: 如选择KinD部署方式,以下步骤可以自动完成。
pip install -r requirements.txt
export CI_LOG_PATH=/tmp/ci_logs/test/
| Log Level | Log File |
|---|---|
| Debug | ci_test_log.debug |
| Info | ci_test_log.log |
| Error | ci_test_log.err |
addopts = --host *.*.*.* --html=/tmp/ci_logs/report.html
python3 -W ignore -m pytest <选择的测试文件>
模块调用关系图

可参考添加新的测试用例或框架工具。
test类:每一个 test 文件中分两个类
TestObjectParams :
TestObjectOperations:
testcase 命名
TestObjectParams 类
TestObjectOperations 类
如当需要创建多个 partition 对象时,可调用方法 self.init_partition_wrap(),该方法返回的结果就是新生成的 partition 对象。当无需创建多个对象时,直接使用 self.partition_wrap 即可
# create partition -Call the default initialization method
partition_w = self.init_partition_wrap()
assert partition_w.is_empty
# create partition -Directly call the encapsulated object
self.partition_wrap.init_partition(collection=collection_name, name=partition_name)
assert self.partition_wrap.is_empty
验证接口返回错误或异常
# create partition with collection is None
self.partition_wrap.init_partition(collection=None, name=partition_name, check_task=CheckTasks.err_res, check_items={ct.err_code: 1, ct.err_msg: "'NoneType' object has no attribute"})
验证接口返回正常返回值
# create partition
partition_w = self.init_partition_wrap(collection_w, partition_name, check_task=CheckTasks.check_partition_property, check_items={"name": partition_name, "description": description, "is_empty": True, "num_entities": 0})
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_dropped_collection(self, partition_name):
"""
target: verify create partition against a dropped collection
method: 1. create collection1
2. drop collection1
3. create partition in collection1
expected: 1. raise exception
"""
# create collection
collection_w = self.init_collection_wrap()
# drop collection
collection_w.drop()
# create partition failed
self.partition_wrap.init_partition(collection_w.collection, partition_name, check_task=CheckTasks.err_res, check_items={ct.err_code: 1, ct.err_msg: "can't find collection"})
Tips
self.connection_wrap = ApiConnectionsWrapper()
self.utility_wrap = ApiUtilityWrapper()
self.collection_wrap = ApiCollectionWrapper()
self.partition_wrap = ApiPartitionWrapper()
self.index_wrap = ApiIndexWrapper()
self.collection_schema_wrap = ApiCollectionSchemaWrapper()
self.field_schema_wrap = ApiFieldSchemaWrapper()
def init_partition(self, collection, name, description="", check_task=None, check_items=None, **kwargs)