未验证 提交 6283ee1b 编写于 作者: D del-zhenwu 提交者: GitHub

Remove connect (#2193)

* remove disconnect test case
Signed-off-by: Nzw <zw@zilliz.com>

* stable case
Signed-off-by: Nzw <zw@zilliz.com>

* re-trigger
Signed-off-by: Nzw <zw@zilliz.com>

* update cases
Signed-off-by: Nzw <zw@zilliz.com>
上级 2c889636
...@@ -601,12 +601,11 @@ class TestAddBase: ...@@ -601,12 +601,11 @@ class TestAddBase:
processes = [] processes = []
def add(): def add():
milvus = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"]) milvus = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
milvus.connect(uri=uri)
i = 0 i = 0
while i < loop_num: while i < loop_num:
status, ids = milvus.add_vectors(collection, vector) status, ids = milvus.add_vectors(collection, vector)
i = i + 1 i = i + 1
milvus.disconnect() # milvus.disconnect()
for i in range(process_num): for i in range(process_num):
p = Process(target=add, args=()) p = Process(target=add, args=())
processes.append(p) processes.append(p)
......
...@@ -50,7 +50,7 @@ class TestConnect: ...@@ -50,7 +50,7 @@ class TestConnect:
expected: connected is True expected: connected is True
''' '''
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"]) milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
assert milvus.connected() # assert milvus.connected()
def test_connect_connected(self, args): def test_connect_connected(self, args):
''' '''
...@@ -59,8 +59,9 @@ class TestConnect: ...@@ -59,8 +59,9 @@ class TestConnect:
expected: connected is False expected: connected is False
''' '''
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"]) milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
milvus.disconnect() # milvus.disconnect()
assert not milvus.connected() # assert not milvus.connected()
assert milvus
# TODO: Currently we test with remote IP, localhost testing need to add # TODO: Currently we test with remote IP, localhost testing need to add
def _test_connect_ip_localhost(self, args): def _test_connect_ip_localhost(self, args):
...@@ -70,8 +71,8 @@ class TestConnect: ...@@ -70,8 +71,8 @@ class TestConnect:
expected: connected is True expected: connected is True
''' '''
milvus = get_milvus(args["ip"], args["port"], args["handler"]) milvus = get_milvus(args["ip"], args["port"], args["handler"])
milvus.connect(host='localhost', port=args["port"]) # milvus.connect(host='localhost', port=args["port"])
assert milvus.connected() # assert milvus.connected()
@pytest.mark.timeout(CONNECT_TIMEOUT) @pytest.mark.timeout(CONNECT_TIMEOUT)
def test_connect_wrong_ip_null(self, args): def test_connect_wrong_ip_null(self, args):
...@@ -83,7 +84,7 @@ class TestConnect: ...@@ -83,7 +84,7 @@ class TestConnect:
ip = "" ip = ""
with pytest.raises(Exception) as e: with pytest.raises(Exception) as e:
milvus = get_milvus(ip, args["port"], args["handler"]) milvus = get_milvus(ip, args["port"], args["handler"])
assert not milvus.connected() # assert not milvus.connected()
def test_connect_uri(self, args): def test_connect_uri(self, args):
''' '''
...@@ -93,7 +94,7 @@ class TestConnect: ...@@ -93,7 +94,7 @@ class TestConnect:
''' '''
uri_value = "tcp://%s:%s" % (args["ip"], args["port"]) uri_value = "tcp://%s:%s" % (args["ip"], args["port"])
milvus = get_milvus(args["ip"], args["port"], uri=uri_value, handler=args["handler"]) milvus = get_milvus(args["ip"], args["port"], uri=uri_value, handler=args["handler"])
assert milvus.connected() # assert milvus.connected()
def test_connect_uri_null(self, args): def test_connect_uri_null(self, args):
''' '''
...@@ -104,36 +105,36 @@ class TestConnect: ...@@ -104,36 +105,36 @@ class TestConnect:
uri_value = "" uri_value = ""
if self.local_ip(args): if self.local_ip(args):
milvus = get_milvus(uri=uri_value, handler=args["handler"]) milvus = get_milvus(uri=uri_value, handler=args["handler"])
assert milvus.connected() # assert milvus.connected()
else: else:
with pytest.raises(Exception) as e: with pytest.raises(Exception) as e:
milvus = get_milvus(uri=uri_value, handler=args["handler"]) milvus = get_milvus(uri=uri_value, handler=args["handler"])
assert not milvus.connected() # assert not milvus.connected()
# disable # disable
def _test_connect_with_multiprocess(self, args): # def _test_connect_with_multiprocess(self, args):
''' # '''
target: test uri connect with multiprocess # target: test uri connect with multiprocess
method: set correct uri, test with multiprocessing connecting # method: set correct uri, test with multiprocessing connecting
expected: all connection is connected # expected: all connection is connected
''' # '''
uri_value = "tcp://%s:%s" % (args["ip"], args["port"]) # uri_value = "tcp://%s:%s" % (args["ip"], args["port"])
process_num = 10 # process_num = 10
processes = [] # processes = []
def connect(milvus): # def connect(milvus):
milvus.connect(uri=uri_value) # milvus.connect(uri=uri_value)
with pytest.raises(Exception) as e: # with pytest.raises(Exception) as e:
milvus.connect(uri=uri_value) # milvus.connect(uri=uri_value)
assert milvus.connected() # # assert milvus.connected()
for i in range(process_num): # for i in range(process_num):
milvus = get_milvus(args["ip"], args["port"], args["handler"]) # milvus = get_milvus(args["ip"], args["port"], args["handler"])
p = Process(target=connect, args=(milvus, )) # p = Process(target=connect, args=(milvus, ))
processes.append(p) # processes.append(p)
p.start() # p.start()
for p in processes: # for p in processes:
p.join() # p.join()
def test_connect_repeatedly(self, args): def test_connect_repeatedly(self, args):
''' '''
...@@ -143,9 +144,10 @@ class TestConnect: ...@@ -143,9 +144,10 @@ class TestConnect:
''' '''
uri_value = "tcp://%s:%s" % (args["ip"], args["port"]) uri_value = "tcp://%s:%s" % (args["ip"], args["port"])
milvus = Milvus(uri=uri_value, handler=args["handler"]) milvus = Milvus(uri=uri_value, handler=args["handler"])
milvus.connect(uri=uri_value, timeout=5) # milvus.connect(uri=uri_value, timeout=5)
milvus.connect(uri=uri_value, timeout=5) # milvus.connect(uri=uri_value, timeout=5)
assert milvus.connected() milvus = Milvus(uri=uri_value, handler=args["handler"])
# assert milvus.connected()
# def test_connect_disconnect_repeatedly_times(self, args): # def test_connect_disconnect_repeatedly_times(self, args):
# ''' # '''
...@@ -160,43 +162,43 @@ class TestConnect: ...@@ -160,43 +162,43 @@ class TestConnect:
# assert not milvus.connected() # assert not milvus.connected()
# TODO: enable # TODO: enable
def _test_connect_disconnect_with_multiprocess(self, args): # def _test_connect_disconnect_with_multiprocess(self, args):
''' # '''
target: test uri connect and disconnect repeatly with multiprocess # target: test uri connect and disconnect repeatly with multiprocess
method: set correct uri, test with multiprocessing connecting and disconnecting # method: set correct uri, test with multiprocessing connecting and disconnecting
expected: all connection is connected after 10 times operation # expected: all connection is connected after 10 times operation
''' # '''
uri_value = "tcp://%s:%s" % (args["ip"], args["port"]) # uri_value = "tcp://%s:%s" % (args["ip"], args["port"])
process_num = 4 # process_num = 4
processes = [] # processes = []
def connect(milvus): # def connect(milvus):
milvus.connect(uri=uri_value) # milvus.connect(uri=uri_value)
milvus.disconnect() # milvus.disconnect()
milvus.connect(uri=uri_value) # milvus.connect(uri=uri_value)
assert milvus.connected() # assert milvus.connected()
for i in range(process_num): # for i in range(process_num):
milvus = get_milvus(args["ip"], args["port"], args["handler"]) # milvus = get_milvus(args["ip"], args["port"], args["handler"])
p = Process(target=connect, args=(milvus, )) # p = Process(target=connect, args=(milvus, ))
processes.append(p) # processes.append(p)
p.start() # p.start()
for p in processes: # for p in processes:
p.join() # p.join()
# Disable, (issue: https://github.com/milvus-io/milvus/issues/288) # Disable, (issue: https://github.com/milvus-io/milvus/issues/288)
def _test_connect_param_priority_both_hostip_uri(self, args): # def _test_connect_param_priority_both_hostip_uri(self, args):
''' # '''
target: both host_ip_port / uri are both given, and not null, use the uri params # target: both host_ip_port / uri are both given, and not null, use the uri params
method: check if wrong uri connection is ok # method: check if wrong uri connection is ok
expected: connect raise an exception and connected is false # expected: connect raise an exception and connected is false
''' # '''
milvus = get_milvus(args["ip"], args["port"], args["handler"]) # milvus = get_milvus(args["ip"], args["port"], args["handler"])
uri_value = "tcp://%s:%s" % (args["ip"], args["port"]) # uri_value = "tcp://%s:%s" % (args["ip"], args["port"])
with pytest.raises(Exception) as e: # with pytest.raises(Exception) as e:
res = milvus.connect(host=args["ip"], port=39540, uri=uri_value, timeout=1) # res = milvus.connect(host=args["ip"], port=39540, uri=uri_value, timeout=1)
logging.getLogger().info(res) # logging.getLogger().info(res)
# assert not milvus.connected() # # assert not milvus.connected()
def _test_add_vector_and_disconnect_concurrently(self): def _test_add_vector_and_disconnect_concurrently(self):
''' '''
...@@ -250,7 +252,7 @@ class TestConnectIPInvalid(object): ...@@ -250,7 +252,7 @@ class TestConnectIPInvalid(object):
ip = get_invalid_ip ip = get_invalid_ip
with pytest.raises(Exception) as e: with pytest.raises(Exception) as e:
milvus = get_milvus(ip, args["port"], args["handler"]) milvus = get_milvus(ip, args["port"], args["handler"])
assert not milvus.connected() # assert not milvus.connected()
class TestConnectPortInvalid(object): class TestConnectPortInvalid(object):
...@@ -276,7 +278,7 @@ class TestConnectPortInvalid(object): ...@@ -276,7 +278,7 @@ class TestConnectPortInvalid(object):
port = get_invalid_port port = get_invalid_port
with pytest.raises(Exception) as e: with pytest.raises(Exception) as e:
milvus = get_milvus(args["ip"], port, args["handler"]) milvus = get_milvus(args["ip"], port, args["handler"])
assert not milvus.connected() # assert not milvus.connected()
class TestConnectURIInvalid(object): class TestConnectURIInvalid(object):
...@@ -301,4 +303,4 @@ class TestConnectURIInvalid(object): ...@@ -301,4 +303,4 @@ class TestConnectURIInvalid(object):
uri_value = get_invalid_uri uri_value = get_invalid_uri
with pytest.raises(Exception) as e: with pytest.raises(Exception) as e:
milvus = get_milvus(uri=uri_value, handler=args["handler"]) milvus = get_milvus(uri=uri_value, handler=args["handler"])
assert not milvus.connected() # assert not milvus.connected()
...@@ -34,7 +34,7 @@ class TestMixBase: ...@@ -34,7 +34,7 @@ class TestMixBase:
uri = "tcp://%s:%s" % (args["ip"], args["port"]) uri = "tcp://%s:%s" % (args["ip"], args["port"])
id_0 = 0; id_1 = 0 id_0 = 0; id_1 = 0
milvus_instance = get_milvus(args["handler"]) milvus_instance = get_milvus(args["handler"])
milvus_instance.connect(uri=uri) # milvus_instance.connect(uri=uri)
milvus_instance.create_collection({'collection_name': collection, milvus_instance.create_collection({'collection_name': collection,
'dimension': dim, 'dimension': dim,
'index_file_size': index_file_size, 'index_file_size': index_file_size,
...@@ -62,11 +62,11 @@ class TestMixBase: ...@@ -62,11 +62,11 @@ class TestMixBase:
assert result[0][0].id == id_0 assert result[0][0].id == id_0
assert result[1][0].id == id_1 assert result[1][0].id == id_1
milvus_instance = get_milvus(args["handler"]) milvus_instance = get_milvus(args["handler"])
milvus_instance.connect(uri=uri) # milvus_instance.connect(uri=uri)
p_search = Process(target=search, args=(milvus_instance, )) p_search = Process(target=search, args=(milvus_instance, ))
p_search.start() p_search.start()
milvus_instance = get_milvus(args["handler"]) milvus_instance = get_milvus(args["handler"])
milvus_instance.connect(uri=uri) # milvus_instance.connect(uri=uri)
p_create = Process(target=add_vectors, args=(milvus_instance, )) p_create = Process(target=add_vectors, args=(milvus_instance, ))
p_create.start() p_create.start()
p_create.join() p_create.join()
......
...@@ -50,7 +50,8 @@ class TestPing: ...@@ -50,7 +50,8 @@ class TestPing:
# assert msg == __version__ # assert msg == __version__
def test_connected(self, connect): def test_connected(self, connect):
assert connect.connected() # assert connect.connected()
assert connect
# class TestPingDisconnect: # class TestPingDisconnect:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册