Skip to content

Commit

Permalink
LUCENE-9670: retry 'gradle precommit' up to 5 times to work around we…
Browse files Browse the repository at this point in the history
…ird 'IOException: Stream Closed' intermittent issue
  • Loading branch information
mikemccand committed Jan 19, 2021
1 parent e89a565 commit e5a96db
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/python/runNightlyGradleTestPrecommit.py
Expand Up @@ -64,18 +64,24 @@ def runPrecommit(logFile):
open(logFile + '.tmp', 'w').write('git rev: %s\n\n' % os.popen('git rev-parse HEAD').read().strip())
open(logFile + '.tmp', 'a').write('\n\njava version: %s\n\n' % os.popen('java -fullversion 2>&1').read())

if os.system('git clean -xfd >> %s.tmp 2>&1' % logFile):
raise RuntimeError('git clean -xfd failed!')

t0 = time.time()
if not os.system('./gradlew --no-daemon precommit >> %s.tmp 2>&1' % logFile):
# Success
t1 = time.time()
open(logFile + '.tmp', 'a').write('\nTOTAL SEC: %s' % (t1-t0))
os.rename(logFile + '.tmp', logFile)
print(' took: %.1f min' % ((t1-t0)/60.0))
else:
print('FAILED; see %s.tmp' % logFile)
# See https://issues.apache.org/jira/browse/LUCENE-9670 -- retry up to 5 times in case this weird IOException: Stream Closed issue struck:

for i in range(5):
if os.system('git clean -xfd >> %s.tmp 2>&1' % logFile):
raise RuntimeError('git clean -xfd failed!')

t0 = time.time()
if not os.system('./gradlew --no-daemon precommit >> %s.tmp 2>&1' % logFile):
# Success
t1 = time.time()
open(logFile + '.tmp', 'a').write('\nTOTAL SEC: %s' % (t1-t0))
os.rename(logFile + '.tmp', logFile)
print(' took: %.1f min' % ((t1-t0)/60.0))
break
elif i < 4:
print(f'FAILED; see {logFile}.tmp; will try again ({5 - i - 1} attempts remain)')
else:
print('FAILED; see %s.tmp' % logFile)

def getTestCount(line, regexp):
m = regexp.search(line)
Expand Down

0 comments on commit e5a96db

Please sign in to comment.