Ostinato user Stephen asked -
If I setup on the Ostinato manager GUI the streams and emulated devices, but I would like to start, stop, and log a test with the Python API is that possible?
So, basically I would use the manager GUI to define my test parameters (streams, emulated devices, etc.), but use the Python API to help automate the test and logging.
Yes, that is an easy way to get started with the Python API without having to figure out the full stream and protocol configuration API details.
Here are some more details on this approach.
Save the Ostinato GUI configuration as a session file.
Write a simple Python script using the following Ostinato Python APIs -
startTransmit()
stopTransmit()
getStats()
getStreamStatsDict()
Here’s an example - using the above mentioned Ostinato Python APIs to start/stop transmit and log the stats.
from ostinato.core import DroneProxy, ost_pb
import time
# Get ...
drone = DroneProxy('localhost')
# ... set ...
tx_port = ost_pb.PortIdList()
tx_port.port_id.add().id = 1;
rx_port = ost_pb.PortIdList()
rx_port.port_id.add().id = 2;
all_ports = ost_pb.PortIdList()
all_ports.port_id.extend(tx_port.port_id)
all_ports.port_id.extend(rx_port.port_id)
guids = ost_pb.StreamGuidList()
guids.port_id_list.extend(all_ports)
tx_config = ost_pb.TransmitConfig()
tx_config.port_id_list.extend(tx_port.port_id)
# ... GO!
drone.clearStats(all_ports)
drone.startTransmit(tx_config)
time.sleep(30)
drone.stopTransmit(tx_port)
stats = drone.getStats(all_ports)
stream_stats = drone.getStreamStatsDict(guids)
print(stats)
print(stream_stats)
This script assumes that the Drone has already been configured using the Ostinato GUI.
If you are using v2.0 or higher, instead of sleep, you can set tx_config.tx_duration and waitForTransmitFinish -
tx_config = ost_pb.TransmitConfig()
tx_config.port_id_list.extend(tx_port.port_id)
tx_config.tx_duration = 30 # seconds
...
drone.startTransmit(tx_config)
waitForTransmitFinish(tx_port)
Note that the Ostinato session file CANNOT be loaded via the Python API. It can only be loaded in the GUI.
Also, the session file is not portable across setups if the drone hostname/IP is different and/or the port names are different.
This is a quick and easy way to get started with the Ostinato Python API.
Full scripting - easy start
If you want full automation, without having to use the GUI to configure the Drone, but also want to avoid writing a python script from scratch, here’s a modified approach.
Use the GUI to configure everything. Then go to Ports > Save Port Configuration and select the output format as Python script. You can then modify the script to add your own logic to automate the test.
You will need to save a python script for each Tx/Rx test port and then modify/combine them to build an automated test suite.
