testcenter package

Submodules

testcenter.stc_app module

This module implements classes and utility functions to manage STC application.

author:yoram@ignissoft.com
class testcenter.stc_app.StcApp(logger, api_wrapper)

Bases: trafficgenerator.tgn_app.TgnApp

TestCenter driver. Equivalent to TestCenter Application.

clear_results()
connect(lab_server=None)

Create object and (optionally) connect to lab server.

Parameters:lab_server – optional lab server address.
disconnect(terminate=True)

Disconnect from lab server (if used) and reset configuration.

Parameters:terminate – True - terminate session, False - leave session on server.
get_arp_cache()
load_config(config_file_name)

Load configuration file from tcc or xml.

Configuration file type is extracted from the file suffix - xml or tcc.

Parameters:config_file_name – full path to the configuration file.
reset_config()
save_config(config_file_name, server_folder='c:\\temp')

Save configuration file as tcc or xml.

Configuration file type is extracted from the file suffix - xml or tcc. :param config_file_name: full path to the configuration file. :param server_temp_folder: folder on the server where the system will save the files before download.

send_arp_ns()
sequencer_command(command)

Perform sequencer command.

Parameters:command (testcenter.stc_app.StcSequencerOperation) – sequencer command.
start_devices()

Start all devices.

It is the test responsibility to wait for devices to reach required state.

start_traffic(blocking=False)
stop_devices()
stop_traffic()
wait_traffic()
class testcenter.stc_app.StcSequencerOperation

Bases: enum.Enum

pause = 'SequencerPause'
start = 'SequencerStart'
step = 'SequencerStep'
stop = 'SequencerStop'
wait = 'waituntilcomplete'
testcenter.stc_app.init_stc(api, logger, install_dir=None, rest_server=None, rest_port=80)

Helper function to create STC object.

This helper supports only new sessions. In order to connect to existing session on Lab server create StcRestWrapper and StcApp directly.

Parameters:
  • api (trafficgenerator.tgn_utils.ApiType) – tcl/python/rest
  • logger – python logger object
  • install_dir – STC installation directory
  • rest_server – rest server address (either stcweb or lab server)
  • rest_port – rest server port (either stcweb or lab server)
Returns:

STC object

testcenter.stc_device module

This module implements classes and utility functions to manage STC emulated device.

class testcenter.stc_device.StcBfdRouter(**data)

Bases: testcenter.stc_device.StcRouter

class testcenter.stc_device.StcBfdSession(**data)

Bases: testcenter.stc_device.StcObjWithNetworkBlock

class testcenter.stc_device.StcBgpRoute(**data)

Bases: testcenter.stc_device.StcObjWithNetworkBlock

class testcenter.stc_device.StcBgpRouter(**data)

Bases: testcenter.stc_device.StcRouter

class testcenter.stc_device.StcClient(**data)

Bases: testcenter.stc_device.StcEmulation

objects_list = 'BlockList'
class testcenter.stc_device.StcDevice(**data)

Bases: testcenter.stc_object.StcObject

Represents STC emulated device.

command(command, wait_after=2, **arguments)
command_emulations(command, wait_after=4, **arguments)
get_arp_cache()
get_ordered_valns()
has_ip(ip_type)
ping(ip)
send_arp_ns()

Send ARP and NS for ports, devices or stream blocks.

start(wait_after=4)
stop(wait_after=4)
class testcenter.stc_device.StcEmulation(**data)

Bases: testcenter.stc_object.StcObject

Base class for all STC emulations.

command(command, wait_after=4, **arguments)

Perform

class testcenter.stc_device.StcIgmpGroup(**data)

Bases: testcenter.stc_device.StcObjWithNetworkBlock

get_network_block()
class testcenter.stc_device.StcIgmpHost(**data)

Bases: testcenter.stc_device.StcClient

class testcenter.stc_device.StcIgmpQuerier(**data)

Bases: testcenter.stc_device.StcClient

class testcenter.stc_device.StcIsisRouter(**data)

Bases: testcenter.stc_device.StcRouter

class testcenter.stc_device.StcIsisRouterRange(**data)

Bases: testcenter.stc_device.StcObjWithNetworkBlock

class testcenter.stc_device.StcObjWithNetworkBlock(**data)

Bases: testcenter.stc_object.StcObject

get_network_block()
class testcenter.stc_device.StcOseSwitch(**data)

Bases: testcenter.stc_device.StcEmulation

objects_list = 'HandleList'
class testcenter.stc_device.StcOspfLsa(**data)

