Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Haltmayer <filip.haltmayer@zilliz.com>
  • Loading branch information
Filip Haltmayer committed May 23, 2023
1 parent db58cca commit 3cf7092
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions pymilvus/orm/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# the License.

import copy
from pprint import pprint
import threading
from urllib import parse
from typing import Tuple
Expand Down Expand Up @@ -224,13 +225,15 @@ def connect(self, alias=Config.MILVUS_CONN_ALIAS, user="", password="", db_name=
def connect_milvus(**kwargs):
with self._con_lock:
gh = None
pprint(self._alias)
for key, connection_details in self._alias.items():

if (
connection_details["address"] == kwargs["address"]
key in self._connected_alias
and connection_details["address"] == kwargs["address"]
and connection_details["user"] == kwargs["user"]
and connection_details["db_name"] == kwargs["db_name"]
and key in self._connected_alias

):
gh = self._connected_alias[key]
break
Expand All @@ -246,7 +249,6 @@ def connect_milvus(**kwargs):

self._connected_alias[alias] = gh


self._alias[alias] = copy.deepcopy(kwargs)

if id(gh) not in self._connection_references:
Expand All @@ -267,8 +269,6 @@ def connect_milvus(**kwargs):

address, user, password, db_name = self.__parse_info(address, uri, host, port, db_name, user, password)

print("address", address, "user", user, "password", password, "db_name", db_name)

if set([address, uri, host, port]) != {None}:
kwargs["address"] = address

Expand Down Expand Up @@ -408,7 +408,7 @@ def __verify_host_port(self, host, port):
raise ConnectionConfigException(message=f"port number {port} out of range, valid range [0, 65535)")

def __parse_address_from_uri(self, uri: str) -> Tuple[str, str, str, str]:
illegal_uri_msg = "Illegal uri: [{}], expected form 'https://user:pwd@example.com:12345/db_name'"
illegal_uri_msg = "Illegal uri: [{}], expected form 'https://user:pwd@example.com:12345'"
try:
parsed_uri = parse.urlparse(uri)
except (Exception) as e:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def test_add_connection_then_connect(self, uri):

def test_connect_with_reuse_grpc(self):
alias = "default"
default_addr = {"address": "localhost:19530", "user": "", "db_field": ""}
default_addr = {"address": "localhost:19530", "user": "", "db_name": ""}

reuse_alias = "reuse"

Expand Down Expand Up @@ -386,13 +386,13 @@ def test_issue_1196(self):
config = {"alias": alias, "host": "localhost", "port": "19531", "user": "root", "password": 12345, "secure": True}
connections.connect(**config)
config = connections.get_connection_addr(alias)
assert config == {"address": 'localhost:19531', "user": 'root'}
assert config == {"address": 'localhost:19531', "user": 'root', "db_name": ""}

connections.add_connection(default={"host": "localhost", "port": 19531})
config = connections.get_connection_addr("default")
assert config == {"address": 'localhost:19531', "user": ""}
assert config == {"address": 'localhost:19531', "user": "", "db_name": ""}

connections.connect("default", user="root", password="12345", secure=True)

config = connections.get_connection_addr("default")
assert config == {"address": 'localhost:19531', "user": 'root'}
assert config == {"address": 'localhost:19531', "user": 'root', "db_name": ""}

0 comments on commit 3cf7092

Please sign in to comment.