Loading tests/milvus_python_test/test_add_vectors.py +2 −4 Original line number Original line Diff line number Diff line Loading @@ -50,8 +50,7 @@ class TestAddBase: ''' ''' vector = gen_single_vector(dim) vector = gen_single_vector(dim) status, ids = connect.add_vectors(table, vector) status, ids = connect.add_vectors(table, vector) ret = connect.has_table(table) assert assert_has_table(connect, table) assert ret == True @pytest.mark.timeout(ADD_TIMEOUT) @pytest.mark.timeout(ADD_TIMEOUT) def test_delete_table_add_vector(self, connect, table): def test_delete_table_add_vector(self, connect, table): Loading Loading @@ -618,8 +617,7 @@ class TestAddIP: ''' ''' vector = gen_single_vector(dim) vector = gen_single_vector(dim) status, ids = connect.add_vectors(ip_table, vector) status, ids = connect.add_vectors(ip_table, vector) ret = connect.has_table(ip_table) assert assert_has_table(connect, ip_table) assert ret == True @pytest.mark.timeout(ADD_TIMEOUT) @pytest.mark.timeout(ADD_TIMEOUT) def test_delete_table_add_vector(self, connect, ip_table): def test_delete_table_add_vector(self, connect, ip_table): Loading tests/milvus_python_test/test_table.py +11 −12 Original line number Original line Diff line number Diff line Loading @@ -264,7 +264,7 @@ class TestTable: expected: status ok, and no table in tables expected: status ok, and no table in tables ''' ''' status = connect.delete_table(table) status = connect.delete_table(table) assert not connect.has_table(table) assert not assert_has_table(connect, table) def test_delete_table_ip(self, connect, ip_table): def test_delete_table_ip(self, connect, ip_table): ''' ''' Loading @@ -274,7 +274,7 @@ class TestTable: expected: status ok, and no table in tables expected: status ok, and no table in tables ''' ''' status = connect.delete_table(ip_table) status = connect.delete_table(ip_table) assert not connect.has_table(ip_table) assert not assert_has_table(connect, ip_table) @pytest.mark.level(2) @pytest.mark.level(2) def test_table_delete_without_connection(self, table, dis_connect): def test_table_delete_without_connection(self, table, dis_connect): Loading Loading @@ -314,7 +314,7 @@ class TestTable: connect.create_table(param) connect.create_table(param) status = connect.delete_table(table_name) status = connect.delete_table(table_name) time.sleep(1) time.sleep(1) assert not connect.has_table(table_name) assert not assert_has_table(connect, table_name) def test_delete_create_table_repeatedly(self, connect): def test_delete_create_table_repeatedly(self, connect): ''' ''' Loading Loading @@ -371,7 +371,7 @@ class TestTable: def deletetable(milvus): def deletetable(milvus): status = milvus.delete_table(table) status = milvus.delete_table(table) # assert not status.code==0 # assert not status.code==0 assert milvus.has_table(table) assert assert_has_table(milvus, table) assert status.OK() assert status.OK() for i in range(process_num): for i in range(process_num): Loading Loading @@ -411,11 +411,10 @@ class TestTable: def delete(connect,ids): def delete(connect,ids): i = 0 i = 0 while i < loop_num: while i < loop_num: # assert connect.has_table(table[ids*8+i]) status = connect.delete_table(table[ids*process_num+i]) status = connect.delete_table(table[ids*process_num+i]) time.sleep(2) time.sleep(2) assert status.OK() assert status.OK() assert not connect.has_table(table[ids*process_num+i]) assert not assert_has_table(connect, table[ids*process_num+i]) i = i + 1 i = i + 1 for i in range(process_num): for i in range(process_num): Loading Loading @@ -444,7 +443,7 @@ class TestTable: 'index_file_size': index_file_size, 'index_file_size': index_file_size, 'metric_type': MetricType.L2} 'metric_type': MetricType.L2} connect.create_table(param) connect.create_table(param) assert connect.has_table(table_name) assert assert_has_table(connect, table_name) def test_has_table_ip(self, connect): def test_has_table_ip(self, connect): ''' ''' Loading @@ -458,7 +457,7 @@ class TestTable: 'index_file_size': index_file_size, 'index_file_size': index_file_size, 'metric_type': MetricType.IP} 'metric_type': MetricType.IP} connect.create_table(param) connect.create_table(param) assert connect.has_table(table_name) assert assert_has_table(connect, table_name) @pytest.mark.level(2) @pytest.mark.level(2) def test_has_table_without_connection(self, table, dis_connect): def test_has_table_without_connection(self, table, dis_connect): Loading @@ -468,7 +467,7 @@ class TestTable: expected: has table raise exception expected: has table raise exception ''' ''' with pytest.raises(Exception) as e: with pytest.raises(Exception) as e: status = dis_connect.has_table(table) assert_has_table(dis_connect, table) def test_has_table_not_existed(self, connect): def test_has_table_not_existed(self, connect): ''' ''' Loading @@ -478,7 +477,7 @@ class TestTable: expected: False expected: False ''' ''' table_name = gen_unique_str("test_table") table_name = gen_unique_str("test_table") assert not connect.has_table(table_name) assert not assert_has_table(connect, table_name) """ """ ****************************************************************** ****************************************************************** Loading Loading @@ -700,7 +699,7 @@ class TestCreateTableDimInvalid(object): 'dimension': dimension, 'dimension': dimension, 'index_file_size': index_file_size, 'index_file_size': index_file_size, 'metric_type': MetricType.L2} 'metric_type': MetricType.L2} if isinstance(dimension, int) and dimension > 0: if isinstance(dimension, int): status = connect.create_table(param) status = connect.create_table(param) assert not status.OK() assert not status.OK() else: else: Loading Loading @@ -778,7 +777,7 @@ def preload_table(connect, **params): return status return status def has(connect, **params): def has(connect, **params): status = connect.has_table(params["table_name"]) status = assert_has_table(connect, params["table_name"]) return status return status def show(connect, **params): def show(connect, **params): Loading tests/milvus_python_test/utils.py +5 −0 Original line number Original line Diff line number Diff line Loading @@ -462,6 +462,11 @@ def gen_simple_index_params(): return gen_params(index_types, nlists) return gen_params(index_types, nlists) def assert_has_table(conn, table_name): status, ok = conn.has_table(table_name) return status.OK() and ok if __name__ == "__main__": if __name__ == "__main__": import numpy import numpy Loading Loading
tests/milvus_python_test/test_add_vectors.py +2 −4 Original line number Original line Diff line number Diff line Loading @@ -50,8 +50,7 @@ class TestAddBase: ''' ''' vector = gen_single_vector(dim) vector = gen_single_vector(dim) status, ids = connect.add_vectors(table, vector) status, ids = connect.add_vectors(table, vector) ret = connect.has_table(table) assert assert_has_table(connect, table) assert ret == True @pytest.mark.timeout(ADD_TIMEOUT) @pytest.mark.timeout(ADD_TIMEOUT) def test_delete_table_add_vector(self, connect, table): def test_delete_table_add_vector(self, connect, table): Loading Loading @@ -618,8 +617,7 @@ class TestAddIP: ''' ''' vector = gen_single_vector(dim) vector = gen_single_vector(dim) status, ids = connect.add_vectors(ip_table, vector) status, ids = connect.add_vectors(ip_table, vector) ret = connect.has_table(ip_table) assert assert_has_table(connect, ip_table) assert ret == True @pytest.mark.timeout(ADD_TIMEOUT) @pytest.mark.timeout(ADD_TIMEOUT) def test_delete_table_add_vector(self, connect, ip_table): def test_delete_table_add_vector(self, connect, ip_table): Loading
tests/milvus_python_test/test_table.py +11 −12 Original line number Original line Diff line number Diff line Loading @@ -264,7 +264,7 @@ class TestTable: expected: status ok, and no table in tables expected: status ok, and no table in tables ''' ''' status = connect.delete_table(table) status = connect.delete_table(table) assert not connect.has_table(table) assert not assert_has_table(connect, table) def test_delete_table_ip(self, connect, ip_table): def test_delete_table_ip(self, connect, ip_table): ''' ''' Loading @@ -274,7 +274,7 @@ class TestTable: expected: status ok, and no table in tables expected: status ok, and no table in tables ''' ''' status = connect.delete_table(ip_table) status = connect.delete_table(ip_table) assert not connect.has_table(ip_table) assert not assert_has_table(connect, ip_table) @pytest.mark.level(2) @pytest.mark.level(2) def test_table_delete_without_connection(self, table, dis_connect): def test_table_delete_without_connection(self, table, dis_connect): Loading Loading @@ -314,7 +314,7 @@ class TestTable: connect.create_table(param) connect.create_table(param) status = connect.delete_table(table_name) status = connect.delete_table(table_name) time.sleep(1) time.sleep(1) assert not connect.has_table(table_name) assert not assert_has_table(connect, table_name) def test_delete_create_table_repeatedly(self, connect): def test_delete_create_table_repeatedly(self, connect): ''' ''' Loading Loading @@ -371,7 +371,7 @@ class TestTable: def deletetable(milvus): def deletetable(milvus): status = milvus.delete_table(table) status = milvus.delete_table(table) # assert not status.code==0 # assert not status.code==0 assert milvus.has_table(table) assert assert_has_table(milvus, table) assert status.OK() assert status.OK() for i in range(process_num): for i in range(process_num): Loading Loading @@ -411,11 +411,10 @@ class TestTable: def delete(connect,ids): def delete(connect,ids): i = 0 i = 0 while i < loop_num: while i < loop_num: # assert connect.has_table(table[ids*8+i]) status = connect.delete_table(table[ids*process_num+i]) status = connect.delete_table(table[ids*process_num+i]) time.sleep(2) time.sleep(2) assert status.OK() assert status.OK() assert not connect.has_table(table[ids*process_num+i]) assert not assert_has_table(connect, table[ids*process_num+i]) i = i + 1 i = i + 1 for i in range(process_num): for i in range(process_num): Loading Loading @@ -444,7 +443,7 @@ class TestTable: 'index_file_size': index_file_size, 'index_file_size': index_file_size, 'metric_type': MetricType.L2} 'metric_type': MetricType.L2} connect.create_table(param) connect.create_table(param) assert connect.has_table(table_name) assert assert_has_table(connect, table_name) def test_has_table_ip(self, connect): def test_has_table_ip(self, connect): ''' ''' Loading @@ -458,7 +457,7 @@ class TestTable: 'index_file_size': index_file_size, 'index_file_size': index_file_size, 'metric_type': MetricType.IP} 'metric_type': MetricType.IP} connect.create_table(param) connect.create_table(param) assert connect.has_table(table_name) assert assert_has_table(connect, table_name) @pytest.mark.level(2) @pytest.mark.level(2) def test_has_table_without_connection(self, table, dis_connect): def test_has_table_without_connection(self, table, dis_connect): Loading @@ -468,7 +467,7 @@ class TestTable: expected: has table raise exception expected: has table raise exception ''' ''' with pytest.raises(Exception) as e: with pytest.raises(Exception) as e: status = dis_connect.has_table(table) assert_has_table(dis_connect, table) def test_has_table_not_existed(self, connect): def test_has_table_not_existed(self, connect): ''' ''' Loading @@ -478,7 +477,7 @@ class TestTable: expected: False expected: False ''' ''' table_name = gen_unique_str("test_table") table_name = gen_unique_str("test_table") assert not connect.has_table(table_name) assert not assert_has_table(connect, table_name) """ """ ****************************************************************** ****************************************************************** Loading Loading @@ -700,7 +699,7 @@ class TestCreateTableDimInvalid(object): 'dimension': dimension, 'dimension': dimension, 'index_file_size': index_file_size, 'index_file_size': index_file_size, 'metric_type': MetricType.L2} 'metric_type': MetricType.L2} if isinstance(dimension, int) and dimension > 0: if isinstance(dimension, int): status = connect.create_table(param) status = connect.create_table(param) assert not status.OK() assert not status.OK() else: else: Loading Loading @@ -778,7 +777,7 @@ def preload_table(connect, **params): return status return status def has(connect, **params): def has(connect, **params): status = connect.has_table(params["table_name"]) status = assert_has_table(connect, params["table_name"]) return status return status def show(connect, **params): def show(connect, **params): Loading
tests/milvus_python_test/utils.py +5 −0 Original line number Original line Diff line number Diff line Loading @@ -462,6 +462,11 @@ def gen_simple_index_params(): return gen_params(index_types, nlists) return gen_params(index_types, nlists) def assert_has_table(conn, table_name): status, ok = conn.has_table(table_name) return status.OK() and ok if __name__ == "__main__": if __name__ == "__main__": import numpy import numpy Loading