Bases: testcenter.stc_device.StcObjWithNetworkBlock

class testcenter.stc_device.StcOspfv2Router(**data)

Bases: testcenter.stc_device.StcRouter

class testcenter.stc_device.StcPimRouter(**data)

Bases: testcenter.stc_device.StcRouter

class testcenter.stc_device.StcPimv4Group(**data)

Bases: testcenter.stc_device.StcObjWithNetworkBlock

get_network_block()
class testcenter.stc_device.StcRouter(**data)

Bases: testcenter.stc_device.StcEmulation

objects_list = 'RouterList'
class testcenter.stc_device.StcRsvpRouter(**data)

Bases: testcenter.stc_device.StcRouter

class testcenter.stc_device.StcRsvpTunnel(**data)

Bases: testcenter.stc_device.StcObjWithNetworkBlock

get_network_block()
class testcenter.stc_device.StcServer(**data)

Bases: testcenter.stc_device.StcEmulation

objects_list = 'ServerList'

testcenter.stc_hw module

This module implements classes and utility functions to manage STC chassis.

author:yoram@ignissoft.com
class testcenter.stc_hw.StcHw(**data)

Bases: testcenter.stc_object.StcObject

Represent STC port.

get_chassis(hostname)
class testcenter.stc_hw.StcPhyBase(**data)

Bases: testcenter.stc_object.StcObject

get_inventory()
class testcenter.stc_hw.StcPhyChassis(**data)

Bases: testcenter.stc_hw.StcPhyBase

attributes_names = ('Model', 'SerialNum', 'FirmwareVersion')
children_types = {'modules': ('PhysicalTestModule', 'Slot ')}
get_inventory()
get_module_by_index(index)
get_thin_inventory()
pss = {}
class testcenter.stc_hw.StcPhyModule(**data)

Bases: testcenter.stc_hw.StcPhyBase

attributes_names = ('Index', 'Model', 'Description', 'SerialNum', 'FirmwareVersion')
children_types = {'pgs': ('PhysicalPortGroup', 'Port Group ')}
get_inventory()
ps = None
class testcenter.stc_hw.StcPhyPort(**data)

Bases: testcenter.stc_hw.StcPhyBase

attributes_names = ('Index',)
children_types = {}
class testcenter.stc_hw.StcPhyPortGroup(**data)

Bases: testcenter.stc_hw.StcPhyBase

attributes_names = ('Index', 'TestPackage')
children_types = {'ports': ('PhysicalPort', 'Port ')}
class testcenter.stc_hw.StcPhyPowerSupply(index, status)

Bases: object

testcenter.stc_object module

Base classes and utilities to manage Spirent Test Center (STC).

author:yoram@ignissoft.com
class testcenter.stc_object.StcObject(**data)

Bases: trafficgenerator.tgn_object.TgnObject

append_attribute(attribute, value, apply_=False)
command(command, wait_after=0, **arguments)
delete()
get_active()
get_all_child_types()
classmethod get_arp_cache(*objects)
get_attribute(attribute)

Get single attribute value.

Parameters:attribute – attribute name.
Returns:attribute value.
get_attributes(*attributes)

Get multiple attributes values.

Some low level APIs (like Tcl over Telnet) supports limited output length. When using get_attributes() the method will use simple stc::get to read all attributes. This is efficient but the output might exceed the output limit and will be truncated. When using attributes(*attributes) the method will use stc::get -attribute to read the attributes one by one. This is less efficient but less likely to exceed the output length.

Parameters:attributes – list of attributes to retrieve. If empty (default) return all attribute values.
Returns:dictionary {attribute: value} of all requested attributes.
get_children(*types)

Get all children of the requested types.

Parameters:attribute – requested children types.
Returns:list of all children of the requested types.
get_list_attribute(attribute)
Returns:attribute value as Python list.
get_name()
get_obj_class(obj_type)
Parameters:obj_type – STC object type.
Returns:object class if specific class else StcObject.
get_objects_from_attribute(attribute)
classmethod send_arp_ns(*objects)

Send ARP and NS for ports, devices or stream blocks.

set_active(active)
set_attributes(apply_=False, **attributes)
set_attributes_serializer(_apply, attributes)

Set attributes from serialized key value dictionary.

set_sources(apply_=False, **attributes)
set_targets(apply_=False, **attributes)
str_2_class = {}
test_command_rc(attribute)
wait()

Wait until sequencer is finished.

testcenter.stc_object.extract_stc_obj_type_from_obj_ref(obj_ref)

