Modify test cases (#25967)

Signed-off-by: nico <cheng.yuan@zilliz.com>
This commit is contained in:
nico 2023-07-31 10:39:08 +08:00 committed by GitHub
parent c2693ea284
commit c0d2433549
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 33 deletions

View File

@ -12,7 +12,7 @@ allure-pytest==2.7.0
pytest-print==0.2.1
pytest-level==0.1.1
pytest-xdist==2.5.0
pymilvus==2.4.0.dev103
pymilvus==2.4.0.dev109
pytest-rerunfailures==9.1.1
git+https://github.com/Projectplace/pytest-tags
ndg-httpsclient

View File

@ -846,7 +846,7 @@ class TestConnect(TestcaseBase):
address = "{}:{}".format(host, port)
self.connection_wrap.connect(alias=connect_name, address=address, check_task=ct.CheckTasks.ccr)
@pytest.mark.tags(ct.CaseLabel.L3)
@pytest.mark.tags(ct.CaseLabel.RBAC)
@pytest.mark.parametrize("connect_name", [DefaultConfig.DEFAULT_USING])
def test_connect_with_default_user_password(self, host, port, connect_name):
"""
@ -999,7 +999,6 @@ class TestConnectUserPasswordInvalid(TestcaseBase):
"""
@pytest.mark.tags(ct.CaseLabel.RBAC)
@pytest.mark.parametrize("port", ["19530"])
def test_connect_without_user_password_after_authorization_enabled(self, host, port):
"""
target: test connect without user password after authorization enabled

View File

@ -20,8 +20,6 @@ class TestDatabaseParams(TestcaseBase):
"""
log.info("[database_teardown_method] Start teardown database test cases ...")
self._connect()
# clear db
for db in self.database_wrap.list_database()[0]:
# using db
@ -208,9 +206,9 @@ class TestDatabaseParams(TestcaseBase):
assert collection_w.name in collections
@pytest.mark.parametrize("invalid_db_name", ["12-s", "12 s", "(mn)", "中文", "%$#"])
def test_using_invalid_db_2(self, invalid_db_name):
def test_using_invalid_db_2(self, host, port, invalid_db_name):
# connect with default alias using
self._connect()
self.connection_wrap.connect(host=host, port=port, user=ct.default_user, password=ct.default_password)
# create collection in default db
collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix))
@ -229,8 +227,6 @@ class TestDatabaseOperation(TestcaseBase):
"""
log.info("[database_teardown_method] Start teardown database test cases ...")
self._connect()
# clear db
for db in self.database_wrap.list_database()[0]:
# using db
@ -511,14 +507,14 @@ class TestDatabaseOperation(TestcaseBase):
using_collections, _ = self.utility_wrap.list_collections()
assert collection_w_default.name in using_collections
def test_using_db_not_existed(self):
def test_using_db_not_existed(self, host, port):
"""
target: test using a not existed db
method: using a not existed db
expected: exception
"""
# create db
self._connect()
self.connection_wrap.connect(host=host, port=port, user=ct.default_user, password=ct.default_password)
collection_w = self.init_collection_wrap(cf.gen_unique_str(prefix))
# list collection with not exist using db -> exception

View File

@ -1872,28 +1872,22 @@ class TestCollectionSearch(TestcaseBase):
"_async": _async})
@pytest.mark.tags(CaseLabel.L2)
def test_search_max_nq(self, auto_id, dim, _async):
@pytest.mark.parametrize("nq", [1, 20, 100, 8000, 16384])
def test_search_different_nq(self, nq):
"""
target: test search with max nq
method: connect milvus, create collection, insert, load and search with max nq
expected: search successfully with max nq
target: test search with different nq
method: create collection, insert, load and search with different nq [1, 16384]
expected: search successfully with different nq
"""
self._connect()
nq = 16384
collection_w, _, _, insert_ids = self.init_collection_general(prefix, True,
auto_id=auto_id,
dim=dim)[0:4]
collection_w.load()
collection_w, _, _, insert_ids = self.init_collection_general(prefix, True, nb=20000)[0:4]
log.info("test_search_max_nq: searching collection %s" % collection_w.name)
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
vectors = [[random.random() for _ in range(default_dim)] for _ in range(nq)]
collection_w.search(vectors[:nq], default_search_field,
default_search_params, default_limit,
default_search_exp, _async=_async,
check_task=CheckTasks.check_search_results,
check_items={"nq": nq,
"ids": insert_ids,
"limit": default_limit,
"_async": _async})
"limit": default_limit})
@pytest.mark.tags(CaseLabel.L2)
@pytest.mark.parametrize("shards_num", [-256, 0, ct.max_shards_num // 2, ct.max_shards_num])
@ -3503,7 +3497,8 @@ class TestCollectionSearch(TestcaseBase):
if enable_dynamic_field:
entities = []
for vector in _vectors[0]:
entities.append({default_float_field_name: vector[default_float_field_name],
entities.append({default_int64_field_name: vector[default_int64_field_name],
default_float_field_name: vector[default_float_field_name],
default_string_field_name: vector[default_string_field_name],
default_search_field: vector[default_search_field]})
original_entities.append(pd.DataFrame(entities))

View File

@ -3301,8 +3301,7 @@ class TestUtilityRBAC(TestcaseBase):
self.connection_wrap.disconnect(alias=DefaultConfig.DEFAULT_USING)
self.connection_wrap.connect(host=host, port=port, user=user,
password=password, check_task=ct.CheckTasks.ccr, **db_kwargs)
self.index_wrap.init_index(collection_w.collection, ct.default_int64_field_name,
default_index_params)
collection_w.create_index(ct.default_float_vec_field_name)
@pytest.mark.tags(CaseLabel.RBAC)
@pytest.mark.parametrize("with_db", [False, True])
@ -3328,14 +3327,13 @@ class TestUtilityRBAC(TestcaseBase):
db_name = db_kwargs.get("db_name", ct.default_db)
self.database_wrap.using_database(db_name)
collection_w = self.init_collection_wrap(name=c_name)
self.index_wrap.init_index(collection_w.collection, ct.default_int64_field_name,
default_index_params)
collection_w.create_index(ct.default_float_vec_field_name)
self.utility_wrap.role_grant("Collection", c_name, "DropIndex", **db_kwargs)
self.connection_wrap.disconnect(alias=DefaultConfig.DEFAULT_USING)
self.connection_wrap.connect(host=host, port=port, user=user,
password=password, check_task=ct.CheckTasks.ccr, **db_kwargs)
self.index_wrap.drop()
collection_w.drop_index()
@pytest.mark.tags(CaseLabel.RBAC)
@pytest.mark.parametrize("with_db", [False, True])
@ -3372,7 +3370,7 @@ class TestUtilityRBAC(TestcaseBase):
password=password, check_task=ct.CheckTasks.ccr, **db_kwargs)
vectors = [[random.random() for _ in range(ct.default_dim)] for _ in range(ct.default_nq)]
collection_w.search(vectors[:ct.default_nq], ct.default_float_vec_field_name,
ct.default_search_params, ct.default_limit,
{}, ct.default_limit,
"int64 >= 0", check_task=CheckTasks.check_search_results,
check_items={"nq": ct.default_nq,
"limit": ct.default_limit})
@ -3866,7 +3864,7 @@ class TestUtilityRBAC(TestcaseBase):
vectors = [[random.random() for _ in range(ct.default_dim)] for _ in range(ct.default_nq)]
collection_w.load()
collection_w.search(vectors[:ct.default_nq], ct.default_float_vec_field_name,
ct.default_search_params, ct.default_limit,
{}, ct.default_limit,
"int64 >= 0")
collection_w.flush()
default_term_expr = f'{ct.default_int64_field_name} in [0, 1]'