From 4a6880af781ee1186bb04fab5ff42ddd8ce9fc78 Mon Sep 17 00:00:00 2001 From: NicoYuan1986 <109071306+NicoYuan1986@users.noreply.github.com> Date: Fri, 21 Oct 2022 17:05:37 +0800 Subject: [PATCH] Add test cases of the new rules of index (#19933) Signed-off-by: nico Signed-off-by: nico --- .../testcases/test_collection.py | 12 ++++++++++++ tests/python_client/testcases/test_index.py | 19 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/python_client/testcases/test_collection.py b/tests/python_client/testcases/test_collection.py index 0b847aec87..6bdf024e99 100644 --- a/tests/python_client/testcases/test_collection.py +++ b/tests/python_client/testcases/test_collection.py @@ -2537,6 +2537,18 @@ class TestLoadCollection(TestcaseBase): check_items={"err_code": 15, "err_msg": "collection not found, maybe not loaded"}) + @pytest.mark.tags(CaseLabel.L1) + def test_load_collection_without_creating_index(self): + """ + target: test drop index after load without release + method: create a collection without index, then load + expected: raise exception + """ + collection_w = self.init_collection_general(prefix, True, is_index=True)[0] + collection_w.load(check_task=CheckTasks.err_res, + check_items={"err_code": 1, + "err_msg": "index not exist"}) + class TestReleaseAdvanced(TestcaseBase): @pytest.mark.tags(CaseLabel.L0) diff --git a/tests/python_client/testcases/test_index.py b/tests/python_client/testcases/test_index.py index ecd449885e..2d128fd6f3 100644 --- a/tests/python_client/testcases/test_index.py +++ b/tests/python_client/testcases/test_index.py @@ -1169,7 +1169,7 @@ class TestNewIndexBinary(TestcaseBase): assert len(collection_w.indexes) == 0 -class TestIndexInvalid(object): +class TestIndexInvalid(TestcaseBase): """ Test create / describe / drop index interfaces with invalid collection names """ @@ -1221,6 +1221,23 @@ class TestIndexInvalid(object): with pytest.raises(Exception) as e: connect.create_index(collection, field_name, get_index) + @pytest.mark.tags(CaseLabel.L1) + def test_drop_index_without_release(self): + """ + target: test drop index after load without release + method: 1. create a collection and build an index then load + 2. drop the index + expected: raise exception + """ + collection_w = self.init_collection_general(prefix, True, is_index=True)[0] + default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "L2"} + collection_w.create_index("float_vector", default_index) + collection_w.load() + collection_w.drop_index(check_task=CheckTasks.err_res, + check_items={"err_code": 1, + "err_msg": "index cannot be dropped, collection is " + "loaded, please release it first"}) + class TestNewIndexAsync(TestcaseBase): @pytest.fixture(scope="function", params=[False, True])