octavia_tempest_plugin.tests package

Subpackages

Submodules

octavia_tempest_plugin.tests.test_base module

class LoadBalancerBaseTest(*args, **kwargs)[source]

Bases: octavia_tempest_plugin.tests.validators.ValidatorsMixin, tempest.test.BaseTestCase

Base class for load balancer tests.

SRC_PORT_NUMBER_MAX = 61000
SRC_PORT_NUMBER_MIN = 32768
client_manager

alias of octavia_tempest_plugin.clients.ManagerV2

credentials = ['admin', 'primary', ['lb_member', 'load-balancer_member'], ['lb_member2', 'load-balancer_member'], ['lb_admin', 'load-balancer_admin']]
classmethod resource_setup()[source]

Setup resources needed by the tests.

classmethod setup_clients()[source]

Setup client aliases.

classmethod setup_credentials()[source]

Setup test credentials and network resources.

classmethod skip_checks()[source]

Check if we should skip all of the children tests.

src_port_number = 32768
used_ips = []
webserver1_response = 1
webserver2_response = 5
class LoadBalancerBaseTestWithCompute(*args, **kwargs)[source]

Bases: octavia_tempest_plugin.tests.test_base.LoadBalancerBaseTest

classmethod resource_setup()[source]

Setup resources needed by the tests.

octavia_tempest_plugin.tests.validators module

class ValidatorsMixin(*args, **kwargs)[source]

Bases: tempest.test.BaseTestCase

assertConsistentResponse(response, url, method='GET', repeat=10, redirect=False, timeout=2, expect_connection_error=False, **kwargs)[source]

Assert that a request to URL gets the expected response.

Parameters
  • response – Expected response in format (status_code, content).

  • url – The URL to request.

  • method – The HTTP method to use (GET, POST, PUT, etc)

  • repeat – How many times to test the response.

  • data – Optional data to send in the request.

  • headers – Optional headers to send in the request.

  • cookies – Optional cookies to send in the request.

  • redirect – Is the request a redirect? If true, assume the passed content should be the next URL in the chain.

  • timeout – Optional seconds to wait for the server to send data.

  • expect_connection_error – Should we expect a connection error

  • expect_timeout – Should we expect a connection timeout

Returns

boolean success status

Raises

testtools.matchers.MismatchError

check_members_balanced(vip_address, traffic_member_count=2, protocol='HTTP', HTTPS_verify=True, protocol_port=80, persistent=True, repeat=20, client_cert_path=None, CA_certs_path=None, request_interval=2, request_timeout=10, source_port=None, delay=None)[source]

Checks that members are evenly balanced behind a VIP.

Parameters
  • vip_address – The VIP address to test.

  • traffic_member_count – The expected number of members.

  • protocol – The protocol to use for the test.

  • HTTPS_verify – How to verify the TLS certificate. True: verify using the system CA certificates. False: Do not verify the VIP certificate. <path>: Filesytem path to a CA certificate bundle file or directory. For directories, the directory must be processed using the c_rehash utility from openssl.

  • protocol_port – The port number to use for the test.

  • persistent – True when the test should persist cookies and use the protocol keepalive mechanism with the target. This may include maintaining a connection to the member server across requests.

  • repeat – The number of requests to make against the VIP.

  • request_timeout – The maximum time, in seconds, to attempt requests.

  • client_cert_path – Filesystem path to a file with the client private key and certificate.

  • CA_certs_path – Filesystem path to a file containing CA certificates to use for HTTPS validation.

  • source_port – If set, the request will come from this source port number. If None, a random port will be used.

  • delay – The time to pause between requests in seconds, can be fractional.

make_request(vip_address, protocol='HTTP', HTTPS_verify=True, protocol_port=80, requests_session=None, client_cert_path=None, CA_certs_path=None, request_timeout=2, source_port=None)[source]

Make a request to a VIP.

Parameters
  • vip_address – The VIP address to test.

  • protocol – The protocol to use for the test.

  • HTTPS_verify – How to verify the TLS certificate. True: verify using the system CA certificates. False: Do not verify the VIP certificate. <path>: Filesytem path to a CA certificate bundle file or directory. For directories, the directory must be processed using the c_rehash utility from openssl.

  • protocol_port – The port number to use for the test.

  • requests_session – A requests session to use for the request. If None, a new session will be created.

  • request_timeout – The maximum time, in seconds, to attempt requests.

  • client_cert_path – Filesystem path to a file with the client private key and certificate.

  • CA_certs_path – Filesystem path to a file containing CA certificates to use for HTTPS validation.

  • source_port – If set, the request will come from this source port number. If None, a random port will be used.

