The neutron_taas.tests.tempest_plugin.tests.scenario.manager Module

class neutron_taas.tests.tempest_plugin.tests.scenario.manager.NetworkScenarioTest(*args, **kwargs)

Bases: neutron_taas.tests.tempest_plugin.tests.scenario.manager.ScenarioTest

Base class for network scenario tests.

This class provide helpers for network scenario tests, using the neutron API. Helpers from ancestor which use the nova network API are overridden with the neutron API.

This Class also enforces using Neutron instead of novanetwork. Subclassed tests will be skipped if Neutron is not enabled

check_floating_ip_status(floating_ip, status)

Verifies floatingip reaches the given status

Parameters:
  • floating_ip (dict) – floating IP dict to check status
  • status – target status
Raises:

AssertionError if status doesn’t match

create_floating_ip(thing, external_network_id=None, port_id=None, client=None)

Create a floating IP and associates to a resource/port on Neutron

create_networks(networks_client=None, routers_client=None, subnets_client=None, tenant_id=None, dns_nameservers=None, port_security_enabled=True)

Create a network with a subnet connected to a router.

The baremetal driver is a special case since all nodes are on the same shared network.

Parameters:
  • tenant_id – id of tenant to create resources in.
  • dns_nameservers – list of dns servers to send to subnet.
Returns:

network, subnet, router

credentials = ['primary', 'admin']
classmethod skip_checks()

Class level skip checks.

Subclasses verify in here all conditions that might prevent the execution of the entire test class. Skipping here prevents any other class fixture from being executed i.e. no credentials or other resource allocation will happen.

Tests defined in the test class will no longer appear in test results. The setUpClass for the entire test class will be marked as SKIPPED instead.

At this stage no test credentials are available, so skip checks should rely on configuration alone. This is deliberate since skips based on the result of an API call are discouraged.

The following checks are implemented in test.py already:

  • check that alt credentials are available when requested by the test
  • check that admin credentials are available when requested by the test
  • check that the identity version specified by the test is marked as enabled in the configuration

Overriders of skip_checks must always invoke skip_check on super first.

Example:

@classmethod
def skip_checks(cls):
    super(Example, cls).skip_checks()
    if not CONF.service_available.my_service:
        skip_msg = ("%s skipped as my_service is not available")
        raise cls.skipException(skip_msg % cls.__name__)
class neutron_taas.tests.tempest_plugin.tests.scenario.manager.ScenarioTest(*args, **kwargs)

Bases: tempest.test.BaseTestCase

Base class for scenario tests. Uses tempest own clients.

check_public_network_connectivity(ip_address, username, private_key, should_connect=True, msg=None, servers=None, mtu=None)
check_vm_connectivity(ip_address, username=None, private_key=None, should_connect=True, mtu=None)

Check server connectivity

Parameters:
  • ip_address – server to test against
  • username – server’s ssh username
  • private_key – server’s ssh private key to be used
  • should_connect – True/False indicates positive/negative test positive - attempt ping and ssh negative - attempt ping and fail if succeed
  • mtu – network MTU to use for connectivity validation
Raises:

AssertError if the result of the connectivity check does not match the value of the should_connect param

create_keypair(client=None)
create_server(name=None, image_id=None, flavor=None, validatable=False, wait_until='ACTIVE', clients=None, **kwargs)

Wrapper utility that returns a test server.

This wrapper utility calls the common create test server and returns a test server. The purpose of this wrapper is to minimize the impact on the code of the tests already using this function.

credentials = ['primary']
get_remote_client(ip_address, username=None, private_key=None)

Get a SSH client to a remote server

@param ip_address the server floating or fixed IP address to use
for ssh validation

@param username name of the Linux account on the remote server @param private_key the SSH private key to use @return a RemoteClient object

ping_ip_address(ip_address, should_succeed=True, ping_timeout=None, mtu=None)
classmethod setup_clients()

Create aliases to the clients in the client managers.

setup_clients is invoked after the credential provisioning step. Client manager objects are available to tests already. The purpose of this helper is to setup shortcuts to specific clients that are useful for the tests implemented in the test class.

Its purpose is mostly for code readability, however it should be used carefully to avoid doing exactly the opposite, i.e. making the code unreadable and hard to debug. If aliases are defined in a super class it won’t be obvious what they refer to, so it’s good practice to define all aliases used in the class. Aliases are meant to be shortcuts to be used in tests, not shortcuts to avoid helper method attributes. If an helper method starts relying on a client alias and a subclass overrides that alias, it will become rather difficult to understand what the helper method actually does.

Example:

class TestDoneItRight(test.BaseTestCase):

    credentials = ['primary', 'alt']

    @classmethod
    def setup_clients(cls):
        super(TestDoneItRight, cls).setup_clients()
        cls.servers = cls.os_primary.ServersClient()
        cls.servers_alt = cls.os_alt.ServersClient()

    def _a_good_helper(self, clients):
        # Some complex logic we're going to use many times
        servers = clients.ServersClient()
        vm = servers.create_server(...)

        def delete_server():
            test_utils.call_and_ignore_notfound_exc(
                servers.delete_server, vm['id'])

        self.addCleanup(self.delete_server)
        return vm

    def test_with_servers(self):
        vm = self._a_good_helper(os.primary)
        vm_alt = self._a_good_helper(os.alt)
        cls.servers.show_server(vm['id'])
        cls.servers_alt.show_server(vm_alt['id'])