CLI Testing Framework Usage¶
The cli.base module¶
-
class
tempest_lib.cli.base.
CLIClient
(username='', password='', tenant_name='', uri='', cli_dir='', *args, **kwargs)¶ Class to use OpenStack official python client CLI’s with auth
Parameters: - username (string) – The username to authenticate with
- password (string) – The password to authenticate with
- tenant_name (string) – The name of the tenant to use with the client calls
- uri (string) – The auth uri for the OpenStack Deployment
- cli_dir (string) – The path where the python client binaries are installed. defaults to /usr/bin
-
ceilometer
(action, flags='', params='', fail_ok=False, endpoint_type='publicURL', merge_stderr=False)¶ Executes ceilometer command for the given action.
Parameters: - action (string) – the cli command to run using ceilometer
- flags (string) – any optional cli flags to use
- params (string) – any optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- endpoint_type (string) – the type of endpoint for the service
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
cinder
(action, flags='', params='', fail_ok=False, endpoint_type='publicURL', merge_stderr=False)¶ Executes cinder command for the given action.
Parameters: - action (string) – the cli command to run using cinder
- flags (string) – any optional cli flags to use
- params (string) – any optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- endpoint_type (string) – the type of endpoint for the service
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
cmd_with_auth
(cmd, action, flags='', params='', fail_ok=False, merge_stderr=False)¶ Executes given command with auth attributes appended.
Parameters: - cmd (string) – command to be executed
- action (string) – command on cli to run
- flags (string) – optional cli flags to use
- params (string) – optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
glance
(action, flags='', params='', fail_ok=False, endpoint_type='publicURL', merge_stderr=False)¶ Executes glance command for the given action.
Parameters: - action (string) – the cli command to run using glance
- flags (string) – any optional cli flags to use
- params (string) – any optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- endpoint_type (string) – the type of endpoint for the service
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
heat
(action, flags='', params='', fail_ok=False, endpoint_type='publicURL', merge_stderr=False)¶ Executes heat command for the given action.
Parameters: - action (string) – the cli command to run using heat
- flags (string) – any optional cli flags to use
- params (string) – any optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- endpoint_type (string) – the type of endpoint for the service
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
keystone
(action, flags='', params='', fail_ok=False, merge_stderr=False)¶ Executes keystone command for the given action.
Parameters: - action (string) – the cli command to run using keystone
- flags (string) – any optional cli flags to use
- params (string) – any optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
neutron
(action, flags='', params='', fail_ok=False, endpoint_type='publicURL', merge_stderr=False)¶ Executes neutron command for the given action.
Parameters: - action (string) – the cli command to run using neutron
- flags (string) – any optional cli flags to use
- params (string) – any optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- endpoint_type (string) – the type of endpoint for the service
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
nova
(action, flags='', params='', fail_ok=False, endpoint_type='publicURL', merge_stderr=False)¶ Executes nova command for the given action.
Parameters: - action (string) – the cli command to run using nova
- flags (string) – any optional cli flags to use
- params (string) – any optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- endpoint_type (string) – the type of endpoint for the service
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
nova_manage
(action, flags='', params='', fail_ok=False, merge_stderr=False)¶ Executes nova-manage command for the given action.
Parameters: - action (string) – the cli command to run using nova-manage
- flags (string) – any optional cli flags to use
- params (string) – any optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
openstack
(action, flags='', params='', fail_ok=False, merge_stderr=False)¶ Executes openstack command for the given action.
Parameters: - action (string) – the cli command to run using openstack
- flags (string) – any optional cli flags to use
- params (string) – any optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
sahara
(action, flags='', params='', fail_ok=False, endpoint_type='publicURL', merge_stderr=True)¶ Executes sahara command for the given action.
Parameters: - action (string) – the cli command to run using sahara
- flags (string) – any optional cli flags to use
- params (string) – any optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- endpoint_type (string) – the type of endpoint for the service
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
swift
(action, flags='', params='', fail_ok=False, endpoint_type='publicURL', merge_stderr=False)¶ Executes swift command for the given action.
Parameters: - action (string) – the cli command to run using swift
- flags (string) – any optional cli flags to use
- params (string) – any optional positional args to use
- fail_ok (boolean) – if True an exception is not raised when the cli return code is non-zero
- endpoint_type (string) – the type of endpoint for the service
- merge_stderr (boolean) – if True the stderr buffer is merged into stdout
-
class
tempest_lib.cli.base.
ClientTestBase
(*args, **kwargs)¶ Base test class for testing the OpenStack client CLI interfaces.
-
assertFirstLineStartsWith
(lines, beginning)¶ Verify that the first line starts with a string
Parameters: - lines (list) – strings for each line of output
- beginning (string) – verify this is at the beginning of the first line
-
assertTableStruct
(items, field_names)¶ Verify that all items has keys listed in field_names.
Parameters: - items (list) – items to assert are field names in the output table
- field_names (list) – field names from the output table of the cmd
-
-
tempest_lib.cli.base.
execute
(cmd, action, flags='', params='', fail_ok=False, merge_stderr=False, cli_dir='/usr/bin')¶ Executes specified command for the given action.
Parameters: - cmd (string) – command to be executed
- action (string) – string of the cli command to run
- flags (string) – any optional cli flags to use
- params (string) – string of any optional positional args to use
- fail_ok (boolean) – boolean if True an exception is not raised when the cli return code is non-zero
- merge_stderr (boolean) – boolean if True the stderr buffer is merged into stdout
- cli_dir (string) – The path where the cmd can be executed
The cli.output_parser module¶
Collection of utilities for parsing CLI clients output.
-
tempest_lib.cli.output_parser.
details
(output_lines, with_label=False)¶ Return dict with details of first item (table) found in output.
-
tempest_lib.cli.output_parser.
details_multiple
(output_lines, with_label=False)¶ Return list of dicts with item details from cli output tables.
If with_label is True, key ‘__label’ is added to each items dict. For more about ‘label’ see OutputParser.tables().
-
tempest_lib.cli.output_parser.
listing
(output_lines)¶ Return list of dicts with basic item info parsed from cli output.
-
tempest_lib.cli.output_parser.
table
(output_lines)¶ Parse single table from cli output.
Return dict with list of column names in ‘headers’ key and rows in ‘values’ key.
-
tempest_lib.cli.output_parser.
tables
(output_lines)¶ Find all ascii-tables in output and parse them.
Return list of tables parsed from cli output as dicts. (see OutputParser.table())
And, if found, label key (separated line preceding the table) is added to each tables dict.