未验证 提交 a4038d9f 编写于 作者: Y yongpengli-z 提交者: GitHub

Modify index test cases by comment (#16969)

Signed-off-by: Nyongpengli-z <yongpeng.li@zilliz.com>
上级 168935f4
...@@ -783,31 +783,6 @@ class TestNewIndexBase(TestcaseBase): ...@@ -783,31 +783,6 @@ class TestNewIndexBase(TestcaseBase):
collection_w.drop_index(index_name=index_name) collection_w.drop_index(index_name=index_name)
assert len(collection_w.collection.indexes)==0 assert len(collection_w.collection.indexes)==0
class TestIndexBase:
@pytest.fixture(
scope="function",
params=gen_simple_index()
)
def get_simple_index(self, request, connect):
log.info(request.param)
# if str(connect._cmd("mode")) == "CPU":
# if request.param["index_type"] in index_cpu_not_support():
# pytest.skip("sq8h not support in CPU mode")
return copy.deepcopy(request.param)
@pytest.fixture(
scope="function",
params=[
1,
10,
1111
],
)
def get_nq(self, request):
yield request.param
""" """
****************************************************************** ******************************************************************
The following cases are used to test `drop_index` function The following cases are used to test `drop_index` function
...@@ -815,148 +790,152 @@ class TestIndexBase: ...@@ -815,148 +790,152 @@ class TestIndexBase:
""" """
@pytest.mark.tags(CaseLabel.L0) @pytest.mark.tags(CaseLabel.L0)
def test_drop_index(self, connect, collection, get_simple_index): def test_drop_index(self, get_simple_index):
""" """
target: test drop index interface target: test drop index interface
method: create collection and add entities in it, create index, call drop index method: create collection and add entities in it, create index, call drop index
expected: return code 0, and default index param expected: return code 0, and default index param
""" """
connect.create_index(collection, field_name, get_simple_index) c_name = cf.gen_unique_str(prefix)
connect.drop_index(collection, field_name) collection_w = self.init_collection_wrap(name=c_name)
index = connect.describe_index(collection, "") data = cf.gen_default_list_data()
assert not index collection_w.insert(data=data)
if get_simple_index["index_type"] != "FLAT":
collection_w.create_index(ct.default_float_vec_field_name, get_simple_index, index_name=ct.default_index_name)
assert len(collection_w.indexes) == 1
collection_w.drop_index(index_name=ct.default_index_name)
assert len(collection_w.indexes) == 0
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
# TODO #7372 # TODO #7372
def test_drop_index_repeatedly(self, connect, collection, get_simple_index): def test_drop_index_repeatedly(self, get_simple_index):
""" """
target: test drop index repeatedly target: test drop index repeatedly
method: create index, call drop index, and drop again method: create index, call drop index, and drop again
expected: return code 0 expected: return code 0
""" """
connect.create_index(collection, field_name, get_simple_index) c_name = cf.gen_unique_str(prefix)
connect.drop_index(collection, field_name) collection_w = self.init_collection_wrap(name=c_name)
connect.drop_index(collection, field_name) if get_simple_index["index_type"] != "FLAT":
index = connect.describe_index(collection, "") collection_w.create_index(ct.default_float_vec_field_name, get_simple_index, index_name=ct.default_index_name)
assert not index assert len(collection_w.indexes) == 1
collection_w.drop_index(index_name=ct.default_index_name)
assert len(collection_w.indexes) == 0
collection_w.drop_index(index_name=ct.default_index_name, check_task=CheckTasks.err_res,
check_items={ct.err_code: 0, ct.err_msg: "Index doesn\'t exist."})
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
def test_drop_index_without_connect(self, dis_connect, collection): def test_drop_index_without_connect(self):
""" """
target: test drop index without connection target: test drop index without connection
method: drop index, and check if drop successfully method: drop index, and check if drop successfully
expected: raise exception expected: raise exception
""" """
with pytest.raises(Exception) as e:
dis_connect.drop_index(collection, field_name)
@pytest.mark.tags(CaseLabel.L0)
def test_drop_index_collection_not_existed(self, connect):
"""
target: test drop index interface when collection name not existed
method: create collection and add entities in it, create index,
make sure the collection name not in index, and then drop it
expected: return code not equals to 0, drop index failed
"""
collection_name = gen_unique_str(uid)
with pytest.raises(Exception) as e:
connect.drop_index(collection_name, field_name)
@pytest.mark.tags(CaseLabel.L0) c_name = cf.gen_unique_str(prefix)
def test_drop_index_collection_not_create(self, connect, collection): collection_w = self.init_collection_wrap(c_name)
""" collection_w.create_index(ct.default_float_vec_field_name, default_index_params, index_name=ct.default_index_name)
target: test drop index interface when index not created self.connection_wrap.remove_connection(ct.default_alias)
method: create collection and add entities in it, create index collection_w.drop_index(index_name=ct.default_index_name, check_task=CheckTasks.err_res,
expected: return code not equals to 0, drop index failed check_items={ct.err_code: 0, ct.err_msg: "should create connect first."})
"""
# no create index
connect.drop_index(collection, field_name)
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
def test_create_drop_index_repeatedly(self, connect, collection, get_simple_index): def test_create_drop_index_repeatedly(self, get_simple_index):
""" """
target: test create / drop index repeatedly, use the same index params target: test create / drop index repeatedly, use the same index params
method: create index, drop index, four times method: create index, drop index, four times
expected: return code 0 expected: return code 0
""" """
c_name = cf.gen_unique_str(prefix)
collection_w = self.init_collection_wrap(name=c_name)
if get_simple_index["index_type"] != "FLAT":
for i in range(4): for i in range(4):
connect.create_index(collection, field_name, get_simple_index) collection_w.create_index(ct.default_float_vec_field_name, get_simple_index,
connect.drop_index(collection, field_name) index_name=ct.default_index_name)
assert len(collection_w.indexes) == 1
collection_w.drop_index(index_name=ct.default_index_name)
assert len(collection_w.indexes) == 0
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
def test_drop_index_ip(self, connect, collection, get_simple_index): def test_drop_index_ip(self, get_simple_index):
""" """
target: test drop index interface target: test drop index interface
method: create collection and add entities in it, create index, call drop index method: create collection and add entities in it, create index, call drop index
expected: return code 0, and default index param expected: return code 0, and default index param
""" """
# result = connect.insert(collection, entities)
get_simple_index["metric_type"] = "IP" get_simple_index["metric_type"] = "IP"
connect.create_index(collection, field_name, get_simple_index) c_name = cf.gen_unique_str(prefix)
connect.drop_index(collection, field_name) collection_w = self.init_collection_wrap(name=c_name)
index = connect.describe_index(collection, "") if get_simple_index["index_type"] != "FLAT":
assert not index collection_w.create_index(ct.default_float_vec_field_name, get_simple_index,
index_name=ct.default_index_name)
assert len(collection_w.indexes) == 1
collection_w.drop_index(index_name=ct.default_index_name)
assert len(collection_w.indexes) == 0
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
def test_drop_index_repeatedly_ip(self, connect, collection, get_simple_index): def test_drop_index_repeatedly_ip(self, get_simple_index):
""" """
target: test drop index repeatedly target: test drop index repeatedly
method: create index, call drop index, and drop again method: create index, call drop index, and drop again
expected: return code 0 expected: return code 0
""" """
get_simple_index["metric_type"] = "IP" get_simple_index["metric_type"] = "IP"
connect.create_index(collection, field_name, get_simple_index) c_name = cf.gen_unique_str(prefix)
connect.drop_index(collection, field_name) collection_w = self.init_collection_wrap(name=c_name)
connect.drop_index(collection, field_name) if get_simple_index["index_type"] != "FLAT":
index = connect.describe_index(collection, "") collection_w.create_index(ct.default_float_vec_field_name, get_simple_index,
assert not index index_name=ct.default_index_name)
assert len(collection_w.indexes) == 1
collection_w.drop_index(index_name=ct.default_index_name)
assert len(collection_w.indexes) == 0
collection_w.drop_index(index_name=ct.default_index_name, check_task=CheckTasks.err_res,
check_items={ct.err_code: 0, ct.err_msg: "Index doesn\'t exist."})
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
def test_drop_index_without_connect_ip(self, dis_connect, collection): def test_drop_index_without_connect_ip(self):
""" """
target: test drop index without connection target: test drop index without connection
method: drop index, and check if drop successfully method: drop index, and check if drop successfully
expected: raise exception expected: raise exception
""" """
with pytest.raises(Exception) as e:
dis_connect.drop_index(collection, field_name)
@pytest.mark.tags(CaseLabel.L2) c_name = cf.gen_unique_str(prefix)
def test_drop_index_collection_not_create_ip(self, connect, collection): collection_w = self.init_collection_wrap(c_name)
""" collection_w.create_index(ct.default_float_vec_field_name, default_ip_index_params, index_name=ct.default_index_name)
target: test drop index interface when index not created self.connection_wrap.remove_connection(ct.default_alias)
method: create collection and add entities in it, create index collection_w.drop_index(index_name=ct.default_index_name, check_task=CheckTasks.err_res,
expected: return code not equals to 0, drop index failed check_items={ct.err_code: 0, ct.err_msg: "should create connect first."})
"""
# result = connect.insert(collection, entities)
# no create index
connect.drop_index(collection, field_name)
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
def test_create_drop_index_repeatedly_ip(self, connect, collection, get_simple_index): def test_create_drop_index_repeatedly_ip(self, get_simple_index):
""" """
target: test create / drop index repeatedly, use the same index params target: test create / drop index repeatedly, use the same index params
method: create index, drop index, four times method: create index, drop index, four times
expected: return code 0 expected: return code 0
""" """
get_simple_index["metric_type"] = "IP" get_simple_index["metric_type"] = "IP"
c_name = cf.gen_unique_str(prefix)
collection_w = self.init_collection_wrap(c_name)
if get_simple_index["index_type"] != "FLAT":
for i in range(4): for i in range(4):
connect.create_index(collection, field_name, get_simple_index) collection_w.create_index(ct.default_float_vec_field_name,get_simple_index, index_name=ct.default_index_name)
connect.drop_index(collection, field_name) assert len(collection_w.indexes) == 1
collection_w.drop_index(index_name=ct.default_index_name)
assert len(collection_w.indexes) == 0
@pytest.mark.tags(CaseLabel.L0) @pytest.mark.tags(CaseLabel.L0)
def test_create_PQ_without_nbits(self, connect, collection): def test_create_PQ_without_nbits(self):
""" """
target: test create PQ index target: test create PQ index
method: create PQ index without nbits method: create PQ index without nbits
expected: create successfully expected: create successfully
""" """
PQ_index = {"index_type": "IVF_PQ", "params": {"nlist": 128, "m": 16}, "metric_type": "L2"} PQ_index = {"index_type": "IVF_PQ", "params": {"nlist": 128, "m": 16}, "metric_type": "L2"}
result = connect.insert(collection, default_entities) c_name = cf.gen_unique_str(prefix)
connect.create_index(collection, field_name, PQ_index) collection_w = self.init_collection_wrap(c_name)
index = connect.describe_index(collection, "") collection_w.create_index(ct.default_float_vec_field_name, PQ_index, index_name=ct.default_index_name)
create_target_index(PQ_index, field_name) assert len(collection_w.indexes) == 1
assert index == PQ_index
class TestIndexBinary: class TestIndexBinary:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册