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>
_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.
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
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)
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)
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'))
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)
"""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'],
"""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 = []