From ea58edc1283abfa97d02f68926a403343761e8de Mon Sep 17 00:00:00 2001 From: XuanYang-cn <51370125+XuanYang-cn@users.noreply.github.com> Date: Wed, 15 Jul 2020 14:32:40 +0800 Subject: [PATCH] Add python functional tests about timeout (#2793) * Add python tests about param timeout Signed-off-by: yangxuan * add faiss configure args msg print Signed-off-by: yangxuan * change assertion conditions Signed-off-by: yangxuan Co-authored-by: yangxuan --- .../index/cmake/ThirdPartyPackagesCore.cmake | 2 + tests/milvus_python_test/test_ping.py | 65 ++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/core/src/index/cmake/ThirdPartyPackagesCore.cmake b/core/src/index/cmake/ThirdPartyPackagesCore.cmake index 9e043e63..40caeaff 100644 --- a/core/src/index/cmake/ThirdPartyPackagesCore.cmake +++ b/core/src/index/cmake/ThirdPartyPackagesCore.cmake @@ -543,6 +543,8 @@ macro(build_faiss) --without-cuda) endif () + message(STATUS "Building FAISS with configure args -${FAISS_CONFIGURE_ARGS}") + if (DEFINED ENV{FAISS_SOURCE_URL}) set(FAISS_SOURCE_URL "$ENV{FAISS_SOURCE_URL}") externalproject_add(faiss_ep diff --git a/tests/milvus_python_test/test_ping.py b/tests/milvus_python_test/test_ping.py index 91b548aa..365567b2 100644 --- a/tests/milvus_python_test/test_ping.py +++ b/tests/milvus_python_test/test_ping.py @@ -9,7 +9,7 @@ class TestPing: ''' target: test get the server version method: call the server_version method after connected - expected: version should be the pymilvus version + expected: version should be the milvus version ''' status, res = connect.server_version() assert res == __version__ @@ -54,6 +54,58 @@ class TestPing: assert connect +class TestPingWithTimeout: + def test_server_version_legal_timeout(self, connect): + ''' + target: test get the server version with legal timeout + method: call the server_version method after connected with altering timeout + expected: version should be the milvus version + ''' + status, res = connect.server_version(20) + assert res == __version__ + + def test_server_version_negative_timeout(self, connect): + ''' + target: test get the server version with negative timeout + method: call the server_version method after connected with altering timeout + expected: when timeout is illegal raises an error; + ''' + status, res = connect.server_version(-1) + assert not status.OK() + + def test_server_cmd_with_params_version_with_legal_timeout(self, connect): + ''' + target: test cmd: version and timeout + method: cmd = "version" , timeout=10 + expected: when cmd = 'version', return version of server; + ''' + cmd = "version" + status, msg = connect._cmd(cmd, 10) + logging.getLogger().info(status) + logging.getLogger().info(msg) + assert status.OK() + assert msg == __version__ + + def test_server_cmd_with_params_version_with_illegal_timeout(self, connect): + ''' + target: test cmd: version and timeout + method: cmd = "version" , timeout=-1 + expected: when timeout is illegal raises an error; + ''' + status, res = connect.server_version(-1) + assert not status.OK() + + def test_server_cmd_with_params_others_with_illegal_timeout(self, connect): + ''' + target: test cmd: lalala, timeout = -1 + method: cmd = "lalala", timeout = -1 + expected: when timeout is illegal raises an error; + ''' + cmd = "rm -rf test" + status, res = connect.server_version(-1) + assert not status.OK() + + class TestPingDisconnect: def test_server_version(self, dis_connect): ''' @@ -76,3 +128,14 @@ class TestPingDisconnect: with pytest.raises(Exception) as e: status, msg = connect.server_status() assert status is None + + def test_server_version_with_timeout(self, dis_connect): + ''' + target: test get the server status with timeout settings after disconnect + method: call the server_status method after connected + expected: status returned should be not ok + ''' + status = None + with pytest.raises(Exception) as e: + status, msg = connect.server_status(100) + assert status is None -- GitLab