Commit 8ff016d3 authored by Kirill Smelkov's avatar Kirill Smelkov

Always log system info and run summary, even if master tells us to do nothing

Nxdtest logs system information (bd91f6f1 "Include system information
into log output") and run summary at the end (9f413221 "Emit run summary
at the end"). However all that information currently is printed only if
master is successfully connected and actually tells to run the tests.

This behaviour is not very useful, because if nxdtest log output on
testnode is empty, it is not clear - whether it was "we have to do
nothing", or nxdtest stuck somewhere or something else.

For example
https://nexedijs.erp5.net/#/test_result_module/20211208-47D165B7/12 is
currently marked as Running for many long hours already. And the log on
testnode regarding nxdtest run is just:

    2021-12-08 15:42:17,314 INFO     $ PATH=/srv/slapgrid/slappart13/srv/slapos/soft/2956f419073cb2249ed953507fa6b173/bin:/opt/slapos/parts/bison/bin:/opt/slapos/parts/bzip2/bin:/opt/slapos/parts/gettext/bin:/opt/slapos/parts/glib/bin:/opt/slapos/parts/libxml2/bin:/opt/slapos/parts/libxslt/bin:/opt/slapos/parts/m4/bin:/opt/slapos/parts/ncurses/bin:/opt/slapos/parts/openssl/bin:/opt/slapos/parts/pkgconfig/bin:/opt/slapos/parts/python2.7/bin:/opt/slapos/parts/readline/bin:/opt/slapos/parts/sqlite3/bin:/opt/slapos/parts/swig/bin:/opt/slapos/bin:/opt/slapos/parts/patch/bin:/opt/slapos/parts/socat/bin:/usr/bin:/usr/sbin:/sbin:/bin SLAPOS_TEST_LOG_DIRECTORY=/srv/slapgrid/slappart13/var/log/testnode/dgd-xStX9safSG SLAPOS_TEST_SHARED_PART_LIST=/srv/slapgrid/slappart13/srv/shared:/srv/slapgrid/slappart13/t/dgd/shared /bin/sh /srv/slapgrid/slappart13/t/dgd/i/0/bin/runTestSuite --master_url $DISTRIBUTOR_URL --revision slapos=13977-ec686a708633f689382426063c21efbe3b2eab04,slapos.core=8698-91edab77ed36c160da8017cfdc1673fe7a8e10de --test_node_title rapidspace-testnode-008-3Nodes-DEPLOYTASK0 --test_suite SLAPOS-SR-TEST --test_suite_title SlapOS.SoftwareReleases.IntegrationTest-kirr.Python2 --project_title 'Rapid.Space Project'

without anything else.

With this patch nxdtest would print system information and report how many
tests it had run, if its invocation did not stuck.

In this patch we only move code that calls system_info and defer summary log
before code that connects to master. In the following patch we'll add more
logging around connecting to master.
parent 9f413221
......@@ -150,6 +150,32 @@ def main():
emit(t.name)
return
# log information about local node
system_info()
# emit run summary at the end
summaryv = [] # of summary line for each ran testcase
def _():
stat = {} # st -> count
for line in summaryv:
st, _ = line.split(None, 1) # 'ok testname ...' -> 'ok'
stat[st] = stat.get(st, 0) + 1
s = '# ran %d test case' % len(summaryv)
if len(summaryv) == 0:
s += 's.'
else:
if len(summaryv) > 1:
s += 's'
s += ':'
# ok, fail, error go in that order
for st in ('ok', 'fail', 'error') + tuple(stat.keys()):
n = stat.pop(st, 0)
if n != 0:
s += ' %d·%s' % (n, st)
emit(s)
defer(_)
# master_url provided -> run tests under master control
if args.master_url is not None:
# connect to master and create 'test result' object with list of tests to run
......@@ -174,9 +200,6 @@ def main():
# tell python not to buffer anything.
os.environ['PYTHONUNBUFFERED'] = 'y'
# log information about local node
system_info()
if sys.version_info < (3,):
bstdout = sys.stdout
bstderr = sys.stderr
......@@ -184,29 +207,6 @@ def main():
bstdout = sys.stdout.buffer
bstderr = sys.stderr.buffer
# emit run summary at the end
summaryv = [] # of summary line for each ran testcase
def _():
stat = {} # st -> count
for line in summaryv:
st, _ = line.split(None, 1) # 'ok testname ...' -> 'ok'
stat[st] = stat.get(st, 0) + 1
s = '# ran %d test case' % len(summaryv)
if len(summaryv) == 0:
s += 's.'
else:
if len(summaryv) > 1:
s += 's'
s += ':'
# ok, fail, error go in that order
for st in ('ok', 'fail', 'error') + tuple(stat.keys()):
n = stat.pop(st, 0)
if n != 0:
s += ' %d·%s' % (n, st)
emit(s)
defer(_)
# run the tests
devnull = open(os.devnull)
while 1:
......
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