taf.testlib.linux.bench¶
bench.py
-
class
taf.testlib.linux.bench.Config(config=None, master_ip=None)[source]¶ Bases:
object-
CLASS_LOGGER= <logging.LoggerAdapter object>¶
-
-
class
taf.testlib.linux.bench.KubernetesBenchmark(config)[source]¶ Bases:
taf.testlib.linux.bench.Test
-
class
taf.testlib.linux.bench.Labels[source]¶ Bases:
taf.testlib.linux.bench.Constants-
LOCAL_CLIENT= 'local-cl'¶
-
LOCAL_SERVER= 'local-srv'¶
-
REMOTE_CLIENT= 'remote-cl'¶
-
REMOTE_SERVER= 'remote-srv'¶
-
SINGLE_VM= 'single-vm'¶
-
-
class
taf.testlib.linux.bench.Modes[source]¶ Bases:
taf.testlib.linux.bench.Constants-
LOCAL= 'local'¶
-
REMOTE= 'remote'¶
-
SINGLE_VM= 'single_vm'¶
-
taf.testlib.linux.collectd¶
collectd.py
Class to abstract collectd operations
Note
collectd.conf path is retrieved from testcases/config/setup/setup.json in format:
{
"env": [
{
"id": "213207",
"collectd_conf_path": "/opt/collectd/etc/collectd.conf"
}
],
"cross": {}
}
If “collectd_conf_path” is not specified in setup.json then default value is set: /etc/collectd.conf
Examples of collectd usage in tests:
# If required, stop running collectd service:
env.lhost[1].ui.collectd.stop()
# Start collectd service:
env.lhost[1].ui.collectd.start()
Consistent and valid collectd.conf content is built from OrderedDict object, e.g.:
python_plugin_config = collections.OrderedDict(
(('ModulePath', '"/tmp/"'),
('Interactive', 'false'),
('Import', '"python_module_name"'),
('Module "python_module_name"', {'Test': 'arg1'})))
env.lhost[1].ui.collectd.plugins_config = collections.OrderedDict(
(('Interval', 3),
('AutoLoadPlugins', 'false'),
('LoadPlugin cpu', {}),
('LoadPlugin "csv"', {}),
('LoadPlugin "python"', {'Interval': 5, 'Globals': 'true'}),
('Plugin "csv"', {'DataDir': '"/tmp/csv_data/"'}),
('Plugin "python"', python_plugin_config)))
As shown above, config parts that depend on parameters order should be presented as OrderedDict objects. Otherwise, dict() object can be used.
Transform data structure into multiline text block:
env.lhost[1].ui.collectd.update_config_file()
If required, in other test the default plugins configuration may be changed, e.g.:
env.lhost[1].ui.collectd.plugins_config['LoadPlugin "csv"'].update({'Interval': 9})
env.lhost[1].ui.collectd.update_config_file()
Some plugins support multiple entries of parameter with same name. Such case should be presented as:
{param_name: [param1_value, ...]}
Example of resulting collectd.conf file:
Interval 3
AutoLoadPlugins false
<LoadPlugin cpu>
</LoadPlugin>
<LoadPlugin "csv">
Interval 9
</LoadPlugin>
<LoadPlugin "python">
Interval 5
Globals true
</LoadPlugin>
<Plugin "csv">
DataDir "/tmp/csv_data/"
</Plugin>
<Plugin "python">
ModulePath "/tmp/"
Interactive false
Import "python_module_name"
<Module "python_module_name">
Test arg1
</Module>
</Plugin>
Restart collectd service:
env.lhost[1].ui.collectd.restart()
-
class
taf.testlib.linux.collectd.Collectd(cli_send_command)[source]¶ Bases:
object-
SERVICE= 'collectd'¶
-
__call__(cmd, expected_rc)[source]¶ Overloaded call method.
Parameters: - cmd (str) – command to execute
- expected_rc (int | set | list | frozenset) – expected return code
Returns: named tuple
Return type:
-
-
class
taf.testlib.linux.collectd.IndentationContext(char=' ', count=4, buffer=None)[source]¶ Bases:
object-
pad¶
-
-
taf.testlib.linux.collectd.build_tagged_section(config_data, indent=None, buffer=None)[source]¶ Fill in data into text block.
Parameters: - config_data (collections.Mapping) – plugins configuration data structure
- indent (int) – indentation level
- buffer (StringIO object) – resulting text block
Returns: resulting text block
Return type:
taf.testlib.linux.commands.cmd_helper¶
cmd_helper.py
Flexible command representation with parsing and building support
-
class
taf.testlib.linux.commands.cmd_helper.ArgumentBuilder(args_order=None, args_formatter=None)[source]¶ Bases:
object-
ARGS_ORDER= []¶
-
-
class
taf.testlib.linux.commands.cmd_helper.Command(*args, **kwargs)[source]¶ Bases:
collections.abc.MappingCommand holder object flexible representation.
-
CMD_HELPER= <taf.testlib.linux.commands.cmd_helper.CommandHelper object>¶
-
extend(*args, **kwargs)[source]¶ Add new stuff only
cmd{a: 1, b: 2, c:3} + (cmd{b: ‘b’, c: ‘c’, d: ‘d’}) => cmd{a: 1, b: 2, c: 3, d: ‘d’}
-
unset(*args, **kwargs)[source]¶ Remove stuff
cmd{a: 1, b: 2, c: 3} - {cmd{b: ‘b’, c: ‘c’, d: ‘d’} => cmd{a: 1}
-
-
class
taf.testlib.linux.commands.cmd_helper.CommandHelper(prog=None, arg_parser=None, conflict_handler=None, params=None, arg_builder=None, default_list=None)[source]¶ Bases:
object-
MANGLED_CLS_PREFIX= None¶
-
__init__(prog=None, arg_parser=None, conflict_handler=None, params=None, arg_builder=None, default_list=None)[source]¶
-
build_cmd_list(**kwargs)[source]¶ A command builder helper function.
Reverse parse_args() functionality. Converts the input sequence of command arguments(key[:value] pairs) to a command options list.
-
get_set_args(args_in, args_out=None, args_order=None)[source]¶ A command builder helper function.
Strips the dict off the unset (default) arguments. Learns which fields in ‘args_in’ (dict or argparse.Namespace instance), possibly parsed earlier, had been set before the parsing took place. If an intermediate dict is provided in ‘args_out’, mutate in place and overwrite it on collision.
-
taf.testlib.linux.commands.mkdir_cmd¶
‘’iperf_cmd.py’‘
‘iperf command parsing and building support’
-
class
taf.testlib.linux.commands.mkdir_cmd.CmdMkdir(*args, **kwargs)[source]¶ Bases:
testlib.linux.commands.cmd_helper.Command-
CMD_HELPER= <taf.testlib.linux.commands.mkdir_cmd.CmdMkdirHelper object>¶
-
-
class
taf.testlib.linux.commands.mkdir_cmd.CmdMkdirHelper(prog=None, arg_parser=None, conflict_handler=None, params=None, arg_builder=None, default_list=None)[source]¶ Bases:
testlib.linux.commands.cmd_helper.CommandHelper
taf.testlib.linux.commands.suricata_cmd¶
‘’suricata_cmd.py’‘
Suricata command parsing and building support
-
class
taf.testlib.linux.commands.suricata_cmd.CmdSuricata(*args, **kwargs)[source]¶ Bases:
testlib.linux.commands.cmd_helper.Command-
CMD_HELPER= <taf.testlib.linux.commands.suricata_cmd.CmdSuricataHelper object>¶
-
-
class
taf.testlib.linux.commands.suricata_cmd.CmdSuricataHelper(prog=None, arg_parser=None, conflict_handler=None, params=None, arg_builder=None, default_list=None)[source]¶ Bases:
testlib.linux.commands.cmd_helper.CommandHelper-
classmethod
check_keywords(_CmdSuricataHelper__config=None, _CmdSuricataHelper__pcap_live_mode=None, _CmdSuricataHelper__bpf_filter=None, _CmdSuricataHelper__pcap_offline_mode=None, _CmdSuricataHelper__inline_nfqueue_mode=None, _CmdSuricataHelper__sig_file=None, _CmdSuricataHelper__sig_exc_file=None, _CmdSuricataHelper__log_dir=None, _CmdSuricataHelper__checksum_check=None, _CmdSuricataHelper__runmode=None, _CmdSuricataHelper__pid_file=None, _CmdSuricataHelper__pcap_buf_size=None, _CmdSuricataHelper__user=None, _CmdSuricataHelper__group=None, _CmdSuricataHelper__erf_in=None, _CmdSuricataHelper__set=None, **_CmdSuricataHelper__kwargs)[source]¶
-
classmethod
check_opt_keywords(_CmdSuricataHelper__list_keywords=None, _CmdSuricataHelper__pcap_mode=None, _CmdSuricataHelper__af_packet=None, _CmdSuricataHelper__unix_socket=None, **_CmdSuricataHelper__kwargs)[source]¶
-
classmethod
check_opts(_CmdSuricataHelper__test_config=False, _CmdSuricataHelper__daemon=False, _CmdSuricataHelper__version=False, _CmdSuricataHelper__verbosity=False, _CmdSuricataHelper__list_app_layer_prots=False, _CmdSuricataHelper__list_runmodes=False, _CmdSuricataHelper__engine_analysis=False, _CmdSuricataHelper__init_errors_fatal=False, _CmdSuricataHelper__disable_detection=False, _CmdSuricataHelper__dump_config=False, _CmdSuricataHelper__build_info=False, **_CmdSuricataHelper__kwargs)[source]¶
-
classmethod
-
class
taf.testlib.linux.commands.suricata_cmd.SuricataArgumentBuilder[source]¶ Bases:
testlib.linux.commands.cmd_helper.ArgumentBuilder-
ARGS_FORMATTER= {'optional': <function ArgumentBuilder.FORMATTER_BY_VALUE_MAP.<locals>.wrapper>, 'positional': <function ArgumentBuilder.FORMAT_VAL_TRANSFORM.<locals>.wrapper>}¶
-
ARGS_ORDERED= {'af_packet': {'const': <object object>, 'default': <object object>, 'help': '[=<dev>]: run in af-packet mode, no value select interfaces from suricata.yaml', 'names': {'long': '--af-packet'}, 'nargs': '?'}, 'bpf_filter': {'help': '<bpf filter file>: bpf filter file', 'names': {'short': '-F'}}, 'build_info': {'action': 'store_true', 'help': 'display build information', 'names': {'long': '--build-info'}}, 'checksum_check': {'choices': ['all', 'none'], 'help': '[all|none]: force checksum check (all) or disabled it (none)', 'names': {'short': '-k'}}, 'config': {'help': '<path>: path to configuration file', 'names': {'short': '-c'}}, 'daemon': {'action': 'store_true', 'help': 'run as daemon', 'names': {'short': '-D'}}, 'disable_detection': {'action': 'store_true', 'help': 'disable detection engine', 'names': {'long': '--disable-detection'}}, 'dump_config': {'action': 'store_true', 'help': 'show the running configuration', 'names': {'long': '--dump-config'}}, 'engine_analysis': {'action': 'store_true', 'help': 'print reports on analysis of different sections in the engine and exit. Please have a look at the conf parameter engine-analysis on what reports can be printed', 'names': {'long': '--engine-analysis'}}, 'erf_in': {'help': '<path>: process an ERF file', 'names': {'long': '--erf-in'}}, 'group': {'help': '<group>: run suricata as this group after init', 'names': {'long': '--group'}}, 'init_errors_fatal': {'action': 'store_true', 'help': 'enable fatal failure on signature init error', 'names': {'long': '--init-errors-fatal'}}, 'inline_nfqueue_mode': {'help': '<qid>: run in inline nfqueue mode', 'names': {'short': '-q'}}, 'list_app_layer_prots': {'action': 'store_true', 'help': 'list supported app layer protocols', 'names': {'long': '--list-app-layer-protos'}}, 'list_keywords': {'const': <object object>, 'default': <object object>, 'help': '[=all|csv|<kword>]: list keywords implemented by the engine', 'names': {'long': '--list-keywords'}, 'nargs': '?'}, 'list_runmodes': {'action': 'store_true', 'help': 'list supported runmodes', 'names': {'long': '--list-runmodes'}}, 'log_dir': {'help': '<dir>: default log directory', 'names': {'short': '-l'}}, 'pcap_buf_size': {'help': '<size>: size of the pcap buffer value from 0 - 2147483647', 'names': {'long': '--pcap-buffer-size'}, 'type': <class 'int'>}, 'pcap_live_mode': {'help': '<dev or ip>: run in pcap live mode', 'names': {'short': '-i'}}, 'pcap_mode': {'const': <object object>, 'default': <object object>, 'help': '[=<dev>]: run in pcap mode, no value select interfaces from suricata.yaml', 'names': {'long': '--pcap'}, 'nargs': '?'}, 'pcap_offline_mode': {'help': '<path>: run in pcap file/offline mode', 'names': {'short': '-r'}}, 'pid_file': {'help': '<file>: write pid to this file', 'names': {'long': '--pidfile'}}, 'runmode': {'help': '<unmode_id>: specific runmode modification the engine should run. The argument supplied should be the id for the runmode obtained by running --list-runmodes', 'names': {'long': '--runmode'}}, 'set': {'help': 'name=value: set a configuration value', 'names': {'long': '--set'}}, 'sig_exc_file': {'help': '<path>: path to signature file loaded exclusively (optional)', 'names': {'short': '-S'}}, 'sig_file': {'help': '<path>: path to signature file loaded in addition to suricata.yaml settings (optional)', 'names': {'short': '-s'}}, 'test_config': {'action': 'store_true', 'help': 'test configuration file (use with -c)', 'names': {'short': '-T'}}, 'unix_socket': {'const': <object object>, 'default': <object object>, 'help': '[=<file>]: use unix socket to control suricata work', 'names': {'long': '--unix-socket'}, 'nargs': '?'}, 'user': {'help': '<user>: run suricata as this user after init', 'names': {'long': '--user'}}, 'verbosity': {'action': 'store_true', 'help': 'increase default Suricata verbosity', 'names': {'short': '-v'}}, 'version': {'action': 'store_true', 'help': 'display Suricata version', 'names': {'short': '-V'}}}¶
-
taf.testlib.linux.dcrpd.dcrpd¶
dcrpd.py
Class to abstract dcrpd operations
-
class
taf.testlib.linux.dcrpd.dcrpd.Dcrpd(run_command, switch)[source]¶ Bases:
object-
CONFIG_PATH= '/usr/lib/systemd/system/'¶
-
MANIFEST_FILE= '/usr/lib/systemd/system/dcrpd.service'¶
-
SERVICE= 'dcrpd'¶
-
__init__(run_command, switch)[source]¶ Initialize Dcrpd class.
Parameters: run_command (function) – function that runs the actual commands
-
disable()[source]¶ Disabling dcrpd service on start.
Raises: UICmdException – On non-zero return code
-
enable()[source]¶ Enabling dcrpd service on start.
Raises: UICmdException – On non-zero return code
-
force_reload()[source]¶ Restarting the switch driver and then the dcrpd process.
Raises: UICmdException – On non-zero return code
-
get_status()[source]¶ Get dcrpd process status.
Raises: UICmdException – On non-zero or non-three return code Returns: str
-
restart()[source]¶ Restarting dcrpd process.
Raises: UICmdException – On non-zero return code
-
start()[source]¶ Start dcrpd process.
Raises: UICmdException – On non-zero return code
-
stop()[source]¶ Stop dcrpd process.
Raises: UICmdException – On non-zero return code
-
taf.testlib.linux.dpdk¶
dpdk.py
Class for dpdk operations
Note
Examples of dpdk usage in tests:
inst.ui.dpdk.modify_iface_status(bind_action='bind', ifaces=["0000:01:00.0", "01:00.0"],
drv='igb_uio', force=False, show_status=True)
-
class
taf.testlib.linux.dpdk.Dpdk(cli_send_command)[source]¶ Bases:
objectClass for interfaces modifications using DPDK tools.
-
SERVICE= 'dpdk-devbind'¶
-
modify_iface_status(bind_action='', ifaces=None, drv='', force=False, show_status=False)[source]¶ Performs binding, unbinding NICs to specific driver and/or showing NICs status.
Parameters: - ifaces (str) – List of network interfaces in format <domain:bus:slot.func> or <bus:slot.func>
- bind_action (str) – action to be performed on NICs: bind | unbind
- drv (str) – Driver file name (without extension)
- force (bool) – Flag to override modifying NIC used by Linux
- show_status (bool) – Flag to override modifying NIC used by Linux
Returns: None or dictionary with interfaces status information
Return type:
-
taf.testlib.linux.etcd_helper¶
etcd_helper.py
taf.testlib.linux.hugepages¶
hugepages.py
Class to abstract hugepages operations
-
class
taf.testlib.linux.hugepages.HugePages(cli_send_command)[source]¶ Bases:
object-
_hugepages_helper(kwargs)[source]¶ Helper function for getting and setting hugepages.
Parameters: kwargs (dict) – Arguments to pass Returns: Returns CmdStatus namedtuple of stdout, stderr, return code Return type: tuple(str, str, int) | CmdStatus
-
change_number(nr_hugepages, per_node=None, hugepage_size=2048)[source]¶ Change number of hugepages.
Parameters:
-
get_free_memory(per_node=None, hugepage_size=2048)[source]¶ Get free hugepages
Parameters: Returns: Returns number of free hugepages
Return type:
-
get_number(per_node=None, hugepage_size=2048)[source]¶ Get number of hugepages.
Parameters: Returns: Returns number of hugepages
Return type:
-
taf.testlib.linux.ipmitool¶
ipmitool.py
Class to abstract ipmitool operations
-
class
taf.testlib.linux.ipmitool.IpmiTool(run_command)[source]¶ Bases:
object-
SERVICE= 'ipmitool'¶
-
generate_event(sensor, sensor_state)[source]¶ Method for generating event for sensor with sensor state.
Parameters:
-
get_sdr_list()[source]¶ Get all available Sensor Data Repository entries.
Returns: Returns list of sdr Return type: list
-
taf.testlib.linux.kubernetes¶
kubernetes.py
taf.testlib.linux.libvirt¶
libvirt.py
Class to abstract libvirt operations
Notes
Examples of libvirt usage in tests:
env.lhost[1].ui.libvirt.start()
env.lhost[1].ui.libvirt.stop()
env.lhost[1].ui.libvirt.restart()
env.lhost[1].ui.libvirt.virsh_execute_command('list')
env.lhost[1].ui.libvirt.virsh_execute_command('domstats vm_name', exp_rc = frozenset({1})))
-
class
taf.testlib.linux.libvirt.Libvirt(cli_send_command)[source]¶ Bases:
object-
SERVICE= 'libvirtd'¶
-
__call__(cmd, expected_rc)[source]¶ Overloaded call method.
Parameters: - cmd (str) – command to execute
- expected_rc (int | set | list | frozenset) – expected return code
Returns: named tuple
Return type:
-
taf.testlib.linux.lldp.lldp¶
lldp.py
-
class
taf.testlib.linux.lldp.lldp.ChassisIdSubTypes[source]¶ Bases:
enum.IntEnumAn enumeration.
-
CHASSIS_COMPONENT= 1¶
-
INTERFACE_ALIAS= 2¶
-
INTERFACE_NAME= 6¶
-
LOCALLY_ASSIGNED= 7¶
-
MAC_ADDRESS= 4¶
-
NETWORK_ADDRESS= 5¶
-
PORT_COMPONENT= 3¶
-
RESERVED= 0¶
-
-
class
taf.testlib.linux.lldp.lldp.Lldp(run_command)[source]¶ Bases:
object
-
class
taf.testlib.linux.lldp.lldp.ManAddrIfSubTypes[source]¶ Bases:
enum.IntEnumAn enumeration.
-
IFINDEX= 2¶
-
SYS_PORT_NUM= 3¶
-
UNKNOWN= 1¶
-
-
class
taf.testlib.linux.lldp.lldp.ManAddrSubTypes[source]¶ Bases:
enum.IntEnumAn enumeration.
-
AFI= 25¶
-
ALL802= 6¶
-
APPLETALK= 12¶
-
ASNUMBER= 18¶
-
BANYANVINES= 14¶
-
BBN1822= 5¶
-
DECNETIV= 13¶
-
DISTINGUISHEDNAME= 17¶
-
DNS= 16¶
-
E163= 7¶
-
E164= 8¶
-
E164WITHNSAP= 15¶
-
F69= 9¶
-
FIBRECHANNELWWNN= 23¶
-
FIBRECHANNELWWPN= 22¶
-
GWID= 24¶
-
HDLC= 4¶
-
IPV4= 1¶
-
IPV6= 2¶
-
IPX= 11¶
-
NSAP= 3¶
-
OTHER= 0¶
-
RESERVED= 65535¶
-
X121= 10¶
-
XTPNATIVEMODEXTP= 21¶
-
XTPOVERIPV4= 19¶
-
XTPOVERIPV6= 20¶
-
taf.testlib.linux.lldp.lldptool¶
lldptool.py
-
class
taf.testlib.linux.lldp.lldptool.CEESubTLVParser(tlv_handlers=None)[source]¶ Bases:
object-
TLV_DATA_RE= re.compile('^(?:\t| {8})\\s+\\S[^\n]+')¶
-
TLV_RE= re.compile('^(?:\t| {8})\\S[^\n]+TLV')¶
-
-
class
taf.testlib.linux.lldp.lldptool.Parser(tlv_handlers)[source]¶ Bases:
object-
END_TLV_RE= re.compile('^End of LLDPDU TLV')¶
-
NON_TLV_RE= re.compile('^(\\S[^\n]+)(?!TLV)')¶
-
TLV_DATA_RE= re.compile('^\\s+([^\n]+)')¶
-
TLV_RE= re.compile('^(\\S[^\n]+)TLV')¶
-
-
class
taf.testlib.linux.lldp.lldptool.TlvNames[source]¶ Bases:
object-
CEE_DCBX= 'CEE DCBX TLV'¶
-
CHASSIS_ID= 'Chassis ID TLV'¶
-
END_OF_LLDPDU= 'End of LLDPDU TLV'¶
-
EVB_DRAFT_0_2_CONFIGURATION= 'EVB draft 0.2 Configuration TLV'¶
-
IEEE_8021QAZ_ETS_CONFIGURATION= 'IEEE 8021QAZ ETS Configuration TLV'¶
-
IEEE_8021QAZ_PFC= 'IEEE 8021QAZ PFC TLV'¶
-
LINK_AGGREGATION= 'Link Aggregation TLV'¶
-
LLDP_MED_ASSET_ID= 'LLDP-MED Asset ID TLV'¶
-
LLDP_MED_CAPABILITIES= 'LLDP-MED Capabilities TLV'¶
-
LLDP_MED_FIRMWARE_REVISION= 'LLDP-MED Firmware Revision TLV'¶
-
LLDP_MED_HARDWARE_REVISION= 'LLDP-MED Hardware Revision TLV'¶
-
LLDP_MED_MANUFACTURER_NAME= 'LLDP-MED Manufacturer Name TLV'¶
-
LLDP_MED_MODEL_NAME= 'LLDP-MED Model Name TLV'¶
-
LLDP_MED_SERIAL_NUMBER= 'LLDP-MED Serial Number TLV'¶
-
LLDP_MED_SOFTWARE_REVISION= 'LLDP-MED Software Revision TLV'¶
-
MAC_PHY_CONFIGURATION_STATUS= 'MAC/PHY Configuration Status TLV'¶
-
MANAGEMENT_ADDRESS= 'Management Address TLV'¶
-
MAXIMUM_FRAME_SIZE= 'Maximum Frame Size TLV'¶
-
PORT_DESCRIPTION= 'Port Description TLV'¶
-
PORT_ID= 'Port ID TLV'¶
-
SYSTEM_CAPABILITIES= 'System Capabilities TLV'¶
-
SYSTEM_DESCRIPTION= 'System Description TLV'¶
-
SYSTEM_NAME= 'System Name TLV'¶
-
TIME_TO_LIVE= 'Time to Live TLV'¶
-
-
taf.testlib.linux.lldp.lldptool.int_auto_base(n)[source]¶ Convert string to an int, automatically detecting the base.
taf.testlib.linux.lldp.lldptool_unittest¶
lldptool_unittest.py
-
class
taf.testlib.linux.lldp.lldptool_unittest.LLDPToolParse(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
taf.testlib.linux.maa.maa¶
maa.py
Class to abstract match action acceleration operations
-
class
taf.testlib.linux.maa.maa.MatchActionAcceleration(run_command)[source]¶ Bases:
object-
__init__(run_command)[source]¶ Initialize MatchActionAcceleration class.
Parameters: run_command (function) – function that runs the actual commands
-
create_maa_rule(prio_id, handle_id, table_id, match_field_value_mask_list, action, action_value=None)[source]¶ Set a rule into the table.
Parameters: - prio_id (int) – Higher id has a higher priority.
- handle_id (int) – handle for match.
- table_id (int) – the source table id where match to be set.
- match_field_value_mask_list (list[tuple(str, str, str)]) – field with match field, value and mask.
- action (str) – given action for source table
- action_value (int) – action value for a specified action
Raises: - UIException – for TypeError - Not enough arguments for format string
- UIException – In case of Command execution Error reported in MatchAPI
-
create_maa_tcam_subtable(source_id, table_id, table_name, max_table_entries, match_field_type_pairs, actions)[source]¶ Create a sub-table of tcam.
Parameters: - source_id (int) – the source id in the tcam table.
- table_id (int) – a given table id. If switchd is running, table id starts from 5 If matchd is running, table id starts from 4
- table_name (str) – a given table name.
- max_table_entries (int) – maximum number of rules can be set.
- match_field_type_pairs (list[tuple(str, str)]) – list of given match field with match type
- actions (list[str]) – list of actions for configurable matches
Raises: - UIException – System table id not supported
- UIException – for TypeError - Not enough arguments for format string
- UIException – In case of Command execution Error reported in MatchAPI
-
delete_maa_rule(handle_id, table_id)[source]¶ Delete a rule from the table.
Parameters: Raises: UIException – In case of Command execution Error reported in MatchAPI
-
delete_maa_tcam_subtable(source_id, table_id=0, table_name=None)[source]¶ Destroy a sub-table of tcam.
Parameters: Raises: - UIException – System table id not supported
- UIException – In case of Command execution Error reported in MatchAPI
-
taf.testlib.linux.networkd¶
networkd.py
Class to abstract networkd operations
-
class
taf.testlib.linux.networkd.NetworkD(run_command, mgmt_ports)[source]¶ Bases:
object-
CONFIG_PATH= '/etc/systemd/network/'¶
-
SERVICE= 'systemd-networkd'¶
-
__init__(run_command, mgmt_ports)[source]¶ Initialize NetworkD class.
Parameters: - run_command (function) – function that runs the actual commands
- mgmt_ports (iter) – list of mgmt ports to treat specially
-
clear_settings(exclude_ports=None)[source]¶ Clear networkd settings for all ports except those excluded.
Parameters: exclude_ports (iter()) – list of extra ports to exclude from clear settings, is appended to mgmt_ports
-
taf.testlib.linux.openvswitch¶
openvswitch.py
Class to abstract openvswitch operations
Note
Examples of openvswitch usage in tests:
env.lhost[1].ui.openvswitch.start()
env.lhost[1].ui.openvswitch.stop()
env.lhost[1].ui.openvswitch.restart()
env.lhost[1].ui.openvswitch.add_bridge('br0')
env.lhost[1].ui.openvswitch.get_interface_info('br0')
env.lhost[1].ui.openvswitch.del_interface('br0')
env.lhost[1].ui.openvswitch.set_ovsdb_manager(ptcp=6640)
-
class
taf.testlib.linux.openvswitch.OpenvSwitch(cli_send_command, switch_map, name_to_switchid_map)[source]¶ Bases:
object-
SERVICE= 'openvswitch-switch'¶
-
add_bridge(br_name)[source]¶ Add new openvswitch bridge.
Parameters: br_name (str) – name of ovs bridge
-
del_bridge(br_name)[source]¶ Delete openvswitch bridgew.
Parameters: br_name (str) – name of ovs bridge
-
get_existing_bridges_interfaces()[source]¶ Get already existing bridges and interfaces from ovsdb.
Returns: list of existing ovs bridges and interfaces Return type: list
-
get_interface_info(interface_name)[source]¶ Get ovs interface information from ovsdb.
Parameters: interface_name (str) – name of ovs interface Returns: Output of OVS interface information Return type: dict
-
get_interface_statistic(iface_name)[source]¶ Get ovs interface statistic from ovsdb.
Parameters: iface_name (str) – name of ovs interface Returns: Output of OVS interface statistics Return type: dict
-
get_interface_statistic_counter(iface_name, counter_name)[source]¶ Get ovs interface statistic from ovsdb.
Parameters: Returns: Output of OVS interface statistics
Return type:
-
get_status()[source]¶ Method for get openvswitch status.
Returns: ovs status ‘active’ or ‘inactive’ Return type: list
-
get_table_record(table, rec, column)[source]¶ Get column value in record in specific table.
Parameters: Returns: Returns StdOut of get command
Return type:
-
set_bridge_port_interface(inst_type, name, **kwargs)[source]¶ Method set parameters for bridge, port or interface.
Parameters: Raises:
-
set_ovsdb_manager(**kwargs)[source]¶ Set connection type to ovsdb.
Parameters: kwargs (dict) – type of ovsdb connection Raises: CustomException –
-
set_table_record(table, rec, **kwargs)[source]¶ Set column values in record in specific table.
Parameters:
-
start(ovs_dpdk_opts=None)[source]¶ Start openvswitch service
Parameters: ovs_dpdk_opts (dict | None) – option indicating OVS run with or without DPDK Note
If ovs_dpdk_opts is provided, a dictionary with EAL parameters is expected. Else it is assumed that vanilla OVS service start is expected.
-
taf.testlib.linux.service_lib¶
service_lib.py
SystemD service library
-
class
taf.testlib.linux.service_lib.GenericServiceManager(run_func, command_list=None)[source]¶ Bases:
object
-
class
taf.testlib.linux.service_lib.ReturnCodes[source]¶ Bases:
object-
RUNNING= 0¶
-
STOPPED= 3¶
-
SUCCESS= 0¶
-
UNKNOWN= None¶
-
-
class
taf.testlib.linux.service_lib.ServiceCommandGenerator(command_generator, return_codes=<class 'taf.testlib.linux.service_lib.ReturnCodes'>, command_list=None)[source]¶ Bases:
object
-
class
taf.testlib.linux.service_lib.ServiceConfigChangeContext(specific_service_manager)[source]¶ Bases:
objectContext manager suitable for service configuration.
taf.testlib.linux.stresstool¶
stresstool.py
Run stress tool on the remote host and parse output
-
class
taf.testlib.linux.stresstool.Line(loglevel, worker, message)¶ Bases:
tuple-
__getnewargs__()¶ Return self as a plain tuple. Used by copy and pickle.
-
static
__new__(_cls, loglevel, worker, message)¶ Create new instance of Line(loglevel, worker, message)
-
__repr__()¶ Return a nicely formatted representation string
-
_asdict()¶ Return a new OrderedDict which maps field names to their values.
-
classmethod
_make(iterable, new=<built-in method __new__ of type object>, len=<built-in function len>)¶ Make a new Line object from a sequence or iterable
-
_replace(**kwds)¶ Return a new Line object replacing specified fields with new values
-
loglevel¶ Alias for field number 0
-
message¶ Alias for field number 2
-
worker¶ Alias for field number 1
-
-
class
taf.testlib.linux.stresstool.StressParser[source]¶ Bases:
objectClass for parsing stress output.
-
class
taf.testlib.linux.stresstool.StressTool(run_command)[source]¶ Bases:
testlib.linux.tool_general.GenericToolClass for Stress tool functionality.
-
__init__(run_command)[source]¶ Initialize StressTool class.
Parameters: run_command (function) – function that runs the actual commands
-
parse(output)[source]¶ Parse the stress output.
Parameters: output (str) – stress origin output Returns: list of parsed stress results Return type: list
-
taf.testlib.linux.suricata.parser¶
parser.py
Suricata rules parsing support
-
class
taf.testlib.linux.suricata.parser.AST_N_Node(n, parent=<taf.testlib.linux.suricata.parser.TreeNodeBase object>, data=None)[source]¶ Bases:
taf.testlib.linux.suricata.parser.AST_NodeAST Nonterminal nodes.
-
class
taf.testlib.linux.suricata.parser.AST_Node(parent=<taf.testlib.linux.suricata.parser.TreeNodeBase object>, data=None)[source]¶
-
class
taf.testlib.linux.suricata.parser.AST_Node_Pred[source]¶ Bases:
objectAST Node predicates helper.
-
class
taf.testlib.linux.suricata.parser.AST_T_Node(parent=<taf.testlib.linux.suricata.parser.TreeNodeBase object>, data=None)[source]¶ Bases:
taf.testlib.linux.suricata.parser.AST_NodeAST Terminal - leaf nodes.
-
class
taf.testlib.linux.suricata.parser.HostLexer(**options)[source]¶ Bases:
pygments.lexer.RegexLexer-
tokens= {'root': [('\\s+', Token.Text.Whitespace), ('any', Token.Keyword.Any), ('pass', Token.Keyword.Action.Pass), ('reject', Token.Keyword.Action.Reject), ('drop', Token.Keyword.Action.Drop), ('alert', Token.Keyword.Action.Alert), ('ip', Token.Keyword.Proto.Ip), ('tcp', Token.Keyword.Proto.Tcp), ('udp', Token.Keyword.Proto.Udp), ('icmp', Token.Keyword.Proto.Icmp), ('\\[', Token.Operator.LeftBracket), (']', Token.Operator.RightBracket), ('!', Token.Operator.ExclMark), (',', Token.Operator.Comma), ('\\d+\\.\\d+\\.\\d+\\.\\d+/\\d+', Token.IPv4.Addr_w_Mask), ('\\d+\\.\\d+\\.\\d+\\.\\d+', Token.IPv4.Addr), ('\\$[\\w_][\\w_\\d]*', Token.Variable)]}¶
-
-
class
taf.testlib.linux.suricata.parser.HostParser[source]¶ Bases:
taf.testlib.linux.suricata.parser.LL_Parser-
HOST_GRAMMAR= {'N': {'<HOST_EXPR>', '<HOST_GRP>', '<HOST_PARENS_CONTD>'}, 'R': {(('<HOST_EXPR>',), (Token.IPv4,)), (('<HOST_GRP>',), (Token.Operator.LeftBracket, '<HOST_GRP>', '<HOST_PARENS_CONTD>', Token.Operator.RightBracket)), (('<HOST_PARENS_CONTD>',), ()), (('<HOST_EXPR>',), (Token.Variable,)), (('<HOST_GRP>',), (Token.Operator.ExclMark, '<HOST_GRP>')), (('<HOST_GRP>',), ('<HOST_EXPR>',)), (('<HOST_PARENS_CONTD>',), (Token.Operator.Comma, '<HOST_GRP>', '<HOST_PARENS_CONTD>'))}, 'S': '<HOST_GRP>', 'T': {Token.IPv4.Addr, Token.IPv4.Addr_w_Mask, Token.Operator.Comma, Token.Operator.ExclMark, Token.Operator.LeftBracket, Token.Operator.RightBracket, Token.Variable}}¶
-
-
class
taf.testlib.linux.suricata.parser.SR_Header(proto, src_host, src_port, direction, dst_host, dst_port)¶ Bases:
tuple-
__getnewargs__()¶ Return self as a plain tuple. Used by copy and pickle.
-
static
__new__(_cls, proto, src_host, src_port, direction, dst_host, dst_port)¶ Create new instance of SR_Header(proto, src_host, src_port, direction, dst_host, dst_port)
-
__repr__()¶ Return a nicely formatted representation string
-
_asdict()¶ Return a new OrderedDict which maps field names to their values.
-
classmethod
_make(iterable, new=<built-in method __new__ of type object>, len=<built-in function len>)¶ Make a new SR_Header object from a sequence or iterable
-
_replace(**kwds)¶ Return a new SR_Header object replacing specified fields with new values
-
direction¶ Alias for field number 3
-
dst_host¶ Alias for field number 4
-
dst_port¶ Alias for field number 5
-
proto¶ Alias for field number 0
-
src_host¶ Alias for field number 1
-
src_port¶ Alias for field number 2
-
-
class
taf.testlib.linux.suricata.parser.SuricataRule(action, header, options)¶ Bases:
tuple-
__getnewargs__()¶ Return self as a plain tuple. Used by copy and pickle.
-
static
__new__(_cls, action, header, options)¶ Create new instance of SuricataRule(action, header, options)
-
__repr__()¶ Return a nicely formatted representation string
-
_asdict()¶ Return a new OrderedDict which maps field names to their values.
-
classmethod
_make(iterable, new=<built-in method __new__ of type object>, len=<built-in function len>)¶ Make a new SuricataRule object from a sequence or iterable
-
_replace(**kwds)¶ Return a new SuricataRule object replacing specified fields with new values
-
action¶ Alias for field number 0
-
header¶ Alias for field number 1
-
options¶ Alias for field number 2
-
-
class
taf.testlib.linux.suricata.parser.TreeNode(parent=<taf.testlib.linux.suricata.parser.TreeNodeBase object>, data=None)[source]¶ Bases:
taf.testlib.linux.suricata.parser.TreeNodeBase-
TN_NO_PARENT= <taf.testlib.linux.suricata.parser.TreeNodeBase object>¶
-
taf.testlib.linux.suricata.suricata¶
suricata.py
Suricata support and helpers
-
class
taf.testlib.linux.suricata.suricata.Suricata(run_command)[source]¶ Bases:
testlib.linux.tool_general.GenericTool-
__init__(run_command)[source]¶ Initialize Suricata class.
Parameters: run_command (function) – function that runs the actual commands
-
taf.testlib.linux.testpmd¶
testpmd.py
Class for testpmd operations
Note
Examples of testpmd usage in tests:
inst.ui.testpmd.start(end_options='--burst=64', cores='0x3', mem_channels=4, driver_dir='librte_pmd_e1000.so', socket_mem='1024,0', huge_unlink=True)
inst.ui.testpmd.exec_cmd('help')
inst.ui.testpmd.stop()
-
class
taf.testlib.linux.testpmd.TestPmd(host)[source]¶ Bases:
object-
exec_cmd(cmd, timeout=5)[source]¶ Execute command in interactive testpmd shell.
Parameters: timeout (int) – Timeout Raises: CustomException – in case testpmd is not started in interactive mode Returns: Output of command execution Return type: str
-
start(interactive_shell=True, end_options='', timeout=10, **kwargs)[source]¶ Start testpmd tool.
Parameters: Raises: AssertionError – in case unsupported arguments are passed
Returns: None
-
stop(timeout=2)[source]¶ Stop testpmd tool.
Parameters: timeout (int) – Timeout Raises: CustomException – in case testpmd is not started Returns: None
-
taf.testlib.linux.tool_general¶
tool_general.py
General functionality for Linux tool
-
class
taf.testlib.linux.tool_general.GenericTool(run_command, tool)[source]¶ Bases:
objectGeneral Linux tool functionality.
-
__init__(run_command, tool)[source]¶ Initialize GenericTool class.
Parameters: run_command (function) – function that runs the actual commands.
-
_stop(instance_id, timeout=None, expected_rcs=frozenset({0}))[source]¶ Stop the tool instance.
Parameters: Raises:
-
get_results(instance_id)[source]¶ Read the tool results from the file.
Parameters: instance_id (int) – instance_id Returns: tool output Return type: str
-
is_active(instance_id, timeout=None, expected_rcs=frozenset({0}))[source]¶ Get process info for specific tool instance.
Parameters: Raises: Returns: tool process info
Return type:
-
taf.testlib.linux.utils¶
utils.py
taf.testlib.linux.iperf.iperf¶
iperf.py
Run iperf on the remote host and parse output
-
class
taf.testlib.linux.iperf.iperf.IPerfParser(*args, **kwargs)[source]¶ Bases:
utils.iperflexer.sumparser.SumParserClass for parsing Iperf output.
-
class
taf.testlib.linux.iperf.iperf.Iperf(run_command)[source]¶ Bases:
testlib.linux.tool_general.GenericToolClass for Iperf functionality.
-
__init__(run_command)[source]¶ Initialize Iperf class.
Parameters: run_command (function) – function that runs the actual commands
-
parse(output, parser=None, threads=1, units='m')[source]¶ Parse the Iperf output.
Parameters: - output (str) – Iperf origin output
- parser (IPerfParser) – parser object
- threads (int) – num iperf threads
- units (str) – iperf units
Returns: list of parsed iperf results
Return type:
-
-
class
taf.testlib.linux.iperf.iperf.Line(interval, transfer, t_units, bandwidth, b_units)¶ Bases:
tuple-
__getnewargs__()¶ Return self as a plain tuple. Used by copy and pickle.
-
static
__new__(_cls, interval, transfer, t_units, bandwidth, b_units)¶ Create new instance of Line(interval, transfer, t_units, bandwidth, b_units)
-
__repr__()¶ Return a nicely formatted representation string
-
_asdict()¶ Return a new OrderedDict which maps field names to their values.
-
classmethod
_make(iterable, new=<built-in method __new__ of type object>, len=<built-in function len>)¶ Make a new Line object from a sequence or iterable
-
_replace(**kwds)¶ Return a new Line object replacing specified fields with new values
-
b_units¶ Alias for field number 4
-
bandwidth¶ Alias for field number 3
-
interval¶ Alias for field number 0
-
t_units¶ Alias for field number 2
-
transfer¶ Alias for field number 1
-
taf.testlib.linux.iperf.iperf_cmd¶
iperf_cmd.py
iperf command parsing and building support
-
class
taf.testlib.linux.iperf.iperf_cmd.CmdIperf(*args, **kwargs)[source]¶ Bases:
testlib.linux.commands.cmd_helper.Command-
CMD_HELPER= <taf.testlib.linux.iperf.iperf_cmd.CmdIperfHelper object>¶
-
-
class
taf.testlib.linux.iperf.iperf_cmd.CmdIperfHelper(prog=None, arg_parser=None, conflict_handler=None, params=None, arg_builder=None, default_list=None)[source]¶ Bases:
testlib.linux.commands.cmd_helper.CommandHelper
-
class
taf.testlib.linux.iperf.iperf_cmd.IperfArgumentBuilder[source]¶ Bases:
testlib.linux.commands.cmd_helper.ArgumentBuilder-
ARGS_ORDERED= ['server', 'client', 'daemon', 'single_udp', 'bandwidth', 'dualtest', 'fileinput', 'linux-congestion', 'listenport', 'num', 'parallel', 'stdin', 'time', 'tradeoff', 'ttl', 'IPv6Version', 'bind', 'compatibility', 'format', 'help', 'interval', 'len', 'mss', 'nodelay', 'output', 'port', 'print_mss', 'reportexclude', 'reportstyle', 'udp', 'version', 'window']¶
-
-
taf.testlib.linux.iperf.iperf_cmd.chain_it()¶ chain.from_iterable(iterable) –> chain object
Alternate chain() constructor taking a single iterable argument that evaluates lazily.