This Page

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

The nova.tests.api.openstack.test_limits Module

Tests dealing with HTTP rate-limiting.

class nova.tests.api.openstack.test_limits.BaseLimitTestSuite(methodName='runTest')

Bases: unittest.case.TestCase

Base test suite which provides relevant stubs and time abstraction.

setUp()

Run before each test.

tearDown()

Run after each test.

class nova.tests.api.openstack.test_limits.FakeHttplibConnection(app, host)

Bases: object

Fake httplib.HTTPConnection.

getresponse()

Return our generated response from the request.

request(method, path, body='', headers={})

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 nova.tests.api.openstack.test_limits.FakeHttplibSocket(response_string)

Bases: object

Fake httplib.HTTPResponse replacement.

makefile(_mode, _other)

Returns the socket’s internal buffer.

class nova.tests.api.openstack.test_limits.LimitMiddlewareTest(methodName='runTest')

Bases: nova.tests.api.openstack.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_limited_request_json()

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

test_limited_request_xml()

Test a rate-limited (403) response as XML

class nova.tests.api.openstack.test_limits.LimitTest(methodName='runTest')

Bases: nova.tests.api.openstack.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 nova.tests.api.openstack.test_limits.LimiterTest(methodName='runTest')

Bases: nova.tests.api.openstack.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_servers()

Ensure PUT on /servers 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.

class nova.tests.api.openstack.test_limits.LimitsControllerTest(methodName='runTest')

Bases: nova.tests.api.openstack.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_empty_index_xml()

Test getting limit details in XML.

test_index_json()

Test getting limit details in JSON.

test_index_xml()

Test getting limit details in XML.

class nova.tests.api.openstack.test_limits.WsgiLimiterProxyTest(methodName='runTest')

Bases: nova.tests.api.openstack.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.

test_200()

Successful request test.

test_403()

Forbidden request test.

class nova.tests.api.openstack.test_limits.WsgiLimiterTest(methodName='runTest')

Bases: nova.tests.api.openstack.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()
nova.tests.api.openstack.test_limits.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.