diff options
Diffstat (limited to 'testsuites/vstf/vstf_scripts/vstf/agent/perf')
12 files changed, 88 insertions, 24 deletions
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/__init__.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/__init__.py index df7d24d0..83b8d15d 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/__init__.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/__init__.py @@ -6,4 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/affctl.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/affctl.py index 5b203632..316cbab8 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/affctl.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/affctl.py @@ -18,4 +18,3 @@ def affctl_load(policy): def affctl_list(): cmd = "affctl list" return check_output(cmd, shell=True) - diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/iperf.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/iperf.py index 3105be4b..8eca165c 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/iperf.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/iperf.py @@ -21,6 +21,7 @@ LOG = logging.getLogger(__name__) class Iperf(object): + def __init__(self): self._send_processes = [] self._receive_processes = [] @@ -40,7 +41,10 @@ class Iperf(object): cmd = self.format_send_start(**kwargs) LOG.debug("cmd:%s", cmd) - process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = subprocess.Popen( + cmd.split(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) time.sleep(1) ret = process.poll() if ret is None: @@ -90,7 +94,10 @@ class Iperf(object): cmd = self.format_receive_start(**kwargs) LOG.debug("cmd:%s", cmd) - process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = subprocess.Popen( + cmd.split(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) time.sleep(1) ret = process.poll() if ret is None: @@ -151,5 +158,8 @@ def unit_test(): if __name__ == "__main__": from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/vstf-iperf.log", clevel=logging.DEBUG) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/vstf-iperf.log", + clevel=logging.DEBUG) unit_test() diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netmap.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netmap.py index 88a25444..bd9cc97f 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netmap.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netmap.py @@ -18,6 +18,7 @@ LOG = logging.getLogger(__name__) class Netmap(object): + def __init__(self): self._send_processes = [] self._receive_processes = [] @@ -33,7 +34,10 @@ class Netmap(object): cmd = self.format_send_start(**kwargs) LOG.info("cmd:%s", cmd) - process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = my_popen( + cmd.split(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) self._send_processes.append(process) time.sleep(0.5) @@ -89,7 +93,10 @@ class Netmap(object): cmd = self.format_receive_start(**kwargs) LOG.info("cmd:%s", cmd) - process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = my_popen( + cmd.split(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) self._receive_processes.append(process) time.sleep(0.5) @@ -164,5 +171,8 @@ def unit_test(): if __name__ == "__main__": from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-netmap.log", clevel=logging.INFO) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/vstf/vstf-netmap.log", + clevel=logging.INFO) unit_test() diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netns.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netns.py index c3b73860..9aaaf58f 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netns.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netns.py @@ -16,6 +16,7 @@ LOG = logging.getLogger(__name__) class Netns(object): + def __init__(self): super(Netns, self).__init__() self.netns_add_str = "ip netns add %s" @@ -74,13 +75,14 @@ class Netns(object): class NetnsManager(object): + def __init__(self): super(NetnsManager, self).__init__() self._netns = Netns() def config_dev(self, netdev): - ns, device, ip = netdev["namespace"], netdev["iface"], netdev['ip_setting'] if "ip_setting" in netdev else \ - netdev['ip'] + ns, device, ip = netdev["namespace"], netdev["iface"], netdev[ + 'ip_setting'] if "ip_setting" in netdev else netdev['ip'] self._netns.create_namespace(ns) self._netns.add_device(ns, device) self._netns.config_ip(ns, device, ip) diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netperf.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netperf.py index 99f1c904..dac7d649 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netperf.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netperf.py @@ -20,6 +20,7 @@ LOG = logging.getLogger(__name__) class Netperf(object): + def __init__(self): self._send_processes = [] self._islat = False @@ -48,7 +49,10 @@ class Netperf(object): LOG.info("cmd:%s", cmd) for _ in range(threads): - process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = my_popen( + cmd.split(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) self._send_processes.append(process) time.sleep(0.5) for process in self._send_processes: @@ -119,7 +123,10 @@ class Netperf(object): cmd = self.format_receive_start(**kwargs) LOG.info("cmd:%s", cmd) - process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = my_popen( + cmd.split(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) time.sleep(0.5) ret = process.poll() if ret: @@ -177,5 +184,8 @@ def unit_test(): if __name__ == "__main__": from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-netperf.log", clevel=logging.DEBUG) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/vstf/vstf-netperf.log", + clevel=logging.DEBUG) unit_test() diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/pktgen.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/pktgen.py index 671e1aa7..9aff0a0c 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/pktgen.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/pktgen.py @@ -18,6 +18,7 @@ LOG = logging.getLogger(__name__) class Pktgen(object): + def __init__(self): utils.modprobe_pktgen() self._send_processes = [] @@ -33,7 +34,11 @@ class Pktgen(object): def _start(self): cmd = 'echo start > /proc/net/pktgen/pgctrl' - process = my_popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = my_popen( + cmd, + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) LOG.info('running pid:%s', process.pid) time.sleep(0.5) ret = process.poll() @@ -42,7 +47,8 @@ class Pktgen(object): self._send_processes.append(process) error_str = "start pktgen send success" else: - error_str = "start pktgen send failed, stdout:%s,stderr:%s" % (process.stdout.read(), process.stderr.read()) + error_str = "start pktgen send failed, stdout:%s,stderr:%s" % ( + process.stdout.read(), process.stderr.read()) LOG.info(error_str) return ret, error_str @@ -149,5 +155,8 @@ def unit_test(): if __name__ == "__main__": from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-pktgen.log", clevel=logging.DEBUG) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/vstf/vstf-pktgen.log", + clevel=logging.DEBUG) unit_test() diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/qperf.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/qperf.py index afdf44d7..25272d89 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/qperf.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/qperf.py @@ -18,6 +18,7 @@ LOG = logging.getLogger(__name__) class Qperf(object): + def __init__(self): self._send_processes = [] self._receive_processes = [] @@ -30,7 +31,10 @@ class Qperf(object): def send_start(self, **kwargs): cmd = self.format_send_start(**kwargs) LOG.info("cmd:%s", cmd) - process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = my_popen( + cmd.split(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) time.sleep(0.5) ret = process.poll() if ret is None: @@ -76,7 +80,10 @@ class Qperf(object): cmd = self.format_receive_start(**kwargs) LOG.info("cmd:%s", cmd) - process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = my_popen( + cmd.split(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) time.sleep(0.5) ret = process.poll() if ret is None: @@ -163,5 +170,8 @@ def unit_test(): if __name__ == "__main__": from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-qperf.log", clevel=logging.DEBUG) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/vstf/vstf-qperf.log", + clevel=logging.DEBUG) unit_test() diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/sar.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/sar.py index 0231d5c1..72d0082d 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/sar.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/sar.py @@ -20,13 +20,17 @@ LOG = logging.getLogger(__name__) class Sar(object): + def __init__(self): self.sar_cmd_str = "sar -u %(interval)s" self.child_process = {} def start(self, interval=2): cmd = self.sar_cmd_str % {'interval': interval} - child = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + child = my_popen( + cmd.split(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) time.sleep(1) if child.poll() is not None: print child.poll() @@ -55,7 +59,9 @@ class Sar(object): data = {} for h, d in zip(head, average): data[h.strip('%')] = float(d) - cpu_num = check_output('cat /proc/cpuinfo | grep processor | wc -l', shell=True).strip() + cpu_num = check_output( + 'cat /proc/cpuinfo | grep processor | wc -l', + shell=True).strip() data.update({'cpu_num': int(cpu_num)}) return data diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/utils.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/utils.py index 4f7ddb6a..f9ca46cd 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/utils.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/utils.py @@ -26,7 +26,9 @@ def get_pid_by_name(process_name): def get_cpu_num(): - cpu_num = check_output('cat /proc/cpuinfo | grep processor | wc -l', shell=True).strip() + cpu_num = check_output( + 'cat /proc/cpuinfo | grep processor | wc -l', + shell=True).strip() cpu_num = int(cpu_num) return cpu_num diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/vnstat.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/vnstat.py index b12ac1af..49e4f0c1 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/vnstat.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/vnstat.py @@ -19,6 +19,7 @@ LOG = logging.getLogger(__name__) class VnStat(object): + def __init__(self): self.netns_exec_str = "ip netns exec %s " self.vnstat_cmd_str = "vnstat -l -i %s" @@ -63,7 +64,9 @@ class VnStat(object): m = {} digits = re.compile(r"\d+\.?\d*") - units = re.compile("(?:gib|mib|kib|kbit/s|gbits/s|mbit/s|p/s)", re.IGNORECASE | re.MULTILINE) + units = re.compile( + "(?:gib|mib|kib|kbit/s|gbits/s|mbit/s|p/s)", + re.IGNORECASE | re.MULTILINE) units_arr = units.findall(buf) LOG.debug(units_arr) diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/vstfperf.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/vstfperf.py index 8be3c4e5..939b12ef 100644 --- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/vstfperf.py +++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/vstfperf.py @@ -40,6 +40,7 @@ LOG = logging.getLogger(__name__) class Vstfperf(object): + def __init__(self): for tool in cst.TOOLS: obj_name = 'vstf_' + tool @@ -75,7 +76,10 @@ class Vstfperf(object): def unit_test(): from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-vstfperf.log", clevel=logging.INFO) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/vstf/vstf-vstfperf.log", + clevel=logging.INFO) perf = Vstfperf() start = { |