2021-05-28 11:50:31 +08:00
|
|
|
import copy
|
2021-05-11 17:59:29 +08:00
|
|
|
import pytest
|
2021-05-28 11:50:31 +08:00
|
|
|
from pymilvus_orm import FieldSchema
|
2021-06-05 10:25:34 +08:00
|
|
|
from base.client_base import TestcaseBase
|
2021-06-04 09:35:34 +08:00
|
|
|
from base.collection_wrapper import ApiCollectionWrapper
|
|
|
|
from base.partition_wrapper import ApiPartitionWrapper
|
|
|
|
from base.index_wrapper import ApiIndexWrapper
|
|
|
|
from base.utility_wrapper import ApiUtilityWrapper
|
2021-05-13 12:17:15 +08:00
|
|
|
from utils.util_log import test_log as log
|
2021-05-28 11:50:31 +08:00
|
|
|
from common import common_func as cf
|
|
|
|
from common import common_type as ct
|
|
|
|
from common.common_type import CaseLabel
|
2021-05-11 17:59:29 +08:00
|
|
|
|
2021-05-28 11:50:31 +08:00
|
|
|
prefix = "utility"
|
|
|
|
default_schema = cf.gen_default_collection_schema()
|
|
|
|
default_field_name = ct.default_float_vec_field_name
|
|
|
|
default_index_params = {"index_type": "IVF_SQ8", "metric_type": "L2", "params": {"nlist": 64}}
|
2021-05-11 17:59:29 +08:00
|
|
|
|
|
|
|
|
2021-06-05 10:25:34 +08:00
|
|
|
class TestUtilityParams(TestcaseBase):
|
2021-05-28 11:50:31 +08:00
|
|
|
""" Test case of index interface """
|
|
|
|
|
|
|
|
@pytest.fixture(
|
|
|
|
scope="function",
|
|
|
|
params=ct.get_invalid_strs
|
|
|
|
)
|
|
|
|
def get_invalid_collection_name(self, request):
|
|
|
|
yield request.param
|
|
|
|
|
|
|
|
@pytest.fixture(
|
|
|
|
scope="function",
|
|
|
|
params=ct.get_invalid_strs
|
|
|
|
)
|
|
|
|
def get_invalid_partition_name(self, request):
|
|
|
|
yield request.param
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_has_collection_name_invalid(self, get_invalid_collection_name):
|
|
|
|
"""
|
|
|
|
target: test has_collection with error collection name
|
|
|
|
method: input invalid name
|
|
|
|
expected: raise exception
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = get_invalid_collection_name
|
|
|
|
ex, _ = ut.has_collection(c_name)
|
|
|
|
log.error(str(ex))
|
|
|
|
assert "invalid" or "illegal" in str(ex)
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_has_partition_collection_name_invalid(self, get_invalid_collection_name):
|
|
|
|
"""
|
|
|
|
target: test has_partition with error collection name
|
|
|
|
method: input invalid name
|
|
|
|
expected: raise exception
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = get_invalid_collection_name
|
|
|
|
p_name = cf.gen_unique_str(prefix)
|
|
|
|
ex, _ = ut.has_partition(c_name, p_name)
|
|
|
|
log.error(str(ex))
|
|
|
|
assert "invalid" or "illegal" in str(ex)
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_has_partition_name_invalid(self, get_invalid_partition_name):
|
|
|
|
"""
|
|
|
|
target: test has_partition with error partition name
|
|
|
|
method: input invalid name
|
|
|
|
expected: raise exception
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
p_name = get_invalid_partition_name
|
|
|
|
ex, _ = ut.has_partition(c_name, p_name)
|
|
|
|
log.error(str(ex))
|
|
|
|
assert "invalid" or "illegal" in str(ex)
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_list_collections_using_invalid(self):
|
|
|
|
"""
|
|
|
|
target: test list_collections with invalid using
|
|
|
|
method: input invalid name
|
|
|
|
expected: raise exception
|
|
|
|
"""
|
|
|
|
self._connect()
|
|
|
|
using = "empty"
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper(using=using)
|
2021-05-28 11:50:31 +08:00
|
|
|
ex, _ = ut.list_collections()
|
|
|
|
log.error(str(ex))
|
|
|
|
assert "invalid" or "illegal" in str(ex)
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_index_process_invalid_name(self, get_invalid_collection_name):
|
|
|
|
"""
|
|
|
|
target: test building_process
|
|
|
|
method: input invalid name
|
|
|
|
expected: raise exception
|
|
|
|
"""
|
|
|
|
self._connect()
|
|
|
|
c_name = get_invalid_collection_name
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
ex, _ = ut.index_building_progress(c_name)
|
|
|
|
log.error(str(ex))
|
|
|
|
assert "invalid" or "illegal" in str(ex)
|
|
|
|
|
|
|
|
# TODO: not support index name
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def _test_index_process_invalid_index_name(self, get_invalid_index_name):
|
|
|
|
"""
|
|
|
|
target: test building_process
|
|
|
|
method: input invalid index name
|
|
|
|
expected: raise exception
|
|
|
|
"""
|
|
|
|
self._connect()
|
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
index_name = get_invalid_index_name
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
ex, _ = ut.index_building_progress(c_name, index_name)
|
|
|
|
log.error(str(ex))
|
|
|
|
assert "invalid" or "illegal" in str(ex)
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_wait_index_invalid_name(self, get_invalid_collection_name):
|
|
|
|
"""
|
|
|
|
target: test wait_index
|
|
|
|
method: input invalid name
|
|
|
|
expected: raise exception
|
|
|
|
"""
|
|
|
|
self._connect()
|
|
|
|
c_name = get_invalid_collection_name
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
ex, _ = ut.wait_for_index_building_complete(c_name)
|
|
|
|
log.error(str(ex))
|
|
|
|
assert "invalid" or "illegal" in str(ex)
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_wait_index_invalid_index_name(self, get_invalid_index_name):
|
|
|
|
"""
|
|
|
|
target: test wait_index
|
|
|
|
method: input invalid index name
|
|
|
|
expected: raise exception
|
|
|
|
"""
|
|
|
|
self._connect()
|
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
index_name = get_invalid_index_name
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
ex, _ = ut.wait_for_index_building_complete(c_name, index_name)
|
|
|
|
log.error(str(ex))
|
|
|
|
assert "invalid" or "illegal" in str(ex)
|
|
|
|
|
|
|
|
|
2021-06-05 10:25:34 +08:00
|
|
|
class TestUtilityBase(TestcaseBase):
|
2021-05-28 11:50:31 +08:00
|
|
|
""" Test case of index interface """
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_has_collection(self):
|
|
|
|
"""
|
|
|
|
target: test has_collection with collection name
|
|
|
|
method: input collection name created before
|
|
|
|
expected: True
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
|
|
|
res, _ = ut.has_collection(c_name)
|
|
|
|
assert res is True
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_has_collection_not_created(self):
|
|
|
|
"""
|
|
|
|
target: test has_collection with collection name which is not created
|
|
|
|
method: input random collection name
|
|
|
|
expected: False
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
self._collection()
|
|
|
|
res, _ = ut.has_collection(c_name)
|
|
|
|
assert res is False
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_has_collection_after_drop(self):
|
|
|
|
"""
|
|
|
|
target: test has_collection with collection name droped before
|
|
|
|
method: input random collection name
|
|
|
|
expected: False
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
|
|
|
res, _ = ut.has_collection(c_name)
|
|
|
|
assert res is True
|
2021-06-04 09:35:34 +08:00
|
|
|
self.collection_wrap.drop()
|
2021-05-28 11:50:31 +08:00
|
|
|
res, _ = ut.has_collection(c_name)
|
|
|
|
assert res is False
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_has_partition(self):
|
|
|
|
"""
|
|
|
|
target: test has_partition with partition name
|
|
|
|
method: input collection name and partition name created before
|
|
|
|
expected: True
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
p_name = cf.gen_unique_str()
|
|
|
|
collection = self._collection(c_name)
|
2021-06-04 09:35:34 +08:00
|
|
|
api_p = ApiPartitionWrapper()
|
2021-06-07 12:15:35 +08:00
|
|
|
api_p.init_partition(collection, p_name)
|
2021-05-28 11:50:31 +08:00
|
|
|
res, _ = ut.has_partition(c_name, p_name)
|
|
|
|
assert res is True
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_has_partition_not_created(self):
|
|
|
|
"""
|
|
|
|
target: test has_partition with partition name
|
|
|
|
method: input collection name, and partition name not created before
|
|
|
|
expected: True
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
p_name = cf.gen_unique_str()
|
|
|
|
self._collection(c_name)
|
|
|
|
res, _ = ut.has_partition(c_name, p_name)
|
|
|
|
assert res is False
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_has_partition_after_drop(self):
|
|
|
|
"""
|
|
|
|
target: test has_partition with partition name
|
|
|
|
method: input collection name, and partition name dropped
|
|
|
|
expected: True
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
p_name = cf.gen_unique_str()
|
|
|
|
collection = self._collection(c_name)
|
2021-06-04 09:35:34 +08:00
|
|
|
api_p = ApiPartitionWrapper()
|
2021-06-07 12:15:35 +08:00
|
|
|
api_p.init_partition(collection, p_name)
|
2021-05-28 11:50:31 +08:00
|
|
|
res, _ = ut.has_partition(c_name, p_name)
|
|
|
|
assert res is True
|
|
|
|
api_p.drop()
|
|
|
|
res, _ = ut.has_partition(c_name, p_name)
|
|
|
|
assert res is False
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_list_collections(self):
|
|
|
|
"""
|
|
|
|
target: test list_collections
|
|
|
|
method: create collection, list_collections
|
|
|
|
expected: in the result
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
|
|
|
res, _ = ut.list_collections()
|
|
|
|
assert c_name in res
|
|
|
|
|
|
|
|
# TODO: make sure all collections deleted
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def _test_list_collections_no_collection(self):
|
|
|
|
"""
|
|
|
|
target: test list_collections
|
|
|
|
method: no collection created, list_collections
|
|
|
|
expected: length of the result equals to 0
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
res, _ = ut.list_collections()
|
|
|
|
assert len(res) == 0
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_index_process_collection_not_existed(self):
|
|
|
|
"""
|
|
|
|
target: test building_process
|
|
|
|
method: input collection not created before
|
|
|
|
expected: raise exception
|
|
|
|
"""
|
|
|
|
self._connect()
|
|
|
|
c_name = cf.gen_unique_str(prefix)
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
ex, _ = ut.index_building_progress(c_name)
|
|
|
|
log.error(str(ex))
|
|
|
|
assert "exist" in str(ex)
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_index_process_collection_empty(self):
|
|
|
|
"""
|
|
|
|
target: test building_process
|
|
|
|
method: input empty collection
|
|
|
|
expected: no exception raised
|
|
|
|
"""
|
|
|
|
self._connect()
|
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
res, _ = ut.index_building_progress(c_name)
|
|
|
|
assert "num_indexed_entities" in res
|
|
|
|
assert res["num_indexed_entities"] == 0
|
|
|
|
assert "num_total_entities" in res
|
|
|
|
assert res["num_total_entities"] == 0
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_index_process_collection_insert_no_index(self):
|
|
|
|
"""
|
|
|
|
target: test building_process
|
|
|
|
method: insert 1 entity, no index created
|
|
|
|
expected: no exception raised
|
|
|
|
"""
|
|
|
|
nb = 1
|
|
|
|
self._connect()
|
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
|
|
|
data = cf.gen_default_list_data(nb)
|
2021-06-04 09:35:34 +08:00
|
|
|
self.collection_wrap.insert(data=data)
|
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
res, _ = ut.index_building_progress(c_name)
|
|
|
|
assert "num_indexed_entities" in res
|
|
|
|
assert res["num_indexed_entities"] == 0
|
|
|
|
assert "num_total_entities" in res
|
|
|
|
assert res["num_total_entities"] == nb
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_index_process_collection_insert_index_not_enough(self):
|
|
|
|
"""
|
|
|
|
target: test building_process
|
|
|
|
method: insert 1 entity, no index created
|
|
|
|
expected: no exception raised
|
|
|
|
"""
|
|
|
|
nb = 1
|
|
|
|
self._connect()
|
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
|
|
|
data = cf.gen_default_list_data(nb)
|
2021-06-04 09:35:34 +08:00
|
|
|
self.collection_wrap.insert(data=data)
|
|
|
|
self.collection_wrap.create_index(default_field_name, default_index_params)
|
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
ut.wait_for_index_building_complete(c_name)
|
|
|
|
res, _ = ut.index_building_progress(c_name)
|
|
|
|
assert "num_indexed_entities" in res
|
|
|
|
assert res["num_indexed_entities"] == 0
|
|
|
|
assert "num_total_entities" in res
|
|
|
|
assert res["num_total_entities"] == nb
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_index_process_collection_index(self):
|
|
|
|
"""
|
|
|
|
target: test building_process
|
|
|
|
method: insert 1200 entities, build and call building_process
|
|
|
|
expected: 1200 entity indexed
|
|
|
|
"""
|
|
|
|
nb = 1200
|
|
|
|
self._connect()
|
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
|
|
|
data = cf.gen_default_list_data(nb)
|
2021-06-04 09:35:34 +08:00
|
|
|
self.collection_wrap.insert(data=data)
|
|
|
|
self.collection_wrap.create_index(default_field_name, default_index_params)
|
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
ut.wait_for_index_building_complete(c_name)
|
|
|
|
res, _ = ut.index_building_progress(c_name)
|
|
|
|
assert "num_indexed_entities" in res
|
|
|
|
assert res["num_indexed_entities"] == nb
|
|
|
|
assert "num_total_entities" in res
|
|
|
|
assert res["num_total_entities"] == nb
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_index_process_collection_indexing(self):
|
|
|
|
"""
|
|
|
|
target: test building_process
|
|
|
|
method: call building_process during building
|
|
|
|
expected: 1200 entity indexed
|
|
|
|
"""
|
|
|
|
nb = 1200
|
|
|
|
self._connect()
|
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
|
|
|
data = cf.gen_default_list_data(nb)
|
2021-06-04 09:35:34 +08:00
|
|
|
self.collection_wrap.insert(data=data)
|
|
|
|
self.collection_wrap.create_index(default_field_name, default_index_params)
|
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
res, _ = ut.index_building_progress(c_name)
|
|
|
|
for _ in range(2):
|
|
|
|
assert "num_indexed_entities" in res
|
|
|
|
assert res["num_indexed_entities"] <= nb
|
|
|
|
assert res["num_indexed_entities"] >= 0
|
|
|
|
assert "num_total_entities" in res
|
|
|
|
assert res["num_total_entities"] == nb
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_wait_index_collection_not_existed(self):
|
|
|
|
"""
|
|
|
|
target: test wait_index
|
|
|
|
method: input collection not created before
|
|
|
|
expected: raise exception
|
|
|
|
"""
|
|
|
|
self._connect()
|
|
|
|
c_name = cf.gen_unique_str(prefix)
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
ex, _ = ut.wait_for_index_building_complete(c_name)
|
|
|
|
log.error(str(ex))
|
|
|
|
assert "exist" in str(ex)
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_wait_index_collection_empty(self):
|
|
|
|
"""
|
|
|
|
target: test wait_index
|
|
|
|
method: input empty collection
|
|
|
|
expected: no exception raised
|
|
|
|
"""
|
|
|
|
self._connect()
|
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
res, _ = ut.wait_for_index_building_complete(c_name)
|
|
|
|
assert res is None
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L1)
|
|
|
|
def test_wait_index_collection_index(self):
|
|
|
|
"""
|
|
|
|
target: test wait_index
|
|
|
|
method: insert 1200 entities, build and call wait_index
|
|
|
|
expected: 1200 entity indexed
|
|
|
|
"""
|
|
|
|
nb = 1200
|
|
|
|
self._connect()
|
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
|
|
|
data = cf.gen_default_list_data(nb)
|
2021-06-04 09:35:34 +08:00
|
|
|
self.collection_wrap.insert(data=data)
|
|
|
|
self.collection_wrap.create_index(default_field_name, default_index_params)
|
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
res, _ = ut.wait_for_index_building_complete(c_name)
|
|
|
|
assert res is None
|
|
|
|
res, _ = ut.index_building_progress(c_name)
|
|
|
|
assert res["num_indexed_entities"] == nb
|
|
|
|
|
|
|
|
|
2021-06-05 10:25:34 +08:00
|
|
|
class TestUtilityAdvanced(TestcaseBase):
|
2021-05-28 11:50:31 +08:00
|
|
|
""" Test case of index interface """
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L2)
|
|
|
|
def test_has_collection_multi_collections(self):
|
|
|
|
"""
|
|
|
|
target: test has_collection with collection name
|
|
|
|
method: input collection name created before
|
|
|
|
expected: True
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
c_name_2 = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
2021-06-04 09:35:34 +08:00
|
|
|
api_c = ApiCollectionWrapper()
|
2021-06-07 14:14:37 +08:00
|
|
|
api_c.init_collection(c_name_2)
|
2021-05-28 11:50:31 +08:00
|
|
|
for name in [c_name, c_name_2]:
|
|
|
|
res, _ = ut.has_collection(name)
|
|
|
|
assert res is True
|
|
|
|
|
|
|
|
@pytest.mark.tags(CaseLabel.L2)
|
|
|
|
def test_list_collections_multi_collection(self):
|
|
|
|
"""
|
|
|
|
target: test list_collections
|
|
|
|
method: create collection, list_collections
|
|
|
|
expected: in the result
|
|
|
|
"""
|
|
|
|
self._connect()
|
2021-06-04 09:35:34 +08:00
|
|
|
ut = ApiUtilityWrapper()
|
2021-05-28 11:50:31 +08:00
|
|
|
c_name = cf.gen_unique_str(prefix)
|
|
|
|
c_name_2 = cf.gen_unique_str(prefix)
|
|
|
|
self._collection(c_name)
|
2021-06-04 09:35:34 +08:00
|
|
|
api_c = ApiCollectionWrapper()
|
2021-06-07 14:14:37 +08:00
|
|
|
api_c.init_collection(c_name_2)
|
2021-05-28 11:50:31 +08:00
|
|
|
res, _ = ut.list_collections()
|
|
|
|
for name in [c_name, c_name_2]:
|
|
|
|
assert name in res
|