Raises
  • InvalidHttpSuccessCode – The expected_status_code did not match.

  • InvalidHTTPResponseBody – The response body did not match the expected content.

  • TimeoutException – The request timed out.

  • Exception – If a protocol is requested that is not implemented.

Returns

The response data.

classmethod make_udp_request(vip_address, port=80, timeout=None, source_port=None)[source]
static validate_URL_response(URL, expected_status_code=200, requests_session=None, expected_body=None, HTTPS_verify=True, client_cert_path=None, CA_certs_path=None, source_port=None, request_interval=5.0, request_timeout=300)[source]

Check a URL response (HTTP or HTTPS).

Parameters
  • URL – The URL to query.

  • expected_status_code – The expected HTTP status code.

  • requests_session – A requests session to use for the request. If None, a new session will be created.

  • expected_body – The expected response text, None will not compare.

  • HTTPS_verify – Should we verify the HTTPS server.

  • client_cert_path – Filesystem path to a file with the client private key and certificate.

  • CA_certs_path – Filesystem path to a file containing CA certificates to use for HTTPS validation.

  • source_port – If set, the request will come from this source port number. If None, a random port will be used.

  • request_interval – Time, in seconds, to timeout a request.

  • request_timeout – The maximum time, in seconds, to attempt requests. Failed validation of expected results does not result in a retry.

Raises
  • InvalidHttpSuccessCode – The expected_status_code did not match.

  • InvalidHTTPResponseBody – The response body did not match the expected content.

  • TimeoutException – The request timed out.

Returns

The response data.

octavia_tempest_plugin.tests.waiters module

wait_for_deleted_status_or_not_found(show_client, id, status_key, check_interval, check_timeout, root_tag=None, **kwargs)[source]

Waits for an object to reach a DELETED status or be not found (404).

Parameters
  • show_client – The tempest service client show method. Ex. cls.os_primary.servers_client.show_server

  • id – The id of the object to query.

  • status_key – The key of the status field in the response. Ex. provisioning_status

Check_interval

How often to check the status, in seconds.

Check_timeout

The maximum time, in seconds, to check the status.

Root_tag

The root tag on the response to remove, if any.

Raises
  • CommandFailed – Raised if the object goes into ERROR and ERROR was not the desired status.

  • TimeoutException – The object did not achieve the status or ERROR in the check_timeout period.

Returns

None

wait_for_not_found(delete_func, show_func, *args, **kwargs)[source]

Call the delete function, then wait for it to be ‘NotFound’

Parameters
  • delete_func – The delete function to call.

  • show_func – The show function to call looking for ‘NotFound’.

  • ID – The ID of the object to delete/show.

Raises

TimeoutException – The object did not achieve the status or ERROR in the check_timeout period.

Returns

None

wait_for_spare_amps(list_func, check_interval, check_timeout)[source]

Waits for amphorae in spare pool.

Parameters

list_func – The tempest service client amphora list method. Ex. cls.os_admin.amphora_client.list_amphorae

Check_interval

How often to check the status, in seconds.

Check_timeout

The maximum time, in seconds, to check the status.

Raises

TimeoutException – No amphora available in spare pool in the check_timeout period.

Returns

A list of amphorae in spare pool.

wait_for_status(show_client, id, status_key, status, check_interval, check_timeout, root_tag=None, error_ok=False, **kwargs)[source]

Waits for an object to reach a specific status.

Parameters
  • show_client – The tempest service client show method. Ex. cls.os_primary.servers_client.show_server

  • id – The id of the object to query.

  • status_key – The key of the status field in the response. Ex. provisioning_status

  • status – The status to wait for. Ex. “ACTIVE”

Check_interval

How often to check the status, in seconds.

Check_timeout

The maximum time, in seconds, to check the status.

Root_tag

The root tag on the response to remove, if any.

Error_ok

When true, ERROR status will not raise an exception.

Raises
  • CommandFailed – Raised if the object goes into ERROR and ERROR was not the desired status.

  • TimeoutException – The object did not achieve the status or ERROR in the check_timeout period.

Returns

The object details from the show client.

wait_until_true(func, timeout=60, sleep=1, **kwargs)[source]

Wait until callable predicate is evaluated as True

Parameters
  • func – Callable deciding whether waiting should continue.

  • timeout – Timeout in seconds how long should function wait.

  • sleep – Polling interval for results in seconds.

Module contents