From a1d303086741a28521e0b37018370879b6e2002d Mon Sep 17 00:00:00 2001 From: zhuwenxing Date: Wed, 29 Mar 2023 15:22:01 +0800 Subject: [PATCH] [test] fix get collection (#23099) Signed-off-by: zhuwenxing --- .../chaos/testcases/test_get_collections.py | 10 ++++------ tests/python_client/deploy/common.py | 12 +++++++++++- .../testcases/test_action_second_deployment.py | 4 ++-- .../deploy/testcases/test_get_all_collections.py | 6 +++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/tests/python_client/chaos/testcases/test_get_collections.py b/tests/python_client/chaos/testcases/test_get_collections.py index a14958577e..9fbfb5bca3 100644 --- a/tests/python_client/chaos/testcases/test_get_collections.py +++ b/tests/python_client/chaos/testcases/test_get_collections.py @@ -4,9 +4,7 @@ from collections import defaultdict import pytest from base.client_base import TestcaseBase -from common import common_func as cf -from common import common_type as ct -from deploy.common import get_collections +from deploy.common import get_chaos_test_collections from common.common_type import CaseLabel from utils.util_log import test_log as log @@ -36,8 +34,8 @@ class TestGetCollections(TestcaseBase): data = { "all": selected_collections, } - with open("/tmp/ci_logs/all_collections.json", "w") as f: + with open("/tmp/ci_logs/chaos_test_all_collections.json", "w") as f: f.write(json.dumps(data)) - log.info(f"write {len(selected_collections)} collections to /tmp/ci_logs/all_collections.json") - collections_in_json = get_collections() + log.info(f"write {len(selected_collections)} collections to /tmp/ci_logs/chaos_test_all_collections.json") + collections_in_json = get_chaos_test_collections() assert len(selected_collections) == len(collections_in_json) diff --git a/tests/python_client/deploy/common.py b/tests/python_client/deploy/common.py index c6df7022c1..1b938b97a2 100644 --- a/tests/python_client/deploy/common.py +++ b/tests/python_client/deploy/common.py @@ -44,7 +44,7 @@ def gen_search_param(index_type, metric_type="L2"): return search_params -def get_collections(): +def get_deploy_test_collections(): try: with open("/tmp/ci_logs/deploy_test_all_collections.json", "r") as f: data = json.load(f) @@ -52,4 +52,14 @@ def get_collections(): except Exception as e: log.error(f"get_all_collections error: {e}") return [] + return collections + +def get_chaos_test_collections(): + try: + with open("/tmp/ci_logs/chaos_test_all_collections.json", "r") as f: + data = json.load(f) + collections = data["all"] + except Exception as e: + log.error(f"get_all_collections error: {e}") + return [] return collections \ No newline at end of file diff --git a/tests/python_client/deploy/testcases/test_action_second_deployment.py b/tests/python_client/deploy/testcases/test_action_second_deployment.py index 63288ed955..98fb92c48a 100644 --- a/tests/python_client/deploy/testcases/test_action_second_deployment.py +++ b/tests/python_client/deploy/testcases/test_action_second_deployment.py @@ -8,7 +8,7 @@ from common.common_type import CaseLabel, CheckTasks from common.milvus_sys import MilvusSys from utils.util_pymilvus import * from deploy.base import TestDeployBase -from deploy.common import gen_index_param, gen_search_param, get_collections +from deploy.common import gen_index_param, gen_search_param, get_deploy_test_collections from utils.util_log import test_log as log default_nb = ct.default_nb @@ -31,7 +31,7 @@ pymilvus_version = pymilvus.__version__ class TestActionSecondDeployment(TestDeployBase): """ Test case of action before reinstall """ - @pytest.fixture(scope="function", params=get_collections()) + @pytest.fixture(scope="function", params=get_deploy_test_collections()) def all_collection_name(self, request): if request.param == [] or request.param == "": pytest.skip("The collection name is invalid") diff --git a/tests/python_client/deploy/testcases/test_get_all_collections.py b/tests/python_client/deploy/testcases/test_get_all_collections.py index 237fc1fa0a..53c6cd4d3e 100644 --- a/tests/python_client/deploy/testcases/test_get_all_collections.py +++ b/tests/python_client/deploy/testcases/test_get_all_collections.py @@ -2,7 +2,7 @@ import json import pytest from base.client_base import TestcaseBase -from deploy.common import get_collections +from deploy.common import get_deploy_test_collections from common.common_type import CaseLabel from utils.util_log import test_log as log @@ -20,8 +20,8 @@ class TestGetCollections(TestcaseBase): data = { "all": all_collections, } - with open("/tmp/ci_logs/all_collections.json", "w") as f: + with open("/tmp/ci_logs/deploy_test_all_collections.json", "w") as f: f.write(json.dumps(data)) log.info(f"write {len(all_collections)} collections to /tmp/ci_logs/deploy_test_all_collections.json") - collections_in_json = get_collections() + collections_in_json = get_deploy_test_collections() assert len(all_collections) == len(collections_in_json)