Previous topic

The cinder.tests.api.openstack.volume.test_extensions Module

Next topic

The cinder.tests.api.openstack.volume.test_router Module

This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Cinder 2011.2 docs or all OpenStack docs too.

The cinder.tests.api.openstack.volume.test_limits Module

Tests dealing with HTTP rate-limiting.

class BaseLimitTestSuite(methodName='runTest')

Bases: cinder.test.TestCase

Base test suite which provides relevant stubs and time abstraction.

setUp()
class FakeHttplibConnection(app, host)

Bases: object

Fake httplib.HTTPConnection.

getresponse()

Return our generated response from the request.

request(method, path, body='', headers=None)

Requests made via this connection actually get translated and routed into our WSGI app, we then wait for the response and turn it back into an httplib.HTTPResponse.

class FakeHttplibSocket(response_string)

Bases: object

Fake httplib.HTTPResponse replacement.

makefile(_mode, _other)

Returns the socket’s internal buffer.

class LimitMiddlewareTest(methodName='runTest')

Bases: cinder.tests.api.openstack.volume.test_limits.BaseLimitTestSuite

Tests for the limits.RateLimitingMiddleware class.

setUp()

Prepare middleware for use through fake WSGI app.

test_good_request()

Test successful GET request through middleware.

test_limit_class()

Test that middleware selected correct limiter class.

test_limited_request_json()

Test a rate-limited (413) GET request through middleware.

test_limited_request_xml()

Test a rate-limited (413) response as XML

class LimitTest(methodName='runTest')

Bases: cinder.tests.api.openstack.volume.test_limits.BaseLimitTestSuite

Tests for the limits.Limit class.

test_GET_delay()

Test two calls to 1 GET per second limit.

test_GET_no_delay()

Test a limit handles 1 GET per second.

class LimiterTest(methodName='runTest')

Bases: cinder.tests.api.openstack.volume.test_limits.BaseLimitTestSuite

Tests for the in-memory limits.Limiter class.

setUp()

Run before each test.

test_delay_GET()

Ensure the 11th GET will result in NO delay.

test_delay_POST()

Ensure the 8th POST will result in a delay of 6.0 seconds until the next request will be granced.

test_delay_PUT()

Ensure the 11th PUT will result in a delay of 6.0 seconds until the next request will be granced.

test_delay_PUT_volumes()

Ensure PUT on /volumes limits at 5 requests, and PUT elsewhere is still OK after 5 requests...but then after 11 total requests, PUT limiting kicks in.

test_delay_PUT_wait()

Ensure after hitting the limit and then waiting for the correct amount of time, the limit will be lifted.

test_multiple_delays()

Ensure multiple requests still get a delay.

test_multiple_users()

Tests involving multiple users.

test_no_delay_GET()

Simple test to ensure no delay on a single call for a limit verb we didn”t set.

test_no_delay_PUT()

Simple test to ensure no delay on a single call for a known limit.

test_user_limit()

Test user-specific limits.

class LimitsControllerTest(methodName='runTest')

Bases: cinder.tests.api.openstack.volume.test_limits.BaseLimitTestSuite

Tests for limits.LimitsController class.

setUp()

Run before each test.

test_empty_index_json()

Test getting empty limit details in JSON.

test_index_diff_regex()

Test getting limit details in JSON.

test_index_ignores_extra_absolute_limits_json()
test_index_json()

Test getting limit details in JSON.

class LimitsViewBuilderTest(methodName='runTest')

Bases: cinder.test.TestCase

setUp()
test_build_limits()
test_build_limits_empty_limits()
class LimitsXMLSerializationTest(methodName='runTest')

Bases: cinder.test.TestCase

test_index()
test_index_no_limits()
test_xml_declaration()
class ParseLimitsTest(methodName='runTest')

Bases: cinder.tests.api.openstack.volume.test_limits.BaseLimitTestSuite

Tests for the default limits parser in the in-memory limits.Limiter class.

test_bad_rule()

Test that parse_limits() handles bad rules correctly.

test_bad_unit()

Test that parse_limits() handles bad units correctly.

test_bad_value()

Test that parse_limits() handles bad values correctly.

test_invalid()

Test that parse_limits() handles invalid input correctly.

test_missing_arg()

Test that parse_limits() handles missing args correctly.

test_multiple_rules()

Test that parse_limits() handles multiple rules correctly.

class TestLimiter(limits, **kwargs)

Bases: cinder.api.openstack.volume.limits.Limiter

class WsgiLimiterProxyTest(methodName='runTest')

Bases: cinder.tests.api.openstack.volume.test_limits.BaseLimitTestSuite

Tests for the limits.WsgiLimiterProxy class.

setUp()

Do some nifty HTTP/WSGI magic which allows for WSGI to be called directly by something like the httplib library.

tearDown()
test_200()

Successful request test.

test_403()

Forbidden request test.

class WsgiLimiterTest(methodName='runTest')

Bases: cinder.tests.api.openstack.volume.test_limits.BaseLimitTestSuite

Tests for limits.WsgiLimiter class.

setUp()

Run before each test.

test_escaping()
test_good_url()
test_invalid_methods()

Only POSTs should work.

test_response_to_delays()
test_response_to_delays_usernames()
wire_HTTPConnection_to_WSGI(host, app)

Monkeypatches HTTPConnection so that if you try to connect to host, you are instead routed straight to the given WSGI app.

After calling this method, when any code calls

httplib.HTTPConnection(host)

the connection object will be a fake. Its requests will be sent directly to the given WSGI app rather than through a socket.

Code connecting to hosts other than host will not be affected.

This method may be called multiple times to map different hosts to different apps.

This method returns the original HTTPConnection object, so that the caller can restore the default HTTPConnection interface (for all hosts).