Skip to content

Commit

Permalink
test: add testcase for multi vec (#287)
Browse files Browse the repository at this point in the history
* test: add testcase for multi vec

Signed-off-by: zhuwenxing <[email protected]>

* test: update ci config

Signed-off-by: zhuwenxing <[email protected]>

* test: update tag name

Signed-off-by: zhuwenxing <[email protected]>

---------

Signed-off-by: zhuwenxing <[email protected]>
  • Loading branch information
zhuwenxing authored Jan 30, 2024
1 parent 4f1785b commit 5bdf7b1
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 21 deletions.
18 changes: 2 additions & 16 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@ pull_request_rules:
- name: Test passed for code changed-main
conditions:
- base=main
- "status-success=test-backup-restore-cli (docker-compose, standalone, standalone)"
- "status-success=test-backup-restore-cli (docker-compose, standalone, cluster)"
- "status-success=test-backup-restore-cli (docker-compose, cluster, standalone)"
- "status-success=test-backup-restore-cli (docker-compose, cluster, cluster)"
- "status-success=test-backup-restore-api (docker-compose, standalone)"
- "status-success=test-backup-restore-api (docker-compose, cluster)"
- "status-success=test-backup-restore-api (helm, standalone)"
# - "status-success=codecov/patch"
# - "status-success=codecov/project"
- check-success=Test
actions:
label:
add:
Expand Down Expand Up @@ -108,13 +100,7 @@ pull_request_rules:
- base=main
- files~=^(?=.*((\.(go|h|cpp)|CMakeLists.txt))).*$
- or:
- "status-success!=test-backup-restore-cli (docker-compose, standalone, standalone)"
- "status-success!=test-backup-restore-cli (docker-compose, standalone, cluster)"
- "status-success!=test-backup-restore-cli (docker-compose, cluster, standalone)"
- "status-success!=test-backup-restore-cli (docker-compose, cluster, cluster)"
- "status-success!=test-backup-restore-api (docker-compose, standalone)"
- "status-success!=test-backup-restore-api (docker-compose, cluster)"
- "status-success!=test-backup-restore-api (helm, standalone)"
- check-failure=CI
actions:
label:
remove:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,10 @@ jobs:
deploy_tools: [docker-compose]
milvus_mode: [standalone]
image_tag: [master-latest, 2.3-latest]
case_tag: [L0, L1, L2]
case_tag: [L0, L1, L2, MASTER]
exclude:
- deploy_tools: helm
milvus_mode: cluster
# mq_type: [pulsar, kafka] # TODO: add pulsar and kafka
- image_tag: 2.3-latest
case_tag: MASTER

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions tests/common/common_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,5 @@ class CaseLabel:
L2 = "L2"
L3 = "L3"
Perf = "Perf"
MASTER = "MASTER"
RELEASE = "RELEASE"
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pytest-print==0.2.1
pytest-level==0.1.1
pytest-xdist==2.5.0
pytest-loguru==0.2.0
pymilvus==2.3.2
pymilvus==2.4.0rc24
pytest-rerunfailures==9.1.1
git+https://github.com/Projectplace/pytest-tags
ndg-httpsclient
Expand Down
83 changes: 83 additions & 0 deletions tests/testcases/test_restore_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,89 @@ def test_milvus_restore_back_with_array_datatype(self, include_dynamic, include_
all_backup = []
assert back_up_name not in all_backup


@pytest.mark.parametrize("include_partition_key", [True, False])
@pytest.mark.parametrize("include_dynamic", [True, False])
@pytest.mark.tags(CaseLabel.MASTER)
def test_milvus_restore_back_with_multi_vector_datatype(self, include_dynamic, include_partition_key):
self._connect()
name_origin = cf.gen_unique_str(prefix)
back_up_name = cf.gen_unique_str(backup_prefix)
fields = [cf.gen_int64_field(name="int64", is_primary=True),
cf.gen_int64_field(name="key"),
cf.gen_json_field(name="json"),
cf.gen_array_field(name="var_array", element_type=DataType.VARCHAR),
cf.gen_array_field(name="int_array", element_type=DataType.INT64),
cf.gen_float_vec_field(name="float_vector_0", dim=128),
cf.gen_float_vec_field(name="float_vector_1", dim=128),
cf.gen_float_vec_field(name="float_vector_2", dim=128),
]
if include_partition_key:
partition_key = "key"
default_schema = cf.gen_collection_schema(fields,
enable_dynamic_field=include_dynamic,
partition_key_field=partition_key)
else:
default_schema = cf.gen_collection_schema(fields,
enable_dynamic_field=include_dynamic)

collection_w = self.init_collection_wrap(name=name_origin, schema=default_schema, active_trace=True)
nb = 3000
data = [
[i for i in range(nb)],
[i % 3 for i in range(nb)],
[{f"key_{str(i)}": i} for i in range(nb)],
[[str(x) for x in range(10)] for i in range(nb)],
[[int(x) for x in range(10)] for i in range(nb)],
[[np.float32(i) for i in range(128)] for _ in range(nb)],
[[np.float32(i) for i in range(128)] for _ in range(nb)],
[[np.float32(i) for i in range(128)] for _ in range(nb)]
]
collection_w.insert(data=data)
if include_dynamic:
data = [
{
"int64": i,
"key": i % 3,
"json": {f"key_{str(i)}": i},
"var_array": [str(x) for x in range(10)],
"int_array": [int(x) for x in range(10)],
"float_vector_0": [np.float32(i) for i in range(128)],
"float_vector_1": [np.float32(i) for i in range(128)],
"float_vector_2": [np.float32(i) for i in range(128)],
f"dynamic_{str(i)}": i
} for i in range(nb, nb*2)
]
collection_w.insert(data=data)
res = client.create_backup({"async": False, "backup_name": back_up_name, "collection_names": [name_origin]})
log.info(f"create_backup {res}")
res = client.list_backup()
log.info(f"list_backup {res}")
if "data" in res:
all_backup = [r["name"] for r in res["data"]]
else:
all_backup = []
assert back_up_name in all_backup
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"]]
assert name_origin in backup_collections
res = client.restore_backup({"async": False, "backup_name": back_up_name, "collection_names": [name_origin],
"collection_suffix": suffix})
log.info(f"restore_backup: {res}")
res, _ = self.utility_wrap.list_collections()
assert name_origin + suffix in res
output_fields = None
self.compare_collections(name_origin, name_origin + suffix, output_fields=output_fields)
res = client.delete_backup(back_up_name)
res = client.list_backup()
if "data" in res:
all_backup = [r["name"] for r in res["data"]]
else:
all_backup = []
assert back_up_name not in all_backup


@pytest.mark.tags(CaseLabel.L1)
def test_milvus_restore_back_with_delete(self):
self._connect()
Expand Down

0 comments on commit 5bdf7b1

Please sign in to comment.