Skip to content

Commit

Permalink
Tests: Use small timeouts for server selection tests in http.txt
Browse files Browse the repository at this point in the history
This tries to improve timing behaviour/flakyness on CI.

References: #404, 575f6a3
  • Loading branch information
amotl committed Oct 10, 2022
1 parent cb7bd4c commit b647ea0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/crate/client/doctests/http.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ When using a list of servers, the servers are selected by round-robin::

>>> invalid_host = "invalid_host:9999"
>>> even_more_invalid_host = "even_more_invalid_host:9999"
>>> http_client = HttpClient([crate_host, invalid_host, even_more_invalid_host])
>>> http_client = HttpClient([crate_host, invalid_host, even_more_invalid_host], timeout=0.3)
>>> http_client._get_server()
'http://127.0.0.1:44209'

Expand All @@ -36,17 +36,18 @@ When using a list of servers, the servers are selected by round-robin::

Servers with connection errors will be removed from the active server list::

>>> http_client = HttpClient([invalid_host, even_more_invalid_host, crate_host])
>>> http_client = HttpClient([invalid_host, even_more_invalid_host, crate_host], timeout=0.3)
>>> result = http_client.sql('select name from locations')
>>> http_client._active_servers
['http://127.0.0.1:44209']

Inactive servers will be re-added after a given time interval.
To validate this, set the interval very short and sleep for that interval::
To validate this, set the interval and timeout very short and sleep after the first request::

>>> http_client.retry_interval = 1
>>> import time; time.sleep(1)
>>> result = http_client.sql('select name from locations')
>>> import time; time.sleep(1)
>>> server = http_client._get_server()
>>> http_client._active_servers
['http://invalid_host:9999',
'http://even_more_invalid_host:9999',
Expand All @@ -55,7 +56,7 @@ To validate this, set the interval very short and sleep for that interval::
If no active servers are available and the retry interval is not reached, just use the oldest
inactive one::

>>> http_client = HttpClient([invalid_host, even_more_invalid_host, crate_host])
>>> http_client = HttpClient([invalid_host, even_more_invalid_host, crate_host], timeout=0.3)
>>> result = http_client.sql('select name from locations')
>>> http_client._active_servers = []
>>> http_client._get_server()
Expand Down

0 comments on commit b647ea0

Please sign in to comment.