VSPERF: Add Timestamps to Logfiles 37/66537/2
authorSridhar K. N. Rao <sridhar.rao@spirent.com>
Mon, 21 Jan 2019 06:59:46 +0000 (12:29 +0530)
committerSridhar K. N. Rao <sridhar.rao@spirent.com>
Mon, 21 Jan 2019 07:53:54 +0000 (13:23 +0530)
This patch adds timestamps to all the logfiles created by VSPERF.
The logfiles covered are:
1. LOG_FILE_VSWITCHD
2. LOG_FILE_OVS
3. LOG_FILE_VPP
4. LOG_FILE_QEMU
5. LOG_FILE_GUEST_CMDS
6. LOG_FILE_TRAFFIC_GEN
7. LOG_FILE_HOST_CMDS

Added fix for pylint errors

This patch also ensures the extension is only .log always.

JIRA: VSPERF-586

Change-Id: I319c075e7d3af06539266f4c759a41f877d4cff2
Signed-off-by: Sridhar K. N. Rao <sridhar.rao@spirent.com>
src/dpdk/testpmd_proc.py
vnfs/qemu/qemu.py
vsperf
vswitches/ovs.py
vswitches/vpp_dpdk_vhost.py

index a8fa8ee..b89bcec 100644 (file)
@@ -27,8 +27,12 @@ from tools import tasks
 
 _TESTPMD_PROMPT = 'Done'
 
+_NAME, _EXT = os.path.splitext(settings.getValue('LOG_FILE_VSWITCHD'))
 _LOG_FILE_VSWITCHD = os.path.join(
-    settings.getValue('LOG_DIR'), settings.getValue('LOG_FILE_VSWITCHD'))
+    settings.getValue('LOG_DIR'),
+    ("{name}_{uid}{ex}".format(name=_NAME, uid=settings.getValue(
+        'LOG_TIMESTAMP'), ex=_EXT)))
+
 
 class TestPMDProcess(tasks.Process):
     """Class wrapper for controlling a TestPMD instance.
index d3e1b34..2ccf3aa 100644 (file)
@@ -46,12 +46,14 @@ class IVnfQemu(IVnf):
         Initialisation function.
         """
         super(IVnfQemu, self).__init__()
-
+        name, ext = os.path.splitext(S.getValue('LOG_FILE_QEMU'))
+        name = name + str(self._number)
+        rename_qemu = "{name}_{uid}{ex}".format(name=name,
+                                                uid=S.getValue('LOG_TIMESTAMP'),
+                                                ex=ext)
         self._expect = S.getValue('GUEST_PROMPT_LOGIN')[self._number]
         self._logger = logging.getLogger(__name__)
-        self._logfile = os.path.join(
-            S.getValue('LOG_DIR'),
-            S.getValue('LOG_FILE_QEMU')) + str(self._number)
+        self._logfile = os.path.join(S.getValue('LOG_DIR'), rename_qemu)
         self._timeout = S.getValue('GUEST_TIMEOUT')[self._number]
         self._monitor = '%s/vm%dmonitor' % ('/tmp', self._number)
         # read GUEST NICs configuration and use only defined NR of NICS
@@ -115,10 +117,13 @@ class IVnfQemu(IVnf):
         self.GuestCommandFilter.prefix = self._log_prefix
 
         logger = logging.getLogger()
+        name, ext = os.path.splitext(S.getValue('LOG_FILE_GUEST_CMDS'))
+        name = name + str(self._number)
+        rename_gcmd = "{name}_{uid}{ex}".format(name=name,
+                                                uid=S.getValue('LOG_TIMESTAMP'),
+                                                ex=ext)
         cmd_logger = logging.FileHandler(
-            filename=os.path.join(S.getValue('LOG_DIR'),
-                                  S.getValue('LOG_FILE_GUEST_CMDS')) +
-            str(self._number))
+            filename=os.path.join(S.getValue('LOG_DIR'), rename_gcmd))
         cmd_logger.setLevel(logging.DEBUG)
         cmd_logger.addFilter(self.GuestCommandFilter())
         logger.addHandler(cmd_logger)
diff --git a/vsperf b/vsperf
index 4c41a7b..1afe858 100755 (executable)
--- a/vsperf
+++ b/vsperf
@@ -235,20 +235,29 @@ def parse_arguments():
 def configure_logging(level):
     """Configure logging.
     """
-    date = datetime.datetime.fromtimestamp(time.time())
-    timestamp = date.strftime('%Y-%m-%d_%H-%M-%S')
-    settings.setValue('LOG_TIMESTAMP', timestamp)
     name, ext = os.path.splitext(settings.getValue('LOG_FILE_DEFAULT'))