testcenter.stc_port module

This module implements classes and utility functions to manage STC port.

author:yoram@ignissoft.com
class testcenter.stc_port.StcAnalyzer(**data)

Bases: testcenter.stc_object.StcObject

Represent STC port analyzer.

class testcenter.stc_port.StcGenerator(**data)

Bases: testcenter.stc_object.StcObject

Represent STC port generator.

get_attributes()

Get generator attribute from generatorConfig object.

set_attributes(apply_=False, **attributes)

Set generator attributes to generatorConfig object.

class testcenter.stc_port.StcLag(**data)

Bases: testcenter.stc_object.StcObject

Represents STC LAG.

add_ports(*ports)
class testcenter.stc_port.StcPort(**data)

Bases: testcenter.stc_object.StcObject

Represent STC port.

clear_results()

Clear all port results.

get_arp_cache()

Send ARP/ND for the port.

get_children(*types)

Get all port children including emulateddevices.

Note: get_children() is not supported.

get_devices()
Returns:dictionary {name: object} of all emulated devices.
get_name()
Returns:port name without the ‘offilne’ tag added by STC.
get_stream_blocks()
Returns:dictionary {name: object} of all streams.
is_online()
Returns:Port link status. True - port is up. False - port is offline.
is_running()
Returns:Returns running state of the port. True – port is running. False – port is not running.
release()

Release the physical port reserved for the port.

reserve(location=None, force=False, wait_for_up=True, timeout=40)

Reserve physical port.

Parameters:
  • location – port location in the form ip/slot/port.
  • force – whether to revoke existing reservation (True) or not (False).
  • wait_for_up – True - wait for port to come up, False - return immediately.
  • timeout – how long (seconds) to wait for port to come up.
Todo:

seems like reserve takes forever even if port is already owned by the user. should test for ownership and take it forcefully only if really needed?

send_arp_ns()

Send ARP/ND for the port.

set_media_type(media_type)

Set media type for dual phy 1G ports.

Parameters:media_type – requested media type - EthernetCopper or EthernetFiber.
start(blocking=False)

Start port traffic.

Parameters:blocking – True - wait for traffic end. False - return immidately.
stop()

Stop port traffic.

wait()

Wait for traffic end.

wait_for_states(timeout=40, *states)

Wait until port reaches requested state(s).

Parameters:
  • timeout – how long (seconds) to wait for port to come up.
  • states – list of requested states.

testcenter.stc_project module

This module implements classes and utility functions to manage STC project.

Any command that can act on list of objects (ports, devices, emulations etc.) should be implemented by StcProject.

class testcenter.stc_project.StcIpGroup(**data)

Bases: testcenter.stc_object.StcObject

Base class for STC IP groups.

class testcenter.stc_project.StcIpv4Group(**data)

Bases: testcenter.stc_project.StcIpGroup

Represents STC IPv4 group.

class testcenter.stc_project.StcIpv6Group(**data)

Bases: testcenter.stc_project.StcIpGroup

Represents STC IPv6 group.

class testcenter.stc_project.StcProject(**data)

Bases: testcenter.stc_object.StcObject

Represents STC project object.

clear_results(*ports)

Clear emulations and traffic results on ports.

Parameters:ports – list of ports to clear results on, if empty clear results for all ports.
command_device_emulations(command, wait_after=4, *devices, **arguments)

Perform emulation command on list of devices.

Use this method for all emulation specific commands. For emulation start/stop use start_emulation and stop_emulation accordingly.

Parameters:
  • command – requested command.
  • wait_after – time to wait after command execution in seconds.
  • devices – list of devices to act on. If list is empty - perform on all devices.
  • arguments – additional optional arguments per requested command.
command_devices(command, wait_after=4, *devices, **arguments)

Perform device command on list of devices.

Parameters:
  • command – requested command.
  • wait_after – time to wait after command execution in seconds.
  • devices – list of devices to act on. If list is empty - perform on all devices.
  • arguments – additional optional arguments per requested command.
command_emulations(command, wait_after=4, *emulations, **arguments)

Perform emulation command on list of emulations.

Use this method for all emulation specific commands. For emulation start/stop use start_emulation and stop_emulation accordingly.

Parameters:
  • command – requested command.
  • wait_after – time to wait after command execution in seconds.
  • emulations – list of emulations to act on.
  • arguments – additional optional arguments per requested command.
