I have a testsuite written in Python/unittest+TeamcityTestRunner and running under Linux.
Most of the tests involve running a separate thread subprocess.Popen with the tested app (which is a console app, itself running multiple subprocesses/plugins - C++ code) and checking if: a subprocess/plugin of the app is restarted when killed, creating the files it has to create, etc.
The problem is that when I run the test suite normally - ssh to the build machine (VM), running the script against the binary/app - all tests pass.
When I run the same test suite against the same binary/app from TeamCity, all tests fail.
After some debugging, I found out that the app runs/loads very slowly when run from TeamCity-unittest-subprocess.Popen.
What can be the culprit of this? Has the TeamcityTestRunner that much additional overhead to cause this behavior? What can I do about it?
The culprit seems to be the overhead caused by running under TeamCity, on a slow VM and the overhead of subprocess.Popen
the old code which did not work for me was:
cmd = [binary, 'param1']
outfile = open(redirect_to, 'w')
subprocess.call(cmd, stdout=outfile)
the new, much faster in practice as it turned out is:
cmd = [binary, 'param1']
redirect_to = '/tmp/out'
p = os.popen(' '.join(cmd) + '2>&1 >' + redirect_to)
p.close()
more info here: http://essays.ajs.com/2011/02/python-subprocess-vs-ospopen-overhead.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.