octavia_tempest_plugin.tests package¶
Subpackages¶
- octavia_tempest_plugin.tests.act_stdby_scenario package
- octavia_tempest_plugin.tests.api package
- Subpackages
- octavia_tempest_plugin.tests.api.v2 package
- Submodules
- octavia_tempest_plugin.tests.api.v2.test_amphora module
- octavia_tempest_plugin.tests.api.v2.test_availability_zone module
- octavia_tempest_plugin.tests.api.v2.test_availability_zone_capabilities module
- octavia_tempest_plugin.tests.api.v2.test_availability_zone_profile module
- octavia_tempest_plugin.tests.api.v2.test_flavor module
- octavia_tempest_plugin.tests.api.v2.test_flavor_capabilities module
- octavia_tempest_plugin.tests.api.v2.test_flavor_profile module
- octavia_tempest_plugin.tests.api.v2.test_healthmonitor module
- octavia_tempest_plugin.tests.api.v2.test_l7policy module
- octavia_tempest_plugin.tests.api.v2.test_l7rule module
- octavia_tempest_plugin.tests.api.v2.test_listener module
- octavia_tempest_plugin.tests.api.v2.test_load_balancer module
- octavia_tempest_plugin.tests.api.v2.test_member module
- octavia_tempest_plugin.tests.api.v2.test_pool module
- octavia_tempest_plugin.tests.api.v2.test_provider module
- Module contents
- octavia_tempest_plugin.tests.api.v2 package
- Module contents
- Subpackages
- octavia_tempest_plugin.tests.barbican_scenario package
- octavia_tempest_plugin.tests.scenario package
- Subpackages
- octavia_tempest_plugin.tests.scenario.v2 package
- Submodules
- octavia_tempest_plugin.tests.scenario.v2.test_healthmonitor module
- octavia_tempest_plugin.tests.scenario.v2.test_ipv6_traffic_ops module
- octavia_tempest_plugin.tests.scenario.v2.test_l7policy module
- octavia_tempest_plugin.tests.scenario.v2.test_l7rule module
- octavia_tempest_plugin.tests.scenario.v2.test_listener module
- octavia_tempest_plugin.tests.scenario.v2.test_load_balancer module
- octavia_tempest_plugin.tests.scenario.v2.test_member module
- octavia_tempest_plugin.tests.scenario.v2.test_pool module
- octavia_tempest_plugin.tests.scenario.v2.test_traffic_ops module
- Module contents
- octavia_tempest_plugin.tests.scenario.v2 package
- Module contents
- Subpackages
- octavia_tempest_plugin.tests.spare_pool_scenario package
Submodules¶
octavia_tempest_plugin.tests.RBAC_tests module¶
- class RBACTestsMixin(*args, **kwargs)[source]¶
Bases:
BaseTestCase
- check_create_RBAC_enforcement(client_str, method_str, expected_allowed, status_method=None, obj_id=None, *args, **kwargs)[source]¶
Test an API create call RBAC enforcement.
- Parameters:
client_str – The service client to use for the test, without the credential. Example: ‘AmphoraClient’
method_str – The method on the client to call for the test. Example: ‘list_amphorae’
expected_allowed – The list of credentials expected to be allowed. Example: [‘os_roles_lb_member’].
status_method – The service client method that will provide the object status for a status change waiter.
obj_id – The ID of the object to check for the expected status update.
args – Any positional parameters needed by the method.
kwargs – Any named parameters needed by the method.
- Raises:
AssertionError – Raised if the RBAC tests fail.
Forbidden – Raised if a credential that should have access does not and is denied.
InvalidScope – Raised if a credential that should have the correct scope for access is denied.
- Returns:
None on success
- check_delete_RBAC_enforcement(client_str, method_str, expected_allowed, status_method=None, obj_id=None, *args, **kwargs)[source]¶
Test an API delete call RBAC enforcement.
- Parameters:
client_str – The service client to use for the test, without the credential. Example: ‘AmphoraClient’
method_str – The method on the client to call for the test. Example: ‘list_amphorae’
expected_allowed – The list of credentials expected to be allowed. Example: [‘os_roles_lb_member’].
status_method – The service client method that will provide the object status for a status change waiter.
obj_id – The ID of the object to check for the expected status update.
args – Any positional parameters needed by the method.
kwargs – Any named parameters needed by the method.
- Raises:
AssertionError – Raised if the RBAC tests fail.
Forbidden – Raised if a credential that should have access does not and is denied.
InvalidScope – Raised if a credential that should have the correct scope for access is denied.
- Returns:
None on success
- check_list_IDs_RBAC_enforcement(client_str, method_str, expected_allowed, expected_ids, *args, **kwargs)[source]¶
Test an API list call RBAC enforcement result contains IDs.
List APIs will return the object list for the project associated with the token used to access the API. This means most credentials will have access, but will get differing results.
This test will query the list API using a list of credentials and will validate that the expected object Ids in included in the results.
- Parameters:
client_str – The service client to use for the test, without the credential. Example: ‘AmphoraClient’
method_str – The method on the client to call for the test. Example: ‘list_amphorae’
expected_allowed – The list of credentials expected to be allowed. Example: [‘os_roles_lb_member’].
expected_ids – The list of object IDs to validate are included in the returned list from the API.
args – Any positional parameters needed by the method.
kwargs – Any named parameters needed by the method.
- Raises:
AssertionError – Raised if the RBAC tests fail.
Forbidden – Raised if a credential that should have access does not and is denied.
InvalidScope – Raised if a credential that should have the correct scope for access is denied.
- Returns:
None on success
- check_list_RBAC_enforcement(client_str, method_str, expected_allowed, *args, **kwargs)[source]¶
Test an API list call RBAC enforcement.
- Parameters:
client_str – The service client to use for the test, without the credential. Example: ‘AmphoraClient’
method_str – The method on the client to call for the test. Example: ‘list_amphorae’
expected_allowed – The list of credentials expected to be allowed. Example: [‘os_roles_lb_member’].
args – Any positional parameters needed by the method.
kwargs – Any named parameters needed by the method.
- Raises:
AssertionError – Raised if the RBAC tests fail.
Forbidden – Raised if a credential that should have access does not and is denied.
InvalidScope – Raised if a credential that should have the correct scope for access is denied.
- Returns:
None on success
- check_list_RBAC_enforcement_count(client_str, method_str, expected_allowed, expected_count, *args, **kwargs)[source]¶
Test an API list call RBAC enforcement result count.
List APIs will return the object list for the project associated with the token used to access the API. This means most credentials will have access, but will get differing results.
This test will query the list API using a list of credentials and will validate that only the expected count of results are returned.
- Parameters:
client_str – The service client to use for the test, without the credential. Example: ‘AmphoraClient’
method_str – The method on the client to call for the test. Example: ‘list_amphorae’
expected_allowed – The list of credentials expected to be allowed. Example: [‘os_roles_lb_member’].
expected_count – The number of results expected in the list returned from the API.
args – Any positional parameters needed by the method.
kwargs – Any named parameters needed by the method.
- Raises:
AssertionError – Raised if the RBAC tests fail.
Forbidden – Raised if a credential that should have access does not and is denied.
InvalidScope – Raised if a credential that should have the correct scope for access is denied.
- Returns:
None on success
- check_show_RBAC_enforcement(client_str, method_str, expected_allowed, *args, **kwargs)[source]¶
Test an API show call RBAC enforcement.
- Parameters:
client_str – The service client to use for the test, without the credential. Example: ‘AmphoraClient’
method_str – The method on the client to call for the test. Example: ‘list_amphorae’
expected_allowed – The list of credentials expected to be allowed. Example: [‘os_roles_lb_member’].
args – Any positional parameters needed by the method.
kwargs – Any named parameters needed by the method.
- Raises:
AssertionError – Raised if the RBAC tests fail.
Forbidden – Raised if a credential that should have access does not and is denied.
InvalidScope – Raised if a credential that should have the correct scope for access is denied.
- Returns:
None on success
- check_update_RBAC_enforcement(client_str, method_str, expected_allowed, status_method=None, obj_id=None, *args, **kwargs)[source]¶
Test an API update call RBAC enforcement.
- Parameters:
client_str – The service client to use for the test, without the credential. Example: ‘AmphoraClient’
method_str – The method on the client to call for the test. Example: ‘list_amphorae’
expected_allowed – The list of credentials expected to be allowed. Example: [‘os_roles_lb_member’].
status_method – The service client method that will provide the object status for a status change waiter.
obj_id – The ID of the object to check for the expected status update.
args – Any positional parameters needed by the method.
kwargs – Any named parameters needed by the method.
- Raises:
AssertionError – Raised if the RBAC tests fail.
Forbidden – Raised if a credential that should have access does not and is denied.
InvalidScope – Raised if a credential that should have the correct scope for access is denied.
- Returns:
None on success
octavia_tempest_plugin.tests.test_base module¶
- class LoadBalancerBaseTest(*args, **kwargs)[source]¶
Bases:
ValidatorsMixin
,RBACTestsMixin
,BaseTestCase
Base class for load balancer tests.
- SRC_PORT_NUMBER_MAX = 61000¶
- SRC_PORT_NUMBER_MIN = 32768¶
- allocated_credentials = ('os_admin', 'os_primary', 'os_roles_lb_admin', 'os_roles_lb_observer', 'os_roles_lb_global_observer', 'os_roles_lb_member', 'os_roles_lb_member2')¶
- allocated_creds = ['os_admin', 'os_primary', 'os_roles_lb_admin', 'os_roles_lb_observer', 'os_roles_lb_global_observer', 'os_roles_lb_member', 'os_roles_lb_member2']¶
- cred = ['lb_member2', 'load-balancer_member', 'member']¶
- credentials = ['admin', 'primary', ['lb_admin', 'load-balancer_admin'], ['lb_observer', 'load-balancer_observer', 'reader'], ['lb_global_observer', 'load-balancer_global_observer', 'reader'], ['lb_member', 'load-balancer_member', 'member'], ['lb_member2', 'load-balancer_member', 'member']]¶
- src_port_number = 32768¶
- used_ips = []¶
- webserver1_response = 1¶
- webserver2_response = 5¶
octavia_tempest_plugin.tests.validators module¶
- class ValidatorsMixin(*args, **kwargs)[source]¶
Bases:
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.
- make_udp_requests_with_retries(vip_address, number_of_retries, dst_port, src_port=None, socket_timeout=20)[source]¶
Send UDP packets using retries mechanism
The delivery of data to the destination cannot be guaranteed in UDP. In case when UDP package is getting lost and we might want to check what could be the reason for that (Network issues or Server Side), well need to send more packets to get into the conclusion.
- Parameters:
vip_address – LB VIP address
number_of_retries – integer number of retries
dst_port – UDP server destination port
src_port – UDP source port to bind for UDP connection
socket_timeout – UDP socket timeout
- Returns:
None if all UPD retries failed, else first successful response data from UDP server.
- 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.