-    rename_default = "{name}_{uid}{ex}".format(name=name, uid=timestamp, ex=ext)
+    rename_default = "{name}_{uid}{ex}".format(name=name,
+                                               uid=settings.getValue(
+                                                   'LOG_TIMESTAMP'),
+                                               ex=ext)
     log_file_default = os.path.join(
         settings.getValue('LOG_DIR'), rename_default)
+    name, ext = os.path.splitext(settings.getValue('LOG_FILE_HOST_CMDS'))
+    rename_hostcmd = "{name}_{uid}{ex}".format(name=name,
+                                               uid=settings.getValue(
+                                                   'LOG_TIMESTAMP'),
+                                               ex=ext)
     log_file_host_cmds = os.path.join(
-        settings.getValue('LOG_DIR'), settings.getValue('LOG_FILE_HOST_CMDS'))
+        settings.getValue('LOG_DIR'), rename_hostcmd)
+    name, ext = os.path.splitext(settings.getValue('LOG_FILE_TRAFFIC_GEN'))
+    rename_traffic = "{name}_{uid}{ex}".format(name=name,
+                                               uid=settings.getValue(
+                                                   'LOG_TIMESTAMP'),
+                                               ex=ext)
     log_file_traffic_gen = os.path.join(
-        settings.getValue('LOG_DIR'),
-        settings.getValue('LOG_FILE_TRAFFIC_GEN'))
+        settings.getValue('LOG_DIR'), rename_traffic)
     metrics_file = (settings.getValue('LOG_FILE_INFRA_METRICS_PFX') +
-                    timestamp + '.log')
+                    settings.getValue('LOG_TIMESTAMP') + '.log')
     log_file_infra_metrics = os.path.join(settings.getValue('LOG_DIR'),
                                           metrics_file)
 
@@ -663,6 +672,11 @@ def main():
 
     settings.load_from_dir(os.path.join(_CURR_DIR, 'conf'))
 
+    # Define the timestamp to be used by logs and results
+    date = datetime.datetime.fromtimestamp(time.time())
+    timestamp = date.strftime('%Y-%m-%d_%H-%M-%S')
+    settings.setValue('LOG_TIMESTAMP', timestamp)
+
     # Load non performance/integration tests
     if args['integration']:
         settings.load_from_dir(os.path.join(_CURR_DIR, 'conf/integration'))
@@ -772,8 +786,8 @@ def main():
     settings.setValue('WHITELIST_NICS', list(nic['pci'] for nic in nic_list))
 
     # generate results directory name
-    date = datetime.datetime.fromtimestamp(time.time())
-    results_dir = "results_" + date.strftime('%Y-%m-%d_%H-%M-%S')
+    date = datetime.datetime.fromtimestamp(time.time())
+    results_dir = "results_" + timestamp
     results_path = os.path.join(settings.getValue('LOG_DIR'), results_dir)
     settings.setValue('RESULTS_PATH', results_path)
 
index 6dbf0cf..03c8dad 100644 (file)
@@ -47,8 +47,13 @@ class IVSwitchOvs(IVSwitch, tasks.Process):
         """See IVswitch for general description
         """
         super().__init__()
+        name, ext = os.path.splitext(settings.getValue('LOG_FILE_VSWITCHD'))
+        rename_vswitchd = "{name}_{uid}{ex}".format(name=name,
+                                                    uid=settings.getValue(
+                                                        'LOG_TIMESTAMP'),
+                                                    ex=ext)
         self._logfile = os.path.join(settings.getValue('LOG_DIR'),
-                                     settings.getValue('LOG_FILE_VSWITCHD'))
+                                     rename_vswitchd)
         self._ovsdb_pidfile_path = os.path.join(settings.getValue('TOOLS')['ovs_var_tmp'],
                                                 "ovsdb-server.pid")
         self._vswitchd_pidfile_path = os.path.join(settings.getValue('TOOLS')['ovs_var_tmp'],
index 5d676a0..f639d3d 100644 (file)
@@ -37,8 +37,12 @@ class VppDpdkVhost(IVSwitch, tasks.Process):
         """See IVswitch for general description
         """
         super().__init__()
-        self._logfile = os.path.join(S.getValue('LOG_DIR'),
-                                     S.getValue('LOG_FILE_VPP'))
+        name, ext = os.path.splitext(S.getValue('LOG_FILE_VPP'))
+        rename_vpplf = "{name}_{uid}{ex}".format(name=name,
+                                                 uid=S.getValue(
+                                                     'LOG_TIMESTAMP'),
+                                                 ex=ext)
+        self._logfile = os.path.join(S.getValue('LOG_DIR'), rename_vpplf)
         self._expect = r'vpp#'
         self._cmd_template = ['sudo', '-E', S.getValue('TOOLS')['vpp']]
         self._phy_ports = []