The nova.tests.api.openstack.compute.test_limits Module

Tests dealing with HTTP rate-limiting.

class BaseLimitTestSuite(*args, **kwargs)

Bases: nova.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(*args, **kwargs)

Bases: nova.tests.api.openstack.compute.test_limits.BaseLimitTestSuite

Tests for the limits.RateLimitingMiddleware class.

setUp()

Prepare middleware for use through fake WSGI app.

test_good_request()
test_limit_class()
test_limited_request_json()
test_limited_request_xml()
class LimitTest(*args, **kwargs)

Bases: nova.tests.api.openstack.compute.test_limits.BaseLimitTestSuite

Tests for the limits.Limit class.

test_GET_delay()
test_GET_no_delay()
class LimiterTest(*args, **kwargs)

Bases: nova.tests.api.openstack.compute.test_limits.BaseLimitTestSuite

Tests for the in-memory limits.Limiter class.

setUp()

Run before each test.

test_delay_GET()
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()
test_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()
test_user_limit()
class LimitsControllerTest(*args, **kwargs)

Bases: nova.tests.api.openstack.compute.test_limits.BaseLimitTestSuite

Tests for limits.LimitsController class.

setUp()

Run before each test.

test_empty_index_json()
test_index_absolute_cores_json()
test_index_absolute_injected_files()
test_index_absolute_instances_json()
test_index_absolute_metadata_json()
test_index_absolute_ram_json()
test_index_absolute_security_groups()
test_index_diff_regex()
test_index_ignores_extra_absolute_limits_json()
test_index_json()
test_limit_create()
test_limit_delete()
test_limit_detail()
test_limit_show()
test_limit_update()
class LimitsViewBuilderTest(*args, **kwargs)

Bases: nova.test.TestCase

setUp()
test_build_limits()
test_build_limits_empty_limits()
class LimitsXMLSerializationTest(*args, **kwargs)

Bases: nova.test.TestCase

test_index()
test_index_no_limits()
test_xml_declaration()
class ParseLimitsTest(*args, **kwargs)

Bases: nova.tests.api.openstack.compute.test_limits.BaseLimitTestSuite

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

test_bad_rule()
test_bad_unit()
test_bad_value()
test_invalid()
test_missing_arg()
test_multiple_rules()
class TestLimiter(limits, **kwargs)

Bases: nova.api.openstack.compute.limits.Limiter

class WsgiLimiterProxyTest(*args, **kwargs)

Bases: nova.tests.api.openstack.compute.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()
test_403()
class WsgiLimiterTest(*args, **kwargs)

Bases: nova.tests.api.openstack.compute.test_limits.BaseLimitTestSuite

Tests for limits.WsgiLimiter class.

setUp()

Run before each test.

test_escaping()
test_good_url()
test_invalid_methods()
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).

Previous topic

The nova.tests.api.openstack.compute.test_images Module

Next topic

The nova.tests.api.openstack.compute.test_server_actions Module

This Page