get_devices(*ports)
Parameters:ports – list of ports to get devices for, if empty get for all ports.
Returns:list of requested devices.
get_emulations(emulation, *ports)
Parameters:
  • emulation – requested emulation class.
  • ports – list of ports to get emulations for, if empty get for all ports.
Returns:

list of requested emulations.

get_ports()
Returns:dictionary {name: object} of all port.
get_stream_blocks()
Returns:all stream blocks in the configuration.
start_emulations(emulations, wait_after=4)

Start emulations.

Parameters:
  • emulations – list of emulations to act on.
  • wait_after – time to wait after command execution in seconds.
start_ports(blocking=False, *ports)

Start traffic on ports.

Parameters:
  • blocking – True - wait for traffic end, False - return after traffic start.
  • ports – list of ports to start traffic on, if empty start on all ports.
stop_emulations(emulations, wait_after=4)

Start emulations.

Parameters:
  • emulations – list of emulations to act on.
  • wait_after – time to wait after command execution in seconds.
stop_ports(*ports)

Stop traffic on ports.

Parameters:ports – list of ports to stop traffic on, if empty start on all ports.
wait_for_ports = 4
wait_traffic(*ports)

Wait for traffic end on ports.

Parameters:ports – list of ports to wait for, if empty wait for all ports.

testcenter.stc_statistics_view module

Classes and utilities to manage STC statistics views.

class testcenter.stc_statistics_view.StcStats(project, view)

Bases: object

Represents statistics view.

The statistics dictionary represents a table: Statistics Name | Object 1 Value | Object 2 Value | … object | | | parents | | | topLevelName | | | Stat 1 | | | …

For example, generatorportresults statistics for two ports might look like the following: Statistics Name | Object 1 Value | Object 2 Value object | analyzerportresults1 | analyzerportresults2 parents | project1/port1/analyzer1 | project1/port2/analyzer2 topLevelName | Port 1 | Port 2 GeneratorFrameCount | 1000 | 2000 …

get_all_stats(obj_id_stat='topLevelName')
Parameters:obj_id_stat – which statistics name to use as object ID, sometimes topLevelName is not meaningful and it is better to use other unique identifier like stream ID.
Returns:all statistics values for all object IDs.
get_counter(obj_id, counter, obj_id_stat='topLevelName')
Parameters:
  • obj_id – requested object ID.
  • counter – requested statistics (note that some statistics are not counters).
  • obj_id_stat – which statistics name to use as object ID, sometimes topLevelName is not meaningful and it is better to use other unique identifier like stream ID.
Returns:

the int value of the requested counter for the requested object ID.

get_object_stats(obj_id, obj_id_stat='topLevelName')
Parameters:
  • obj_id – requested object ID.
  • obj_id_stat – which statistics name to use as object ID, sometimes topLevelName is not meaningful and it is better to use other unique identifier like stream ID.
Returns:

all statistics values for the requested object ID.

get_stat(obj_id, counter, obj_id_stat='topLevelName')
Parameters:
  • obj_id – requested object id.
  • counter – requested statistics (note that some statistics are not counters).
  • obj_id_stat – which statistics name to use as object ID, sometimes topLevelName is not meaningful and it is better to use other unique identifier like stream ID.
Returns:

the value of the requested counter for the requested object ID.

get_stats(row='topLevelName')
Parameters:row – requested row (== statistic name)
Returns:all statistics values for the requested row.
read_stats(*stats)

Reads the statistics view from STC and saves it in statistics dictionary.

Parameters:stats – list of statistics names to read, empty list will read all statistics. Relevant for system (not dynamic) result views only.
Todo:add support for user statistics.
subscribe(view, config_type=None)

Subscribe to statistics view.

Parama view:statistics view to subscribe to.
Parama config_type:
 configuration type to subscribe to.
unsubscribe()

UnSubscribe from statistics view.

testcenter.stc_stream module

This module implements classes and utility functions to manage STC streamblocks.

class testcenter.stc_stream.StcGroupCollection(**data)

Bases: testcenter.stc_object.StcObject

Represent STC group collection.

get_name()
class testcenter.stc_stream.StcStream(**data)

Bases: testcenter.stc_object.StcObject

Represent STC stream block.

get_arp_cache()
send_arp_ns()

Send ARP and NS for ports, devices or stream blocks.

class testcenter.stc_stream.StcTrafficGroup(**data)

Bases: testcenter.stc_object.StcObject

Represent STC traffic group.

get_name()
get_stream_blocks()
set_attributes(apply_=False, **attributes)

Module contents

@author yoram@ignissoft.com