From 222112d98af598e172d59672f921fcdd19be78e6 Mon Sep 17 00:00:00 2001 From: binbin <83755740+binbinlv@users.noreply.github.com> Date: Fri, 29 Apr 2022 09:11:47 +0800 Subject: [PATCH] Enable and modify test cases after code fix (#16720) Signed-off-by: Binbin Lv --- tests/python_client/requirements.txt | 2 +- .../testcases/test_connection.py | 100 +++++++++++++----- tests/python_client/testcases/test_utility.py | 32 +++--- 3 files changed, 91 insertions(+), 43 deletions(-) diff --git a/tests/python_client/requirements.txt b/tests/python_client/requirements.txt index ab821f2e0b..c27dc94718 100644 --- a/tests/python_client/requirements.txt +++ b/tests/python_client/requirements.txt @@ -9,7 +9,7 @@ allure-pytest==2.7.0 pytest-print==0.2.1 pytest-level==0.1.1 pytest-xdist==2.2.1 -pymilvus==2.1.0.dev33 +pymilvus==2.1.0.dev36 pytest-rerunfailures==9.1.1 git+https://github.com/Projectplace/pytest-tags ndg-httpsclient diff --git a/tests/python_client/testcases/test_connection.py b/tests/python_client/testcases/test_connection.py index b9983e8ae2..d92ad860a9 100644 --- a/tests/python_client/testcases/test_connection.py +++ b/tests/python_client/testcases/test_connection.py @@ -30,7 +30,9 @@ class TestConnectionParams(TestcaseBase): # get addr of default alias self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "19530", + "user": ""}}) # list all connections and check the response self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr, @@ -150,11 +152,17 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "19530", + "user": ""}}) self.connection_wrap.get_connection_addr(alias="alias1", check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {"host": "localhost", "port": "1"}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "1", + "user": ""}}) self.connection_wrap.get_connection_addr(alias="alias2", check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {"host": "hostlocal", "port": "-1"}}) + check_items={ct.dict_content: {"host": "hostlocal", + "port": "-1", + "user": ""}}) self.connection_wrap.get_connection_addr(alias="testing", check_task=ct.CheckTasks.ccr, check_items={ct.dict_content: {}}) @@ -181,11 +189,17 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "19530", + "user": ""}}) self.connection_wrap.get_connection_addr(alias="alias1", check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {"host": "localhost", "port": "1"}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "1", + "user": ""}}) self.connection_wrap.get_connection_addr(alias="alias2", check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {"host": "192.168.1.1", "port": "123"}}) + check_items={ct.dict_content: {"host": "192.168.1.1", + "port": "123", + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L1) def test_connection_add_single_more(self): @@ -206,11 +220,17 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "19530", + "user": ""}}) self.connection_wrap.get_connection_addr(alias="alias1", check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {"host": "localhost", "port": "1"}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "1", + "user": ""}}) self.connection_wrap.get_connection_addr(alias="alias2", check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {"host": "192.168.1.1", "port": "123"}}) + check_items={ct.dict_content: {"host": "192.168.1.1", + "port": "123", + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L0) def test_connection_add_default(self): @@ -230,7 +250,9 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "19530", + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L1) def test_connection_add_cover_default(self): @@ -242,7 +264,9 @@ class TestConnectionOperation(TestcaseBase): # get all addr of default alias and check the response self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "19530", + "user": ""}}) # add connections self.connection_wrap.add_connection(default={'host': '192.168.1.1', 'port': '12345'}) @@ -253,8 +277,9 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': '192.168.1.1', - 'port': '12345'}}) + check_items={ct.dict_content: {"host": "192.168.1.1", + "port": "12345", + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L1) def test_connection_get_addr_not_exist(self): @@ -334,14 +359,18 @@ class TestConnectionOperation(TestcaseBase): # get the connection address after it disconnected self.connection_wrap.get_connection_addr(alias="test_alias_name", check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {"host": host, "port": port}}) + check_items={ct.dict_content: {"host": host, + "port": port, + "user": ""}}) # re-add connection by the same alias with different connection params self.connection_wrap.add_connection(test_alias_name={"host": "localhost", "port": "1"}) # re-get the connection address self.connection_wrap.get_connection_addr(alias="test_alias_name", check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {"host": "localhost", "port": "1"}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "1", + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L1) def test_connection_add_after_remove(self, host, port): @@ -367,7 +396,9 @@ class TestConnectionOperation(TestcaseBase): # get an addr that is exist self.connection_wrap.get_connection_addr(alias="test_alias_name", check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {"host": "localhost", "port": "1"}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "1", + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L1) def test_connection_connect_alias_not_exist(self): @@ -388,7 +419,9 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': "localhost", 'port': "19530"}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "19530", + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L1) def test_connection_connect_default_alias_invalid(self, port): @@ -413,7 +446,9 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': "host", 'port': port}}) + check_items={ct.dict_content: {"host": "host", + "port": port, + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L0) def test_connection_connect_default_alias_effective(self, host, port): @@ -438,7 +473,9 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': host, 'port': port}}) + check_items={ct.dict_content: {"host": host, + "port": port, + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L1) @pytest.mark.parametrize("connect_name", [DefaultConfig.DEFAULT_USING]) @@ -499,7 +536,9 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=connect_name, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': host, 'port': port}}) + check_items={ct.dict_content: {"host": host, + "port": port, + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L1) @pytest.mark.parametrize("connect_name", [DefaultConfig.DEFAULT_USING, "test_alias_nme"]) @@ -521,7 +560,8 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response dict_content = {'host': DefaultConfig.DEFAULT_HOST, - 'port': DefaultConfig.DEFAULT_PORT} if connect_name == DefaultConfig.DEFAULT_USING else {} + 'port': DefaultConfig.DEFAULT_PORT, + 'user': ''} if connect_name == DefaultConfig.DEFAULT_USING else {} self.connection_wrap.get_connection_addr(alias=connect_name, check_task=ct.CheckTasks.ccr, check_items={ct.dict_content: dict_content}) @@ -547,7 +587,9 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {"host": "localhost", "port": "19530"}}) + check_items={ct.dict_content: {"host": "localhost", + "port": "19530", + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L1) def test_connection_disconnect_after_default_connect(self, host, port): @@ -588,7 +630,9 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': host, 'port': port}}) + check_items={ct.dict_content: {"host": host, + "port": port, + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L1) def test_connection_disconnect_after_connect(self, host, port): @@ -615,7 +659,9 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=test_alias_name, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': host, 'port': port}}) + check_items={ct.dict_content: {"host": host, + "port": port, + "user": ""}}) # disconnect alias is exist self.connection_wrap.disconnect(alias=test_alias_name) @@ -627,7 +673,9 @@ class TestConnectionOperation(TestcaseBase): # get all addr of alias and check the response self.connection_wrap.get_connection_addr(alias=test_alias_name, check_task=ct.CheckTasks.ccr, - check_items={ct.dict_content: {'host': host, 'port': port}}) + check_items={ct.dict_content: {"host": host, + "port": port, + "user": ""}}) @pytest.mark.tags(ct.CaseLabel.L1) def test_connection_remove_connection_not_exist(self): diff --git a/tests/python_client/testcases/test_utility.py b/tests/python_client/testcases/test_utility.py index 159783e262..756698f21c 100644 --- a/tests/python_client/testcases/test_utility.py +++ b/tests/python_client/testcases/test_utility.py @@ -21,6 +21,8 @@ default_nb = ct.default_nb num_loaded_entities = "num_loaded_entities" num_total_entities = "num_total_entities" loading_progress = "loading_progress" +num_loaded_partitions = "num_loaded_partitions" +not_loaded_partitions = "not_loaded_partitions" class TestUtilityParams(TestcaseBase): @@ -242,6 +244,7 @@ class TestUtilityParams(TestcaseBase): check_task=CheckTasks.err_res, check_items=err_msg) @pytest.mark.tags(CaseLabel.L2) + @pytest.mark.xfail(reason="issue to be discussed") @pytest.mark.parametrize("partition_names", [[ct.default_tag], [ct.default_partition_name, ct.default_tag]]) def test_loading_progress_not_existed_partitions(self, partition_names): """ @@ -761,20 +764,19 @@ class TestUtilityBase(TestcaseBase): assert res["indexed_rows"] == nb @pytest.mark.tags(CaseLabel.L2) - @pytest.mark.xfail(reason="https://github.com/milvus-io/milvus/issues/16468") def test_loading_progress_without_loading(self): """ target: test loading progress without loading method: insert and flush data, call loading_progress without loading - expected: loaded entities is 0 + expected: raise exception """ collection_w = self.init_collection_wrap() df = cf.gen_default_dataframe_data() collection_w.insert(df) assert collection_w.num_entities == ct.default_nb - exp_res = {loading_progress: '0%'} - res, _ = self.utility_wrap.loading_progress(collection_w.name) - assert res == exp_res + error = {ct.err_code: 1, ct.err_msg: {"has not been loaded into QueryNode"}} + self.utility_wrap.loading_progress(collection_w.name, + check_task=CheckTasks.err_res, check_items=error) @pytest.mark.tags(CaseLabel.L1) @pytest.mark.parametrize("nb", [ct.default_nb, 5000]) @@ -818,25 +820,24 @@ class TestUtilityBase(TestcaseBase): collection_w = self.init_collection_wrap() collection_w.load() res, _ = self.utility_wrap.loading_progress(collection_w.name) - exp_res = {loading_progress: '100%'} + exp_res = {loading_progress: '100%', num_loaded_partitions: 1, not_loaded_partitions: []} + assert exp_res == res @pytest.mark.tags(CaseLabel.L1) - @pytest.mark.xfail(reason="https://github.com/milvus-io/milvus/issues/16468") def test_loading_progress_after_release(self): """ - target: test loading progress without loading - method: insert and flush data, call loading_progress without loading - expected: loaded entities is 0 + target: test loading progress after release + method: insert and flush data, call loading_progress after release + expected: raise exception """ collection_w = self.init_collection_general(prefix, insert_data=True)[0] collection_w.release() - exp_res = {loading_progress: '0%'} - res, _ = self.utility_wrap.loading_progress(collection_w.name) - assert res == exp_res + error = {ct.err_code: 1, ct.err_msg: {"has not been loaded into QueryNode"}} + self.utility_wrap.loading_progress(collection_w.name, + check_task=CheckTasks.err_res, check_items=error) @pytest.mark.tags(CaseLabel.L2) - @pytest.mark.xfail(reason="https://github.com/milvus-io/milvus/issues/16468") def test_loading_progress_with_release_partition(self): """ target: test loading progress after release part partitions @@ -852,7 +853,6 @@ class TestUtilityBase(TestcaseBase): assert res[loading_progress] == '50%' @pytest.mark.tags(CaseLabel.L2) - @pytest.mark.xfail(reason="https://github.com/milvus-io/milvus/issues/16468") def test_loading_progress_with_load_partition(self): """ target: test loading progress after load partition @@ -892,7 +892,7 @@ class TestUtilityBase(TestcaseBase): cw.load() self.utility_wrap.wait_for_loading_complete(cw.name) res, _ = self.utility_wrap.loading_progress(cw.name) - exp_res = {loading_progress: "100%"} + exp_res = {loading_progress: "100%", not_loaded_partitions: [], num_loaded_partitions: 1} assert res == exp_res @pytest.mark.tags(CaseLabel.L1)