Skip to content

Commit b647ea0

Browse files
committed
Tests: Use small timeouts for server selection tests in http.txt
This tries to improve timing behaviour/flakyness on CI. References: #404, 575f6a3
1 parent cb7bd4c commit b647ea0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/crate/client/doctests/http.txt

+6-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ When using a list of servers, the servers are selected by round-robin::
2424

2525
>>> invalid_host = "invalid_host:9999"
2626
>>> even_more_invalid_host = "even_more_invalid_host:9999"
27-
>>> http_client = HttpClient([crate_host, invalid_host, even_more_invalid_host])
27+
>>> http_client = HttpClient([crate_host, invalid_host, even_more_invalid_host], timeout=0.3)
2828
>>> http_client._get_server()
2929
'http://127.0.0.1:44209'
3030

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

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

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

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

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

58-
>>> http_client = HttpClient([invalid_host, even_more_invalid_host, crate_host])
59+
>>> http_client = HttpClient([invalid_host, even_more_invalid_host, crate_host], timeout=0.3)
5960
>>> result = http_client.sql('select name from locations')
6061
>>> http_client._active_servers = []
6162
>>> http_client._get_server()

0 commit comments

Comments
 (0)