mirror of https://github.com/milvus-io/milvus.git
[skip ci] Add case that delete time travel (#12401)
Signed-off-by: ThreadDao <yufen.zong@zilliz.com>pull/12409/head
parent
9af7e179f2
commit
f6f6dfaabe
|
@ -870,6 +870,74 @@ class TestDeleteOperation(TestcaseBase):
|
|||
"""
|
||||
pass
|
||||
|
||||
@pytest.mark.xfail(reason="Issue 12336")
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
def test_delete_time_travel(self):
|
||||
"""
|
||||
target: test search with time travel after delete
|
||||
method: 1.insert and flush
|
||||
2.delete
|
||||
3.load and search with time travel
|
||||
expected: search successfully
|
||||
"""
|
||||
from datetime import datetime
|
||||
from pymilvus import utility
|
||||
|
||||
collection_w = self.init_collection_wrap(cf.gen_unique_str(prefix))
|
||||
df = cf.gen_default_dataframe_data(tmp_nb)
|
||||
insert_res, _ = collection_w.insert(df)
|
||||
collection_w.load()
|
||||
|
||||
before_delete = utility.mkts_from_datetime(datetime.now(), milliseconds=1.0)
|
||||
|
||||
res_before, _ = collection_w.search(df[ct.default_float_vec_field_name][:1].to_list(),
|
||||
ct.default_float_vec_field_name,
|
||||
ct.default_search_params, ct.default_limit)
|
||||
|
||||
expr = f'{ct.default_int64_field_name} in {insert_res.primary_keys[:tmp_nb // 2]}'
|
||||
delete_res, _ = collection_w.delete(expr)
|
||||
|
||||
collection_w.load()
|
||||
res_travel, _ = collection_w.search(df[ct.default_float_vec_field_name][:1].to_list(),
|
||||
ct.default_float_vec_field_name,
|
||||
ct.default_search_params, ct.default_limit,
|
||||
travel_timestamp=before_delete
|
||||
)
|
||||
assert res_before[0].ids == res_travel[0].ids
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.xfail(reason="Issue 12336")
|
||||
def test_delete_insert_multi(self):
|
||||
"""
|
||||
target: test delete after multi insert
|
||||
method: 1.create
|
||||
2.insert multi times, no flush
|
||||
3.load
|
||||
3.delete even number
|
||||
4.search and query
|
||||
expected: Verify result
|
||||
"""
|
||||
# create collection, insert multi times, each with tmp_nb entities
|
||||
collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix))
|
||||
multi = 3
|
||||
for i in range(multi):
|
||||
start = i * tmp_nb
|
||||
df = cf.gen_default_dataframe_data(tmp_nb, start=start)
|
||||
collection_w.insert(df)
|
||||
|
||||
# delete even numbers
|
||||
ids = [i for i in range(0, tmp_nb*multi, 2)]
|
||||
expr = f'{ct.default_int64_field_name} in {ids}'
|
||||
collection_w.delete(expr)
|
||||
|
||||
collection_w.load()
|
||||
collection_w.query(expr, check_task=CheckTasks.check_query_empty)
|
||||
search_res, _ = collection_w.search(cf.gen_vectors(ct.default_nq, ct.default_dim),
|
||||
ct.default_float_vec_field_name,
|
||||
ct.default_search_params, ct.default_limit)
|
||||
for res_id in search_res[0].ids:
|
||||
assert res_id not in ids
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L3)
|
||||
def test_delete_sealed_only(self):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue