summaryrefslogtreecommitdiffstats
path: root/api/stl
diff options
context:
space:
mode:
Diffstat (limited to 'api/stl')
-rw-r--r--api/stl/examples/stl_simple_burst.py47
1 files changed, 30 insertions, 17 deletions
diff --git a/api/stl/examples/stl_simple_burst.py b/api/stl/examples/stl_simple_burst.py
index 7efb574a..b60df4bf 100644
--- a/api/stl/examples/stl_simple_burst.py
+++ b/api/stl/examples/stl_simple_burst.py
@@ -12,36 +12,49 @@ def simple_burst ():
passed = True
+ c = STLClient()
+
try:
- with STLClient() as c:
+ # activate this for some logging information
+ #c.logger.set_verbose(c.logger.VERBOSE_REGULAR)
+
+ # connect to server
+ c.connect()
+
+ # prepare port 0,1
+ c.reset(ports = [0, 1])
- # activate this for some logging information
- #c.logger.set_verbose(c.logger.VERBOSE_REGULAR)
+ # load profile to both ports
+ c.load_profile('../profiles/burst.yaml', ports = [0, 1])
- # repeat for 5 times
- for i in xrange(1, 6):
+ # repeat for 5 times
+ for i in xrange(1, 6):
- # read the stats before
- before_ipackets = c.get_stats()['total']['ipackets']
+ c.clear_stats()
- # inject burst profile on two ports and block until done
- c.start(profiles = '../profiles/burst.yaml', ports = [0, 1], mult = "1gbps")
- c.wait_on_traffic(ports = [0, 1])
+ # start traffic and block until done
+ c.start(ports = [0, 1], mult = "1gbps", duration = 5)
+ c.wait_on_traffic(ports = [0, 1])
- after_ipackets = c.get_stats()['total']['ipackets']
+ # read the stats
+ stats = c.get_stats()
+ ipackets = stats['total']['ipackets']
- print "Test iteration {0} - Packets Received: {1} ".format(i, (after_ipackets - before_ipackets))
+ print "Test iteration {0} - Packets Received: {1} ".format(i, ipackets)
- # we have 600 packets in the burst and two ports
- if (after_ipackets - before_ipackets) != (600 * 2):
- passed = False
+ # we have 600 packets in the burst and two ports
+ if (ipackets != (600 * 2)):
+ passed = False
- # error handling
+
+ # error handling
except STLError as e:
passed = False
print e
-
+ # cleanup
+ finally:
+ c.disconnect()
if passed:
print "\nTest has passed :-)\n"