Skip to content

Commit

Permalink
[test]Add more partitions in br test (#203)
Browse files Browse the repository at this point in the history
Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
  • Loading branch information
zhuwenxing authored Oct 13, 2023
1 parent ac245de commit ca4ad82
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tests/base/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ def prepare_data(self, name=None, db_name="default", nb=ct.default_nb, dim=ct.de
collection_w = self.init_collection_wrap(name=name, schema=default_schema, active_trace=True)
# create partitions
if enable_partition:
partition_w = self.init_partition_wrap(collection_wrap=collection_w)
for i in range(5):
partition_w = self.init_partition_wrap(collection_wrap=collection_w)
assert collection_w.name == name
if nb > 0:
cf.insert_data(collection_w, nb=nb, is_binary=is_binary, auto_id=auto_id, dim=dim)
Expand Down
61 changes: 60 additions & 1 deletion tests/testcases/test_restore_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TestRestoreBackup(TestcaseBase):

@pytest.mark.parametrize("nb", [3000])
@pytest.mark.parametrize("is_auto_id", [True, False])
@pytest.mark.parametrize("enable_partition", [True, False])
@pytest.mark.parametrize("enable_partition", [False])
@pytest.mark.parametrize("is_async", [True, False])
@pytest.mark.parametrize("collection_need_to_restore", [1, 2, 3])
@pytest.mark.parametrize("collection_type", ["binary", "float", "all"])
Expand Down Expand Up @@ -79,6 +79,65 @@ def test_milvus_restore_back(self, collection_type, collection_need_to_restore,
for name in restore_collections:
self.compare_collections(name, name+suffix)

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("nb", [3000])
@pytest.mark.parametrize("is_auto_id", [True])
@pytest.mark.parametrize("enable_partition", [True])
@pytest.mark.parametrize("is_async", [True])
@pytest.mark.parametrize("collection_need_to_restore", [3])
@pytest.mark.parametrize("collection_type", ["all"])
def test_milvus_restore_back_with_multi_partition(self, collection_type, collection_need_to_restore, is_async, is_auto_id, enable_partition, nb):
# prepare data
names_origin = []
back_up_name = cf.gen_unique_str(backup_prefix)
if collection_type == "all":
for is_binary in [True, False, False]:
names_origin.append(cf.gen_unique_str(prefix))
self.prepare_data(names_origin[-1], nb=nb, is_binary=is_binary, auto_id=is_auto_id, check_function=False, enable_partition=enable_partition)
if collection_type == "float":
for is_binary in [False, False, False]:
names_origin.append(cf.gen_unique_str(prefix))
self.prepare_data(names_origin[-1], nb=nb, is_binary=is_binary, auto_id=is_auto_id, check_function=False, enable_partition=enable_partition)
if collection_type == "binary":
for is_binary in [True, True, True]:
names_origin.append(cf.gen_unique_str(prefix))
self.prepare_data(names_origin[-1], nb=nb, is_binary=is_binary, auto_id=is_auto_id, check_function=False, enable_partition=enable_partition)
log.info(f"name_origin:{names_origin}, back_up_name: {back_up_name}")
for name in names_origin:
res, _ = self.utility_wrap.has_collection(name)
assert res is True
# create backup

names_need_backup = names_origin
payload = {"async": False, "backup_name": back_up_name, "collection_names": names_need_backup}
res = client.create_backup(payload)
log.info(f"create backup response: {res}")
backup = client.get_backup(back_up_name)
assert backup["data"]["name"] == back_up_name
backup_collections = [backup["collection_name"]for backup in backup["data"]["collection_backups"]]
restore_collections = backup_collections
if collection_need_to_restore == "all":
payload = {"async": False, "backup_name": back_up_name,
"collection_suffix": suffix}
else:
restore_collections = names_need_backup[:collection_need_to_restore]
payload = {"async": False, "backup_name": back_up_name,
"collection_suffix": suffix, "collection_names": restore_collections}
t0 = time.time()
res = client.restore_backup(payload)
restore_id = res["data"]["id"]
log.info(f"restore_backup: {res}")
if is_async:
res = client.wait_restore_complete(restore_id)
assert res is True
t1 = time.time()
log.info(f"restore {restore_collections} cost time: {t1 - t0}")
res, _ = self.utility_wrap.list_collections()
for name in restore_collections:
assert name + suffix in res
for name in restore_collections:
self.compare_collections(name, name+suffix)

@pytest.mark.tags(CaseLabel.L1)
def test_milvus_restore_back_with_db_support(self):
# prepare data
Expand Down

0 comments on commit ca4ad82

Please sign in to comment.