MCPcopy Create free account
hub / github.com/apache/solr / fetchAndParseJenkinsLog

Function fetchAndParseJenkinsLog

dev-tools/scripts/reproduceJenkinsFailures.py:102–154  ·  view source on GitHub ↗
(url, numRetries)

Source from the content-addressed store, hash-verified

100 return code
101
102def fetchAndParseJenkinsLog(url, numRetries):
103 global revisionFromLog
104 global branchFromLog
105 global antOptions
106 revisionFromLog = None
107 antOptions = ''
108 tests = {}
109 print('[repro] Jenkins log URL: %s\n' % url)
110 try:
111 # HTTPS fails at certificate validation, see LUCENE-9412, PEP-476
112 context = ssl._create_unverified_context()
113 with urllib.request.urlopen(url, context=context) as consoleText:
114 for rawLine in consoleText:
115 line = rawLine.decode(encoding)
116 match = reGitRev.match(line)
117 if match is not None:
118 revisionFromLog = match.group(1)
119 branchFromLog = match.group(2)
120 print('[repro] Revision: %s\n' % revisionFromLog)
121 else:
122 match = reReproLine.search(line)
123 if match is not None:
124 print('[repro] Repro line: %s\n' % match.group(1))
125 testcase = match.group(2)
126 reproLineWithoutMethod = match.group(3).strip()
127 tests[testcase] = reproLineWithoutMethod
128 else:
129 match = reAntInvocation.search(line)
130 if match is not None:
131 antOptions = ' '.join(reAntSysprops.findall(line))
132 if len(antOptions) > 0:
133 print('[repro] Ant options: %s' % antOptions)
134 except urllib.error.URLError as e:
135 raise RuntimeError('ERROR: fetching %s : %s' % (url, e))
136 except http.client.IncompleteRead as e:
137 if numRetries > 0:
138 print('[repro] Encountered IncompleteRead exception, pausing and then retrying...')
139 time.sleep(2) # pause for 2 seconds
140 return fetchAndParseJenkinsLog(url, numRetries - 1)
141 else:
142 print('[repro] Encountered IncompleteRead exception, aborting after too many retries.')
143 raise RuntimeError('ERROR: fetching %s : %s' % (url, e))
144
145 if revisionFromLog == None:
146 if reJenkinsURLWithoutConsoleText.match(url):
147 print('[repro] Not a Jenkins log. Appending "/consoleText" and retrying ...\n')
148 return fetchAndParseJenkinsLog(url + '/consoleText', numRetries)
149 else:
150 raise RuntimeError('ERROR: %s does not appear to be a Jenkins log.' % url)
151 if 0 == len(tests):
152 print('[repro] No "reproduce with" lines found; exiting.')
153 sys.exit(0)
154 return tests
155
156def prepareWorkspace(useGit, gitRef):
157 global gitCheckoutSucceeded

Callers 1

mainFunction · 0.85

Calls 7

stripMethod · 0.80
decodeMethod · 0.65
matchMethod · 0.45
searchMethod · 0.45
joinMethod · 0.45
sleepMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…