[dts] [PATCH V1 3/3] vm_pw_mgmt_policy: framework etgen/ixia
yufengx.mo at intel.com
yufengx.mo at intel.com
Wed Jun 6 07:35:34 CEST 2018
From: yufengmx <yufengx.mo at intel.com>
extend ixia class to support continuous sending stream, app will stop it after
app complete sample statistics data.
Signed-off-by: yufengmx <yufengx.mo at intel.com>
---
conf/vm_pw_mgmt_policy.cfg | 39 ++++++++++
framework/etgen.py | 184 +++++++++++++++++++++++++++++++++++++++++++--
framework/tester.py | 54 ++++++++++++-
3 files changed, 271 insertions(+), 6 deletions(-)
create mode 100644 conf/vm_pw_mgmt_policy.cfg
mode change 100755 => 100644 framework/tester.py
diff --git a/conf/vm_pw_mgmt_policy.cfg b/conf/vm_pw_mgmt_policy.cfg
new file mode 100644
index 0000000..86ed1fb
--- /dev/null
+++ b/conf/vm_pw_mgmt_policy.cfg
@@ -0,0 +1,39 @@
+# libvirtd options:
+# [VM name] section value is the name for VM
+# cpu # hard code type to host-passthrough
+# number: number of vcpus
+# cpupin: host cpu list
+# mem
+# size: 4096
+# disk
+# file: absolute path to disk image
+# type: disk image format
+# login
+# user: user name to login into VM
+# password: passwork to login into VM
+# device
+# pf_idx: pass-through device index of DUT ports
+# guestpci: hardcode value of guest pci address
+# virtio_serial_channel
+# path: virtio unix socket absolute path
+# name: virtio serial name in VM
+
+# vm configuration for vm power management case
+[vm0]
+cpu =
+ number=4,cpupin=4 5 6 7;
+mem =
+ size=8196;
+disk =
+ file=/home/image/sriov-fc20-pw-1.img,type=raw;
+login =
+ user=root,password=tester;
+[vm1]
+cpu =
+ number=2,cpupin=7 8;
+mem =
+ size=2048;
+disk =
+ file=/home/image/sriov-fc20-pw-2.img,type=raw;
+login =
+ user=root,password=tester;
diff --git a/framework/etgen.py b/framework/etgen.py
index 2856a28..296d416 100644
--- a/framework/etgen.py
+++ b/framework/etgen.py
@@ -1,6 +1,6 @@
# BSD LICENSE
#
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2018 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -168,6 +168,8 @@ class IxiaPacketGenerator(SSHConnection):
"""
def __init__(self, tester):
+ self.bpsRate, self.oversize, self.rate = 0, 0, 0
+ self.rxPortlist, self.txPortlist = None, None
self.tester = tester
self.NAME = 'ixia'
self.logger = getLogger(self.NAME)
@@ -227,6 +229,12 @@ class IxiaPacketGenerator(SSHConnection):
Add one tcl command into command list.
"""
self.tcl_cmds.append(cmd)
+
+ def add_tcl_cmds(self, cmds):
+ """
+ Add multiple tcl commands into command list.
+ """
+ self.tcl_cmds += cmds
def clean(self):
"""
@@ -393,7 +401,62 @@ class IxiaPacketGenerator(SSHConnection):
self.add_tcl_cmd("stream set %d %d %d %d" %
(self.chasId, txport['card'], txport['port'], stream_id))
- def config_ixia_stream(self, rate_percent, flows, latency):
+ def config_burst_stream(self, fpcap, txport, rate_percent, stream_id=1,
+ latency=False, **kwargs):
+ """
+ Configure IXIA stream and enable mutliple flows.
+ """
+ flows = self.parse_pcap(fpcap)
+
+ self.add_tcl_cmd("ixGlobalSetDefault")
+
+ dma = kwargs.get('flow_type', 'stopStream')
+ frameType = kwargs.get('frameType', None)
+ gapUnit = frameType.get('type', 'gapMilliSeconds')
+ isg = frameType.get('isg', 100)
+ ifg = frameType.get('ifg', 100)
+ ibg = frameType.get('ibg', 100)
+ pkt = kwargs.get('count', 100)
+ frame_cmds = [
+ "stream config -numBursts {0}".format(pkt),
+ "stream config -gapUnit {0}".format(gapUnit),
+ "stream config -rateMode useGap",
+ "stream config -ifg {0}".format(ifg),
+ "stream config -ifgType gapFixed",
+ "stream config -enableIbg true",
+ "stream config -ibg {0}".format(ibg),
+ "stream config -enableIsg true",
+ "stream config -isg {0}".format(isg),]
+
+ self.config_ixia_stream(rate_percent, flows, latency)
+
+ pat = re.compile(r"(\w+)\((.*)\)")
+ for flow in flows:
+ for header in flow.split('/'):
+ match = pat.match(header)
+ params = eval('dict(%s)' % match.group(2))
+ method_name = match.group(1)
+ if method_name == 'Vxlan':
+ method = getattr(self, method_name.lower())
+ method(txport, **params)
+ break
+ if method_name in SCAPY2IXIA:
+ method = getattr(self, method_name.lower())
+ method(txport, **params)
+ cmds =["stream config -name {0}".format(stream_id),
+ "stream set %d %d %d %d" % (self.chasId, txport['card'],
+ txport['port'], stream_id)]
+ self.add_tcl_cmds(frame_cmds + cmds)
+ stream_id += 1
+
+ stream_id -= 1
+ cmds = ["stream config -dma {0}".format(dma),
+ "stream set %d %d %d %d" %
+ (self.chasId, txport['card'], txport['port'], stream_id),
+ ]
+ self.add_tcl_cmds(cmds)
+
+ def config_ixia_stream(self, rate_percent, flows, latency, dma=None):
"""
Configure IXIA stream with rate and latency.
Override this method if you want to add custom stream configuration.
@@ -402,7 +465,7 @@ class IxiaPacketGenerator(SSHConnection):
self.add_tcl_cmd("stream config -percentPacketRate %s" % rate_percent)
self.add_tcl_cmd("stream config -numFrames 1")
if len(flows) == 1:
- self.add_tcl_cmd("stream config -dma contPacket")
+ self.add_tcl_cmd("stream config -dma {0}".format(dma or 'contPacket'))
else:
self.add_tcl_cmd("stream config -dma advance")
# request by packet Group
@@ -527,6 +590,43 @@ class IxiaPacketGenerator(SSHConnection):
return {'card': int(m.group(1)), 'port': int(m.group(2))}
+ def get_port_stats(self, rxPortlist, txPortlist, delay=5):
+ """
+ Get RX/TX packet statistics and calculate loss rate.
+ """
+ time.sleep(delay)
+
+ #self.send_expect("ixStopTransmit portList", "%", 10)
+ time.sleep(2)
+ sendNumber = 0
+ for port in txPortlist:
+ self.stat_get_stat_all_stats(port)
+ sendNumber += self.get_frames_sent()
+ time.sleep(0.5)
+
+ self.logger.info("send :%f" % sendNumber)
+
+ assert sendNumber != 0
+
+ revNumber = 0
+ for port in rxPortlist:
+ self.stat_get_stat_all_stats(port)
+ revNumber += self.get_frames_received()
+ self.logger.info("rev :%f" % revNumber)
+
+ return sendNumber, revNumber
+
+ def port_stats(self, portList, ratePercent, delay=5):
+ rxPortlist, txPortlist = self.rxPortlist, self.txPortlist
+ return self.get_port_stats(rxPortlist, txPortlist, delay)
+
+ def port_line_rate(self):
+ chasId = '1'
+ port_line_rate = []
+ for port in self.ports:
+ port_line_rate.append(self.get_line_rate(chasId, port))
+ return port_line_rate
+
def loss(self, portList, ratePercent, delay=5):
"""
Run loss performance test and return loss rate.
@@ -589,6 +689,41 @@ class IxiaPacketGenerator(SSHConnection):
"""
rxPortlist, txPortlist = self._configure_everything(port_list, rate_percent)
return self.get_transmission_results(rxPortlist, txPortlist, delay)
+
+ def loop_throughput(self, port_list, rate_percent=100, delay=5):
+ """
+ Run throughput performance test and return throughput statistics.
+ """
+ rxPortlist, txPortlist = self._configure_everything(port_list, rate_percent)
+ self.rxPortlist, self.txPortlist = rxPortlist, txPortlist
+
+ def stop_loop_throughput(self, port_list, rate_percent=100, delay=5):
+ """
+ Run throughput performance test and return throughput statistics.
+ """
+
+ return self.stop_loop_transmission(self.rxPortlist, self.txPortlist, delay)
+ return True
+
+ def burst_throughput(self, port_list, rate_percent=100, delay=5, **kwargs):
+ """
+ Run burst performance test and return throughput statistics.
+ """
+ rxPortlist, txPortlist = self._configure_burst(port_list, rate_percent, **kwargs)
+ self.rxPortlist, self.txPortlist = rxPortlist, txPortlist
+ return True
+
+ def _configure_burst(self, port_list, rate_percent, latency=False, **kwargs):
+ """
+ Prepare and configure IXIA ports for performance test.
+ """
+ rxPortlist, txPortlist = self.prepare_port_list(port_list, rate_percent,
+ latency , **kwargs)
+ self.prepare_ixia_for_transmission(txPortlist, rxPortlist)
+ self.configure_transmission()
+ self.start_transmission()
+ self.clear_tcl_commands()
+ return rxPortlist, txPortlist
"""
This function could be used to check the packets' order whether same as the receive sequence.
@@ -644,12 +779,14 @@ class IxiaPacketGenerator(SSHConnection):
"""
self.add_tcl_cmd("ixStartTransmit portList")
- def prepare_port_list(self, portList, rate_percent=100, latency=False):
+ def prepare_port_list(self, portList, rate_percent=100, latency=False,
+ **kwargs):
"""
Configure stream and flow on every IXIA ports.
"""
txPortlist = set()
rxPortlist = set()
+ stream_type= kwargs.get('stream_type') or 'normal'
for (txPort, rxPort, pcapFile) in portList:
txPortlist.add(txPort)
@@ -661,7 +798,15 @@ class IxiaPacketGenerator(SSHConnection):
# stream/flow setting
for (txPort, rxPort, pcapFile) in portList:
- self.config_stream(pcapFile, self.pci_to_port(self.tester.get_pci(txPort)), rate_percent, 1, latency)
+ if stream_type != 'normal':
+ config_stream = getattr(self, 'config_{0}_stream'.format(stream_type))
+ config_stream(pcapFile,
+ self.pci_to_port(self.tester.get_pci(txPort)),
+ rate_percent, 1, latency, **kwargs)
+ else:
+ self.config_stream(pcapFile,
+ self.pci_to_port(self.tester.get_pci(txPort)),
+ rate_percent, 1, latency)
# config stream before packetGroup
if latency is not False:
@@ -686,6 +831,35 @@ class IxiaPacketGenerator(SSHConnection):
def hook_transmission_func(self):
pass
+ def loop_get_transmission_results(self, rx_port_list, tx_port_list, delay=5):
+ """
+ Override this method if you want to change the way of getting results
+ back from IXIA.
+ """
+ time.sleep(delay)
+ bpsRate = self.bpsRate
+ rate = self.rate
+ oversize = self.oversize
+ for port in rx_port_list:
+ self.stat_get_rate_stat_all_stats(port)
+ out = self.send_expect("stat cget -framesReceived", '%', 10)
+ rate += int(out.strip())
+ out = self.send_expect("stat cget -bitsReceived", '% ', 10)
+ self.logger.debug("port %d bits rate:" % (port) + out)
+ bpsRate += int(out.strip())
+ out = self.send_expect("stat cget -oversize", '%', 10)
+ oversize += int(out.strip())
+
+ self.logger.info("Rate: %f Mpps" % (rate * 1.0 / 1000000))
+ self.logger.info("Mbps rate: %f Mbps" % (bpsRate * 1.0 / 1000000))
+ self.hook_transmissoin_func()
+
+ return True
+
+ def stop_loop_transmission(self, rx_port_list, tx_port_list, delay=5):
+ return self.get_transmission_results(self.rxPortlist, self.txPortlist,
+ delay)
+
def get_transmission_results(self, rx_port_list, tx_port_list, delay=5):
"""
Override this method if you want to change the way of getting results
diff --git a/framework/tester.py b/framework/tester.py
old mode 100755
new mode 100644
index a775f68..043c6fc
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -1,6 +1,6 @@
# BSD LICENSE
#
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2018 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -502,6 +502,42 @@ class Tester(Crb):
return None
return self.packet_gen.throughput(portList, rate_percent)
+ def loop_traffic_generator_throughput(self, portList, rate_percent=100,
+ delay=5):
+ """
+ Run throughput performance test on specified ports.
+ """
+ print rate_percent
+ if self.check_port_list(portList, 'ixia'):
+ return self.ixia_packet_gen.loop_throughput(portList, rate_percent,
+ delay)
+ if not self.check_port_list(portList):
+ self.logger.warning("exception by mixed port types")
+ return None
+ result = self.packet_gen.loop_throughput(portList, rate_percent)
+ return result
+
+ def stop_traffic_generator_throughput_loop(self, portList,
+ rate_percent=100, delay=5):
+ """
+ Run throughput performance test on specified ports.
+ """
+ return self.ixia_packet_gen.stop_loop_throughput(portList,
+ rate_percent, delay)
+
+ def burst_traffic_generator_throughput(self, portList, rate_percent=100,
+ delay=5, **kwargs):
+ """
+ Run throughput performance test on specified ports.
+ """
+ if self.check_port_list(portList, 'ixia'):
+ return self.ixia_packet_gen.burst_throughput(portList, rate_percent,
+ delay, **kwargs)
+ if not self.check_port_list(portList):
+ self.logger.warning("exception by mixed port types")
+ return None
+ return result
+
def verify_packet_order(self, portList, delay):
if self.check_port_list(portList, 'ixia'):
return self.ixia_packet_gen.is_packet_ordered(portList, delay)
@@ -536,6 +572,22 @@ class Tester(Crb):
return None
return self.packet_gen.loss(portList, ratePercent, delay)
+ def traffic_get_port_stats(self, portList, delay=60):
+ """
+ Run loss performance test on specified ports.
+ """
+ ratePercent = float(100)
+ if self.check_port_list(portList, 'ixia'):
+ return self.ixia_packet_gen.port_stats(portList, ratePercent, delay)
+ elif not self.check_port_list(portList):
+ self.logger.warning("exception by mixed port types")
+ return None
+ else:
+ return None
+
+ def get_port_line_rate(self):
+ return self.ixia_packet_gen.port_line_rate()
+
def traffic_generator_latency(self, portList, ratePercent=100, delay=5):
"""
Run latency performance test on specified ports.
--
1.9.3
More information about the dts
mailing list