import re import threading import subprocess import json import benchUtil # NOTE # - only works in the module's working directory, # e.g. "lucene/core", or "lucene/analyzers/common" # TODO # - we currently cannot detect if a test did not in fact run because # it was @Ignore, @Nightly, or hit an AssumptionViolatedExc ... we # should fail in that case, if nothing actually ran ROOT = common.findRootDir(os.getcwd()) # True to use simple JUnit test runner; False to use # randomizedtesting's runner: USE_JUNIT = True ASSERTS = True osName = common.osName #JAVA_ARGS = '-Xmx512m -Xms512m -XX:+UseG1GC' #JAVA_ARGS = '-Xmx512m -Xms512m -server -XX:+UseSerialGC' #JAVA_ARGS += ' -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:CompileCommand=print,*Version.init' # print # print 'WARNING: *** running java w/ 8 GB heap ***' # print
def main(): global tTestsStart rootDir = common.findRootDir(os.getcwd()) localHostName = socket.gethostname() stats = Stats() classpath, tests = gatherTests(stats, rootDir) print '%d test suites' % len(tests) if False: print 'CP:' for x in classpath: print ' %s' % x try: SEED = sys.argv[1 + sys.argv.index('-seed')] except ValueError: #SEED = hex(random.getrandbits(63))[2:-1] SEED = None try: CODEC = sys.argv[1 + sys.argv.index('-codec')] except ValueError: CODEC = 'random' if '-nightly' in sys.argv: NIGHTLY = 'true' else: NIGHTLY = 'false' try: MULT = int(sys.argv[1 + sys.argv.index('-mult')]) except ValueError: MULT = 1 #tests = [(1.0, 'org.apache.solr.client.solrj.embedded.SolrExampleStreamingTest')] #tests = [(1.0, 'org.apache.lucene.TestDemo')] # TODO: solr has tests.cleanthreads=perClass but lucene has perMethod... maybe I need dedicated solr vs lucene jvms command = 'java' command += ' -Dtests.prefix=tests' command += ' -Xmx512M' command += ' -Dtests.iters=' command += ' -Dtests.verbose=false' if TEST_ASSERTS: command += ' -Dtests.asserts=true' else: command += ' -Dtests.asserts=false' command += ' -Dtests.infostream=false' command += ' -Dtests.lockdir=%s/lucene/build' % rootDir command += ' -Dtests.postingsformat=random' #print('NOTE: using Lucene410 DVFormat') #command += ' -Dtests.docvaluesformat=Lucene410' #command += ' -Dtests.locale=random' #command += ' -Dtests.timezone=random' command += ' -Dtests.directory=random' command += ' -Dtests.linedocsfile=europarl.lines.txt.gz' command += ' -Dtests.luceneMatchVersion=%s' % common.getLuceneMatchVersion( rootDir) command += ' -Dtests.LUCENE_VERSION=%s' % common.getLuceneMatchVersion( rootDir) command += ' -Dtests.cleanthreads=perMethod' command += ' -Djava.util.logging.config.file=%s/lucene/tools/junit4/logging.properties' % rootDir command += ' -Dtests.nightly=%s' % NIGHTLY command += ' -Dtests.weekly=false' command += ' -Dtests.slow=true' command += ' -Dtests.multiplier=%s' % MULT command += ' -DtempDir=./temp' command += ' -Djava.io.tmpDir=./temp' command += ' -Djetty.testMode=1' command += ' -Djetty.insecurerandom=1' command += ' -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory' command += ' -Djava.security.egd=file:/dev/./urandom' command += ' -Djava.security.policy=%s/lucene/tools/junit4/tests.policy' % rootDir command += ' -Dtests.codec=%s' % CODEC if SEED is not None: command += ' -Dtests.seed=%s' % SEED if TEST_ASSERTS: command += ' -ea -esa' command += ' com.carrotsearch.ant.tasks.junit4.slave.SlaveMainSafe -flush -stdin' # Tests first chdir to lucene/build: classpath2 = [] for x in classpath: if not x.startswith('/'): x = '../../%s' % x classpath2.append(x) classpath = ':'.join(classpath2) print 'CP: %s' % classpath jobs = Jobs(tests) tTestsStart = time.time() # print 'RUN: %s' % command # Launch local first since it can immediately start working, and, it # will pull the hardest jobs...: workers = [] id = 0 for hostName, processCount in RESOURCES: if hostName == localHostName: remote = Remote(id, stats, jobs, command, classpath, rootDir, hostName, processCount) id += 1 remote.start() workers.append(remote) break for hostName, processCount in RESOURCES: if hostName != localHostName: remote = Remote(id, stats, jobs, command, classpath, rootDir, hostName, processCount) id += 1 remote.start() workers.append(remote) workersOrig = workers lastSlowCheckTime = time.time() anyFails = False while True: alive = [] for worker in workers: if worker.isAlive(): alive.append(worker) elif worker.anyFails: anyFails = True if len(alive) == 0: break now = time.time() workers = alive if now - lastPrint > 5.0: l = ['\nRunning:\n'] for worker in workers: l.append(' %s (%d finished jobs):\n' % (worker.hostName, len(worker.finishedJobs))) for job, startTime in worker.runningJobs.items(): l.append(' %s [%.1f sec]\n' % (job, now - startTime)) msg(''.join(l)) if now - lastSlowCheckTime > 5.0: lastSlowCheckTime = now l = ['\nSlow still-running tests:\n'] for worker in workers: slow = [] for job, startTime in worker.runningJobs.items(): runTime = now - startTime if runTime > 30.0: slow.append((runTime, job[1])) if len(slow) > 0: slow.sort(key=lambda x: -x[0]) l.append(' %s (%d finished jobs):\n' % (worker.hostName, len(worker.finishedJobs))) for runTime, job in slow: l.append(' %4.1f sec: %s\n' % (runTime, job)) if len(l) > 1: msg(''.join(l)) time.sleep(.010) stats.save() print if anyFails: print 'FAILED' else: print 'SUCCESS' print print '%.1f sec' % (time.time() - tTestsStart) for worker in workersOrig: print(' %s ran %d tests' % (worker.hostName, len(worker.finishedJobs)))
def main(): global tTestsStart rootDir = common.findRootDir(os.getcwd()) localHostName = socket.gethostname() stats = Stats() classpath, tests = gatherTests(stats, rootDir) print '%d test suites' % len(tests) if False: print 'CP:' for x in classpath: print ' %s' % x try: SEED = sys.argv[1+sys.argv.index('-seed')] except ValueError: #SEED = hex(random.getrandbits(63))[2:-1] SEED = None try: CODEC = sys.argv[1+sys.argv.index('-codec')] except ValueError: CODEC = 'random' if '-nightly' in sys.argv: NIGHTLY = 'true' else: NIGHTLY = 'false' try: MULT = int(sys.argv[1+sys.argv.index('-mult')]) except ValueError: MULT = 1 #tests = [(1.0, 'org.apache.solr.client.solrj.embedded.SolrExampleStreamingTest')] #tests = [(1.0, 'org.apache.lucene.TestDemo')] # TODO: solr has tests.cleanthreads=perClass but lucene has perMethod... maybe I need dedicated solr vs lucene jvms command = 'java' command += ' -Dtests.prefix=tests' command += ' -Xmx512M' command += ' -Dtests.iters=' command += ' -Dtests.verbose=false' if TEST_ASSERTS: command += ' -Dtests.asserts=true' else: command += ' -Dtests.asserts=false' command += ' -Dtests.infostream=false' command += ' -Dtests.lockdir=%s/lucene/build' % rootDir command += ' -Dtests.postingsformat=random' #print('NOTE: using Lucene410 DVFormat') #command += ' -Dtests.docvaluesformat=Lucene410' #command += ' -Dtests.locale=random' #command += ' -Dtests.timezone=random' command += ' -Dtests.directory=random' command += ' -Dtests.linedocsfile=europarl.lines.txt.gz' command += ' -Dtests.luceneMatchVersion=%s' % common.getLuceneMatchVersion(rootDir) command += ' -Dtests.LUCENE_VERSION=%s' % common.getLuceneMatchVersion(rootDir) command += ' -Dtests.cleanthreads=perMethod' command += ' -Djava.util.logging.config.file=%s/lucene/tools/junit4/logging.properties' % rootDir command += ' -Dtests.nightly=%s' % NIGHTLY command += ' -Dtests.weekly=false' command += ' -Dtests.slow=true' command += ' -Dtests.multiplier=%s' % MULT command += ' -DtempDir=./temp' command += ' -Djava.io.tmpDir=./temp' command += ' -Djetty.testMode=1' command += ' -Djetty.insecurerandom=1' command += ' -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory' command += ' -Djava.security.egd=file:/dev/./urandom' command += ' -Djava.security.policy=%s/lucene/tools/junit4/tests.policy' % rootDir command += ' -Dtests.codec=%s' % CODEC if SEED is not None: command += ' -Dtests.seed=%s' % SEED if TEST_ASSERTS: command += ' -ea -esa' command += ' com.carrotsearch.ant.tasks.junit4.slave.SlaveMainSafe -flush -stdin' # Tests first chdir to lucene/build: classpath = ':'.join(['../../%s' % x for x in classpath]) #print 'CP: %s' % classpath jobs = Jobs(tests) tTestsStart = time.time() # print 'RUN: %s' % command # Launch local first since it can immediately start working, and, it # will pull the hardest jobs...: workers = [] id = 0 for hostName, processCount in RESOURCES: if hostName == localHostName: remote = Remote(id, stats, jobs, command, classpath, rootDir, hostName, processCount) id += 1 remote.start() workers.append(remote) break for hostName, processCount in RESOURCES: if hostName != localHostName: remote = Remote(id, stats, jobs, command, classpath, rootDir, hostName, processCount) id += 1 remote.start() workers.append(remote) workersOrig = workers lastSlowCheckTime = time.time() anyFails = False while True: alive = [] for worker in workers: if worker.isAlive(): alive.append(worker) elif worker.anyFails: anyFails = True if len(alive) == 0: break now = time.time() workers = alive if now - lastPrint > 5.0: l = ['\nRunning:\n'] for worker in workers: l.append(' %s (%d finished jobs):\n' % (worker.hostName, len(worker.finishedJobs))) for job, startTime in worker.runningJobs.items(): l.append(' %s [%.1f sec]\n' % (job, now - startTime)) msg(''.join(l)) if now - lastSlowCheckTime > 5.0: lastSlowCheckTime = now l = ['\nSlow still-running tests:\n'] for worker in workers: slow = [] for job, startTime in worker.runningJobs.items(): runTime = now - startTime if runTime > 30.0: slow.append((runTime, job[1])) if len(slow) > 0: slow.sort(key=lambda x: -x[0]) l.append(' %s (%d finished jobs):\n' % (worker.hostName, len(worker.finishedJobs))) for runTime, job in slow: l.append(' %4.1f sec: %s\n' % (runTime, job)) if len(l) > 1: msg(''.join(l)) time.sleep(.010) stats.save() print if anyFails: print 'FAILED' else: print 'SUCCESS' print print '%.1f sec' % (time.time()-tTestsStart) for worker in workersOrig: print(' %s ran %d tests' % (worker.hostName, len(worker.finishedJobs)))
def main(): global tTestsStart rootDir = common.findRootDir(os.getcwd()) localHostName = socket.gethostname() stats = Stats() classpath, tests = gatherTests(stats, rootDir) print "%d test suites" % len(tests) if False: print "CP:" for x in classpath: print " %s" % x try: SEED = sys.argv[1 + sys.argv.index("-seed")] except ValueError: SEED = hex(random.getrandbits(63))[2:-1] try: CODEC = sys.argv[1 + sys.argv.index("-codec")] except ValueError: CODEC = "random" # tests = [(1.0, 'org.apache.solr.client.solrj.embedded.SolrExampleStreamingTest')] # tests = [(1.0, 'org.apache.lucene.TestDemo')] # TODO: solr has tests.cleanthreads=perClass but lucene has # perMethod... maybe I need dedicated solr vs lucene jvms command = ( "java -Dtests.prefix=tests -Xmx512M -Dtests.iters= -Dtests.verbose=false -Dtests.infostream=false -Dtests.lockdir=%s/lucene/build -Dtests.postingsformat=random -Dtests.locale=random -Dtests.timezone=random -Dtests.directory=random -Dtests.linedocsfile=europarl.lines.txt.gz -Dtests.luceneMatchVersion=5.0 -Dtests.cleanthreads=perClass -Djava.util.logging.config.file=solr/testlogging.properties -Dtests.nightly=false -Dtests.weekly=false -Dtests.slow=false -Dtests.asserts.gracious=false -Dtests.multiplier=1 -DtempDir=. -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" % rootDir ) if os.popen("svn info").read().find("/branch_4x/") != -1: version = "4.0" else: version = "5.0" command += " -Dlucene.version=%s-SNAPSHOT" % version command += " -Dtests.codec=%s" % CODEC command += " -Dtests.seed=%s" % SEED command += " -ea:org.apache.lucene... -ea:org.apache.solr... com.carrotsearch.ant.tasks.junit4.slave.SlaveMainSafe -flush -stdin" # Tests first chdir to lucene/build: classpath = ":".join(["../../%s" % x for x in classpath]) # print 'CP: %s' % classpath jobs = Jobs(tests) tTestsStart = time.time() # print 'RUN: %s' % command # Launch local first since it can immediately start working, and, it # will pull the hardest jobs...: workers = [] for hostName, processCount in RESOURCES: if hostName == localHostName: remote = Remote(stats, jobs, command, classpath, rootDir, hostName, processCount) remote.start() workers.append(remote) break for hostName, processCount in RESOURCES: if hostName != localHostName: remote = Remote(stats, jobs, command, classpath, rootDir, hostName, processCount) remote.start() workers.append(remote) anyFails = False while True: alive = [] for worker in workers: if worker.isAlive(): alive.append(worker) elif worker.anyFails: anyFails = True if len(alive) == 0: break workers = alive if time.time() - lastPrint > 5.0: l = ["\nRunning:\n"] for worker in workers: l.append(" %s:\n" % worker.hostName) for job in worker.runningJobs: l.append(" %s\n" % job) msg("".join(l)) time.sleep(0.010) stats.save() print if anyFails: print "FAILED" else: print "SUCCESS" print print "%.1f sec" % (time.time() - tTestsStart)
def main(): global tTestsStart rootDir = common.findRootDir(os.getcwd()) localHostName = socket.gethostname() stats = Stats() classpath, tests = gatherTests(stats, rootDir) print '%d test suites' % len(tests) if False: print 'CP:' for x in classpath: print ' %s' % x try: SEED = sys.argv[1+sys.argv.index('-seed')] except ValueError: SEED = hex(random.getrandbits(63))[2:-1] try: CODEC = sys.argv[1+sys.argv.index('-codec')] except ValueError: CODEC = 'random' #tests = [(1.0, 'org.apache.solr.client.solrj.embedded.SolrExampleStreamingTest')] #tests = [(1.0, 'org.apache.lucene.TestDemo')] # TODO: solr has tests.cleanthreads=perClass but lucene has # perMethod... maybe I need dedicated solr vs lucene jvms command = 'java -Dtests.prefix=tests -Xmx512M -Dtests.iters= -Dtests.verbose=false -Dtests.infostream=false -Dtests.lockdir=%s/lucene/build -Dtests.postingsformat=random -Dtests.locale=random -Dtests.timezone=random -Dtests.directory=random -Dtests.linedocsfile=europarl.lines.txt.gz -Dtests.luceneMatchVersion=5.0 -Dtests.cleanthreads=perClass -Djava.util.logging.config.file=solr/testlogging.properties -Dtests.nightly=false -Dtests.weekly=false -Dtests.slow=false -Dtests.asserts.gracious=false -Dtests.multiplier=1 -DtempDir=. -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory' % rootDir if os.popen('svn info').read().find('/branch_4x/') != -1: version = '4.0' else: version = '5.0' command += ' -Dlucene.version=%s-SNAPSHOT' % version command += ' -Dtests.codec=%s' % CODEC command += ' -Dtests.seed=%s' % SEED command += ' -ea:org.apache.lucene... -ea:org.apache.solr... com.carrotsearch.ant.tasks.junit4.slave.SlaveMainSafe -flush -stdin' # Tests first chdir to lucene/build: classpath = ':'.join(['../../%s' % x for x in classpath]) # print 'CP: %s' % classpath jobs = Jobs(tests) tTestsStart = time.time() # print 'RUN: %s' % command # Launch local first since it can immediately start working, and, it # will pull the hardest jobs...: workers = [] for hostName, processCount in RESOURCES: if hostName == localHostName: remote = Remote(stats, jobs, command, classpath, rootDir, hostName, processCount) remote.start() workers.append(remote) break for hostName, processCount in RESOURCES: if hostName != localHostName: remote = Remote(stats, jobs, command, classpath, rootDir, hostName, processCount) remote.start() workers.append(remote) anyFails = False while True: alive = [] for worker in workers: if worker.isAlive(): alive.append(worker) elif worker.anyFails: anyFails = True if len(alive) == 0: break workers = alive if time.time() - lastPrint > 5.0: l = ['\nRunning:\n'] for worker in workers: l.append(' %s:\n' % worker.hostName) for job in worker.runningJobs: l.append(' %s\n' % job) msg(''.join(l)) time.sleep(.010) stats.save() print if anyFails: print 'FAILED' else: print 'SUCCESS' print print '%.1f sec' % (time.time()-tTestsStart)