You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2021/10/22 09:36:23 UTC
[libcloud] branch trunk updated (bed982a -> 32653fe)
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git.
from bed982a Add changelog entry for #1596.
add 8147b1c Fix: #1575
new 8a2c0d2 Merge branch 'fix-session-timeout' of https://github.com/dimgal1/libcloud into dimgal1-fix-session-timeout
new 21ae20e Add changelog entry for #1576.
new 32653fe Add additional test cases for asserting that timeout argument is correctly passed to the underlying requests send() method.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
CHANGES.rst | 10 ++++++++++
libcloud/http.py | 6 ++++--
libcloud/test/test_connection.py | 22 ++++++++++++++++++++++
libcloud/test/test_http.py | 36 +++++++++++++++++++++++++++++++++++-
4 files changed, 71 insertions(+), 3 deletions(-)
[libcloud] 01/03: Merge branch 'fix-session-timeout' of
https://github.com/dimgal1/libcloud into dimgal1-fix-session-timeout
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit 8a2c0d26c3fce19f76efda70a2062c151fc426ae
Merge: bed982a 8147b1c
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Fri Oct 22 10:57:01 2021 +0200
Merge branch 'fix-session-timeout' of https://github.com/dimgal1/libcloud into dimgal1-fix-session-timeout
libcloud/http.py | 3 ++-
libcloud/test/test_connection.py | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
[libcloud] 02/03: Add changelog entry for #1576.
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit 21ae20ef8f83976fd8cdb24256383a08ffa18635
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Fri Oct 22 10:59:53 2021 +0200
Add changelog entry for #1576.
---
CHANGES.rst | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/CHANGES.rst b/CHANGES.rst
index 45a2c26..042724a 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,6 +4,16 @@
Changes in Apache Libcloud 3.3.2 (in development)
-------------------------------------------------
+Common
+~~~~~~
+
+- Fix how we set HTTP request timeout on the underlying requests session
+ object. requests library has changed how timeout is set so our old
+ code had no affect.
+
+ (GITHUB-1575, GITHUB-1576)
+ [Dimitris Galanis - @dimgal1]
+
Storage
~~~~~~~
[libcloud] 03/03: Add additional test cases for asserting that
timeout argument is correctly passed to the underlying requests send()
method.
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit 32653fe64a045f8c03d127544be86edc74dbfa74
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Fri Oct 22 11:28:22 2021 +0200
Add additional test cases for asserting that timeout argument is
correctly passed to the underlying requests send() method.
---
libcloud/http.py | 3 ++-
libcloud/test/test_http.py | 36 +++++++++++++++++++++++++++++++++++-
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/libcloud/http.py b/libcloud/http.py
index 8c957f4..33d6a25 100644
--- a/libcloud/http.py
+++ b/libcloud/http.py
@@ -218,7 +218,7 @@ class LibcloudConnection(LibcloudBaseConnection):
return self.ca_cert if self.ca_cert is not None else self.verify
def request(self, method, url, body=None, headers=None, raw=False,
- stream=False):
+ stream=False, hooks=None):
url = urlparse.urljoin(self.host, url)
headers = self._normalize_headers(headers=headers)
@@ -231,6 +231,7 @@ class LibcloudConnection(LibcloudBaseConnection):
stream=stream,
verify=self.verification,
timeout=self.session.timeout,
+ hooks=hooks,
)
def prepared_request(self, method, url, body=None,
diff --git a/libcloud/test/test_http.py b/libcloud/test/test_http.py
index d63f0b2..ce76252 100644
--- a/libcloud/test/test_http.py
+++ b/libcloud/test/test_http.py
@@ -20,6 +20,7 @@ import random
import platform
import warnings
import threading
+import time
from http.server import BaseHTTPRequestHandler
from http.server import HTTPServer
@@ -138,10 +139,43 @@ class HttpLayerTestCase(unittest.TestCase):
self.assertEqual(connection.response.status_code, httplib.OK)
self.assertEqual(connection.response.content, b'/test/prepared-request-3')
+ def test_request_custom_timeout_no_timeout(self):
+ def response_hook(*args, **kwargs):
+ # Assert timeout has been passed correctly
+ self.assertEqual(kwargs['timeout'], 5)
+
+ hooks = {
+ 'response': response_hook
+ }
+
+ connection = LibcloudConnection(host=self.listen_host, port=self.listen_port, timeout=5)
+ connection.request(method='GET', url='/test', hooks=hooks)
+
+ def test_request_custom_timeout_timeout(self):
+ def response_hook(*args, **kwargs):
+ # Assert timeout has been passed correctly
+ self.assertEqual(kwargs['timeout'], 0.5)
+
+ hooks = {
+ 'response': response_hook
+ }
+
+ connection = LibcloudConnection(host=self.listen_host, port=self.listen_port, timeout=0.5)
+ self.assertRaisesRegex(requests.exceptions.ReadTimeout, 'Read timed out',
+ connection.request,
+ method='GET', url='/test-timeout', hooks=hooks)
+
class MockHTTPServerRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
- if self.path in ['/test/prepared-request-1', '/test/prepared-request-2']:
+ if self.path in ['/test']:
+ self.send_response(requests.codes.ok)
+ self.end_headers()
+ if self.path in ['/test-timeout']:
+ time.sleep(1)
+ self.send_response(requests.codes.ok)
+ self.end_headers()
+ elif self.path in ['/test/prepared-request-1', '/test/prepared-request-2']:
# Verify that chunked encoding is not used for prepared requests
# with empty body
# See https://github.com/apache/libcloud/issues/1487