From 2d1e67c8b4adff3e1cb092fa69552529459d34d3 Mon Sep 17 00:00:00 2001 From: Chris Hostetter Date: Thu, 21 Nov 2019 15:28:46 -0700 Subject: [PATCH] LUCENE-9054: Fix reproduceJenkinsFailures.py to not overwrite junit XML files when retrying --- dev-tools/scripts/reproduceJenkinsFailures.py | 25 +++++++++++++++---- lucene/CHANGES.txt | 2 ++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/dev-tools/scripts/reproduceJenkinsFailures.py b/dev-tools/scripts/reproduceJenkinsFailures.py index 037c62aba84..2cb86dd833a 100644 --- a/dev-tools/scripts/reproduceJenkinsFailures.py +++ b/dev-tools/scripts/reproduceJenkinsFailures.py @@ -17,6 +17,7 @@ import argparse import http.client import os import re +import shutil import subprocess import sys import time @@ -211,7 +212,7 @@ def runTests(testIters, modules, tests): finally: os.chdir(cwd) -def printReport(testIters, location): +def printAndMoveReports(testIters, newSubDir, location): failures = {} for start in ('lucene/build', 'solr/build'): for (dir, _, files) in os.walk(start): @@ -221,12 +222,17 @@ def printReport(testIters, location): testcase = testOutputFileMatch.group(1) if testcase not in failures: failures[testcase] = 0 - with open(os.path.join(dir, file), encoding='UTF-8') as testOutputFile: + filePath = os.path.join(dir, file) + with open(filePath, encoding='UTF-8') as testOutputFile: for line in testOutputFile: errorFailureMatch = reErrorFailure.search(line) if errorFailureMatch is not None: failures[testcase] += 1 break + # have to play nice with 'ant clean' ... nocommit: test this + newDirPath = os.path.join('repro-reports', newSubDir, dir) + os.makedirs(newDirPath, exist_ok=True) + os.rename(filePath, os.path.join(newDirPath, file)) print("[repro] Failures%s:" % location) for testcase in sorted(failures, key=lambda t: (failures[t],t)): # sort by failure count, then by testcase print("[repro] %d/%d failed: %s" % (failures[testcase], testIters, testcase)) @@ -246,10 +252,17 @@ def main(): localGitBranch = getLocalGitBranch() try: + # have to play nice with ant clean, so printAndMoveReports will move all the junit XML files here... + print('[repro] JUnit rest result XML files will be moved to: ./repro-reports') + if os.path.isdir('repro-reports'): + print('[repro] Deleting old ./repro-reports'); + shutil.rmtree('repro-reports') prepareWorkspace(config.useGit, revisionFromLog) modules = groupTestsByModule(tests) runTests(config.testIters, modules, tests) - failures = printReport(config.testIters, '') + failures = printAndMoveReports(config.testIters, 'orig', + ' w/original seeds' + (' at %s' % revisionFromLog if config.useGit else '')) + if config.useGit: # Retest 100% failures at the tip of the branch @@ -264,7 +277,8 @@ def main(): prepareWorkspace(True, branchFromLog) modules = groupTestsByModule(tests) runTests(config.testIters, modules, tests) - failures = printReport(config.testIters, ' at the tip of %s' % branchFromLog) + failures = printAndMoveReports(config.testIters, 'branch-tip', + ' original seeds at the tip of %s' % branchFromLog) # Retest 100% tip-of-branch failures without a seed oldTests = tests @@ -278,7 +292,8 @@ def main(): prepareWorkspace(False, branchFromLog) modules = groupTestsByModule(tests) runTests(config.testIters, modules, tests) - printReport(config.testIters, ' at the tip of %s without a seed' % branchFromLog) + printAndMoveReports(config.testIters, 'branch-tip-no-seed', + ' at the tip of %s without a seed' % branchFromLog) except Exception as e: print('[repro] %s' % traceback.format_exc()) sys.exit(1) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 740d3a1b450..2879aaa40cd 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -122,6 +122,8 @@ Bug Fixes * LUCENE-9030: Fix WordnetSynonymParser behaviour so it behaves similar to SolrSynonymParser. (Christoph Buescher via Alan Woodward) +* LUCENE-9054: Fix reproduceJenkinsFailures.py to not overwrite junit XML files when retrying (hossman) + Other * LUCENE-8979: Code Cleanup: Use entryset for map iteration wherever possible. - Part 2 (Koen De Groote)