def test_sniff_reuses_connection_instances_if_possible(self):
        t = Transport([{'data': CLUSTER_NODES}, {"host": "1.1.1.1", "port": 123}], connection_class=DummyConnection, randomize_hosts=False)
        connection = t.connection_pool.connections[1]

        t.sniff_hosts()
        self.assertEquals(1, len(t.connection_pool.connections))
        self.assertIs(connection, t.get_connection())
    def test_sniff_will_use_seed_connections(self):
        t = Transport([{'data': CLUSTER_NODES}], connection_class=DummyConnection)
        t.set_connections([{'data': 'invalid'}])

        t.sniff_hosts()
        self.assertEquals(1, len(t.connection_pool.connections))
        self.assertEquals('http://1.1.1.1:123', t.get_connection().host)
Пример #3
0
    def test_sniff_will_pick_up_published_host(self):
        t = Transport([{
            'data': CLUSTER_NODE_PUBLISH_HOST
        }],
                      connection_class=DummyConnection)
        t.sniff_hosts()

        self.assertEquals(1, len(t.connection_pool.connections))
        self.assertEquals('http://obsidian:9200', t.get_connection().host)
 def test_sniff_uses_sniff_timeout(self):
     t = Transport([{
         'data': CLUSTER_NODES
     }],
                   connection_class=DummyConnection,
                   sniff_timeout=42)
     t.sniff_hosts()
     self.assertEquals((('GET', '/_nodes/_all/clear'), {
         'timeout': 42
     }), t.seed_connections[0].calls[0])
Пример #5
0
 def test_sniff_uses_sniff_timeout(self):
     t = Transport(
         [{"data": CLUSTER_NODES}],
         connection_class=DummyConnection,
         sniff_timeout=42,
     )
     t.sniff_hosts()
     self.assertEquals(
         (("GET", "/_nodes/_all/http"), {"timeout": 42}),
         t.seed_connections[0].calls[0],
     )
Пример #6
0
 def test_sniff_7x_publish_host(self):
     # Test the response shaped when a 7.x node has publish_host set
     # and the returend data is shaped in the fqdn/ip:port format.
     t = Transport(
         [{
             "data": CLUSTER_NODES_7x_PUBLISH_HOST
         }],
         connection_class=DummyConnection,
         sniff_timeout=42,
     )
     t.sniff_hosts()
     # Ensure we parsed out the fqdn and port from the fqdn/ip:port string.
     self.assertEqual(t.connection_pool.connection_opts[0][1], {
         'host': 'somehost.tld',
         'port': 123
     })
Пример #7
0
 def test_sniff_uses_sniff_timeout(self):
     t = Transport([{'data': CLUSTER_NODES}], connection_class=DummyConnection, sniff_timeout=42)
     t.sniff_hosts()
     self.assertEquals((('GET', '/_nodes/_all/clear'), {'timeout': 42}), t.seed_connections[0].calls[0])
Пример #8
0
    def test_sniff_will_pick_up_published_host(self):
        t = Transport([{'data': CLUSTER_NODE_PUBLISH_HOST}], connection_class=DummyConnection)
        t.sniff_hosts()

        self.assertEquals(1, len(t.connection_pool.connections))
        self.assertEquals('http://obsidian:9200', t.get_connection().host)