Commit f4220e19 authored by Julien Muchembled's avatar Julien Muchembled

Prevent several test_bot instances from launching tests at the same time

This hask is mainly for performance tests, which should be run on a physical
machine that doesn't do anything else.
parent fd8c8a6e
#!/usr/bin/python #!/usr/bin/python
import os, subprocess, sys, time import errno, os, socket, subprocess, sys, time
def clean(): def clean():
for path, dir_list, file_list in os.walk('.'): for path, dir_list, file_list in os.walk('.'):
...@@ -49,24 +49,35 @@ def main(): ...@@ -49,24 +49,35 @@ def main():
delay = None delay = None
while True: while True:
delay = delay and time.sleep(delay) or 1800 delay = delay and time.sleep(delay) or 1800
old_revision = revision s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
try: try:
_git('fetch') while True:
_git('reset', '--merge', '@{u}') try:
except GitError, e: s.bind("\0neo.tools.test_bot")
continue break
revision = getRevision() except socket.error, e:
if revision == old_revision: if e.errno != errno.EADDRINUSE:
continue raise
if test_bot_revision != getRevision(test_bot): time.sleep(60)
os.execvp(sys.argv[0], sys.argv) old_revision = revision
delay = None try:
for test_home in sys.argv[arg_count:]: _git('fetch')
test_home, tasks = test_home.rsplit('=', 1) _git('reset', '--merge', '@{u}')
tests = ''.join(x for x in tasks if x in 'fuz') except GitError, e:
bin = os.path.join(test_home, 'bin') continue
if not subprocess.call((os.path.join(bin, 'buildout'), '-v'), revision = getRevision()
if revision == old_revision:
continue
if test_bot_revision != getRevision(test_bot):
break
delay = None
for test_home in sys.argv[arg_count:]:
test_home, tasks = test_home.rsplit('=', 1)
tests = ''.join(x for x in tasks if x in 'fuz')
bin = os.path.join(test_home, 'bin')
if subprocess.call((os.path.join(bin, 'buildout'), '-v'),
cwd=test_home): cwd=test_home):
continue
title = '[%s:%s-g%s:%s]' % (branch, title = '[%s:%s-g%s:%s]' % (branch,
git('rev-list', '--topo-order', '--count', revision), git('rev-list', '--topo-order', '--count', revision),
revision[:7], os.path.basename(test_home)) revision[:7], os.path.basename(test_home))
...@@ -82,7 +93,10 @@ def main(): ...@@ -82,7 +93,10 @@ def main():
'--min-replicas=0', '--max-replicas=3', '--min-replicas=0', '--max-replicas=3',
'--title', 'Matrix ' + title, '--title', 'Matrix ' + title,
] + sys.argv[1:arg_count]) ] + sys.argv[1:arg_count])
finally:
s.close()
clean() clean()
os.execvp(sys.argv[0], sys.argv)
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main()) sys.exit(main())
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