From 9f6acc0ed5e118f7874c70071e68def42118703b Mon Sep 17 00:00:00 2001 From: "Yiting.Li" Date: Wed, 20 Jan 2016 11:01:43 +0800 Subject: JIRA: BOTTLENECKS-41 define the documents of vstf in B release Change-Id: Ib2ef6fabf0452a3e686d3de0ec7424e9a0500482 Signed-off-by: Yiting.Li (cherry picked from commit 194ae04e266f63512a8f041f6bfd0dc330cd81af) --- vstf/vstf/agent/perf/qperf.py | 2 +- vstf/vstf/common/daemon.py | 63 ++++++++++++++-------------- vstf/vstf/common/perfmark.py | 4 +- vstf/vstf/controller/res/logo.jpg | Bin 544271 -> 4713 bytes vstf/vstf/controller/sw_perf/performance.py | 4 +- 5 files changed, 37 insertions(+), 36 deletions(-) (limited to 'vstf') diff --git a/vstf/vstf/agent/perf/qperf.py b/vstf/vstf/agent/perf/qperf.py index f84f9c24..afdf44d7 100755 --- a/vstf/vstf/agent/perf/qperf.py +++ b/vstf/vstf/agent/perf/qperf.py @@ -133,7 +133,7 @@ class Qperf(object): if data[3] == "us": latency = float(data[2]) / 1000 else: - latency = float(data[2]) / 1000 + latency = float(data[2]) result = { mark.minLatency: latency, mark.avgLatency: latency, diff --git a/vstf/vstf/common/daemon.py b/vstf/vstf/common/daemon.py index 1085d36c..35933dad 100755 --- a/vstf/vstf/common/daemon.py +++ b/vstf/vstf/common/daemon.py @@ -20,45 +20,46 @@ class Daemon(object): Usage: subclass the Daemon class and override the run() method """ + def __init__(self, pidfile, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'): super(Daemon, self).__init__() self.stdin = stdin self.stdout = stdout self.stderr = stderr self.pidfile = pidfile - + def daemonize(self): """ do the UNIX double-fork magic, see Stevens' "Advanced Programming in the UNIX Environment" for details (ISBN 0201563177) http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16 """ - try: - pid = os.fork() + try: + pid = os.fork() if pid > 0: - sys.exit(0) - except OSError, e: + sys.exit(0) + except OSError, e: LOG.error("fork #1 failed: %(errno)s, %(strerror)s", - {'errno':e.errno, 'strerror': e.strerror}) + {'errno': e.errno, 'strerror': e.strerror}) sys.exit(1) - + # decouple from parent environment - os.chdir("/") - os.setsid() - os.umask(0) - + os.chdir("/") + os.setsid() + os.umask(0) + # do second fork - try: - pid = os.fork() + try: + pid = os.fork() if pid > 0: # exit from second parent - sys.exit(0) - except OSError, e: + sys.exit(0) + except OSError, e: LOG.error("fork #1 failed: %(errno)s, %(strerror)s", - {'errno':e.errno, 'strerror': e.strerror}) - sys.exit(1) - - # redirect standard file descriptors + {'errno': e.errno, 'strerror': e.strerror}) + sys.exit(1) + + # redirect standard file descriptors sys.stdout.flush() sys.stderr.flush() si = file(self.stdin, 'r') @@ -67,12 +68,12 @@ class Daemon(object): os.dup2(si.fileno(), sys.stdin.fileno()) os.dup2(so.fileno(), sys.stdout.fileno()) os.dup2(se.fileno(), sys.stderr.fileno()) - + # write pidfile atexit.register(self.delpid) pid = str(os.getpid()) - file(self.pidfile,'w+').write("%s\n" % pid) - + file(self.pidfile, 'w+').write("%s\n" % pid) + def delpid(self): os.remove(self.pidfile) @@ -80,15 +81,15 @@ class Daemon(object): """ Start the daemon """ - + # Check for a pidfile to see if the daemon already runs try: - pf = file(self.pidfile,'r') + pf = file(self.pidfile, 'r') pid = int(pf.read().strip()) pf.close() except IOError: pid = None - + if pid: message = "pidfile %s already exist. Daemon already running?\n" sys.stderr.write(message % self.pidfile) @@ -104,16 +105,16 @@ class Daemon(object): """ # Get the pid from the pidfile try: - pf = file(self.pidfile,'r') + pf = file(self.pidfile, 'r') pid = int(pf.read().strip()) pf.close() except IOError: pid = None - + if not pid: message = "pidfile %s does not exist. Daemon not running?\n" sys.stderr.write(message % self.pidfile) - return # not an error in a restart + return # not an error in a restart # Try killing the daemon process try: @@ -144,10 +145,10 @@ class Daemon(object): """ pass - + def daemon_die(self): - """You should this method when you shutdown daemon + """You should override this method when you shutdown daemon this func will be call by stop() before kill the process """ - pass \ No newline at end of file + pass diff --git a/vstf/vstf/common/perfmark.py b/vstf/vstf/common/perfmark.py index 5edfe3a4..4f5c3978 100755 --- a/vstf/vstf/common/perfmark.py +++ b/vstf/vstf/common/perfmark.py @@ -19,5 +19,5 @@ rxCount = 'RxFrameCount' duration = 'Duration' cpu = 'CPU' mppsGhz = 'MppspGhz' -rxMbps = "RxMbit" -txMbps = 'TxMbit' +rxMbps = "RxMbps" +txMbps = 'TxMbps' diff --git a/vstf/vstf/controller/res/logo.jpg b/vstf/vstf/controller/res/logo.jpg index 683acfe0..9d524829 100755 Binary files a/vstf/vstf/controller/res/logo.jpg and b/vstf/vstf/controller/res/logo.jpg differ diff --git a/vstf/vstf/controller/sw_perf/performance.py b/vstf/vstf/controller/sw_perf/performance.py index 7e6467ee..3fe91e93 100755 --- a/vstf/vstf/controller/sw_perf/performance.py +++ b/vstf/vstf/controller/sw_perf/performance.py @@ -268,8 +268,8 @@ class Performance(object): record[mark.rxCount] += nic_data['rxpck'] record[mark.txCount] += nic_data['txpck'] record[mark.bandwidth] += nic_data['rxpck/s'] - record[mark.rxMbps] += nic_data['rxmB/s'] - record[mark.txMbps] += nic_data['txmB/s'] + record[mark.rxMbps] += nic_data['rxmB/s'] * 8 + record[mark.txMbps] += nic_data['txmB/s'] * 8 if record[mark.rxMbps] > record[mark.txMbps]: record[mark.rxMbps], record[mark.txMbps] = record[mark.txMbps], record[mark.rxMbps] -- cgit 1.2.3-korg