Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Use small timeouts for server selection tests in http.txt #460

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions docs/by-example/http.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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 @@ -56,17 +56,19 @@ 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 @@ -76,7 +78,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