close http connections
Running full tempest one might run out of file descriptors. httplib2 does not close the connection by default. This patch adds connection:close header to every request, so that sockets won't be hanging around. fixes bug 1215804 Change-Id: Iea19936c45add98fc66588f623854e629cf448fb
This commit is contained in:
parent
025aa66fb0
commit
23a58a3944
|
@ -0,0 +1,27 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2013 OpenStack, LLC
|
||||
# Copyright 2013 Citrix Systems, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import httplib2
|
||||
|
||||
|
||||
class ClosingHttp(httplib2.Http):
|
||||
def request(self, *args, **kwargs):
|
||||
original_headers = kwargs.get('headers', {})
|
||||
new_headers = dict(original_headers, connection='close')
|
||||
new_kwargs = dict(kwargs, headers=new_headers)
|
||||
return super(ClosingHttp, self).request(*args, **new_kwargs)
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
import collections
|
||||
import hashlib
|
||||
import httplib2
|
||||
import json
|
||||
from lxml import etree
|
||||
import re
|
||||
import time
|
||||
|
||||
from tempest.common import http
|
||||
from tempest import exceptions
|
||||
from tempest.openstack.common import log as logging
|
||||
from tempest.services.compute.xml.common import xml_to_json
|
||||
|
@ -64,7 +64,8 @@ class RestClient(object):
|
|||
'retry-after', 'server',
|
||||
'vary', 'www-authenticate'))
|
||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
||||
self.http_obj = http.ClosingHttp(
|
||||
disable_ssl_certificate_validation=dscv)
|
||||
|
||||
def _set_auth(self):
|
||||
"""
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import httplib2
|
||||
import json
|
||||
|
||||
from tempest.common import http
|
||||
from tempest.common.rest_client import RestClient
|
||||
from tempest import exceptions
|
||||
|
||||
|
@ -260,7 +260,8 @@ class TokenClientJSON(RestClient):
|
|||
def request(self, method, url, headers=None, body=None):
|
||||
"""A simple HTTP request interface."""
|
||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
||||
self.http_obj = http.ClosingHttp(
|
||||
disable_ssl_certificate_validation=dscv)
|
||||
if headers is None:
|
||||
headers = {}
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
# under the License.
|
||||
import urlparse
|
||||
|
||||
import httplib2
|
||||
from lxml import etree
|
||||
|
||||
from tempest.common import http
|
||||
from tempest.common.rest_client import RestClientXML
|
||||
from tempest.services.compute.xml.common import Document
|
||||
from tempest.services.compute.xml.common import Element
|
||||
|
@ -50,7 +50,8 @@ class EndPointClientXML(RestClientXML):
|
|||
def request(self, method, url, headers=None, body=None, wait=None):
|
||||
"""Overriding the existing HTTP request in super class RestClient."""
|
||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
||||
self.http_obj = http.ClosingHttp(
|
||||
disable_ssl_certificate_validation=dscv)
|
||||
self._set_auth()
|
||||
self.base_url = self.base_url.replace(
|
||||
urlparse.urlparse(self.base_url).path, "/v3")
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
from urlparse import urlparse
|
||||
|
||||
import httplib2
|
||||
from lxml import etree
|
||||
|
||||
from tempest.common import http
|
||||
from tempest.common.rest_client import RestClientXML
|
||||
from tempest.services.compute.xml.common import Document
|
||||
from tempest.services.compute.xml.common import Element
|
||||
|
@ -51,7 +51,8 @@ class PolicyClientXML(RestClientXML):
|
|||
def request(self, method, url, headers=None, body=None, wait=None):
|
||||
"""Overriding the existing HTTP request in super class RestClient."""
|
||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
||||
self.http_obj = http.ClosingHttp(
|
||||
disable_ssl_certificate_validation=dscv)
|
||||
self._set_auth()
|
||||
self.base_url = self.base_url.replace(urlparse(self.base_url).path,
|
||||
"/v3")
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import httplib2
|
||||
import json
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from tempest.common import http
|
||||
from tempest.common.rest_client import RestClientXML
|
||||
from tempest import exceptions
|
||||
from tempest.services.compute.xml.common import Document
|
||||
|
@ -275,7 +275,8 @@ class TokenClientXML(RestClientXML):
|
|||
def request(self, method, url, headers=None, body=None):
|
||||
"""A simple HTTP request interface."""
|
||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
||||
self.http_obj = http.ClosingHttp(
|
||||
disable_ssl_certificate_validation=dscv)
|
||||
if headers is None:
|
||||
headers = {}
|
||||
self._log_request(method, url, headers, body)
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import httplib2
|
||||
import json
|
||||
import urllib
|
||||
|
||||
from tempest.common import http
|
||||
from tempest.common.rest_client import RestClient
|
||||
from tempest import exceptions
|
||||
|
||||
|
@ -108,7 +108,7 @@ class AccountClientCustomizedHeader(RestClient):
|
|||
|
||||
def request(self, method, url, headers=None, body=None):
|
||||
"""A simple HTTP request interface."""
|
||||
self.http_obj = httplib2.Http()
|
||||
self.http_obj = http.ClosingHttp()
|
||||
if headers is None:
|
||||
headers = {}
|
||||
if self.base_url is None:
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
import hashlib
|
||||
import hmac
|
||||
import httplib2
|
||||
import urlparse
|
||||
|
||||
from tempest.common import http
|
||||
from tempest.common.rest_client import RestClient
|
||||
from tempest import exceptions
|
||||
|
||||
|
@ -162,7 +162,8 @@ class ObjectClientCustomizedHeader(RestClient):
|
|||
def request(self, method, url, headers=None, body=None):
|
||||
"""A simple HTTP request interface."""
|
||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
||||
self.http_obj = http.ClosingHttp(
|
||||
disable_ssl_certificate_validation=dscv)
|
||||
if headers is None:
|
||||
headers = {}
|
||||
if self.base_url is None:
|
||||
|
|
Loading…
Reference in New Issue