From 3cf6cf3802b7277ce930c17b95053caafbd32ad0 Mon Sep 17 00:00:00 2001 From: NicoYuan1986 <109071306+NicoYuan1986@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:08:58 +0800 Subject: [PATCH] Add more cases to test shard_num valid range (#18965) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: “nico” Signed-off-by: “nico” --- .../python_client/testcases/test_collection.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/python_client/testcases/test_collection.py b/tests/python_client/testcases/test_collection.py index 17a3b02d18..41c0ec7906 100644 --- a/tests/python_client/testcases/test_collection.py +++ b/tests/python_client/testcases/test_collection.py @@ -902,8 +902,8 @@ class TestCollectionParams(TestcaseBase): check_items={exp_name: c_name, exp_shards_num: default_shards_num}) assert c_name in self.utility_wrap.list_collections()[0] - @pytest.mark.tags(CaseLabel.L0) - @pytest.mark.parametrize("shards_num", [-256, 0, 10, 256]) + @pytest.mark.tags(CaseLabel.L2) + @pytest.mark.parametrize("shards_num", [-256, 0, 1, 10, 214, 256]) def test_collection_shards_num_with_not_default_value(self, shards_num): """ target:test collection with shards_num @@ -917,6 +917,20 @@ class TestCollectionParams(TestcaseBase): check_items={exp_name: c_name, exp_shards_num: shards_num}) assert c_name in self.utility_wrap.list_collections()[0] + @pytest.mark.tags(CaseLabel.L2) + @pytest.mark.parametrize("shards_num", [257]) + def test_collection_shards_num_invalid(self, shards_num): + """ + target:test collection with invalid shards_num + method:create collection with shards_num out of [1,256] + expected: raise exception + """ + self._connect() + c_name = cf.gen_unique_str(prefix) + error = {ct.err_code: 1, ct.err_msg: "maximum shards's number should be limited to 256"} + self.collection_wrap.init_collection(c_name, schema=default_schema, shards_num=shards_num, + check_task=CheckTasks.err_res, check_items=error) + @pytest.mark.tags(CaseLabel.L2) def test_collection_shards_num_with_error_type(self): """