You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/11/08 15:00:28 UTC

svn commit: r1407083 - /lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py

Author: mikemccand
Date: Thu Nov  8 14:00:28 2012
New Revision: 1407083

URL: http://svn.apache.org/viewvc?rev=1407083&view=rev
Log:
don't hang if Solr example fails to start

Modified:
    lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py

Modified: lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py?rev=1407083&r1=1407082&r2=1407083&view=diff
==============================================================================
--- lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py (original)
+++ lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py Thu Nov  8 14:00:28 2012
@@ -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, fail
   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()
         break
       f.write(line)
       f.flush()
-      # print 'SOLR: %s' % line.strip()
-      if not startupEvent.isSet() and line.find(b'Started SocketConnector@0.0.0.0:8983') != -1:
-        startupEvent.set()
+      #print('SOLR: %s' % line.strip())
+      if not startupEvent.isSet():
+        if line.find(b'Started SocketConnector@0.0.0.0:8983') != -1:
+          startupEvent.set()
+        elif p.poll() is not None:
+          failureEvent.set()
+          startupEvent.set()
+          break
   except:
     print()
     print('Exception reading Solr output:')
     traceback.print_exc()
     failureEvent.set()
+    startupEvent.set()
   finally:
     f.close()
     
@@ -786,16 +798,24 @@ def testSolrExample(unpackPath, javaPath
   env.update(os.environ)
   env['JAVA_HOME'] = javaPath
   env['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
+    print('Startup failed; see log %s' % logFile)
+    printFileContents(logFile)
+    raise RuntimeError('failure on startup; see log %s' % logFile)
+    
   print('      startup done')
   
   try: