Replace pytest-parallel plug-in with pytest-xdist in orm test (#6833)

* add case running progress

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>

* add case progress

change pytest-xdist -n4 to auto

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>

* remove pytest-parallel plug-in

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>

* add pytest -x exitfirst

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>
pull/6834/head
ThreadDao 2021-07-27 16:05:21 +08:00 committed by GitHub
parent 8a1a841011
commit 964af814ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 105 additions and 82 deletions

View File

@ -4,6 +4,7 @@ log_date_format = %Y-%m-%d %H:%M:%S
log_cli = true log_cli = true
log_level = 20 log_level = 20
addopts = -x
timeout = 360 timeout = 360

View File

@ -11,7 +11,7 @@ allure-pytest==2.7.0
pytest-print==0.2.1 pytest-print==0.2.1
pytest-level==0.1.1 pytest-level==0.1.1
pytest-xdist==2.2.1 pytest-xdist==2.2.1
pytest-parallel # pytest-parallel
pymilvus-orm==2.0.0rc3.dev7 pymilvus-orm==2.0.0rc3.dev7
pytest-rerunfailures==9.1.1 pytest-rerunfailures==9.1.1
git+https://github.com/Projectplace/pytest-tags git+https://github.com/Projectplace/pytest-tags
@ -23,3 +23,4 @@ pytest-html==3.1.1
delayed-assert delayed-assert
kubernetes==17.17.0 kubernetes==17.17.0
PyYAML==5.4.1 PyYAML==5.4.1
pytest-sugar==0.9.4

View File

@ -68,10 +68,10 @@ pushd "${ROOT}/tests/docker"
else else
if [[ "${MILVUS_CLIENT}" == "pymilvus" ]]; then if [[ "${MILVUS_CLIENT}" == "pymilvus" ]]; then
export MILVUS_PYTEST_WORKSPACE="/milvus/tests/python_test" export MILVUS_PYTEST_WORKSPACE="/milvus/tests/python_test"
docker-compose run --rm pytest /bin/bash -c "pytest -n ${PARALLEL_NUM} --ip ${MILVUS_SERVICE_IP} --port ${MILVUS_SERVICE_PORT} ${@:-}" docker-compose run --rm pytest /bin/bash -c "pytest -n auto --ip ${MILVUS_SERVICE_IP} --port ${MILVUS_SERVICE_PORT} ${@:-}"
elif [[ "${MILVUS_CLIENT}" == "pymilvus-orm" ]]; then elif [[ "${MILVUS_CLIENT}" == "pymilvus-orm" ]]; then
export MILVUS_PYTEST_WORKSPACE="/milvus/tests20/python_client" export MILVUS_PYTEST_WORKSPACE="/milvus/tests20/python_client"
docker-compose run --rm pytest /bin/bash -c "pytest --workers ${PARALLEL_NUM} --host ${MILVUS_SERVICE_IP} --port ${MILVUS_SERVICE_PORT} \ docker-compose run --rm pytest /bin/bash -c "pytest -n auto --host ${MILVUS_SERVICE_IP} --port ${MILVUS_SERVICE_PORT} \
--html=\${CI_LOG_PATH}/report.html --self-contained-html ${@:-}" --html=\${CI_LOG_PATH}/report.html --self-contained-html ${@:-}"
fi fi
fi fi

View File

@ -1,7 +1,7 @@
[pytest] [pytest]
addopts = --host 10.98.0.7 --html=/tmp/ci_logs/report.html --self-contained-html -v addopts = --host 10.98.0.7 --html=/tmp/ci_logs/report.html --self-contained-html -v -x
# -;addopts = --host 172.28.255.155 --html=/tmp/report.html # -;addopts = --host 172.28.255.155 --html=/tmp/report.html
# python3 -W ignore -m pytest # python3 -W ignore -m pytest

View File

@ -11,7 +11,7 @@ allure-pytest==2.7.0
pytest-print==0.2.1 pytest-print==0.2.1
pytest-level==0.1.1 pytest-level==0.1.1
pytest-xdist==2.2.1 pytest-xdist==2.2.1
pytest-parallel # pytest-parallel
pymilvus-orm==2.0.0rc3.dev7 pymilvus-orm==2.0.0rc3.dev7
pytest-rerunfailures==9.1.1 pytest-rerunfailures==9.1.1
git+https://github.com/Projectplace/pytest-tags git+https://github.com/Projectplace/pytest-tags
@ -23,3 +23,4 @@ pytest-html==3.1.1
delayed-assert delayed-assert
kubernetes==17.17.0 kubernetes==17.17.0
PyYAML==5.4.1 PyYAML==5.4.1
pytest-sugar==0.9.4

View File

@ -410,7 +410,7 @@ class TestConnectionOperation(TestcaseBase):
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
check_items={ct.dict_content: {'host': "host", 'port': port}}) check_items={ct.dict_content: {'host': "host", 'port': port}})
@ pytest.mark.tags(ct.CaseLabel.L0) @pytest.mark.tags(ct.CaseLabel.L0)
def test_connection_connect_default_alias_effective(self, host, port): def test_connection_connect_default_alias_effective(self, host, port):
""" """
target: connect passes useful configure that adds by add_connect target: connect passes useful configure that adds by add_connect
@ -427,7 +427,7 @@ class TestConnectionOperation(TestcaseBase):
# list all connections and check the response # list all connections and check the response
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr, self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING,
ct.Connect_Object_Name)]}) ct.Connect_Object_Name)]})
# get all addr of alias and check the response # get all addr of alias and check the response
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
@ -485,7 +485,7 @@ class TestConnectionOperation(TestcaseBase):
check_items={ct.value_content: ct.Connect_Object_Name}) check_items={ct.value_content: ct.Connect_Object_Name})
# list all connections and check the response # list all connections and check the response
list_content = [(connect_name, ct.Connect_Object_Name)] if connect_name is DefaultConfig.DEFAULT_USING else\ list_content = [(connect_name, ct.Connect_Object_Name)] if connect_name is DefaultConfig.DEFAULT_USING else \
[(DefaultConfig.DEFAULT_USING, None), (connect_name, ct.Connect_Object_Name)] [(DefaultConfig.DEFAULT_USING, None), (connect_name, ct.Connect_Object_Name)]
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr, self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
check_items={ct.list_content: list_content}) check_items={ct.list_content: list_content})
@ -596,7 +596,8 @@ class TestConnectionOperation(TestcaseBase):
# list all connections and check the response # list all connections and check the response
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr, self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None), check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None),
(test_alias_name, ct.Connect_Object_Name)]}) (
test_alias_name, ct.Connect_Object_Name)]})
# get all addr of alias and check the response # get all addr of alias and check the response
self.connection_wrap.get_connection_addr(alias=test_alias_name, check_task=ct.CheckTasks.ccr, self.connection_wrap.get_connection_addr(alias=test_alias_name, check_task=ct.CheckTasks.ccr,
@ -692,9 +693,9 @@ class TestConnectionOperation(TestcaseBase):
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr, check_items={ct.list_content: list_content}) self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr, check_items={ct.list_content: list_content})
@pytest.mark.tags(ct.CaseLabel.L1) @pytest.mark.tags(ct.CaseLabel.L1)
@pytest.mark.parametrize("collection_name, schema", [(cf.gen_unique_str('connection_test_'), # @pytest.mark.parametrize("collection_name, schema", [(cf.gen_unique_str('connection_test_'),
cf.gen_default_collection_schema())]) # cf.gen_default_collection_schema())])
def test_connection_init_collection_invalid_connection(self, collection_name, schema): def test_connection_init_collection_invalid_connection(self):
""" """
target: create collection with invalid connection target: create collection with invalid connection
method: init collection with invalid connection method: init collection with invalid connection
@ -702,15 +703,17 @@ class TestConnectionOperation(TestcaseBase):
""" """
# init collection failed # init collection failed
collection_name = cf.gen_unique_str('connection_test_')
schema = cf.gen_default_collection_schema()
self.collection_wrap.init_collection(name=collection_name, schema=schema, check_task=ct.CheckTasks.err_res, self.collection_wrap.init_collection(name=collection_name, schema=schema, check_task=ct.CheckTasks.err_res,
check_items={ct.err_code: 0, check_items={ct.err_code: 0,
ct.err_msg: cem.ConnectFirst}, ct.err_msg: cem.ConnectFirst},
_using=ct.Not_Exist) _using=ct.Not_Exist)
@pytest.mark.tags(ct.CaseLabel.L1) @pytest.mark.tags(ct.CaseLabel.L1)
@pytest.mark.parametrize("collection_name, schema", [(cf.gen_unique_str('connection_test_'), # @pytest.mark.parametrize("collection_name, schema", [(cf.gen_unique_str('connection_test_'),
cf.gen_default_collection_schema())]) # cf.gen_default_collection_schema())])
def test_connection_init_collection_connection(self, collection_name, schema, host, port): def test_connection_init_collection_connection(self, host, port):
""" """
target: create collection then disconnection target: create collection then disconnection
method: connection, init collection, then disconnection method: connection, init collection, then disconnection
@ -722,6 +725,8 @@ class TestConnectionOperation(TestcaseBase):
check_task=ct.CheckTasks.ccr) check_task=ct.CheckTasks.ccr)
# init collection successfully # init collection successfully
collection_name = cf.gen_unique_str('connection_test_')
schema = cf.gen_default_collection_schema()
self.collection_wrap.init_collection(name=collection_name, schema=schema, _using=DefaultConfig.DEFAULT_USING) self.collection_wrap.init_collection(name=collection_name, schema=schema, _using=DefaultConfig.DEFAULT_USING)
# remove connection # remove connection

View File

@ -12,10 +12,11 @@ prefix = "e2e_"
class TestE2e(TestcaseBase): class TestE2e(TestcaseBase):
""" Test case of end to end""" """ Test case of end to end"""
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
@pytest.mark.parametrize("name", [(cf.gen_unique_str(prefix))]) # @pytest.mark.parametrize("name", [(cf.gen_unique_str(prefix))])
def test_milvus_default(self, name): def test_milvus_default(self):
from utils.util_log import test_log as log from utils.util_log import test_log as log
# create # create
name = cf.gen_unique_str(prefix)
t0 = datetime.datetime.now() t0 = datetime.datetime.now()
collection_w = self.init_collection_wrap(name=name) collection_w = self.init_collection_wrap(name=name)
tt = datetime.datetime.now() - t0 tt = datetime.datetime.now() - t0

View File

@ -15,9 +15,9 @@ class TestPartitionParams(TestcaseBase):
""" Test case of partition interface in parameters""" """ Test case of partition interface in parameters"""
@pytest.mark.tags(CaseLabel.L0) @pytest.mark.tags(CaseLabel.L0)
@pytest.mark.parametrize("partition_name, description", # @pytest.mark.parametrize("partition_name, description",
[(cf.gen_unique_str(prefix), cf.gen_unique_str("desc_"))]) # [(cf.gen_unique_str(prefix), cf.gen_unique_str("desc_"))])
def test_partition_default(self, partition_name, description): def test_partition_default(self):
""" """
target: verify create a partition target: verify create a partition
method: 1. create a partition method: 1. create a partition
@ -27,6 +27,8 @@ class TestPartitionParams(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create partition # create partition
partition_name = cf.gen_unique_str(prefix)
description = cf.gen_unique_str("desc_")
self.init_partition_wrap(collection_w, partition_name, self.init_partition_wrap(collection_w, partition_name,
description=description, description=description,
check_task=CheckTasks.check_partition_property, check_task=CheckTasks.check_partition_property,
@ -55,8 +57,8 @@ class TestPartitionParams(TestcaseBase):
check_items={ct.err_code: 1, ct.err_msg: "Partition name should not be empty"}) check_items={ct.err_code: 1, ct.err_msg: "Partition name should not be empty"})
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name, description", [(cf.gen_unique_str(prefix), "")]) # @pytest.mark.parametrize("partition_name, description", [(cf.gen_unique_str(prefix), "")])
def test_partition_empty_description(self, partition_name, description): def test_partition_empty_description(self):
""" """
target: verify create a partition with empty description target: verify create a partition with empty description
method: 1. create a partition with empty description method: 1. create a partition with empty description
@ -66,6 +68,8 @@ class TestPartitionParams(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# init partition # init partition
partition_name = cf.gen_unique_str(prefix)
description = ""
self.init_partition_wrap(collection_w, partition_name, self.init_partition_wrap(collection_w, partition_name,
description=description, description=description,
check_task=CheckTasks.check_partition_property, check_task=CheckTasks.check_partition_property,
@ -77,9 +81,9 @@ class TestPartitionParams(TestcaseBase):
assert collection_w.has_partition(partition_name)[0] assert collection_w.has_partition(partition_name)[0]
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name, description", # @pytest.mark.parametrize("partition_name, description",
[(cf.gen_str_by_length(255), cf.gen_str_by_length(2048))]) # [(cf.gen_str_by_length(255), cf.gen_str_by_length(2048))])
def test_partition_max_description_length(self, partition_name, description): def test_partition_max_description_length(self):
""" """
target: verify create a partition with 255 length name and 1024 length description target: verify create a partition with 255 length name and 1024 length description
method: 1. create a partition with 255 length name and 1024 length description method: 1. create a partition with 255 length name and 1024 length description
@ -89,6 +93,8 @@ class TestPartitionParams(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# init partition # init partition
partition_name = cf.gen_str_by_length(255)
description = cf.gen_str_by_length(2048)
self.init_partition_wrap(collection_w, partition_name, self.init_partition_wrap(collection_w, partition_name,
description=description, description=description,
check_task=CheckTasks.check_partition_property, check_task=CheckTasks.check_partition_property,
@ -97,9 +103,9 @@ class TestPartitionParams(TestcaseBase):
) )
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("collection_name, partition_name, description", # @pytest.mark.parametrize("collection_name, partition_name, description",
[(cf.gen_unique_str(), cf.gen_unique_str(prefix), cf.gen_unique_str())]) # [(cf.gen_unique_str(), cf.gen_unique_str(prefix), cf.gen_unique_str())])
def test_partition_dup_name(self, collection_name, partition_name, description): def test_partition_dup_name(self):
""" """
target: verify create partitions with duplicate name target: verify create partitions with duplicate name
method: 1. create partitions with duplicate name method: 1. create partitions with duplicate name
@ -110,6 +116,8 @@ class TestPartitionParams(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create two partitions # create two partitions
partition_name = cf.gen_unique_str(prefix)
description = cf.gen_unique_str()
partition_w1 = self.init_partition_wrap(collection_w, partition_name, description) partition_w1 = self.init_partition_wrap(collection_w, partition_name, description)
partition_w2 = self.init_partition_wrap(collection_w, partition_name, description) partition_w2 = self.init_partition_wrap(collection_w, partition_name, description)
@ -120,8 +128,8 @@ class TestPartitionParams(TestcaseBase):
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("description", ct.get_invalid_strs) @pytest.mark.parametrize("description", ct.get_invalid_strs)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_special_chars_description(self, partition_name, description): def test_partition_special_chars_description(self, description):
""" """
target: verify create a partition with special characters in description target: verify create a partition with special characters in description
method: 1. create a partition with special characters in description method: 1. create a partition with special characters in description
@ -131,6 +139,7 @@ class TestPartitionParams(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create partition # create partition
partition_name = cf.gen_unique_str(prefix)
self.init_partition_wrap(collection_w, partition_name, self.init_partition_wrap(collection_w, partition_name,
description=description, description=description,
check_task=CheckTasks.check_partition_property, check_task=CheckTasks.check_partition_property,
@ -161,8 +170,8 @@ class TestPartitionParams(TestcaseBase):
assert collection.name == partition_w.name assert collection.name == partition_w.name
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name", [cf.gen_str_by_length(256)]) # @pytest.mark.parametrize("partition_name", [cf.gen_str_by_length(256)])
def test_partition_maxlength_name(self, partition_name): def test_partition_maxlength_name(self):
""" """
target: verify create a partition with maxlength(256) name target: verify create a partition with maxlength(256) name
method: 1. create a partition with max length names method: 1. create a partition with max length names
@ -172,6 +181,7 @@ class TestPartitionParams(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create partition # create partition
partition_name = cf.gen_str_by_length(256)
self.partition_wrap.init_partition(collection_w.collection, partition_name, self.partition_wrap.init_partition(collection_w.collection, partition_name,
check_task=CheckTasks.err_res, check_task=CheckTasks.err_res,
check_items={ct.err_code: 1, 'err_msg': "is illegal"} check_items={ct.err_code: 1, 'err_msg': "is illegal"}
@ -196,22 +206,23 @@ class TestPartitionParams(TestcaseBase):
# TODO: need an error code issue #5144 and assert independently # TODO: need an error code issue #5144 and assert independently
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_none_collection(self, partition_name): def test_partition_none_collection(self):
""" """
target: verify create a partition with none collection target: verify create a partition with none collection
method: 1. create a partition with none collection method: 1. create a partition with none collection
expected: 1. raise exception expected: 1. raise exception
""" """
# create partition with collection is None # create partition with collection is None
partition_name = cf.gen_unique_str(prefix)
self.partition_wrap.init_partition(collection=None, name=partition_name, self.partition_wrap.init_partition(collection=None, name=partition_name,
check_task=CheckTasks.err_res, check_task=CheckTasks.err_res,
check_items={ct.err_code: 1, check_items={ct.err_code: 1,
ct.err_msg: "must be pymilvus_orm.Collection"}) ct.err_msg: "must be pymilvus_orm.Collection"})
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_drop(self, partition_name): def test_partition_drop(self):
""" """
target: verify drop a partition in one collection target: verify drop a partition in one collection
method: 1. create a partition in one collection method: 1. create a partition in one collection
@ -222,6 +233,7 @@ class TestPartitionParams(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create partition # create partition
partition_name = cf.gen_unique_str(prefix)
partition_w = self.init_partition_wrap(collection_w, partition_name) partition_w = self.init_partition_wrap(collection_w, partition_name)
# check that the partition exists # check that the partition exists
@ -234,8 +246,8 @@ class TestPartitionParams(TestcaseBase):
assert not collection_w.has_partition(partition_name)[0] assert not collection_w.has_partition(partition_name)[0]
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("search_vectors", [cf.gen_vectors(1, ct.default_dim)]) # @pytest.mark.parametrize("search_vectors", [cf.gen_vectors(1, ct.default_dim)])
def test_partition_release(self, search_vectors): def test_partition_release(self):
""" """
target: verify release partition target: verify release partition
method: 1. create a collection and several partitions method: 1. create a collection and several partitions
@ -262,6 +274,7 @@ class TestPartitionParams(TestcaseBase):
partition_w2.load() partition_w2.load()
# search two partitions # search two partitions
search_vectors = cf.gen_vectors(1, ct.default_dim)
res1, _ = partition_w1.search(data=search_vectors, res1, _ = partition_w1.search(data=search_vectors,
anns_field=ct.default_float_vec_field_name, anns_field=ct.default_float_vec_field_name,
params={"nprobe": 32}, limit=1) params={"nprobe": 32}, limit=1)
@ -285,11 +298,11 @@ class TestPartitionParams(TestcaseBase):
assert len(res2) == 1 assert len(res2) == 1
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
@pytest.mark.parametrize("data", [cf.gen_default_dataframe_data(10), @pytest.mark.parametrize("data", [cf.gen_default_dataframe_data(10),
cf.gen_default_list_data(10), cf.gen_default_list_data(10),
cf.gen_default_tuple_data(10)]) cf.gen_default_tuple_data(10)])
def test_partition_insert(self, partition_name, data): def test_partition_insert(self, data):
""" """
target: verify insert multi entities by dataFrame target: verify insert multi entities by dataFrame
method: 1. create a collection and a partition method: 1. create a collection and a partition
@ -302,6 +315,7 @@ class TestPartitionParams(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create partition # create partition
partition_name = cf.gen_unique_str(prefix)
partition_w = self.init_partition_wrap(collection_w, partition_name, partition_w = self.init_partition_wrap(collection_w, partition_name,
check_task=CheckTasks.check_partition_property, check_task=CheckTasks.check_partition_property,
check_items={"name": partition_name, check_items={"name": partition_name,
@ -325,8 +339,8 @@ class TestPartitionOperations(TestcaseBase):
""" Test case of partition interface in operations """ """ Test case of partition interface in operations """
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_dropped_collection(self, partition_name): def test_partition_dropped_collection(self):
""" """
target: verify create partition against a dropped collection target: verify create partition against a dropped collection
method: 1. create collection1 method: 1. create collection1
@ -341,13 +355,13 @@ class TestPartitionOperations(TestcaseBase):
collection_w.drop() collection_w.drop()
# create partition failed # create partition failed
self.partition_wrap.init_partition(collection_w.collection, partition_name, self.partition_wrap.init_partition(collection_w.collection, cf.gen_unique_str(prefix),
check_task=CheckTasks.err_res, check_task=CheckTasks.err_res,
check_items={ct.err_code: 1, ct.err_msg: "can't find collection"}) check_items={ct.err_code: 1, ct.err_msg: "can't find collection"})
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_same_name_in_diff_collections(self, partition_name): def test_partition_same_name_in_diff_collections(self):
""" """
target: verify create partitions with same name in diff collections target: verify create partitions with same name in diff collections
method: 1. create a partition in collection1 method: 1. create a partition in collection1
@ -359,6 +373,7 @@ class TestPartitionOperations(TestcaseBase):
collection_w2 = self.init_collection_wrap() collection_w2 = self.init_collection_wrap()
# create 2 partitions in 2 diff collections # create 2 partitions in 2 diff collections
partition_name = cf.gen_unique_str(prefix)
self.init_partition_wrap(collection_wrap=collection_w1, name=partition_name) self.init_partition_wrap(collection_wrap=collection_w1, name=partition_name)
self.init_partition_wrap(collection_wrap=collection_w2, name=partition_name) self.init_partition_wrap(collection_wrap=collection_w2, name=partition_name)
@ -434,8 +449,8 @@ class TestPartitionOperations(TestcaseBase):
check_items={ct.err_code: 1, ct.err_msg: "default partition cannot be deleted"}) check_items={ct.err_code: 1, ct.err_msg: "default partition cannot be deleted"})
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_drop_partition_twice(self, partition_name): def test_partition_drop_partition_twice(self):
""" """
target: verify drop the same partition twice target: verify drop the same partition twice
method: 1.create a partition with default schema method: 1.create a partition with default schema
@ -447,6 +462,7 @@ class TestPartitionOperations(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create partition # create partition
partition_name = cf.gen_unique_str(prefix)
partition_w = self.init_partition_wrap(collection_w, partition_name) partition_w = self.init_partition_wrap(collection_w, partition_name)
collection_w.has_partition(partition_name) collection_w.has_partition(partition_name)
@ -459,8 +475,8 @@ class TestPartitionOperations(TestcaseBase):
check_items={ct.err_code: 1, ct.err_msg: PartitionErrorMessage.PartitionNotExist}) check_items={ct.err_code: 1, ct.err_msg: PartitionErrorMessage.PartitionNotExist})
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_create_and_drop_multi_times(self, partition_name): def test_partition_create_and_drop_multi_times(self):
""" """
target: verify create and drop for times target: verify create and drop for times
method: 1.create a partition with default schema method: 1.create a partition with default schema
@ -472,6 +488,7 @@ class TestPartitionOperations(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# range for 5 times # range for 5 times
partition_name = cf.gen_unique_str(prefix)
for i in range(5): for i in range(5):
# create partition and check that the partition exists # create partition and check that the partition exists
partition_w = self.init_partition_wrap(collection_w, partition_name) partition_w = self.init_partition_wrap(collection_w, partition_name)
@ -483,8 +500,8 @@ class TestPartitionOperations(TestcaseBase):
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
# @pytest.mark.parametrize("flush", [True, False]) # @pytest.mark.parametrize("flush", [True, False])
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_drop_non_empty_partition(self, partition_name): def test_partition_drop_non_empty_partition(self):
""" """
target: verify drop a partition which has data inserted target: verify drop a partition which has data inserted
method: 1.create a partition with default schema method: 1.create a partition with default schema
@ -497,6 +514,7 @@ class TestPartitionOperations(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create partition # create partition
partition_name = cf.gen_unique_str(prefix)
partition_w = self.init_partition_wrap(collection_w, partition_name) partition_w = self.init_partition_wrap(collection_w, partition_name)
assert collection_w.has_partition(partition_name)[0] assert collection_w.has_partition(partition_name)[0]
@ -513,9 +531,9 @@ class TestPartitionOperations(TestcaseBase):
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
# @pytest.mark.parametrize("flush", [True, False]) # @pytest.mark.parametrize("flush", [True, False])
@pytest.mark.parametrize("partition_name, data", [(cf.gen_unique_str(prefix), cf.gen_default_list_data(nb=3000))]) @pytest.mark.parametrize("data", [cf.gen_default_list_data(nb=3000)])
@pytest.mark.parametrize("index_param", cf.gen_simple_index()) @pytest.mark.parametrize("index_param", cf.gen_simple_index())
def test_partition_drop_indexed_partition(self, partition_name, data, index_param): def test_partition_drop_indexed_partition(self, data, index_param):
""" """
target: verify drop an indexed partition target: verify drop an indexed partition
method: 1.create a partition method: 1.create a partition
@ -529,6 +547,7 @@ class TestPartitionOperations(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create partition # create partition
partition_name = cf.gen_unique_str(prefix)
partition_w = self.init_partition_wrap(collection_w, partition_name) partition_w = self.init_partition_wrap(collection_w, partition_name)
assert collection_w.has_partition(partition_name)[0] assert collection_w.has_partition(partition_name)[0]
@ -583,8 +602,8 @@ class TestPartitionOperations(TestcaseBase):
check_items={ct.err_code: 1, ct.err_msg: PartitionErrorMessage.PartitionNotExist}) check_items={ct.err_code: 1, ct.err_msg: PartitionErrorMessage.PartitionNotExist})
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_release_dropped_collection(self, partition_name): def test_partition_release_dropped_collection(self):
""" """
target: verify release an dropped collection target: verify release an dropped collection
method: 1.create a collection and partition method: 1.create a collection and partition
@ -596,6 +615,7 @@ class TestPartitionOperations(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create partition # create partition
partition_name = cf.gen_unique_str(prefix)
partition_w = self.init_partition_wrap(collection_w, partition_name) partition_w = self.init_partition_wrap(collection_w, partition_name)
assert collection_w.has_partition(partition_name)[0] assert collection_w.has_partition(partition_name)[0]
@ -607,9 +627,9 @@ class TestPartitionOperations(TestcaseBase):
check_items={ct.err_code: 1, ct.err_msg: "can't find collection"}) check_items={ct.err_code: 1, ct.err_msg: "can't find collection"})
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name, search_vectors", # @pytest.mark.parametrize("partition_name, search_vectors",
[(cf.gen_unique_str(prefix), cf.gen_vectors(1, ct.default_dim))]) # [(cf.gen_unique_str(prefix), cf.gen_vectors(1, ct.default_dim))])
def test_partition_release_after_collection_released(self, partition_name, search_vectors): def test_partition_release_after_collection_released(self):
""" """
target: verify release a partition after the collection released target: verify release a partition after the collection released
method: 1.create a collection and partition method: 1.create a collection and partition
@ -622,6 +642,7 @@ class TestPartitionOperations(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create partition # create partition
partition_name = cf.gen_unique_str(prefix)
partition_w = self.init_partition_wrap(collection_w, partition_name) partition_w = self.init_partition_wrap(collection_w, partition_name)
assert collection_w.has_partition(partition_name)[0] assert collection_w.has_partition(partition_name)[0]
@ -635,6 +656,7 @@ class TestPartitionOperations(TestcaseBase):
partition_w.load() partition_w.load()
# search of partition # search of partition
search_vectors = cf.gen_vectors(1, ct.default_dim)
res_1, _ = partition_w.search(data=search_vectors, res_1, _ = partition_w.search(data=search_vectors,
anns_field=ct.default_float_vec_field_name, anns_field=ct.default_float_vec_field_name,
params={"nprobe": 32}, limit=1) params={"nprobe": 32}, limit=1)
@ -655,8 +677,8 @@ class TestPartitionOperations(TestcaseBase):
partition_w.release() partition_w.release()
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name, data", [(ct.default_partition_name, cf.gen_default_dataframe_data())]) # @pytest.mark.parametrize("partition_name, data", [(ct.default_partition_name, cf.gen_default_dataframe_data())])
def test_partition_insert_default_partition(self, partition_name, data): def test_partition_insert_default_partition(self):
""" """
target: verify insert data into _default partition target: verify insert data into _default partition
method: 1.create a collection method: 1.create a collection
@ -667,10 +689,12 @@ class TestPartitionOperations(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# get the default partition # get the default partition
partition_name = ct.default_partition_name
assert collection_w.has_partition(partition_name)[0] assert collection_w.has_partition(partition_name)[0]
partition_w = self.init_partition_wrap(collection_w, partition_name) partition_w = self.init_partition_wrap(collection_w, partition_name)
# insert data to partition # insert data to partition
data = cf.gen_default_dataframe_data()
partition_w.insert(data) partition_w.insert(data)
# self._connect().flush([collection_w.name]) # self._connect().flush([collection_w.name])
assert partition_w.num_entities == len(data) assert partition_w.num_entities == len(data)
@ -696,8 +720,8 @@ class TestPartitionOperations(TestcaseBase):
# TODO: update the assert error # TODO: update the assert error
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_insert_dropped_collection(self, partition_name): def test_partition_insert_dropped_collection(self):
""" """
target: verify insert data into dropped collection target: verify insert data into dropped collection
method: 1.create a collection method: 1.create a collection
@ -708,6 +732,7 @@ class TestPartitionOperations(TestcaseBase):
collection_w = self.init_collection_wrap() collection_w = self.init_collection_wrap()
# create partition # create partition
partition_name = cf.gen_unique_str(prefix)
partition_w = self.init_partition_wrap(collection_w, partition_name) partition_w = self.init_partition_wrap(collection_w, partition_name)
assert collection_w.has_partition(partition_name)[0] assert collection_w.has_partition(partition_name)[0]
@ -720,7 +745,7 @@ class TestPartitionOperations(TestcaseBase):
check_items={ct.err_code: 1, ct.err_msg: "None Type"}) check_items={ct.err_code: 1, ct.err_msg: "None Type"})
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
def test_partition_insert_maximum_size_data(self, data): def test_partition_insert_maximum_size_data(self):
""" """
target: verify insert maximum size data(256M?) a time target: verify insert maximum size data(256M?) a time
method: 1.create a partition method: 1.create a partition

View File

@ -621,8 +621,8 @@ class TestQueryOperation(TestcaseBase):
""" """
@pytest.mark.tags(ct.CaseLabel.L2) @pytest.mark.tags(ct.CaseLabel.L2)
@pytest.mark.parametrize("collection_name", [cf.gen_unique_str(prefix)]) # @pytest.mark.parametrize("collection_name", [cf.gen_unique_str(prefix)])
def test_query_without_connection(self, collection_name): def test_query_without_connection(self):
""" """
target: test query without connection target: test query without connection
method: close connect and query method: close connect and query
@ -630,7 +630,7 @@ class TestQueryOperation(TestcaseBase):
""" """
# init a collection with default connection # init a collection with default connection
collection_w = self.init_collection_wrap(name=collection_name) collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix))
# remove default connection # remove default connection
self.connection_wrap.remove_connection(alias=DefaultConfig.DEFAULT_USING) self.connection_wrap.remove_connection(alias=DefaultConfig.DEFAULT_USING)
@ -643,9 +643,9 @@ class TestQueryOperation(TestcaseBase):
check_items={ct.err_code: 0, ct.err_msg: cem.ConnectFirst}) check_items={ct.err_code: 0, ct.err_msg: cem.ConnectFirst})
@pytest.mark.tags(ct.CaseLabel.L1) @pytest.mark.tags(ct.CaseLabel.L1)
@pytest.mark.parametrize("collection_name, data", # @pytest.mark.parametrize("collection_name, data",
[(cf.gen_unique_str(prefix), cf.gen_default_list_data(ct.default_nb))]) # [(cf.gen_unique_str(prefix), cf.gen_default_list_data(ct.default_nb))])
def test_query_without_loading(self, collection_name, data): def test_query_without_loading(self):
""" """
target: test query without loading target: test query without loading
method: no loading before query method: no loading before query
@ -653,10 +653,11 @@ class TestQueryOperation(TestcaseBase):
""" """
# init a collection with default connection # init a collection with default connection
collection_name = cf.gen_unique_str(prefix)
collection_w = self.init_collection_wrap(name=collection_name) collection_w = self.init_collection_wrap(name=collection_name)
# insert data to collection # insert data to collection
collection_w.insert(data=data) collection_w.insert(data=cf.gen_default_list_data(ct.default_nb))
# check number of entities and that method calls the flush interface # check number of entities and that method calls the flush interface
assert collection_w.num_entities == ct.default_nb assert collection_w.num_entities == ct.default_nb

View File

@ -1,12 +0,0 @@
import pytest
from base.client_base import TestcaseBase
from utils.util_log import test_log as log
from common.common_type import *
class TestSchema(TestcaseBase):
""" Test case of schema interface """
@pytest.mark.tags(CaseLabel.L3)
def test_case(self):
log.info("Test case of schema interface")