Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test cases nightly #24752

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions tests/python_client/testcases/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3800,7 +3800,7 @@ def test_collection_json_field_as_primary_key(self, auto_id):
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L2)
@pytest.mark.parametrize("primary_field", [ct.default_int64_field_name, ct.default_string_field_name])
@pytest.mark.parametrize("primary_field", [ct.default_float_field_name, ct.default_json_field_name])
def test_collection_json_field_partition_key(self, primary_field):
"""
target: test create collection with multiple JSON fields
Expand All @@ -3809,11 +3809,10 @@ def test_collection_json_field_partition_key(self, primary_field):
expected: Raise exception
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
schema = cf.gen_json_default_collection_schema(primary_field=primary_field, is_partition_key=True)
cf.gen_unique_str(prefix)
error = {ct.err_code: 1, ct.err_msg: "Partition key field type must be DataType.INT64 or DataType.VARCHAR."}
self.collection_wrap.init_collection(name=c_name, schema=schema, partition_key_field=ct.default_json_field_name,
check_task=CheckTasks.err_res, check_items=error)
cf.gen_json_default_collection_schema(primary_field=primary_field, is_partition_key=True,
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.parametrize("primary_field", [ct.default_int64_field_name, ct.default_string_field_name])
Expand Down
49 changes: 28 additions & 21 deletions tests/python_client/testcases/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def get_invalid_travel_timestamp(self, request):
def get_invalid_guarantee_timestamp(self, request):
if request.param == 9999999999:
pytest.skip("9999999999 is valid for guarantee_timestamp")
if request.param is None:
pytest.skip("None is valid for guarantee_timestamp")
yield request.param

@pytest.fixture(scope="function", params=ct.get_invalid_strs)
Expand Down Expand Up @@ -2648,10 +2650,12 @@ def test_search_binary_without_flush(self, metrics, auto_id):
expected: search successfully with limit(topK)
"""
# 1. initialize a collection without data
collection_w = self.init_collection_general(prefix, is_binary=True, auto_id=auto_id)[0]
collection_w = self.init_collection_general(prefix, is_binary=True, auto_id=auto_id, is_index=False)[0]
# 2. insert data
insert_ids = cf.insert_data(collection_w, default_nb, is_binary=True, auto_id=auto_id)[3]
# 3. load data
index_params = {"index_type": "BIN_FLAT", "params": {"nlist": 128}, "metric_type": metrics}
collection_w.create_index("binary_vector", index_params)
collection_w.load()
# 4. search
log.info("test_search_binary_without_flush: searching collection %s" % collection_w.name)
Expand Down Expand Up @@ -4067,8 +4071,9 @@ def test_search_ip_flat(self, get_top_k):
default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "IP"}
collection_w.create_index("float_vector", default_index)
collection_w.load()
search_params = {"metric_type": "IP", "params": {"nprobe": 10}}
res, _ = collection_w.search(vectors[:nq], default_search_field,
ct.default_search_params, top_k,
search_params, top_k,
default_search_exp)
assert len(res[0]) <= top_k

Expand All @@ -4094,8 +4099,9 @@ def test_search_ip_after_index(self, index, params):
default_index = {"index_type": index, "params": params, "metric_type": "IP"}
collection_w.create_index("float_vector", default_index)
collection_w.load()
search_params = {"metric_type": "IP", "params": {"nprobe": 10}}
res, _ = collection_w.search(vectors[:nq], default_search_field,
ct.default_search_params, top_k,
search_params, top_k,
default_search_exp)
assert len(res[0]) <= top_k

Expand Down Expand Up @@ -4161,14 +4167,15 @@ def test_search_ip_index_empty_partition(self, index, params):
collection_w.load()

# 4. search
search_params = {"metric_type": "IP", "params": {"nprobe": 10}}
res, _ = collection_w.search(vectors[:nq], default_search_field,
default_search_params, top_k,
search_params, top_k,
default_search_exp)

assert len(res[0]) <= top_k

