diff --git a/elasticsearch/transport.py b/elasticsearch/transport.py index e87e4cc5..6fea4bdd 100644 --- a/elasticsearch/transport.py +++ b/elasticsearch/transport.py @@ -7,7 +7,7 @@ from .serializer import JSONSerializer from .exceptions import ConnectionError, TransportError, SerializationError # get ip/port from "inet[wind/127.0.0.1:9200]" -ADDRESS_RE = re.compile(r'/(?P[\.:0-9a-f]*):(?P[0-9]+)\]') +ADDRESS_RE = re.compile(r'/(?P[\.:0-9a-f]*):(?P[0-9]+)\]?$') def get_host_info(node_info, host): diff --git a/test_elasticsearch/test_transport.py b/test_elasticsearch/test_transport.py index 92446036..868fe171 100644 --- a/test_elasticsearch/test_transport.py +++ b/test_elasticsearch/test_transport.py @@ -28,7 +28,8 @@ CLUSTER_NODES = '''{ "transport_address" : "inet[/127.0.0.1:9300]", "hostname" : "wind", "version" : "0.20.4", - "http_address" : "inet[/1.1.1.1:123]" + "http_address" : "inet[/1.1.1.1:123]", + "thrift_address" : "/1.1.1.1:9500]" } } }''' @@ -88,6 +89,13 @@ class TestTransport(TestCase): self.assertEquals(1, len(t.connection_pool.connections)) self.assertEquals('http://1.1.1.1:123', t.get_connection().host) + def test_sniff_on_start_fetches_and_uses_nodes_list_for_its_schema(self): + class DummyThriftConnection(DummyConnection): + transport_schema = 'thrift' + t = Transport([{'data': CLUSTER_NODES}], connection_class=DummyThriftConnection, sniff_on_start=True) + self.assertEquals(1, len(t.connection_pool.connections)) + self.assertEquals('thrift://1.1.1.1:9500', t.get_connection().host) + def test_sniff_on_start_fetches_and_uses_nodes_list(self): t = Transport([{'data': CLUSTER_NODES}], connection_class=DummyConnection, sniff_on_start=True) self.assertEquals(1, len(t.connection_pool.connections))