From d078f884ca23cf3c25c3bbb4472af6156ed079d8 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 12 May 2022 21:22:08 +0200 Subject: [PATCH 1/2] Fix `406 Client Error: Not Acceptable` errors in test suite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a test case which validates that the HTTP client croaks appropriately when connecting to non-CrateDB servers. Within that test, we used http://crate.io to connect to. However, it looks like Fastly now blocks excessive requests to that domain, for example when running the test matrix on CI, which invokes quite a number of requests. > By default, the Signal Sciences agent returns a “406” response code when a request is blocked (similar to an HTTP 406 NOT ACCEPTABLE response). > > -- https://docs.fastly.com/signalsciences/faq/response-codes/#what-is-a-406-agent-response-code --- src/crate/client/doctests/http.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crate/client/doctests/http.txt b/src/crate/client/doctests/http.txt index 5382b5b6..0ff5b9a5 100644 --- a/src/crate/client/doctests/http.txt +++ b/src/crate/client/doctests/http.txt @@ -183,11 +183,11 @@ an exception is raised when the timeout is reached:: When connecting to non Crate servers the HttpClient will raise a ConnectionError like this:: - >>> http_client = HttpClient(["https://crate.io"]) + >>> http_client = HttpClient(["https://httpbin.org/html"]) >>> http_client.server_infos(http_client._get_server()) Traceback (most recent call last): ... - crate.client.exceptions.ProgrammingError: Invalid server response of content-type 'text/html; charset=UTF-8': + crate.client.exceptions.ProgrammingError: Invalid server response of content-type 'text/html; charset=utf-8': ... When using the ``error_trace`` kwarg a full traceback of the server exception From fc491bdbd22826cc2b701df287bf1cae55ac886c Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 12 May 2022 21:30:13 +0200 Subject: [PATCH 2/2] Slightly improve documentation --- src/crate/client/doctests/http.txt | 2 +- src/crate/client/doctests/mocking.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crate/client/doctests/http.txt b/src/crate/client/doctests/http.txt index 0ff5b9a5..fa9407c3 100644 --- a/src/crate/client/doctests/http.txt +++ b/src/crate/client/doctests/http.txt @@ -181,7 +181,7 @@ an exception is raised when the timeout is reached:: ... crate.client.exceptions.ConnectionError: No more Servers available, exception from last server: ... -When connecting to non Crate servers the HttpClient will raise a ConnectionError like this:: +When connecting to non-CrateDB servers, the HttpClient will raise a ConnectionError like this:: >>> http_client = HttpClient(["https://httpbin.org/html"]) >>> http_client.server_infos(http_client._get_server()) diff --git a/src/crate/client/doctests/mocking.txt b/src/crate/client/doctests/mocking.txt index a2201cad..c32a701b 100644 --- a/src/crate/client/doctests/mocking.txt +++ b/src/crate/client/doctests/mocking.txt @@ -5,7 +5,7 @@ Client Mocking For testing purposes it is often useful to replace the client used for communication with the CrateDB server with a stub or mock. -This can be done by passing a object of the Client class when calling the +This can be done by passing an object of the Client class when calling the ``connect`` method:: >>> from crate import client