collection_w.search(vectors[:nq], default_search_field,
default_search_params, top_k,
search_params, top_k,
default_search_exp, [partition_name],
check_task=CheckTasks.check_search_results,
check_items={"nq": nq,
Expand Down Expand Up @@ -4202,8 +4209,9 @@ def test_search_ip_index_partitions(self, index, params):
collection_w.load()

# 4. search
search_params = {"metric_type": "IP", "params": {"nprobe": 10}}
res, _ = collection_w.search(vectors[:nq], default_search_field,
default_search_params, top_k,
search_params, top_k,
default_search_exp, [par_name])

assert len(res[0]) <= top_k
Expand Down Expand Up @@ -5791,10 +5799,9 @@ def test_range_search_only_range_filter(self):
collection_w.search(vectors[:default_nq], default_search_field,
range_search_params, default_limit,
default_search_exp,
check_task=CheckTasks.check_search_results,
check_items={"nq": default_nq,
"ids": insert_ids,
"limit": default_limit})
check_task=CheckTasks.err_res,
check_items={ct.err_code: 1,
ct.err_msg: "metric type not match: expected=L2, actual=IP"})

@pytest.mark.tags(CaseLabel.L2)
def test_range_search_only_radius(self):
Expand Down Expand Up @@ -5822,10 +5829,9 @@ def test_range_search_only_radius(self):
collection_w.search(vectors[:default_nq], default_search_field,
range_search_params, default_limit,
default_search_exp,
check_task=CheckTasks.check_search_results,
check_items={"nq": default_nq,
"ids": insert_ids,
"limit": default_limit})
check_task=CheckTasks.err_res,
check_items={ct.err_code: 1,
ct.err_msg: "metric type not match: expected=L2, actual=IP"})

@pytest.mark.tags(CaseLabel.L2)
def test_range_search_radius_range_filter_not_in_params(self):
Expand Down Expand Up @@ -5853,10 +5859,9 @@ def test_range_search_radius_range_filter_not_in_params(self):
collection_w.search(vectors[:default_nq], default_search_field,
range_search_params, default_limit,
default_search_exp,
check_task=CheckTasks.check_search_results,
check_items={"nq": default_nq,
"ids": insert_ids,
"limit": default_limit})
check_task=CheckTasks.err_res,
check_items={ct.err_code: 1,
ct.err_msg: "metric type not match: expected=L2, actual=IP"})

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("dup_times", [1, 2])
Expand Down Expand Up @@ -6449,7 +6454,7 @@ def test_range_search_binary_hamming_invalid_params(self, index):
dim=default_dim,
is_index=False,)[0:5]
# 2. create index
default_index = {"index_type": index, "params": {"nlist": 128}, "metric_type": "JACCARD"}
default_index = {"index_type": index, "params": {"nlist": 128}, "metric_type": "HAMMING"}
collection_w.create_index("binary_vector", default_index)
collection_w.load()
# 3. compute the distance
Expand Down Expand Up @@ -6539,7 +6544,7 @@ def test_range_search_binary_tanimoto_invalid_params(self, index):
# 3. compute the distance
query_raw_vector, binary_vectors = cf.gen_binary_vectors(3000, default_dim)
# 4. range search
search_params = {"metric_type": "TANIMOTO", "params": {"nprobe": 10, "radius": -1,
search_params = {"metric_type": "JACCARD", "params": {"nprobe": 10, "radius": -1,
"range_filter": -10}}
collection_w.search(binary_vectors[:default_nq], "binary_vector",
search_params, default_limit,
Expand All @@ -6556,10 +6561,12 @@ def test_range_search_binary_without_flush(self, metrics, auto_id):
expected: search successfully with limit(topK)
"""
# 1. initialize a collection without data
collection_w = self.init_collection_general(prefix, is_binary=True, auto_id=auto_id)[0]
collection_w = self.init_collection_general(prefix, is_binary=True, auto_id=auto_id, is_index=False)[0]
# 2. insert data
insert_ids = cf.insert_data(collection_w, default_nb, is_binary=True, auto_id=auto_id)[3]
# 3. load data
index_params = {"index_type": "BIN_FLAT", "params": {"nlist": 128}, "metric_type": metrics}
collection_w.create_index("binary_vector", index_params)
collection_w.load()
# 4. search
log.info("test_range_search_binary_without_flush: searching collection %s" % collection_w.name)
Expand Down