test_wsgi.py (glance-20.0.0) | : | test_wsgi.py (glance-20.0.1) | ||
---|---|---|---|---|
skipping to change at line 22 | skipping to change at line 22 | |||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |||
# License for the specific language governing permissions and limitations | # License for the specific language governing permissions and limitations | |||
# under the License. | # under the License. | |||
"""Tests for `glance.wsgi`.""" | """Tests for `glance.wsgi`.""" | |||
import os | import os | |||
import socket | import socket | |||
import time | import time | |||
import fixtures | ||||
from glance.common import wsgi | from glance.common import wsgi | |||
from glance.tests import functional | from glance.tests import functional | |||
class TestWSGIServer(functional.FunctionalTest): | class TestWSGIServer(functional.FunctionalTest): | |||
"""WSGI server tests.""" | """WSGI server tests.""" | |||
def test_client_socket_timeout(self): | def test_client_socket_timeout(self): | |||
test_dir = self.useFixture(fixtures.TempDir()).path | ||||
image_cache_dir = os.path.join(test_dir, 'cache') | ||||
self.config(workers=0) | self.config(workers=0) | |||
self.config(client_socket_timeout=1) | self.config(client_socket_timeout=1) | |||
self.config(image_cache_dir=image_cache_dir) | ||||
self.config(image_cache_driver="sqlite") | ||||
"""Verify connections are timed out as per 'client_socket_timeout'""" | """Verify connections are timed out as per 'client_socket_timeout'""" | |||
greetings = b'Hello, World!!!' | greetings = b'Hello, World!!!' | |||
def hello_world(env, start_response): | def hello_world(env, start_response): | |||
start_response('200 OK', [('Content-Type', 'text/plain')]) | start_response('200 OK', [('Content-Type', 'text/plain')]) | |||
return [greetings] | return [greetings] | |||
server = wsgi.Server() | server = wsgi.Server() | |||
server.start(hello_world, 0) | server.start(hello_world, 0) | |||
port = server.sock.getsockname()[1] | port = server.sock.getsockname()[1] | |||
End of changes. 3 change blocks. | ||||
6 lines changed or deleted | 0 lines changed or added |