From 4d8d69c5012b4d5a6dc0a0f65c6737e37cf46a32 Mon Sep 17 00:00:00 2001 From: zhuwenxing Date: Mon, 23 Sep 2024 15:03:35 +0800 Subject: [PATCH] test: add test cases for text match feature (#431) * test: add test cases for text match feature Signed-off-by: zhuwenxing * test: fix Signed-off-by: zhuwenxing * test: add text match test Signed-off-by: zhuwenxing --------- Signed-off-by: zhuwenxing --- tests/requirements.txt | 8 ++++++-- tests/testcases/test_restore_backup.py | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/requirements.txt b/tests/requirements.txt index 92c9edb0..9845f900 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -21,12 +21,12 @@ pyopenssl pyasn1 pytest-html==3.1.1 delayed-assert==0.3.5 -kubernetes==17.17.0 +kubernetes==24.2.0 PyYAML==6.0 pytest-sugar==0.9.5 pytest-parallel pytest-random-order -numpy==1.25.0 +numpy==1.24.4 # for customize config test python-benedict==0.24.3 timeout-decorator==0.5.0 @@ -52,3 +52,7 @@ tenacity==8.1.0 # for bf16 datatype jax==0.4.13 jaxlib==0.4.13 + +# for text match +bm25s==0.2.0 +jieba==0.42.1 diff --git a/tests/testcases/test_restore_backup.py b/tests/testcases/test_restore_backup.py index 8ac15f31..82d41eda 100644 --- a/tests/testcases/test_restore_backup.py +++ b/tests/testcases/test_restore_backup.py @@ -13,6 +13,8 @@ from common.common_type import CaseLabel from utils.util_log import test_log as log from api.milvus_backup import MilvusBackupClient +from faker import Faker +fake_en = Faker("en_US") prefix = "restore_backup" backup_prefix = "backup" suffix = "_bak" @@ -652,13 +654,15 @@ def test_milvus_restore_back_with_f16_bf16_datatype(self, include_dynamic, inclu @pytest.mark.parametrize("include_partition_key", [True]) @pytest.mark.parametrize("include_dynamic", [True]) + @pytest.mark.parametrize("enable_text_match", [True]) @pytest.mark.tags(CaseLabel.MASTER) - def test_milvus_restore_back_with_sparse_vector_datatype(self, include_dynamic, include_partition_key): + def test_milvus_restore_back_with_sparse_vector_datatype(self, include_dynamic, include_partition_key, enable_text_match): 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_string_field(name="text", enable_match=enable_text_match), 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), @@ -680,6 +684,7 @@ def test_milvus_restore_back_with_sparse_vector_datatype(self, include_dynamic, data = [ [i for i in range(nb)], [i % 3 for i in range(nb)], + [fake_en.text() 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)], @@ -694,6 +699,7 @@ def test_milvus_restore_back_with_sparse_vector_datatype(self, include_dynamic, { "int64": i, "key": i % 3, + "text": fake_en.text(), "json": {f"key_{str(i)}": i}, "var_array": [str(x) for x in range(10)], "int_array": [int(x) for x in range(10)],