Apache Solr open-source search software
don't hang if Solr example fails to start
Michael McCandlessc85875c33e77
diff --git a/dev-tools/scripts/smokeTestRelease.py b/dev-tools/scripts/smokeTestRelease.pyindex 92c65bfe7ca..b83de5891c3 100644--- a/dev-tools/scripts/smokeTestRelease.py+++ b/dev-tools/scripts/smokeTestRelease.py@@ -463,27 +463,29 @@ def cygwinifyPaths(command):if '; ant ' in command: command = reUnixPath.sub(unix2win, command)return command+def printFileContents(fileName):++ # Assume log file was written in system's default encoding, but+ # even if we are wrong, we replace errors ... the ASCII chars+ # (which is what we mostly care about eg for the test seed) should+ # still survive:+ txt = codecs.open(fileName, 'r', encoding=sys.getdefaultencoding(), errors='replace').read()++ # Encode to our output encoding (likely also system's default+ # encoding):+ bytes = txt.encode(sys.stdout.encoding, errors='replace')++ # Decode back to string and print... we should hit no exception here+ # since all errors have been replaced:+ print(codecs.getdecoder(sys.stdout.encoding)(bytes)[0])+ print()+def run(command, logFile):if cygwin: command = cygwinifyPaths(command)if os.system('%s > %s 2>&1' % (command, logFile)):logPath = os.path.abspath(logFile)print('\ncommand "%s" failed:' % command)-- # Assume log file was written in system's default encoding, but- # even if we are wrong, we replace errors ... the ASCII chars- # (which is what we mostly care about eg for the test seed) should- # still survive:- txt = codecs.open(logPath, 'r', encoding=sys.getdefaultencoding(), errors='replace').read()-- # Encode to our output encoding (likely also system's default- # encoding):- bytes = txt.encode(sys.stdout.encoding, errors='replace')-- # Decode back to string and print... we should hit no exception here- # since all errors have been replaced:- print(codecs.getdecoder(sys.stdout.encoding)(bytes)[0])- print()-+ printFileContents(logFile)raise RuntimeError('command "%s" failed; see log file %s' % (command, logPath))def verifyDigests(artifact, urlString, tmpDir):@@ -762,19 +764,29 @@ def readSolrOutput(p, startupEvent, failureEvent, logFile):f = open(logFile, 'wb')try:while True:- line = p.readline()+ line = p.stderr.readline()if len(line) == 0:+ p.poll()+ if not startupEvent.isSet():+ failureEvent.set()+ startupEvent.set()breakf.write(line)f.flush()- # print 'SOLR: %s' % line.strip()- if not startupEvent.isSet() and line.find(b'Started [email protected]:8983') != -1:- startupEvent.set()+ #print('SOLR: %s' % line.strip())+ if not startupEvent.isSet():+ if line.find(b'Started [email protected]:8983') != -1:+ startupEvent.set()+ elif p.poll() is not None:+ failureEvent.set()+ startupEvent.set()+ breakexcept:print()print('Exception reading Solr output:')traceback.print_exc()failureEvent.set()+ startupEvent.set()finally:f.close()@@ -786,16 +798,24 @@ def testSolrExample(unpackPath, javaPath, isSrc):env.update(os.environ)env['JAVA_HOME'] = javaPathenv['PATH'] = '%s/bin:%s' % (javaPath, env['PATH'])- server = subprocess.Popen(['java', '-jar', 'start.jar'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)+ server = subprocess.Popen(['java', '-jar', 'start.jar'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, env=env)startupEvent = threading.Event()failureEvent = threading.Event()- serverThread = threading.Thread(target=readSolrOutput, args=(server.stderr, startupEvent, failureEvent, logFile))+ serverThread = threading.Thread(target=readSolrOutput, args=(server, startupEvent, failureEvent, logFile))serverThread.setDaemon(True)serverThread.start()# Make sure Solr finishes startup:- startupEvent.wait()+ if not startupEvent.wait(1800):+ raise RuntimeError('startup took more than 30 minutes')+ if failureEvent.isSet():+ logFile = os.path.abspath(logFile)+ print('Startup failed; see log %s' % logFile)+ printFileContents(logFile)+ raise RuntimeError('failure on startup; see log %s' % logFile)+print(' startup done')try: