Ironic¶
Ironic conftest¶
Imports fixtures specific for Ironic.
-
stepler.baremetal.conftest.api_ironic_client_v1(get_api_ironic_client)[source]¶ Function fixture to get API ironic client v1.
Parameters: get_api_ironic_client (function) – function to get ironic client Returns: instantiated API ironic client v1 Return type: api_clients.ApiClientV1
-
stepler.baremetal.conftest.api_ironic_steps(get_api_ironic_steps)[source]¶ Function fixture to get API ironic steps.
Parameters: get_api_ironic_steps (function) – function to get API ironic steps Returns: instantiated ironic steps Return type: ironicSteps
-
stepler.baremetal.conftest.api_ironic_steps_v1(get_api_ironic_steps)[source]¶ Function fixture to get API ironic steps for v1.
Parameters: get_api_ironic_steps (function) – function to get ironic steps Returns: instantiated ironic steps v1 Return type: ironicStepsV1
-
stepler.baremetal.conftest.cleanup_chassis(uncleanable)[source]¶ Callable session fixture to cleanup chassis.
Parameters: uncleanable (AttrDict) – Data structure with skipped resources
-
stepler.baremetal.conftest.cleanup_nodes(uncleanable)[source]¶ Callable session fixture to cleanup nodes.
Parameters: uncleanable (AttrDict) – Data structure with skipped resources
-
stepler.baremetal.conftest.get_api_ironic_client(get_session)[source]¶ Callable session fixture to get ironic client v1.
Parameters: get_session (function) – function to get keystone session Returns: function to get ironic client v1 Return type: function
-
stepler.baremetal.conftest.get_api_ironic_steps(request, get_api_ironic_client)[source]¶ Callable session fixture to get ironic steps.
Parameters: get_api_ironic_client (function) – function to get ironic client Returns: function to get ironic steps Return type: function
-
stepler.baremetal.conftest.get_ironic_chassis_steps(get_ironic_client)[source]¶ Callable session fixture to get ironic steps.
Parameters: get_ironic_client (function) – function to get ironic client Returns: function to instantiated ironic steps Return type: function
-
stepler.baremetal.conftest.get_ironic_client(get_session)[source]¶ Callable session fixture to get ironic client.
Parameters: get_session (function) – function to get authenticated ironic session Returns: function to get ironic client Return type: function
-
stepler.baremetal.conftest.get_ironic_node_steps(get_ironic_client)[source]¶ Callable session fixture to get ironic steps.
Parameters: get_ironic_client (function) – function to get ironic client Returns: function to instantiated ironic steps Return type: function
-
stepler.baremetal.conftest.get_ironic_port_steps(get_ironic_client)[source]¶ Callable session fixture to get ironic port steps.
Parameters: get_ironic_client (function) – function to get ironic client Returns: function to get ironic port steps Return type: function
-
stepler.baremetal.conftest.ironic_chassis_steps(unexpected_chassis_cleanup, get_ironic_chassis_steps, cleanup_chassis)[source]¶ Callable function fixture to get ironic steps.
Can be called several times during a test. After the test it destroys all created chassis.
Parameters: - get_ironic_chassis_steps (function) – function to get ironic steps
- cleanup_chassis (function) – function to cleanup chassis after test
Yields: IronicChassisSteps – instantiated ironic chassis steps
-
stepler.baremetal.conftest.ironic_client(get_ironic_client)[source]¶ Callable function fixture to get ironic client.
Parameters: get_ironic_client (function) – function to get ironic client Returns: instantiated ironic client Return type: ironicclient.v1.client.
-
stepler.baremetal.conftest.ironic_client_v1(get_api_ironic_client)[source]¶ Function fixture to get ironic client v1.
Parameters: get_api_ironic_client (function) – function to get ironic client Returns: instantiated ironic client Return type: ironicclient.get_client
-
stepler.baremetal.conftest.ironic_node(ironic_node_steps)[source]¶ Function fixture to create ironic node with default options.
Parameters: ironic_node_steps (function) – function to get ironic steps Returns: ironic node Return type: object
-
stepler.baremetal.conftest.ironic_node_steps(unexpected_node_cleanup, get_ironic_node_steps, cleanup_nodes)[source]¶ Callable function fixture to get ironic steps.
Can be called several times during a test. After the test it destroys all created nodes.
Parameters: - get_ironic_node_steps (function) – function to get ironic steps
- cleanup_nodes (function) – function to cleanup nodes after test
Yields: IronicNodeSteps – instantiated ironic node steps
-
stepler.baremetal.conftest.ironic_port(ironic_node, ironic_port_steps)[source]¶ Fixture to create ironic port with default options before test.
Parameters: ironic_node (object) – ironic node of the ports should be associated with Returns: ironic port Return type: (object)
-
stepler.baremetal.conftest.ironic_port_steps(get_ironic_port_steps)[source]¶ Callable function fixture to get ironic steps.
Can be called several times during a test.
Parameters: get_ironic_port_steps (function) – function to get ironic steps Returns: instantiated ironic port steps Return type: IronicPortSteps
-
stepler.baremetal.conftest.ironic_steps_v1(get_api_ironic_steps)[source]¶ Function fixture to get ironic steps for v1.
Parameters: get_api_ironic_steps (function) – function to get ironic steps Returns: instantiated ironic steps v1 Return type: ironicStepsV1
-
stepler.baremetal.conftest.multitenancy_networks(request, network_steps, neutron_nets_for_projects)[source]¶ Function fixture to prepare multitenancy networks.
Can be parametrized with dict {‘shared_network’: True}. If shared_network is True - fixture returns shared network, otherwise it returns 2 networks for each of projects.
Parameters: - request (obj) – py.test SubRequest
- network_steps (obj) – instantiated network steps
- neutron_nets_for_projects (obj) – networks for different projects fixture
Returns: created resources
Return type: attrdict.AttrDict
-
stepler.baremetal.conftest.multitenancy_resources(request, projects, multitenancy_networks, get_neutron_security_group_steps, get_neutron_security_group_rule_steps, get_server_steps, get_keypair_steps, glance_steps, baremetal_flavor, baremetal_ubuntu_image, port_steps, create_floating_ip, public_network)[source]¶ Function fixture to prepare environment for ironic multitenancy tests.
- This fixture:
- creates projects;
- creates net, subnet, router in each project;
- creates security groups in each project;
- add ping + ssh rules for 1’st project’s security group;
- add ssh rules for 2’nd project security group;
- creates 2 servers in 1’st project;
- creates 2 servers in 2’nd project with same fixed ip as for 1’st
- project;
- add floating ips for one of servers in each project.
All created resources are to be deleted after test.
Parameters: - request (obj) – py.test SubRequest
- projects (obj) – projects fixture
- multitenancy_networks (obj) – multitenancy tests networks fixture
- get_neutron_security_group_steps (function) – function to get neutron security group steps
- get_neutron_security_group_rule_steps (function) – function to get neutron security group rule steps
- get_server_steps (function) – function to get server steps
- get_keypair_steps (function) – function to get keypair steps
- glance_steps (obj) – instantiated glance steps
- baremetal_flavor (obj) – baremetal flavor
- baremetal_ubuntu_image (oobj) – baremetal ubuntu image
- port_steps (obj) – instantiated port steps
- create_floating_ip (function) – function to create floating ip
- public_network (dict) – neutron public network
Returns: created resources
Return type: attrdict.AttrDict
-
stepler.baremetal.conftest.primary_chassis(get_ironic_chassis_steps, cleanup_chassis, uncleanable)[source]¶ Session fixture to remember primary chassis before tests.
Also optionally in finalization it deletes all unexpected chassis which are remained after tests.
Parameters: - get_ironic_chassis_steps (function) – Function to get ironic steps.
- cleanup_chassis (function) – Function to cleanup volumes.
- uncleanable (AttrDict) – Data structure with skipped resources.
-
stepler.baremetal.conftest.primary_nodes(get_ironic_node_steps, cleanup_nodes, uncleanable)[source]¶ Session fixture to remember primary nodes before tests.
Also optionally in finalization it deletes all unexpected nodes which are remained after tests.
Parameters: - get_ironic_node_steps (function) – Function to get ironic steps.
- cleanup_nodes (function) – Function to cleanup nodes.
- uncleanable (AttrDict) – Data structure with skipped resources.
Ironic steps¶
-
class
stepler.baremetal.steps.IronicNodeSteps(client)[source]¶ Node steps.
-
check_ironic_nodes_attribute_value(nodes, attribute, expected_value, node_timeout=0)[source]¶ Check ironic nodes attribute value.
Parameters: - nodes (list) – the list of ironic nodes.
- attribute (str) – the node attribute.
- expected_value (str) – the value of the node attribute.
- node_timeout (int) – seconds to wait a result of check.
Raises: TimeoutExpired– if check failed after timeout.
-
check_ironic_nodes_maintenance(nodes, state, node_timeout=0)[source]¶ Check ironic node maintenance was changed.
Parameters: - nodes (list) – The list of ironic nodes.
- state (Bool) – the maintenance mode; either a Boolean or a string representation of a Boolean (eg, ‘true’, ‘on’, ‘false’, ‘off’). True to put the node in maintenance mode; False to take the node out of maintenance mode.
- node_timeout (int) – seconds to wait a result of check.
Raises: TimeoutExpired– if check failed after timeout.
-
check_ironic_nodes_power_state(nodes, state, node_timeout=0)[source]¶ Check ironic node power state was changed.
Parameters: - nodes (list) – The list of ironic nodes.
- state (str) – the power state mode; on to put the node in power state mode on; off to put the node in power state mode off; reboot to reboot the node.
- node_timeout (int) – seconds to wait a result of check.
Raises: TimeoutExpired– if check failed after timeout.
-
check_ironic_nodes_presence(nodes, must_present=True, node_timeout=0)[source]¶ Verify step to check ironic node is present.
Parameters: - nodes (list) – list of ironic nodes.
- must_present (bool) – flag whether node should present or not.
- node_timeout (int) – seconds to wait a result of check.
Raises: TimeoutExpired– if check failed after timeout.
-
check_ironic_nodes_provision_state(nodes, state, node_timeout=0)[source]¶ Check ironic node provision state was changed.
Parameters: - nodes (list) – the list of ironic nodes.
- state (str) – the provision state mode.
- node_timeout (int) – seconds to wait a result of check.
Raises: TimeoutExpired– if check failed after timeout.
-
create_ironic_nodes(driver='fake', nodes_names=None, count=1, check=True, **kwargs)[source]¶ Step to create a ironic node.
Parameters: - driver (str) – The name or UUID of the driver.
- nodes_names (list) – names of created nodes, if not specified one node name will be generated.
- count (int) – count of nodes to be created.
- check (str) – For checking node presence
- **kwargs (optional) – A dictionary containing the attributes
- the resource that will be created (of) – chassis_uuid - The uuid of the chassis. driver_info - The driver info. extra - Extra node parameters. uuid - The uuid of the node. properties - Node properties. name - The name of the node. network_interface - The network interface of the node. resource_class - The resource class of the node.
Raises: TimeoutExpired– if check failed after timeout.Returns: nodes_list – list of created ironic nodes
Return type:
-
delete_ironic_nodes(nodes, check=True)[source]¶ Step to delete node.
Parameters: - nodes (list) – list of ironic nodes.
- check (bool) – flag whether to check step or not.
-
get_ironic_node(check=True, **kwargs)[source]¶ Find one node by provided **kwargs.
Parameters: - check (bool) – flag whether to check step or not.
- **kwargs – like: {‘name’: ‘test_node’, ‘status’: ‘active’}
Returns: ironic node.
Return type: object
Raises: ValueError– if ‘**kwargs’ were not provided.
-
get_ironic_nodes(check=True, **kwargs)[source]¶ Step to retrieve nodes.
Parameters: check (bool) – flag whether to check step or not. Returns: list of nodes. **kwargs: like: {‘name’: ‘test_node’, ‘status’: ‘active’} Return type: list of objects Raises: AssertionError– if nodes collection is empty.
-
get_node_by_instance_uuid(server_uuid, check=True)[source]¶ Step to get node by instance uuid.
Parameters: - server_uuid (str) – the uuid of the nova server.
- check (bool) – flag whether to check step or not.
Returns: ironic node.
Return type: object
Raises: AssertionError– if node is empty.
-
set_ironic_nodes_power_state(nodes, state, check=True)[source]¶ Set the power state for the node.
Parameters: - nodes (list) – The list of ironic nodes.
- state (str) – the power state mode; on to put the node in power state mode on; off to put the node in power state mode off; reboot to reboot the node.
- check (bool) – flag whether to check step or not.
Raises: InvalidAttribute– if state is an invalid string.
-
set_maintenance(nodes, state, reason=None, check=True)[source]¶ Set the maintenance mode for the nodes.
Parameters: - nodes (list) – The list of ironic nodes.
- state (Bool) – the maintenance mode; either a Boolean or a string representation of a Boolean (eg, ‘true’, ‘on’, ‘false’, ‘off’). True to put the node in maintenance mode; False to take the node out of maintenance mode.
- reason (str) – Optional string. Reason for putting node into maintenance mode.
- check (bool) – flag whether to check step or not.
Raises: InvalidAttribute– if state is an invalid string.
-
-
class
stepler.baremetal.steps.IronicPortSteps(client)[source]¶ Ironic port steps.
-
check_ports_presence(ports, must_present=True, port_timeout=0)[source]¶ Step to check ports is present.
Parameters: - ports (list) – list of ironic ports
- must_present (bool) – flag whether ports should be present or not
- port_timeout (int) – seconds to wait a result of check
Raises: TimeoutExpired– if check failed after timeout
-
create_ports(node, addresses=None, count=1, check=True, **kwargs)[source]¶ Step to create ironic ports with kwargs dictionary of attributes.
Parameters: - addresses (list) – MAC addresses for ports
- node (object) – node of the ports should be associated with
- count (int) – count of created ports
- check (bool) – For checking ports were created correct with correct addresses
- kwargs –
Optional. A dictionary containing the attributes of the resource that will be created:
- extra (dictionary) - Extra node parameters
- local_link_connection (dictionary) - Contains the port binding profile
- pxe_enabled (bool) - Indicates whether PXE is enabled for the port
- uuid (str) - The uuid of the port
Returns: ports – list of created ironic ports
Return type: Raises: TimeoutExpired|AssertionError– if check failed after timeout
-
-
class
stepler.baremetal.steps.IronicChassisSteps(client)[source]¶ Chassis steps.
-
check_ironic_chassis_presence(chassis_list, must_present=True, chassis_timeout=0)[source]¶ Verify step to check ironic chassis is present.
Parameters: - chassis_list (list) – list of ironic chassis to check presence status
- must_present (bool) – flag whether chassis should present or not
- chassis_timeout (int) – seconds to wait a result of check
Raises: TimeoutExpired– if check failed after timeout
-
create_ironic_chassis(descriptions=None, count=1, check=True)[source]¶ Step to create a ironic chassis.
Parameters: - descriptions (list) – descriptions of created chassis, if not specified one chassis description will be generate
- count (int) – count of created chassis, it’s ignored if chassis_descriptions are specified; one chassis is created if both args are missing
- check (str) – flag for checking chassis presence
Raises: TimeoutExpired– if check was triggered to False after timeoutReturns: list of the created chassis or None in case of exception, and an exception, if it appears.
Return type:
-
Ironic node tests¶
Ironic node tests¶
Ironic baremetal node tests¶
-
stepler.baremetal.tests.test_boot_baremetal_server.test_boot_server_simple(keypair, baremetal_flavor, baremetal_ubuntu_image, baremetal_network, server_steps)[source]¶ *Scenario: Boot one baremetal server.
Setup:
- Create keypair
- Create baremetal flavor
- Upload baremetal ubuntu image
Steps:
- Create and boot server, check that server status is active
Teardown:
- Delete server
- Delete image
- Delete flavor
- Delete keypair
-
stepler.baremetal.tests.test_boot_baremetal_server.test_boot_servers_concurrently_on_ironic_node(keypair, baremetal_flavor, baremetal_ubuntu_image, baremetal_network, create_floating_ip, server_steps, ironic_node_steps)[source]¶ Scenario: Boot two baremetal servers concurrently.
Setup:
- Create keypair
- Create baremetal flavor
- Upload baremetal ubuntu image
Steps:
- Create and boot server_1 and server_2
- Check that servers status is active
- Get ironic_node_1
- Get ironic_node_2
- Check that ironic nodes provision state is active
- Create floating ip for server_1
- Attach floating ip to server_2
- Create floating ip for server_2
- Attach floating ip to server_2
- Check ssh access to server_1
- Check ssh access to server_2
Teardown:
- Delete servers
- Delete floating ips
- Delete image
- Delete flavor
- Delete keypair
-
stepler.baremetal.tests.test_boot_baremetal_server.test_boot_servers_consequently_on_ironic_node(keypair, baremetal_flavor, baremetal_ubuntu_image, baremetal_network, create_floating_ip, server_steps, ironic_node_steps)[source]¶ Scenario: Boot two baremetal servers consequently.
Setup:
- Create keypair
- Create baremetal flavor
- Upload baremetal ubuntu image
Steps:
- Create and boot server_1
- Check that server_1 status is active
- Create and boot server_2
- Check that server_2 status is active
- Get ironic_node_1
- Get ironic_node_1
- Check that ironic nodes provision state is active
- Create floating ip for server_1
- Attach floating ip to server_2
- Create floating ip for server_2
- Attach floating ip to server_2
- Check ssh access to server_1
- Check ssh access to server_2
Teardown:
- Delete servers
- Delete floating ips
- Delete image
- Delete flavor
- Delete keypair
-
stepler.baremetal.tests.test_boot_baremetal_server.test_create_server_on_baremetal_node(keypair, baremetal_ubuntu_image, baremetal_flavor, baremetal_network, floating_ip, server_steps)[source]¶ Scenario: Launch server on baremetal node.
Setup:
- Create keypair
- Create baremetal flavor
- Upload baremetal ubuntu image
- Create floating ip
Steps:
- Create and boot server
- Check that server status is active
- Attach floating ip to server
- Check ssh access to server
Teardown:
- Delete server
- Delete floating ip
- Delete image
- Delete flavor
- Delete keypair
-
stepler.baremetal.tests.test_boot_baremetal_server.test_create_server_on_baremetal_node_in_maintenance_state(ironic_node_steps, baremetal_network, baremetal_ubuntu_image, baremetal_flavor, server_steps)[source]¶ Scenario: Launch server on baremetal node in maintenance state.
Setup:
- Create baremetal flavor
- Upload baremetal ubuntu image
Steps:
- Get Ironic nodes
- Set all Ironic nodes into maintenance mode
- Create and boot server
- Check that server status is error
- Check that instance doesn’t exist in ironic node
Teardown:
- Delete server
- Delete image
- Delete flavor
-
stepler.baremetal.tests.test_boot_baremetal_server.test_hard_reboot_server_on_ironic_node(keypair, baremetal_flavor, baremetal_ubuntu_image, baremetal_network, floating_ip, server_steps)[source]¶ Scenario: Hard reboot server on ironic node.
Setup:
- Create keypair
- Create baremetal flavor
- Upload baremetal ubuntu image
- Create floating ip
Steps:
- Create and boot server
- Check that server status is active
- Attach floating ip to server
- Check ssh access to server
- Reboot server
- Check that server status is hard reboot
- Check that server status is active
- Check ssh access to server
Teardown:
- Delete server
- Delete floating ip
- Delete image
- Delete flavor
- Delete keypair
-
stepler.baremetal.tests.test_boot_baremetal_server.test_stop_start_server_on_baremetal_node(keypair, baremetal_flavor, baremetal_ubuntu_image, baremetal_network, floating_ip, server_steps)[source]¶ Scenario: Shut off and restart server on baremetal node.
Setup:
- Create keypair
- Create baremetal flavor
- Upload baremetal ubuntu image
- Create floating ip
Steps:
- Create and boot server
- Check that server status is active
- Attach floating ip to server
- Check ssh access to server
- Stop server
- Check that server status is shutoff
- Start server
- Check that server status is active
- Check ssh access to server
Teardown:
- Delete server
- Delete floating ip
- Delete image
- Delete flavor
- Delete keypair
Ironic services tests¶
-
stepler.baremetal.tests.test_ironic_services.test_ironic_api_service(keypair, baremetal_flavor, baremetal_network, baremetal_ubuntu_image, floating_ip, ironic_api_node, server_steps, os_faults_steps)[source]¶ Scenario: Launch server with stopped service ironic-api on one of node.
Setup:
- Create keypair
- Create baremetal flavor
- Upload baremetal ubuntu image
- Create floating ip
- Get node with service ironic-api
Steps:
- Create and boot server
- Stop service ironic-api
- Check that server status is active
- Attach floating ip to server
- Check ssh access to server
- Start service ironic-api
Teardown:
- Delete server
- Delete floating ip
- Delete image
- Delete flavor
- Delete keypair
Ironic chassis tests¶
Ironic multitenancy tests¶
Ironic baremetal multitenancy tests¶
-
stepler.baremetal.tests.test_multitenancy.test_per_project_l3_isolation(multitenancy_resources)[source]¶ Check user can’t get access to other project’s instance.
Setup:
- Create 2 projects and 2 users
- Create network, subnet, router on each project
- Upload public baremetal ubuntu image
- Create baremetal flavor
- Create keypairs
- Boot 2 servers on 1’st project and 1 server on 2’nd project
- Assign Floating IPs to one server from 1’st project and server from 2’nd
- project
Steps:
- Check that users can see only own project’s servers
- Check that 1’nd user can’t ping 2’st project server via fixed IP
- Check that 1’nd user can ping 2’st project server via floating IP
- Check ping between 1’st project servers
Teardown:
- Delete servers
- Delete floating ips
- Delete networks, subnets, routers
- Delete image
- Delete flavor
- Delete keypairs
- Delete projects and users
Check different projects with shared network connectivity.
Setup:
- Create 2 projects and 2 users
- Create shared network, subnet, router
- Upload public baremetal ubuntu image
- Create baremetal flavor
- Boot 2 servers on 1’st project and 1 server on 2’nd project
- Assign Floating IPs to one server from 1’st project and server from 2’nd
- project
Steps:
- Check that 1’nd user can ping 2’st project server via fixed IP
Teardown:
- Delete servers
- Delete floating ips
- Delete network, subnet, router
- Delete image
- Delete flavor
- Delete keypairs
- Delete projects and users