Skip to content

Commit 48723f4

Browse files
test: DNS timeout with algolia.biz
1 parent 5d28223 commit 48723f4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_client.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from __future__ import unicode_literals
44

55
from random import randint
6+
import time
7+
import os
68

79
try:
810
import unittest2 as unittest # py26
@@ -104,6 +106,24 @@ def user_name(self):
104106
self.assertIn('X-User', sub_client.headers)
105107
self.assertEqual(sub_client.headers['X-User'], 'algolia')
106108

109+
def test_dns_timeout(self):
110+
app_id = os.environ['ALGOLIA_APPLICATION_ID']
111+
112+
hosts = [
113+
'%s-dsn.algolia.biz' % app_id,
114+
'%s-dsn.algolia.net' % app_id,
115+
'%s-1.algolianet.com' % app_id,
116+
'%s-2.algolianet.com' % app_id,
117+
'%s-3.algolianet.com' % app_id,
118+
]
119+
120+
client = Client(app_id, os.environ['ALGOLIA_API_KEY'], hosts)
121+
client.set_timeout(5, 2)
122+
123+
now = time.time()
124+
indices = client.list_indexes()
125+
self.assertLess(now + 5, time.time())
126+
107127

108128
class ClientWithDataTest(ClientTest):
109129
"""Tests that use two index with initial data."""

0 commit comments

Comments
 (0)