Commit bd91f6f1 authored by Kirill Smelkov's avatar Kirill Smelkov

Include system information into log output

When checking logs on testnode, it is very useful to know which kernel
version is running inside (wendelin.core uses FUSE and depends on having
patched FUSE module for kernels < 5.2), which CPU is there, etc.

Format of printed output follows go benchmarking format and coincides
with start of `neotest info-local` (see footers on figures in
http://navytux.spb.ru/~kirr/neo.html and here:
https://lab.nexedi.com/kirr/neo/blob/1f26678b/go/neo/t/neotest#L585-874)
parent 6991af9b
......@@ -57,8 +57,8 @@ from __future__ import print_function, absolute_import
from erp5.util.taskdistribution import TaskDistributor
from subprocess import Popen, PIPE
from time import time, strftime, gmtime
import os, sys, threading, argparse, logging, traceback, re
from time import time, strftime, gmtime, localtime
import os, sys, threading, argparse, logging, traceback, re, pwd, socket
import six
# loadNXDTestFile loads .nxdtest file located @path.
......@@ -161,6 +161,9 @@ def main():
# tell python not to buffer anything.
os.environ['PYTHONUNBUFFERED'] = 'y'
# log information about local node
system_info()
# run the tests
devnull = open(os.devnull)
while 1:
......@@ -291,6 +294,29 @@ def test_result_summary(name, kw):
return '%s\t%s\t%.3fs\t# %st %se %sf %ss' % (st, name, kw['duration'], v('test_count'), v('error_count'), v('failure_count'), v('skip_count'))
# system_info prints information about local computer.
def system_info():
print('date:\t%s' % (strftime("%a, %d %b %Y %H:%M:%S %Z", localtime())))
whoami = pwd.getpwuid(os.getuid()).pw_name
print('xnode:\t%s@%s' % (whoami, socket.getfqdn()))
print('uname:\t%s' % ' '.join(os.uname()))
print('cpu:\t%s' % get1('/proc/cpuinfo', 'model name'))
# get1 returns first entry from file @path prefixed with ^<field>\s*:
def get1(path, field, default=None):
with open(path, 'r') as f:
data = f.read()
rex = re.compile(r'^%s\s*:\s*(.*)$' % field)
for l in data.splitlines():
m = rex.match(l)
if m is not None:
return m.group(1)
if default is not None:
return default
raise KeyError('%s does not have field %r' % (path, field))
# LocalTestResult* handle tests runs, when master_url was not provided and tests are run locally.
class LocalTestResult:
def __init__(self, tenv, run=None):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment