2019-06-11 04:17:10 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
2011-06-04 06:37:48 -04:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership.
|
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
# (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2014-08-28 04:01:50 -04:00
|
|
|
import argparse
|
2012-09-26 14:33:46 -04:00
|
|
|
import codecs
|
2013-04-21 09:26:54 -04:00
|
|
|
import datetime
|
2019-06-11 04:17:10 -04:00
|
|
|
import filecmp
|
2022-05-20 07:20:57 -04:00
|
|
|
import glob
|
2011-06-04 06:37:48 -04:00
|
|
|
import hashlib
|
2012-08-03 17:18:14 -04:00
|
|
|
import http.client
|
2019-06-11 04:17:10 -04:00
|
|
|
import os
|
|
|
|
import platform
|
2011-06-04 06:37:48 -04:00
|
|
|
import re
|
2019-06-11 04:17:10 -04:00
|
|
|
import shutil
|
|
|
|
import subprocess
|
2011-06-04 06:37:48 -04:00
|
|
|
import sys
|
2019-06-11 04:17:10 -04:00
|
|
|
import textwrap
|
|
|
|
import traceback
|
|
|
|
import urllib.error
|
|
|
|
import urllib.parse
|
|
|
|
import urllib.parse
|
|
|
|
import urllib.request
|
2012-03-19 13:36:27 -04:00
|
|
|
import xml.etree.ElementTree as ET
|
2019-06-11 04:17:10 -04:00
|
|
|
import zipfile
|
|
|
|
from collections import namedtuple
|
2020-10-08 15:25:51 -04:00
|
|
|
import scriptutil
|
2019-06-11 04:17:10 -04:00
|
|
|
|
2024-02-29 06:16:29 -05:00
|
|
|
BASE_JAVA_VERSION = "21"
|
2024-02-27 07:12:20 -05:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
# This tool expects to find /lucene off the base URL. You
|
2012-03-19 13:36:27 -04:00
|
|
|
# must have a working gpg, tar, unzip in your path. This has been
|
|
|
|
# tested on Linux and on Cygwin under Windows 7.
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2012-09-24 12:33:39 -04:00
|
|
|
cygwin = platform.system().lower().startswith('cygwin')
|
|
|
|
cygwinWindowsRoot = os.popen('cygpath -w /').read().strip().replace('\\','/') if cygwin else ''
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2012-04-08 14:22:14 -04:00
|
|
|
def unshortenURL(url):
|
2012-08-03 17:18:14 -04:00
|
|
|
parsed = urllib.parse.urlparse(url)
|
2012-04-08 14:22:14 -04:00
|
|
|
if parsed[0] in ('http', 'https'):
|
2012-08-03 17:18:14 -04:00
|
|
|
h = http.client.HTTPConnection(parsed.netloc)
|
2012-04-08 14:22:14 -04:00
|
|
|
h.request('HEAD', parsed.path)
|
|
|
|
response = h.getresponse()
|
2012-09-24 08:31:22 -04:00
|
|
|
if int(response.status/100) == 3 and response.getheader('Location'):
|
2012-04-08 14:22:14 -04:00
|
|
|
return response.getheader('Location')
|
2021-10-13 09:24:14 -04:00
|
|
|
return url
|
2012-04-08 14:22:14 -04:00
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
# TODO
|
|
|
|
# - make sure jars exist inside bin release
|
|
|
|
# - make sure docs exist
|
|
|
|
|
|
|
|
reHREF = re.compile('<a href="(.*?)">(.*?)</a>')
|
|
|
|
|
2012-09-26 14:33:46 -04:00
|
|
|
# Set to False to avoid re-downloading the packages...
|
|
|
|
FORCE_CLEAN = True
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
def getHREFs(urlString):
|
|
|
|
|
|
|
|
# Deref any redirects
|
|
|
|
while True:
|
2012-08-03 17:18:14 -04:00
|
|
|
url = urllib.parse.urlparse(urlString)
|
2015-12-07 16:21:05 -05:00
|
|
|
if url.scheme == "http":
|
|
|
|
h = http.client.HTTPConnection(url.netloc)
|
|
|
|
elif url.scheme == "https":
|
|
|
|
h = http.client.HTTPSConnection(url.netloc)
|
|
|
|
else:
|
|
|
|
raise RuntimeError("Unknown protocol: %s" % url.scheme)
|
2016-02-12 16:39:35 -05:00
|
|
|
h.request('HEAD', url.path)
|
2011-06-04 06:37:48 -04:00
|
|
|
r = h.getresponse()
|
|
|
|
newLoc = r.getheader('location')
|
|
|
|
if newLoc is not None:
|
|
|
|
urlString = newLoc
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
|
|
|
|
links = []
|
2012-09-24 08:31:22 -04:00
|
|
|
try:
|
2015-02-10 13:09:53 -05:00
|
|
|
html = load(urlString)
|
2012-09-24 08:31:22 -04:00
|
|
|
except:
|
|
|
|
print('\nFAILED to open url %s' % urlString)
|
2012-09-24 11:25:13 -04:00
|
|
|
traceback.print_exc()
|
2012-09-24 08:31:22 -04:00
|
|
|
raise
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2012-09-24 08:31:22 -04:00
|
|
|
for subUrl, text in reHREF.findall(html):
|
2012-08-03 17:18:14 -04:00
|
|
|
fullURL = urllib.parse.urljoin(urlString, subUrl)
|
2011-06-04 06:37:48 -04:00
|
|
|
links.append((text, fullURL))
|
|
|
|
return links
|
|
|
|
|
2015-02-10 09:40:27 -05:00
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
def load(urlString):
|
2015-02-10 13:09:53 -05:00
|
|
|
try:
|
|
|
|
content = urllib.request.urlopen(urlString).read().decode('utf-8')
|
|
|
|
except Exception as e:
|
|
|
|
print('Retrying download of url %s after exception: %s' % (urlString, e))
|
|
|
|
content = urllib.request.urlopen(urlString).read().decode('utf-8')
|
|
|
|
return content
|
2012-09-25 17:08:51 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2012-09-25 17:08:51 -04:00
|
|
|
def noJavaPackageClasses(desc, file):
|
|
|
|
with zipfile.ZipFile(file) as z2:
|
|
|
|
for name2 in z2.namelist():
|
|
|
|
if name2.endswith('.class') and (name2.startswith('java/') or name2.startswith('javax/')):
|
2021-10-13 09:24:14 -04:00
|
|
|
raise RuntimeError('%s contains sheisty class "%s"' % (desc, name2))
|
|
|
|
|
2012-09-25 17:08:51 -04:00
|
|
|
|
2012-09-26 14:33:46 -04:00
|
|
|
def decodeUTF8(bytes):
|
|
|
|
return codecs.getdecoder('UTF-8')(bytes)[0]
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2012-09-26 14:33:46 -04:00
|
|
|
MANIFEST_FILE_NAME = 'META-INF/MANIFEST.MF'
|
|
|
|
NOTICE_FILE_NAME = 'META-INF/NOTICE.txt'
|
|
|
|
LICENSE_FILE_NAME = 'META-INF/LICENSE.txt'
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2016-02-11 15:19:43 -05:00
|
|
|
def checkJARMetaData(desc, jarFile, gitRevision, version):
|
2012-09-26 14:33:46 -04:00
|
|
|
|
2015-07-28 15:04:21 -04:00
|
|
|
with zipfile.ZipFile(jarFile, 'r') as z:
|
2012-09-26 14:33:46 -04:00
|
|
|
for name in (MANIFEST_FILE_NAME, NOTICE_FILE_NAME, LICENSE_FILE_NAME):
|
2015-07-28 15:04:21 -04:00
|
|
|
try:
|
|
|
|
# The Python docs state a KeyError is raised ... so this None
|
|
|
|
# check is just defensive:
|
|
|
|
if z.getinfo(name) is None:
|
2015-07-27 14:12:45 -04:00
|
|
|
raise RuntimeError('%s is missing %s' % (desc, name))
|
2015-07-28 15:04:21 -04:00
|
|
|
except KeyError:
|
|
|
|
raise RuntimeError('%s is missing %s' % (desc, name))
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2015-07-28 15:04:21 -04:00
|
|
|
s = decodeUTF8(z.read(MANIFEST_FILE_NAME))
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2015-07-28 15:04:21 -04:00
|
|
|
for verify in (
|
|
|
|
'Specification-Vendor: The Apache Software Foundation',
|
|
|
|
'Implementation-Vendor: The Apache Software Foundation',
|
2021-10-13 09:24:14 -04:00
|
|
|
'Specification-Title: Lucene Search Engine:',
|
|
|
|
'Implementation-Title: org.apache.lucene',
|
2024-02-27 07:12:20 -05:00
|
|
|
'X-Compile-Source-JDK: %s' % BASE_JAVA_VERSION,
|
|
|
|
'X-Compile-Target-JDK: %s' % BASE_JAVA_VERSION,
|
2015-07-28 15:04:21 -04:00
|
|
|
'Specification-Version: %s' % version,
|
2024-02-27 07:12:20 -05:00
|
|
|
'X-Build-JDK: %s.' % BASE_JAVA_VERSION,
|
2021-10-13 09:24:14 -04:00
|
|
|
'Extension-Name: org.apache.lucene'):
|
2016-08-21 04:48:59 -04:00
|
|
|
if type(verify) is not tuple:
|
|
|
|
verify = (verify,)
|
|
|
|
for x in verify:
|
|
|
|
if s.find(x) != -1:
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
if len(verify) == 1:
|
2024-02-28 05:49:39 -05:00
|
|
|
raise RuntimeError('%s is missing "%s" inside its META-INF/MANIFEST.MF: %s' % (desc, verify[0], s))
|
2016-08-21 04:48:59 -04:00
|
|
|
else:
|
2024-02-28 05:49:39 -05:00
|
|
|
raise RuntimeError('%s is missing one of "%s" inside its META-INF/MANIFEST.MF: %s' % (desc, verify, s))
|
2015-07-28 15:04:21 -04:00
|
|
|
|
2016-02-11 15:19:43 -05:00
|
|
|
if gitRevision != 'skip':
|
|
|
|
# Make sure this matches the version and git revision we think we are releasing:
|
2021-10-13 09:24:14 -04:00
|
|
|
match = re.search("Implementation-Version: (.+\r\n .+)", s, re.MULTILINE)
|
|
|
|
if match:
|
|
|
|
implLine = match.group(1).replace("\r\n ", "")
|
|
|
|
verifyRevision = '%s %s' % (version, gitRevision)
|
|
|
|
if implLine.find(verifyRevision) == -1:
|
|
|
|
raise RuntimeError('%s is missing "%s" inside its META-INF/MANIFEST.MF (wrong git revision?)' % \
|
2015-07-27 14:12:45 -04:00
|
|
|
(desc, verifyRevision))
|
2021-10-13 09:24:14 -04:00
|
|
|
else:
|
|
|
|
raise RuntimeError('%s is missing Implementation-Version inside its META-INF/MANIFEST.MF' % desc)
|
2015-07-27 14:12:45 -04:00
|
|
|
|
2015-07-28 15:04:21 -04:00
|
|
|
notice = decodeUTF8(z.read(NOTICE_FILE_NAME))
|
2021-10-13 09:24:14 -04:00
|
|
|
lucene_license = decodeUTF8(z.read(LICENSE_FILE_NAME))
|
|
|
|
|
|
|
|
if LUCENE_LICENSE is None:
|
|
|
|
raise RuntimeError('BUG in smokeTestRelease!')
|
|
|
|
if LUCENE_NOTICE is None:
|
|
|
|
raise RuntimeError('BUG in smokeTestRelease!')
|
|
|
|
if notice != LUCENE_NOTICE:
|
|
|
|
raise RuntimeError('%s: %s contents doesn\'t match main NOTICE.txt' % \
|
|
|
|
(desc, NOTICE_FILE_NAME))
|
|
|
|
if lucene_license != LUCENE_LICENSE:
|
|
|
|
raise RuntimeError('%s: %s contents doesn\'t match main LICENSE.txt' % \
|
|
|
|
(desc, LICENSE_FILE_NAME))
|
|
|
|
|
2012-09-26 14:33:46 -04:00
|
|
|
|
2012-09-26 10:51:36 -04:00
|
|
|
def normSlashes(path):
|
|
|
|
return path.replace(os.sep, '/')
|
2016-02-11 15:19:43 -05:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
|
|
|
def checkAllJARs(topDir, gitRevision, version):
|
2013-10-11 12:58:36 -04:00
|
|
|
print(' verify JAR metadata/identity/no javax.* or java.* classes...')
|
2012-09-26 10:51:36 -04:00
|
|
|
for root, dirs, files in os.walk(topDir):
|
|
|
|
|
|
|
|
normRoot = normSlashes(root)
|
|
|
|
|
2012-09-25 17:08:51 -04:00
|
|
|
for file in files:
|
|
|
|
if file.lower().endswith('.jar'):
|
2021-10-13 09:24:14 -04:00
|
|
|
if normRoot.endswith('/replicator/lib') and file.startswith('javax.servlet'):
|
|
|
|
continue
|
2012-09-25 17:08:51 -04:00
|
|
|
fullPath = '%s/%s' % (root, file)
|
|
|
|
noJavaPackageClasses('JAR file "%s"' % fullPath, fullPath)
|
2021-10-13 09:24:14 -04:00
|
|
|
if file.lower().find('lucene') != -1:
|
2016-02-11 15:19:43 -05:00
|
|
|
checkJARMetaData('JAR file "%s"' % fullPath, fullPath, gitRevision, version)
|
2012-09-26 10:51:36 -04:00
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
def checkSigs(urlString, version, tmpDir, isSigned, keysFile):
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' test basics...')
|
2011-06-04 06:37:48 -04:00
|
|
|
ents = getDirEntries(urlString)
|
|
|
|
artifact = None
|
|
|
|
changesURL = None
|
|
|
|
mavenURL = None
|
2021-10-13 09:24:14 -04:00
|
|
|
artifactURL = None
|
2012-04-08 14:22:14 -04:00
|
|
|
expectedSigs = []
|
|
|
|
if isSigned:
|
|
|
|
expectedSigs.append('asc')
|
2018-09-26 09:31:26 -04:00
|
|
|
expectedSigs.extend(['sha512'])
|
2021-10-13 09:24:14 -04:00
|
|
|
sigs = []
|
2011-06-04 06:37:48 -04:00
|
|
|
artifacts = []
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
for text, subURL in ents:
|
|
|
|
if text == 'KEYS':
|
2021-10-13 09:24:14 -04:00
|
|
|
raise RuntimeError('lucene: release dir should not contain a KEYS file - only toplevel /dist/lucene/KEYS is used')
|
2011-06-04 06:37:48 -04:00
|
|
|
elif text == 'maven/':
|
|
|
|
mavenURL = subURL
|
|
|
|
elif text.startswith('changes'):
|
|
|
|
if text not in ('changes/', 'changes-%s/' % version):
|
2021-10-13 09:24:14 -04:00
|
|
|
raise RuntimeError('lucene: found %s vs expected changes-%s/' % (text, version))
|
2011-06-04 06:37:48 -04:00
|
|
|
changesURL = subURL
|
2021-10-13 09:24:14 -04:00
|
|
|
elif artifact is None:
|
2011-06-04 06:37:48 -04:00
|
|
|
artifact = text
|
|
|
|
artifactURL = subURL
|
2021-10-13 09:24:14 -04:00
|
|
|
expected = 'lucene-%s' % version
|
2011-06-04 06:37:48 -04:00
|
|
|
if not artifact.startswith(expected):
|
2021-10-13 09:24:14 -04:00
|
|
|
raise RuntimeError('lucene: unknown artifact %s: expected prefix %s' % (text, expected))
|
2011-06-04 06:37:48 -04:00
|
|
|
sigs = []
|
|
|
|
elif text.startswith(artifact + '.'):
|
|
|
|
sigs.append(text[len(artifact)+1:])
|
|
|
|
else:
|
|
|
|
if sigs != expectedSigs:
|
2021-10-13 09:24:14 -04:00
|
|
|
raise RuntimeError('lucene: artifact %s has wrong sigs: expected %s but got %s' % (artifact, expectedSigs, sigs))
|
2011-06-04 06:37:48 -04:00
|
|
|
artifacts.append((artifact, artifactURL))
|
|
|
|
artifact = text
|
|
|
|
artifactURL = subURL
|
|
|
|
sigs = []
|
|
|
|
|
|
|
|
if sigs != []:
|
|
|
|
artifacts.append((artifact, artifactURL))
|
|
|
|
if sigs != expectedSigs:
|
2021-10-13 09:24:14 -04:00
|
|
|
raise RuntimeError('lucene: artifact %s has wrong sigs: expected %s but got %s' % (artifact, expectedSigs, sigs))
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
expected = ['lucene-%s-src.tgz' % version,
|
2021-10-26 15:21:30 -04:00
|
|
|
'lucene-%s.tgz' % version]
|
2011-06-04 06:37:48 -04:00
|
|
|
|
|
|
|
actual = [x[0] for x in artifacts]
|
|
|
|
if expected != actual:
|
2021-10-13 09:24:14 -04:00
|
|
|
raise RuntimeError('lucene: wrong artifacts: expected %s but got %s' % (expected, actual))
|
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
# Set up clean gpg world; import keys file:
|
2021-10-13 09:24:14 -04:00
|
|
|
gpgHomeDir = '%s/lucene.gpg' % tmpDir
|
2011-06-04 06:37:48 -04:00
|
|
|
if os.path.exists(gpgHomeDir):
|
|
|
|
shutil.rmtree(gpgHomeDir)
|
2012-08-03 17:18:14 -04:00
|
|
|
os.makedirs(gpgHomeDir, 0o700)
|
2011-06-04 06:37:48 -04:00
|
|
|
run('gpg --homedir %s --import %s' % (gpgHomeDir, keysFile),
|
2021-10-13 09:24:14 -04:00
|
|
|
'%s/lucene.gpg.import.log' % tmpDir)
|
2011-06-04 06:37:48 -04:00
|
|
|
|
|
|
|
if mavenURL is None:
|
2021-10-13 09:24:14 -04:00
|
|
|
raise RuntimeError('lucene is missing maven')
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2012-09-24 00:40:14 -04:00
|
|
|
if changesURL is None:
|
2021-10-13 09:24:14 -04:00
|
|
|
raise RuntimeError('lucene is missing changes-%s' % version)
|
|
|
|
testChanges(version, changesURL)
|
2011-06-04 06:37:48 -04:00
|
|
|
|
|
|
|
for artifact, urlString in artifacts:
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' download %s...' % artifact)
|
2020-10-08 15:25:51 -04:00
|
|
|
scriptutil.download(artifact, urlString, tmpDir, force_clean=FORCE_CLEAN)
|
2011-06-04 06:37:48 -04:00
|
|
|
verifyDigests(artifact, urlString, tmpDir)
|
|
|
|
|
2012-04-08 14:22:14 -04:00
|
|
|
if isSigned:
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' verify sig')
|
2012-04-08 14:22:14 -04:00
|
|
|
# Test sig (this is done with a clean brand-new GPG world)
|
2020-10-08 15:25:51 -04:00
|
|
|
scriptutil.download(artifact + '.asc', urlString + '.asc', tmpDir, force_clean=FORCE_CLEAN)
|
2012-04-08 14:22:14 -04:00
|
|
|
sigFile = '%s/%s.asc' % (tmpDir, artifact)
|
|
|
|
artifactFile = '%s/%s' % (tmpDir, artifact)
|
2021-10-13 09:24:14 -04:00
|
|
|
logFile = '%s/lucene.%s.gpg.verify.log' % (tmpDir, artifact)
|
|
|
|
run('gpg --homedir %s --display-charset utf-8 --verify %s %s' % (gpgHomeDir, sigFile, artifactFile),
|
2012-04-08 14:22:14 -04:00
|
|
|
logFile)
|
2014-12-24 00:48:58 -05:00
|
|
|
# Forward any GPG warnings, except the expected one (since it's a clean world)
|
2021-10-13 09:24:14 -04:00
|
|
|
with open(logFile) as f:
|
|
|
|
print("File: %s" % logFile)
|
|
|
|
for line in f.readlines():
|
|
|
|
if line.lower().find('warning') != -1 \
|
|
|
|
and line.find('WARNING: This key is not certified with a trusted signature') == -1:
|
|
|
|
print(' GPG: %s' % line.strip())
|
2011-11-21 08:54:41 -05:00
|
|
|
|
2012-04-08 14:22:14 -04:00
|
|
|
# Test trust (this is done with the real users config)
|
|
|
|
run('gpg --import %s' % (keysFile),
|
2021-10-13 09:24:14 -04:00
|
|
|
'%s/lucene.gpg.trust.import.log' % tmpDir)
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' verify trust')
|
2021-10-13 09:24:14 -04:00
|
|
|
logFile = '%s/lucene.%s.gpg.trust.log' % (tmpDir, artifact)
|
2021-10-19 15:24:06 -04:00
|
|
|
run('gpg --display-charset utf-8 --verify %s %s' % (sigFile, artifactFile), logFile)
|
2012-04-08 14:22:14 -04:00
|
|
|
# Forward any GPG warnings:
|
2021-10-13 09:24:14 -04:00
|
|
|
with open(logFile) as f:
|
|
|
|
for line in f.readlines():
|
|
|
|
if line.lower().find('warning') != -1:
|
|
|
|
print(' GPG: %s' % line.strip())
|
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
def testChanges(version, changesURLString):
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' check changes HTML...')
|
2011-06-04 06:37:48 -04:00
|
|
|
changesURL = None
|
|
|
|
for text, subURL in getDirEntries(changesURLString):
|
|
|
|
if text == 'Changes.html':
|
|
|
|
changesURL = subURL
|
|
|
|
|
|
|
|
if changesURL is None:
|
|
|
|
raise RuntimeError('did not see Changes.html link from %s' % changesURLString)
|
|
|
|
|
|
|
|
s = load(changesURL)
|
2021-10-13 09:24:14 -04:00
|
|
|
checkChangesContent(s, version, changesURL, True)
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
|
|
|
def testChangesText(dir, version):
|
2011-06-28 16:51:05 -04:00
|
|
|
"Checks all CHANGES.txt under this dir."
|
|
|
|
for root, dirs, files in os.walk(dir):
|
|
|
|
|
|
|
|
# NOTE: O(N) but N should be smallish:
|
|
|
|
if 'CHANGES.txt' in files:
|
|
|
|
fullPath = '%s/CHANGES.txt' % root
|
2012-03-22 11:24:44 -04:00
|
|
|
#print 'CHECK %s' % fullPath
|
2021-10-13 09:24:14 -04:00
|
|
|
checkChangesContent(open(fullPath, encoding='UTF-8').read(), version, fullPath, False)
|
2013-04-19 13:38:46 -04:00
|
|
|
|
|
|
|
reChangesSectionHREF = re.compile('<a id="(.*?)".*?>(.*?)</a>', re.IGNORECASE)
|
2021-10-13 09:24:14 -04:00
|
|
|
reUnderbarNotDashHTML = re.compile(r'<li>(\s*(LUCENE)_\d\d\d\d+)')
|
|
|
|
reUnderbarNotDashTXT = re.compile(r'\s+((LUCENE)_\d\d\d\d+)', re.MULTILINE)
|
|
|
|
|
|
|
|
|
|
|
|
def checkChangesContent(s, version, name, isHTML):
|
2016-11-17 12:54:33 -05:00
|
|
|
currentVersionTuple = versionToTuple(version, name)
|
2011-06-28 16:51:05 -04:00
|
|
|
|
|
|
|
if isHTML and s.find('Release %s' % version) == -1:
|
|
|
|
raise RuntimeError('did not see "Release %s" in %s' % (version, name))
|
|
|
|
|
2014-05-19 16:17:58 -04:00
|
|
|
if isHTML:
|
|
|
|
r = reUnderbarNotDashHTML
|
|
|
|
else:
|
|
|
|
r = reUnderbarNotDashTXT
|
|
|
|
|
|
|
|
m = r.search(s)
|
|
|
|
if m is not None:
|
|
|
|
raise RuntimeError('incorrect issue (_ instead of -) in %s: %s' % (name, m.group(1)))
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2011-06-28 16:51:05 -04:00
|
|
|
if s.lower().find('not yet released') != -1:
|
|
|
|
raise RuntimeError('saw "not yet released" in %s' % name)
|
|
|
|
|
|
|
|
if not isHTML:
|
2021-10-13 09:24:14 -04:00
|
|
|
sub = 'Lucene %s' % version
|
2011-06-28 16:51:05 -04:00
|
|
|
if s.find(sub) == -1:
|
2012-06-08 06:18:09 -04:00
|
|
|
# benchmark never seems to include release info:
|
2011-06-28 16:51:05 -04:00
|
|
|
if name.find('/benchmark/') == -1:
|
|
|
|
raise RuntimeError('did not see "%s" in %s' % (sub, name))
|
2012-04-08 13:15:54 -04:00
|
|
|
|
2013-04-19 13:38:46 -04:00
|
|
|
if isHTML:
|
2016-11-17 12:54:33 -05:00
|
|
|
# Make sure that a section only appears once under each release,
|
|
|
|
# and that each release is not greater than the current version
|
2013-04-19 13:38:46 -04:00
|
|
|
seenIDs = set()
|
|
|
|
seenText = set()
|
|
|
|
|
|
|
|
release = None
|
|
|
|
for id, text in reChangesSectionHREF.findall(s):
|
|
|
|
if text.lower().startswith('release '):
|
|
|
|
release = text[8:].strip()
|
|
|
|
seenText.clear()
|
2016-11-17 12:54:33 -05:00
|
|
|
releaseTuple = versionToTuple(release, name)
|
|
|
|
if releaseTuple > currentVersionTuple:
|
|
|
|
raise RuntimeError('Future release %s is greater than %s in %s' % (release, version, name))
|
2013-04-19 13:38:46 -04:00
|
|
|
if id in seenIDs:
|
|
|
|
raise RuntimeError('%s has duplicate section "%s" under release "%s"' % (name, text, release))
|
|
|
|
seenIDs.add(id)
|
|
|
|
if text in seenText:
|
|
|
|
raise RuntimeError('%s has duplicate section "%s" under release "%s"' % (name, text, release))
|
|
|
|
seenText.add(text)
|
|
|
|
|
2016-11-17 12:54:33 -05:00
|
|
|
|
|
|
|
reVersion = re.compile(r'(\d+)\.(\d+)(?:\.(\d+))?\s*(-alpha|-beta|final|RC\d+)?\s*(?:\[.*\])?', re.IGNORECASE)
|
2021-10-13 09:24:14 -04:00
|
|
|
|
|
|
|
|
2016-11-17 12:54:33 -05:00
|
|
|
def versionToTuple(version, name):
|
|
|
|
versionMatch = reVersion.match(version)
|
|
|
|
if versionMatch is None:
|
|
|
|
raise RuntimeError('Version %s in %s cannot be parsed' % (version, name))
|
|
|
|
versionTuple = versionMatch.groups()
|
|
|
|
while versionTuple[-1] is None or versionTuple[-1] == '':
|
|
|
|
versionTuple = versionTuple[:-1]
|
|
|
|
if versionTuple[-1].lower() == '-alpha':
|
|
|
|
versionTuple = versionTuple[:-1] + ('0',)
|
|
|
|
elif versionTuple[-1].lower() == '-beta':
|
|
|
|
versionTuple = versionTuple[:-1] + ('1',)
|
|
|
|
elif versionTuple[-1].lower() == 'final':
|
|
|
|
versionTuple = versionTuple[:-2] + ('100',)
|
|
|
|
elif versionTuple[-1].lower()[:2] == 'rc':
|
|
|
|
versionTuple = versionTuple[:-2] + (versionTuple[-1][2:],)
|
2021-06-08 10:44:59 -04:00
|
|
|
return tuple(int(x) if x is not None and x.isnumeric() else x for x in versionTuple)
|
2016-11-17 12:54:33 -05:00
|
|
|
|
|
|
|
|
2012-04-08 13:15:54 -04:00
|
|
|
reUnixPath = re.compile(r'\b[a-zA-Z_]+=(?:"(?:\\"|[^"])*"' + '|(?:\\\\.|[^"\'\\s])*' + r"|'(?:\\'|[^'])*')" \
|
|
|
|
+ r'|(/(?:\\.|[^"\'\s])*)' \
|
|
|
|
+ r'|("/(?:\\.|[^"])*")' \
|
|
|
|
+ r"|('/(?:\\.|[^'])*')")
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2012-04-08 13:15:54 -04:00
|
|
|
def unix2win(matchobj):
|
|
|
|
if matchobj.group(1) is not None: return cygwinWindowsRoot + matchobj.group()
|
|
|
|
if matchobj.group(2) is not None: return '"%s%s' % (cygwinWindowsRoot, matchobj.group().lstrip('"'))
|
|
|
|
if matchobj.group(3) is not None: return "'%s%s" % (cygwinWindowsRoot, matchobj.group().lstrip("'"))
|
|
|
|
return matchobj.group()
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2012-04-08 13:15:54 -04:00
|
|
|
def cygwinifyPaths(command):
|
2021-10-13 09:24:14 -04:00
|
|
|
# The problem: Native Windows applications running under Cygwin can't
|
2012-04-08 13:15:54 -04:00
|
|
|
# handle Cygwin's Unix-style paths. However, environment variable
|
|
|
|
# values are automatically converted, so only paths outside of
|
|
|
|
# environment variable values should be converted to Windows paths.
|
|
|
|
# Assumption: all paths will be absolute.
|
2021-10-13 09:24:14 -04:00
|
|
|
if '; gradlew ' in command: command = reUnixPath.sub(unix2win, command)
|
2012-04-08 13:15:54 -04:00
|
|
|
return command
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2012-11-08 09:00:28 -05:00
|
|
|
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()
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
def run(command, logFile):
|
2012-04-08 13:15:54 -04:00
|
|
|
if cygwin: command = cygwinifyPaths(command)
|
2011-06-04 06:37:48 -04:00
|
|
|
if os.system('%s > %s 2>&1' % (command, logFile)):
|
2012-03-19 13:36:27 -04:00
|
|
|
logPath = os.path.abspath(logFile)
|
2012-09-26 11:55:27 -04:00
|
|
|
print('\ncommand "%s" failed:' % command)
|
2012-11-08 09:00:28 -05:00
|
|
|
printFileContents(logFile)
|
2012-03-19 13:36:27 -04:00
|
|
|
raise RuntimeError('command "%s" failed; see log file %s' % (command, logPath))
|
2021-10-13 09:24:14 -04:00
|
|
|
|
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
def verifyDigests(artifact, urlString, tmpDir):
|
2018-09-26 09:31:26 -04:00
|
|
|
print(' verify sha512 digest')
|
2018-03-28 03:10:41 -04:00
|
|
|
sha512Expected, t = load(urlString + '.sha512').strip().split()
|
|
|
|
if t != '*'+artifact:
|
|
|
|
raise RuntimeError('SHA512 %s.sha512 lists artifact %s but expected *%s' % (urlString, t, artifact))
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2018-03-28 03:10:41 -04:00
|
|
|
s512 = hashlib.sha512()
|
2012-08-03 17:49:24 -04:00
|
|
|
f = open('%s/%s' % (tmpDir, artifact), 'rb')
|
2011-06-04 06:37:48 -04:00
|
|
|
while True:
|
|
|
|
x = f.read(65536)
|
2012-08-03 17:49:24 -04:00
|
|
|
if len(x) == 0:
|
2011-06-04 06:37:48 -04:00
|
|
|
break
|
2018-03-28 03:10:41 -04:00
|
|
|
s512.update(x)
|
2011-06-04 06:37:48 -04:00
|
|
|
f.close()
|
2018-03-28 03:10:41 -04:00
|
|
|
sha512Actual = s512.hexdigest()
|
|
|
|
if sha512Actual != sha512Expected:
|
|
|
|
raise RuntimeError('SHA512 digest mismatch for %s: expected %s but got %s' % (artifact, sha512Expected, sha512Actual))
|
2012-03-19 13:36:27 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
def getDirEntries(urlString):
|
2012-08-07 16:58:46 -04:00
|
|
|
if urlString.startswith('file:/') and not urlString.startswith('file://'):
|
|
|
|
# stupid bogus ant URI
|
|
|
|
urlString = "file:///" + urlString[6:]
|
|
|
|
|
2012-04-08 14:22:14 -04:00
|
|
|
if urlString.startswith('file://'):
|
|
|
|
path = urlString[7:]
|
|
|
|
if path.endswith('/'):
|
|
|
|
path = path[:-1]
|
2012-09-22 21:28:16 -04:00
|
|
|
if cygwin: # Convert Windows path to Cygwin path
|
|
|
|
path = re.sub(r'^/([A-Za-z]):/', r'/cygdrive/\1/', path)
|
2012-04-08 14:22:14 -04:00
|
|
|
l = []
|
|
|
|
for ent in os.listdir(path):
|
|
|
|
entPath = '%s/%s' % (path, ent)
|
|
|
|
if os.path.isdir(entPath):
|
|
|
|
entPath += '/'
|
|
|
|
ent += '/'
|
|
|
|
l.append((ent, 'file://%s' % entPath))
|
|
|
|
l.sort()
|
|
|
|
return l
|
|
|
|
else:
|
|
|
|
links = getHREFs(urlString)
|
|
|
|
for i, (text, subURL) in enumerate(links):
|
|
|
|
if text == 'Parent Directory' or text == '..':
|
|
|
|
return links[(i+1):]
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
|
|
|
def unpackAndVerify(java, tmpDir, artifact, gitRevision, version, testArgs):
|
2011-06-04 06:37:48 -04:00
|
|
|
destDir = '%s/unpack' % tmpDir
|
|
|
|
if os.path.exists(destDir):
|
|
|
|
shutil.rmtree(destDir)
|
|
|
|
os.makedirs(destDir)
|
|
|
|
os.chdir(destDir)
|
2012-09-25 15:09:58 -04:00
|
|
|
print(' unpack %s...' % artifact)
|
2021-10-13 09:24:14 -04:00
|
|
|
unpackLogFile = '%s/lucene-unpack-%s.log' % (tmpDir, artifact)
|
2011-06-04 06:37:48 -04:00
|
|
|
if artifact.endswith('.tar.gz') or artifact.endswith('.tgz'):
|
|
|
|
run('tar xzf %s/%s' % (tmpDir, artifact), unpackLogFile)
|
|
|
|
elif artifact.endswith('.zip'):
|
|
|
|
run('unzip %s/%s' % (tmpDir, artifact), unpackLogFile)
|
|
|
|
|
|
|
|
# make sure it unpacks to proper subdir
|
|
|
|
l = os.listdir(destDir)
|
2021-10-13 09:24:14 -04:00
|
|
|
expected = 'lucene-%s' % version
|
2011-06-04 06:37:48 -04:00
|
|
|
if l != [expected]:
|
|
|
|
raise RuntimeError('unpack produced entries %s; expected only %s' % (l, expected))
|
|
|
|
|
|
|
|
unpackPath = '%s/%s' % (destDir, expected)
|
2021-10-13 09:24:14 -04:00
|
|
|
verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs)
|
2016-02-12 16:39:35 -05:00
|
|
|
return unpackPath
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2012-09-26 14:33:46 -04:00
|
|
|
LUCENE_NOTICE = None
|
|
|
|
LUCENE_LICENSE = None
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2021-10-19 15:24:06 -04:00
|
|
|
def is_in_list(in_folder, files, indent=4):
|
|
|
|
for fileName in files:
|
|
|
|
print("%sChecking %s" % (" "*indent, fileName))
|
|
|
|
found = False
|
|
|
|
for f in [fileName, fileName + '.txt', fileName + '.md']:
|
|
|
|
if f in in_folder:
|
|
|
|
in_folder.remove(f)
|
|
|
|
found = True
|
|
|
|
if not found:
|
|
|
|
raise RuntimeError('file "%s" is missing' % fileName)
|
|
|
|
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
|
2012-09-26 14:33:46 -04:00
|
|
|
global LUCENE_NOTICE
|
|
|
|
global LUCENE_LICENSE
|
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
os.chdir(unpackPath)
|
|
|
|
isSrc = artifact.find('-src') != -1
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2021-10-19 15:24:06 -04:00
|
|
|
# Check text files in release
|
|
|
|
print(" %s" % artifact)
|
|
|
|
in_root_folder = list(filter(lambda x: x[0] != '.', os.listdir(unpackPath)))
|
|
|
|
in_lucene_folder = []
|
2021-10-13 09:24:14 -04:00
|
|
|
if isSrc:
|
2021-10-19 15:24:06 -04:00
|
|
|
in_lucene_folder.extend(os.listdir(os.path.join(unpackPath, 'lucene')))
|
|
|
|
is_in_list(in_root_folder, ['LICENSE', 'NOTICE', 'README'])
|
2021-10-26 15:58:20 -04:00
|
|
|
is_in_list(in_lucene_folder, ['JRE_VERSION_MIGRATION', 'CHANGES', 'MIGRATE', 'SYSTEM_REQUIREMENTS'])
|
2021-10-19 15:24:06 -04:00
|
|
|
else:
|
|
|
|
is_in_list(in_root_folder, ['LICENSE', 'NOTICE', 'README', 'JRE_VERSION_MIGRATION', 'CHANGES',
|
|
|
|
'MIGRATE', 'SYSTEM_REQUIREMENTS'])
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
if LUCENE_NOTICE is None:
|
|
|
|
LUCENE_NOTICE = open('%s/NOTICE.txt' % unpackPath, encoding='UTF-8').read()
|
|
|
|
if LUCENE_LICENSE is None:
|
|
|
|
LUCENE_LICENSE = open('%s/LICENSE.txt' % unpackPath, encoding='UTF-8').read()
|
2012-09-26 14:33:46 -04:00
|
|
|
|
2021-10-19 15:24:06 -04:00
|
|
|
# if not isSrc:
|
|
|
|
# # TODO: we should add verifyModule/verifySubmodule (e.g. analysis) here and recurse through
|
|
|
|
# expectedJARs = ()
|
|
|
|
#
|
|
|
|
# for fileName in expectedJARs:
|
|
|
|
# fileName += '.jar'
|
|
|
|
# if fileName not in l:
|
|
|
|
# raise RuntimeError('lucene: file "%s" is missing from artifact %s' % (fileName, artifact))
|
|
|
|
# in_root_folder.remove(fileName)
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2024-02-28 05:49:39 -05:00
|
|
|
expected_folders = ['analysis', 'analysis.tests', 'backward-codecs', 'benchmark', 'benchmark-jmh', 'classification', 'codecs', 'core', 'core.tests',
|
2022-03-11 13:22:17 -05:00
|
|
|
'distribution.tests', 'demo', 'expressions', 'facet', 'grouping', 'highlighter', 'join',
|
2021-10-19 15:24:06 -04:00
|
|
|
'luke', 'memory', 'misc', 'monitor', 'queries', 'queryparser', 'replicator',
|
2022-03-11 13:22:17 -05:00
|
|
|
'sandbox', 'spatial-extras', 'spatial-test-fixtures', 'spatial3d', 'suggest', 'test-framework', 'licenses']
|
2021-10-13 09:24:14 -04:00
|
|
|
if isSrc:
|
2024-06-18 04:33:53 -04:00
|
|
|
expected_src_root_files = ['build.gradle', 'build-tools', 'CONTRIBUTING.md', 'dev-docs', 'dev-tools', 'gradle', 'gradlew',
|
2024-06-18 04:17:38 -04:00
|
|
|
'gradlew.bat', 'help', 'lucene', 'settings.gradle', 'versions.lock', 'versions.toml']
|
2021-10-19 15:24:06 -04:00
|
|
|
expected_src_lucene_files = ['build.gradle', 'documentation', 'distribution', 'dev-docs']
|
|
|
|
is_in_list(in_root_folder, expected_src_root_files)
|
|
|
|
is_in_list(in_lucene_folder, expected_folders)
|
|
|
|
is_in_list(in_lucene_folder, expected_src_lucene_files)
|
|
|
|
if len(in_lucene_folder) > 0:
|
|
|
|
raise RuntimeError('lucene: unexpected files/dirs in artifact %s lucene/ folder: %s' % (artifact, in_lucene_folder))
|
|
|
|
else:
|
2022-03-11 13:22:17 -05:00
|
|
|
is_in_list(in_root_folder, ['bin', 'docs', 'licenses', 'modules', 'modules-thirdparty', 'modules-test-framework'])
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2021-10-19 15:24:06 -04:00
|
|
|
if len(in_root_folder) > 0:
|
|
|
|
raise RuntimeError('lucene: unexpected files/dirs in artifact %s: %s' % (artifact, in_root_folder))
|
2011-06-04 06:37:48 -04:00
|
|
|
|
|
|
|
if isSrc:
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' make sure no JARs/WARs in src dist...')
|
2012-04-06 09:33:54 -04:00
|
|
|
lines = os.popen('find . -name \\*.jar').readlines()
|
|
|
|
if len(lines) != 0:
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' FAILED:')
|
2012-04-06 09:33:54 -04:00
|
|
|
for line in lines:
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' %s' % line.strip())
|
2012-04-06 09:33:54 -04:00
|
|
|
raise RuntimeError('source release has JARs...')
|
|
|
|
lines = os.popen('find . -name \\*.war').readlines()
|
|
|
|
if len(lines) != 0:
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' FAILED:')
|
2012-04-06 09:33:54 -04:00
|
|
|
for line in lines:
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' %s' % line.strip())
|
2012-04-06 09:33:54 -04:00
|
|
|
raise RuntimeError('source release has WARs...')
|
|
|
|
|
2021-10-19 15:24:06 -04:00
|
|
|
validateCmd = './gradlew --no-daemon check -p lucene/documentation'
|
2017-04-28 09:58:02 -04:00
|
|
|
print(' run "%s"' % validateCmd)
|
2024-02-27 07:12:20 -05:00
|
|
|
java.run_java(validateCmd, '%s/validate.log' % unpackPath)
|
|
|
|
|
|
|
|
print(" run tests w/ Java %s and testArgs='%s'..." % (BASE_JAVA_VERSION, testArgs))
|
|
|
|
java.run_java('./gradlew --no-daemon test %s' % testArgs, '%s/test.log' % unpackPath)
|
|
|
|
print(" compile jars w/ Java %s" % BASE_JAVA_VERSION)
|
|
|
|
java.run_java('./gradlew --no-daemon jar -Dversion.release=%s' % version, '%s/compile.log' % unpackPath)
|
|
|
|
testDemo(java.run_java, isSrc, version, BASE_JAVA_VERSION)
|
|
|
|
|
|
|
|
if java.run_alt_javas:
|
|
|
|
for run_alt_java, alt_java_version in zip(java.run_alt_javas, java.alt_java_versions):
|
|
|
|
print(" run tests w/ Java %s and testArgs='%s'..." % (alt_java_version, testArgs))
|
|
|
|
run_alt_java('./gradlew --no-daemon test %s' % testArgs, '%s/test.log' % unpackPath)
|
|
|
|
print(" compile jars w/ Java %s" % alt_java_version)
|
|
|
|
run_alt_java('./gradlew --no-daemon jar -Dversion.release=%s' % version, '%s/compile.log' % unpackPath)
|
|
|
|
testDemo(run_alt_java, isSrc, version, alt_java_version)
|
2018-02-09 12:45:10 -05:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
print(' confirm all releases have coverage in TestBackwardsCompatibility')
|
|
|
|
confirmAllReleasesAreTestedForBackCompat(version, unpackPath)
|
2012-04-06 09:33:54 -04:00
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
else:
|
2012-09-26 10:51:36 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
checkAllJARs(os.getcwd(), gitRevision, version)
|
2014-09-11 08:55:42 -04:00
|
|
|
|
2024-02-27 07:12:20 -05:00
|
|
|
testDemo(java.run_java, isSrc, version, BASE_JAVA_VERSION)
|
|
|
|
if java.run_alt_javas:
|
|
|
|
for run_alt_java, alt_java_version in zip(java.run_alt_javas, java.alt_java_versions):
|
|
|
|
testDemo(run_alt_java, isSrc, version, alt_java_version)
|
2014-08-30 11:48:16 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
testChangesText('.', version)
|
2014-10-31 21:22:01 -04:00
|
|
|
|
2014-11-18 15:30:37 -05:00
|
|
|
|
2014-08-30 11:48:16 -04:00
|
|
|
def testDemo(run_java, isSrc, version, jdk):
|
2012-10-27 13:42:45 -04:00
|
|
|
if os.path.exists('index'):
|
2012-10-26 00:53:34 -04:00
|
|
|
shutil.rmtree('index') # nuke any index from any previous iteration
|
|
|
|
|
|
|
|
print(' test demo with %s...' % jdk)
|
2012-04-08 13:15:54 -04:00
|
|
|
sep = ';' if cygwin else ':'
|
2011-06-04 06:37:48 -04:00
|
|
|
if isSrc:
|
2021-10-31 04:25:08 -04:00
|
|
|
# For source release, use the classpath for each module.
|
2021-10-19 15:24:06 -04:00
|
|
|
classPath = ['lucene/core/build/libs/lucene-core-%s.jar' % version,
|
|
|
|
'lucene/demo/build/libs/lucene-demo-%s.jar' % version,
|
|
|
|
'lucene/analysis/common/build/libs/lucene-analyzers-common-%s.jar' % version,
|
|
|
|
'lucene/queryparser/build/libs/lucene-queryparser-%s.jar' % version]
|
|
|
|
cp = sep.join(classPath)
|
|
|
|
docsDir = 'lucene/core/src'
|
2021-10-31 04:25:08 -04:00
|
|
|
checkIndexCmd = 'java -ea -cp "%s" org.apache.lucene.index.CheckIndex index' % cp
|
|
|
|
indexFilesCmd = 'java -cp "%s" -Dsmoketester=true org.apache.lucene.demo.IndexFiles -index index -docs %s' % (cp, docsDir)
|
|
|
|
searchFilesCmd = 'java -cp "%s" org.apache.lucene.demo.SearchFiles -index index -query lucene' % cp
|
2011-06-04 06:37:48 -04:00
|
|
|
else:
|
2022-03-11 13:22:17 -05:00
|
|
|
# For binary release, set up module path.
|
|
|
|
cp = "--module-path %s" % (sep.join(["modules", "modules-thirdparty"]))
|
2011-06-04 06:37:48 -04:00
|
|
|
docsDir = 'docs'
|
2021-12-01 03:59:15 -05:00
|
|
|
checkIndexCmd = 'java -ea %s --module org.apache.lucene.core/org.apache.lucene.index.CheckIndex index' % cp
|
|
|
|
indexFilesCmd = 'java -Dsmoketester=true %s --module org.apache.lucene.demo/org.apache.lucene.demo.IndexFiles -index index -docs %s' % (cp, docsDir)
|
|
|
|
searchFilesCmd = 'java %s --module org.apache.lucene.demo/org.apache.lucene.demo.SearchFiles -index index -query lucene' % cp
|
2024-02-27 07:12:20 -05:00
|
|
|
|
2021-10-31 04:25:08 -04:00
|
|
|
run_java(indexFilesCmd, 'index.log')
|
|
|
|
run_java(searchFilesCmd, 'search.log')
|
2011-06-04 06:37:48 -04:00
|
|
|
reMatchingDocs = re.compile('(\d+) total matching documents')
|
2012-08-03 17:49:24 -04:00
|
|
|
m = reMatchingDocs.search(open('search.log', encoding='UTF-8').read())
|
2011-06-04 06:37:48 -04:00
|
|
|
if m is None:
|
|
|
|
raise RuntimeError('lucene demo\'s SearchFiles found no results')
|
|
|
|
else:
|
|
|
|
numHits = int(m.group(1))
|
|
|
|
if numHits < 100:
|
|
|
|
raise RuntimeError('lucene demo\'s SearchFiles found too few results: %s' % numHits)
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' got %d hits for query "lucene"' % numHits)
|
2021-10-31 04:25:08 -04:00
|
|
|
|
2014-07-28 15:48:09 -04:00
|
|
|
print(' checkindex with %s...' % jdk)
|
2021-10-31 04:25:08 -04:00
|
|
|
run_java(checkIndexCmd, 'checkindex.log')
|
2014-07-28 15:48:09 -04:00
|
|
|
s = open('checkindex.log').read()
|
|
|
|
m = re.search(r'^\s+version=(.*?)$', s, re.MULTILINE)
|
|
|
|
if m is None:
|
|
|
|
raise RuntimeError('unable to locate version=NNN output from CheckIndex; see checkindex.log')
|
|
|
|
actualVersion = m.group(1)
|
|
|
|
if removeTrailingZeros(actualVersion) != removeTrailingZeros(version):
|
|
|
|
raise RuntimeError('wrong version from CheckIndex: got "%s" but expected "%s"' % (actualVersion, version))
|
2012-03-19 13:36:27 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2014-07-28 15:48:09 -04:00
|
|
|
def removeTrailingZeros(version):
|
|
|
|
return re.sub(r'(\.0)*$', '', version)
|
2012-03-19 13:36:27 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
|
|
|
def checkMaven(baseURL, tmpDir, gitRevision, version, isSigned, keysFile):
|
2013-10-11 12:58:36 -04:00
|
|
|
print(' download artifacts')
|
2021-10-13 09:24:14 -04:00
|
|
|
artifacts = []
|
|
|
|
artifactsURL = '%s/lucene/maven/org/apache/lucene/' % baseURL
|
|
|
|
targetDir = '%s/maven/org/apache/lucene' % tmpDir
|
|
|
|
if not os.path.exists(targetDir):
|
|
|
|
os.makedirs(targetDir)
|
|
|
|
crawl(artifacts, artifactsURL, targetDir)
|
2012-08-03 17:18:14 -04:00
|
|
|
print()
|
2012-03-19 13:36:27 -04:00
|
|
|
verifyPOMperBinaryArtifact(artifacts, version)
|
|
|
|
verifyMavenDigests(artifacts)
|
2013-10-09 13:57:31 -04:00
|
|
|
checkJavadocAndSourceArtifacts(artifacts, version)
|
2012-03-19 13:36:27 -04:00
|
|
|
verifyDeployedPOMsCoordinates(artifacts, version)
|
2012-04-08 14:22:14 -04:00
|
|
|
if isSigned:
|
2021-10-13 09:24:14 -04:00
|
|
|
verifyMavenSigs(tmpDir, artifacts, keysFile)
|
2012-03-19 13:36:27 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
distFiles = getBinaryDistFiles(tmpDir, version, baseURL)
|
2013-10-11 12:58:36 -04:00
|
|
|
checkIdenticalMavenArtifacts(distFiles, artifacts, version)
|
2012-03-19 13:36:27 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
checkAllJARs('%s/maven/org/apache/lucene' % tmpDir, gitRevision, version)
|
|
|
|
|
|
|
|
|
|
|
|
def getBinaryDistFiles(tmpDir, version, baseURL):
|
|
|
|
distribution = 'lucene-%s.tgz' % version
|
2013-10-11 12:58:36 -04:00
|
|
|
if not os.path.exists('%s/%s' % (tmpDir, distribution)):
|
2021-10-13 09:24:14 -04:00
|
|
|
distURL = '%s/lucene/%s' % (baseURL, distribution)
|
2013-10-11 12:58:36 -04:00
|
|
|
print(' download %s...' % distribution, end=' ')
|
2020-10-08 15:25:51 -04:00
|
|
|
scriptutil.download(distribution, distURL, tmpDir, force_clean=FORCE_CLEAN)
|
2021-10-13 09:24:14 -04:00
|
|
|
destDir = '%s/unpack-lucene-getBinaryDistFiles' % tmpDir
|
2013-10-11 12:58:36 -04:00
|
|
|
if os.path.exists(destDir):
|
|
|
|
shutil.rmtree(destDir)
|
|
|
|
os.makedirs(destDir)
|
|
|
|
os.chdir(destDir)
|
|
|
|
print(' unpack %s...' % distribution)
|
|
|
|
unpackLogFile = '%s/unpack-%s-getBinaryDistFiles.log' % (tmpDir, distribution)
|
|
|
|
run('tar xzf %s/%s' % (tmpDir, distribution), unpackLogFile)
|
|
|
|
distributionFiles = []
|
|
|
|
for root, dirs, files in os.walk(destDir):
|
|
|
|
distributionFiles.extend([os.path.join(root, file) for file in files])
|
2012-03-19 13:36:27 -04:00
|
|
|
return distributionFiles
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2013-10-09 13:57:31 -04:00
|
|
|
def checkJavadocAndSourceArtifacts(artifacts, version):
|
2013-10-11 12:58:36 -04:00
|
|
|
print(' check for javadoc and sources artifacts...')
|
2021-10-13 09:24:14 -04:00
|
|
|
for artifact in artifacts:
|
|
|
|
if artifact.endswith(version + '.jar'):
|
|
|
|
javadocJar = artifact[:-4] + '-javadoc.jar'
|
|
|
|
if javadocJar not in artifacts:
|
|
|
|
raise RuntimeError('missing: %s' % javadocJar)
|
|
|
|
sourcesJar = artifact[:-4] + '-sources.jar'
|
|
|
|
if sourcesJar not in artifacts:
|
|
|
|
raise RuntimeError('missing: %s' % sourcesJar)
|
|
|
|
|
2012-03-19 13:36:27 -04:00
|
|
|
|
2013-04-26 08:03:13 -04:00
|
|
|
def getZipFileEntries(fileName):
|
|
|
|
entries = []
|
|
|
|
with zipfile.ZipFile(fileName) as zf:
|
|
|
|
for zi in zf.infolist():
|
2013-04-26 16:24:22 -04:00
|
|
|
entries.append(zi.filename)
|
2013-04-26 08:03:13 -04:00
|
|
|
# Sort by name:
|
|
|
|
entries.sort()
|
|
|
|
return entries
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2013-10-11 12:58:36 -04:00
|
|
|
def checkIdenticalMavenArtifacts(distFiles, artifacts, version):
|
|
|
|
print(' verify that Maven artifacts are same as in the binary distribution...')
|
2021-10-13 09:24:14 -04:00
|
|
|
reJarWar = re.compile(r'%s\.[wj]ar$' % version) # exclude *-javadoc.jar and *-sources.jar
|
|
|
|
distFilenames = dict()
|
|
|
|
for file in distFiles:
|
|
|
|
baseName = os.path.basename(file)
|
|
|
|
distFilenames[baseName] = file
|
|
|
|
for artifact in artifacts:
|
|
|
|
if reJarWar.search(artifact):
|
|
|
|
artifactFilename = os.path.basename(artifact)
|
|
|
|
if artifactFilename not in distFilenames:
|
|
|
|
raise RuntimeError('Maven artifact %s is not present in lucene binary distribution' % artifact)
|
|
|
|
else:
|
|
|
|
identical = filecmp.cmp(artifact, distFilenames[artifactFilename], shallow=False)
|
|
|
|
if not identical:
|
|
|
|
raise RuntimeError('Maven artifact %s is not identical to %s in lucene binary distribution'
|
|
|
|
% (artifact, distFilenames[artifactFilename]))
|
|
|
|
|
2012-03-19 13:36:27 -04:00
|
|
|
|
|
|
|
def verifyMavenDigests(artifacts):
|
2018-04-04 20:18:04 -04:00
|
|
|
print(" verify Maven artifacts' md5/sha1 digests...")
|
2012-03-19 13:36:27 -04:00
|
|
|
reJarWarPom = re.compile(r'\.(?:[wj]ar|pom)$')
|
2021-10-13 09:24:14 -04:00
|
|
|
for artifactFile in [a for a in artifacts if reJarWarPom.search(a)]:
|
|
|
|
if artifactFile + '.md5' not in artifacts:
|
|
|
|
raise RuntimeError('missing: MD5 digest for %s' % artifactFile)
|
|
|
|
if artifactFile + '.sha1' not in artifacts:
|
|
|
|
raise RuntimeError('missing: SHA1 digest for %s' % artifactFile)
|
|
|
|
with open(artifactFile + '.md5', encoding='UTF-8') as md5File:
|
|
|
|
md5Expected = md5File.read().strip()
|
|
|
|
with open(artifactFile + '.sha1', encoding='UTF-8') as sha1File:
|
|
|
|
sha1Expected = sha1File.read().strip()
|
|
|
|
md5 = hashlib.md5()
|
|
|
|
sha1 = hashlib.sha1()
|
|
|
|
inputFile = open(artifactFile, 'rb')
|
|
|
|
while True:
|
|
|
|
bytes = inputFile.read(65536)
|
|
|
|
if len(bytes) == 0:
|
|
|
|
break
|
|
|
|
md5.update(bytes)
|
|
|
|
sha1.update(bytes)
|
|
|
|
inputFile.close()
|
|
|
|
md5Actual = md5.hexdigest()
|
|
|
|
sha1Actual = sha1.hexdigest()
|
|
|
|
if md5Actual != md5Expected:
|
|
|
|
raise RuntimeError('MD5 digest mismatch for %s: expected %s but got %s'
|
|
|
|
% (artifactFile, md5Expected, md5Actual))
|
|
|
|
if sha1Actual != sha1Expected:
|
|
|
|
raise RuntimeError('SHA1 digest mismatch for %s: expected %s but got %s'
|
|
|
|
% (artifactFile, sha1Expected, sha1Actual))
|
|
|
|
|
2012-03-19 13:36:27 -04:00
|
|
|
|
|
|
|
def getPOMcoordinate(treeRoot):
|
|
|
|
namespace = '{http://maven.apache.org/POM/4.0.0}'
|
|
|
|
groupId = treeRoot.find('%sgroupId' % namespace)
|
|
|
|
if groupId is None:
|
|
|
|
groupId = treeRoot.find('{0}parent/{0}groupId'.format(namespace))
|
|
|
|
groupId = groupId.text.strip()
|
|
|
|
artifactId = treeRoot.find('%sartifactId' % namespace).text.strip()
|
|
|
|
version = treeRoot.find('%sversion' % namespace)
|
|
|
|
if version is None:
|
|
|
|
version = treeRoot.find('{0}parent/{0}version'.format(namespace))
|
|
|
|
version = version.text.strip()
|
|
|
|
packaging = treeRoot.find('%spackaging' % namespace)
|
|
|
|
packaging = 'jar' if packaging is None else packaging.text.strip()
|
|
|
|
return groupId, artifactId, packaging, version
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
|
|
|
def verifyMavenSigs(tmpDir, artifacts, keysFile):
|
2013-10-11 12:58:36 -04:00
|
|
|
print(' verify maven artifact sigs', end=' ')
|
2012-03-19 13:36:27 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
# Set up clean gpg world; import keys file:
|
|
|
|
gpgHomeDir = '%s/lucene.gpg' % tmpDir
|
|
|
|
if os.path.exists(gpgHomeDir):
|
|
|
|
shutil.rmtree(gpgHomeDir)
|
|
|
|
os.makedirs(gpgHomeDir, 0o700)
|
|
|
|
run('gpg --homedir %s --import %s' % (gpgHomeDir, keysFile),
|
|
|
|
'%s/lucene.gpg.import.log' % tmpDir)
|
|
|
|
|
|
|
|
reArtifacts = re.compile(r'\.(?:pom|[jw]ar)$')
|
|
|
|
for artifactFile in [a for a in artifacts if reArtifacts.search(a)]:
|
|
|
|
artifact = os.path.basename(artifactFile)
|
|
|
|
sigFile = '%s.asc' % artifactFile
|
|
|
|
# Test sig (this is done with a clean brand-new GPG world)
|
|
|
|
logFile = '%s/lucene.%s.gpg.verify.log' % (tmpDir, artifact)
|
2021-10-19 15:24:06 -04:00
|
|
|
run('gpg --display-charset utf-8 --homedir %s --verify %s %s' % (gpgHomeDir, sigFile, artifactFile),
|
2021-10-13 09:24:14 -04:00
|
|
|
logFile)
|
|
|
|
|
|
|
|
# Forward any GPG warnings, except the expected one (since it's a clean world)
|
|
|
|
print_warnings_in_file(logFile)
|
|
|
|
|
|
|
|
# Test trust (this is done with the real users config)
|
|
|
|
run('gpg --import %s' % keysFile,
|
|
|
|
'%s/lucene.gpg.trust.import.log' % tmpDir)
|
|
|
|
logFile = '%s/lucene.%s.gpg.trust.log' % (tmpDir, artifact)
|
2021-10-19 15:24:06 -04:00
|
|
|
run('gpg --display-charset utf-8 --verify %s %s' % (sigFile, artifactFile), logFile)
|
2021-10-13 09:24:14 -04:00
|
|
|
# Forward any GPG warnings:
|
|
|
|
print_warnings_in_file(logFile)
|
|
|
|
|
|
|
|
sys.stdout.write('.')
|
2012-08-03 17:18:14 -04:00
|
|
|
print()
|
2012-03-19 13:36:27 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
|
|
|
def print_warnings_in_file(file):
|
|
|
|
with open(file) as f:
|
|
|
|
for line in f.readlines():
|
|
|
|
if line.lower().find('warning') != -1 \
|
|
|
|
and line.find('WARNING: This key is not certified with a trusted signature') == -1 \
|
|
|
|
and line.find('WARNING: using insecure memory') == -1:
|
|
|
|
print(' GPG: %s' % line.strip())
|
|
|
|
|
|
|
|
|
2012-03-19 13:36:27 -04:00
|
|
|
def verifyPOMperBinaryArtifact(artifacts, version):
|
2013-10-11 12:58:36 -04:00
|
|
|
print(' verify that each binary artifact has a deployed POM...')
|
2012-03-19 13:36:27 -04:00
|
|
|
reBinaryJarWar = re.compile(r'%s\.[jw]ar$' % re.escape(version))
|
2021-10-13 09:24:14 -04:00
|
|
|
for artifact in [a for a in artifacts if reBinaryJarWar.search(a)]:
|
|
|
|
POM = artifact[:-4] + '.pom'
|
|
|
|
if POM not in artifacts:
|
|
|
|
raise RuntimeError('missing: POM for %s' % artifact)
|
|
|
|
|
2012-03-19 13:36:27 -04:00
|
|
|
|
|
|
|
def verifyDeployedPOMsCoordinates(artifacts, version):
|
|
|
|
"""
|
|
|
|
verify that each POM's coordinate (drawn from its content) matches
|
|
|
|
its filepath, and verify that the corresponding artifact exists.
|
|
|
|
"""
|
2013-10-11 12:58:36 -04:00
|
|
|
print(" verify deployed POMs' coordinates...")
|
2021-10-13 09:24:14 -04:00
|
|
|
for POM in [a for a in artifacts if a.endswith('.pom')]:
|
|
|
|
treeRoot = ET.parse(POM).getroot()
|
|
|
|
groupId, artifactId, packaging, POMversion = getPOMcoordinate(treeRoot)
|
|
|
|
POMpath = '%s/%s/%s/%s-%s.pom' \
|
|
|
|
% (groupId.replace('.', '/'), artifactId, version, artifactId, version)
|
|
|
|
if not POM.endswith(POMpath):
|
|
|
|
raise RuntimeError("Mismatch between POM coordinate %s:%s:%s and filepath: %s"
|
|
|
|
% (groupId, artifactId, POMversion, POM))
|
|
|
|
# Verify that the corresponding artifact exists
|
|
|
|
artifact = POM[:-3] + packaging
|
|
|
|
if artifact not in artifacts:
|
|
|
|
raise RuntimeError('Missing corresponding .%s artifact for POM %s' % (packaging, POM))
|
|
|
|
|
2012-03-19 13:36:27 -04:00
|
|
|
|
|
|
|
def crawl(downloadedFiles, urlString, targetDir, exclusions=set()):
|
|
|
|
for text, subURL in getDirEntries(urlString):
|
|
|
|
if text not in exclusions:
|
|
|
|
path = os.path.join(targetDir, text)
|
|
|
|
if text.endswith('/'):
|
|
|
|
if not os.path.exists(path):
|
|
|
|
os.makedirs(path)
|
|
|
|
crawl(downloadedFiles, subURL, path, exclusions)
|
|
|
|
else:
|
2012-09-26 14:33:46 -04:00
|
|
|
if not os.path.exists(path) or FORCE_CLEAN:
|
2020-10-08 15:25:51 -04:00
|
|
|
scriptutil.download(text, subURL, targetDir, quiet=True, force_clean=FORCE_CLEAN)
|
2012-03-19 13:36:27 -04:00
|
|
|
downloadedFiles.append(path)
|
|
|
|
sys.stdout.write('.')
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2024-02-27 07:12:20 -05:00
|
|
|
def make_java_config(parser, alt_java_homes):
|
|
|
|
def _make_runner(java_home, is_base_version=False):
|
2014-08-30 11:48:16 -04:00
|
|
|
if cygwin:
|
2016-11-08 05:42:35 -05:00
|
|
|
java_home = subprocess.check_output('cygpath -u "%s"' % java_home, shell=True).decode('utf-8').strip()
|
2014-08-30 11:48:16 -04:00
|
|
|
cmd_prefix = 'export JAVA_HOME="%s" PATH="%s/bin:$PATH" JAVACMD="%s/bin/java"' % \
|
|
|
|
(java_home, java_home, java_home)
|
|
|
|
s = subprocess.check_output('%s; java -version' % cmd_prefix,
|
|
|
|
shell=True, stderr=subprocess.STDOUT).decode('utf-8')
|
2024-02-27 07:12:20 -05:00
|
|
|
|
|
|
|
actual_version = re.search(r'version "([1-9][0-9]*)', s).group(1)
|
|
|
|
print('Java %s JAVA_HOME=%s' % (actual_version, java_home))
|
|
|
|
|
|
|
|
# validate Java version
|
|
|
|
if is_base_version:
|
|
|
|
if BASE_JAVA_VERSION != actual_version:
|
|
|
|
parser.error('got wrong base version for java %s:\n%s' % (BASE_JAVA_VERSION, s))
|
|
|
|
else:
|
|
|
|
if int(actual_version) < int(BASE_JAVA_VERSION):
|
|
|
|
parser.error('got wrong version for java %s, less than base version %s:\n%s' % (actual_version, BASE_JAVA_VERSION, s))
|
|
|
|
|
2014-08-30 11:48:16 -04:00
|
|
|
def run_java(cmd, logfile):
|
|
|
|
run('%s; %s' % (cmd_prefix, cmd), logfile)
|
|
|
|
|
2024-02-27 07:12:20 -05:00
|
|
|
return run_java, actual_version
|
|
|
|
|
|
|
|
java_home = os.environ.get('JAVA_HOME')
|
|
|
|
if java_home is None:
|
|
|
|
parser.error('JAVA_HOME must be set')
|
|
|
|
run_java, _ = _make_runner(java_home, True)
|
|
|
|
run_alt_javas = []
|
|
|
|
alt_java_versions = []
|
|
|
|
if alt_java_homes:
|
|
|
|
for alt_java_home in alt_java_homes:
|
|
|
|
run_alt_java, version = _make_runner(alt_java_home)
|
|
|
|
run_alt_javas.append(run_alt_java)
|
|
|
|
alt_java_versions.append(version)
|
|
|
|
|
|
|
|
jc = namedtuple('JavaConfig', 'run_java java_home run_alt_javas alt_java_homes alt_java_versions')
|
|
|
|
return jc(run_java, java_home, run_alt_javas, alt_java_homes, alt_java_versions)
|
2014-08-30 11:48:16 -04:00
|
|
|
|
2014-08-28 04:01:50 -04:00
|
|
|
version_re = re.compile(r'(\d+\.\d+\.\d+(-ALPHA|-BETA)?)')
|
2021-11-01 04:29:06 -04:00
|
|
|
revision_re = re.compile(r'rev-([a-f\d]+)')
|
2024-02-27 07:12:20 -05:00
|
|
|
|
2014-08-28 04:01:50 -04:00
|
|
|
def parse_config():
|
|
|
|
epilogue = textwrap.dedent('''
|
|
|
|
Example usage:
|
2021-11-01 04:29:06 -04:00
|
|
|
python3 -u dev-tools/scripts/smokeTestRelease.py https://dist.apache.org/repos/dist/dev/lucene/lucene-9.0.0-RC1-rev-c7510a0...
|
2014-08-28 04:01:50 -04:00
|
|
|
''')
|
|
|
|
description = 'Utility to test a release.'
|
|
|
|
parser = argparse.ArgumentParser(description=description, epilog=epilogue,
|
|
|
|
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
|
|
parser.add_argument('--tmp-dir', metavar='PATH',
|
|
|
|
help='Temporary directory to test inside, defaults to /tmp/smoke_lucene_$version_$revision')
|
|
|
|
parser.add_argument('--not-signed', dest='is_signed', action='store_false', default=True,
|
|
|
|
help='Indicates the release is not signed')
|
2018-09-11 16:27:14 -04:00
|
|
|
parser.add_argument('--local-keys', metavar='PATH',
|
|
|
|
help='Uses local KEYS file instead of fetching from https://archive.apache.org/dist/lucene/KEYS')
|
2014-08-28 04:01:50 -04:00
|
|
|
parser.add_argument('--revision',
|
2016-02-11 15:19:43 -05:00
|
|
|
help='GIT revision number that release was built with, defaults to that in URL')
|
2014-08-28 04:01:50 -04:00
|
|
|
parser.add_argument('--version', metavar='X.Y.Z(-ALPHA|-BETA)?',
|
|
|
|
help='Version of the release, defaults to that in URL')
|
2024-02-27 07:12:20 -05:00
|
|
|
parser.add_argument('--test-alternative-java', action='append',
|
|
|
|
help='Path to alternative Java home directory, to run tests with if specified')
|
2019-06-11 04:17:10 -04:00
|
|
|
parser.add_argument('--download-only', action='store_true', default=False,
|
|
|
|
help='Only perform download and sha hash check steps')
|
2014-08-28 04:01:50 -04:00
|
|
|
parser.add_argument('url', help='Url pointing to release to test')
|
2014-08-30 11:48:16 -04:00
|
|
|
parser.add_argument('test_args', nargs=argparse.REMAINDER,
|
2021-10-13 09:24:14 -04:00
|
|
|
help='Arguments to pass to gradle for testing, e.g. -Dwhat=ever.')
|
2014-08-28 04:01:50 -04:00
|
|
|
c = parser.parse_args()
|
|
|
|
|
|
|
|
if c.version is not None:
|
|
|
|
if not version_re.match(c.version):
|
|
|
|
parser.error('version "%s" does not match format X.Y.Z[-ALPHA|-BETA]' % c.version)
|
|
|
|
else:
|
|
|
|
version_match = version_re.search(c.url)
|
|
|
|
if version_match is None:
|
|
|
|
parser.error('Could not find version in URL')
|
|
|
|
c.version = version_match.group(1)
|
|
|
|
|
|
|
|
if c.revision is None:
|
|
|
|
revision_match = revision_re.search(c.url)
|
|
|
|
if revision_match is None:
|
|
|
|
parser.error('Could not find revision in URL')
|
|
|
|
c.revision = revision_match.group(1)
|
2016-02-11 15:19:43 -05:00
|
|
|
print('Revision: %s' % c.revision)
|
|
|
|
|
2018-09-11 16:27:14 -04:00
|
|
|
if c.local_keys is not None and not os.path.exists(c.local_keys):
|
|
|
|
parser.error('Local KEYS file "%s" not found' % c.local_keys)
|
|
|
|
|
2024-02-27 07:12:20 -05:00
|
|
|
c.java = make_java_config(parser, c.test_alternative_java)
|
2014-08-28 04:01:50 -04:00
|
|
|
|
|
|
|
if c.tmp_dir:
|
|
|
|
c.tmp_dir = os.path.abspath(c.tmp_dir)
|
|
|
|
else:
|
|
|
|
tmp = '/tmp/smoke_lucene_%s_%s' % (c.version, c.revision)
|
|
|
|
c.tmp_dir = tmp
|
|
|
|
i = 1
|
|
|
|
while os.path.exists(c.tmp_dir):
|
|
|
|
c.tmp_dir = tmp + '_%d' % i
|
|
|
|
i += 1
|
2012-09-25 17:37:31 -04:00
|
|
|
|
2014-08-28 04:01:50 -04:00
|
|
|
return c
|
2011-06-04 06:37:48 -04:00
|
|
|
|
2014-09-11 08:55:42 -04:00
|
|
|
reVersion1 = re.compile(r'\>(\d+)\.(\d+)\.(\d+)(-alpha|-beta)?/\<', re.IGNORECASE)
|
|
|
|
reVersion2 = re.compile(r'-(\d+)\.(\d+)\.(\d+)(-alpha|-beta)?\.', re.IGNORECASE)
|
|
|
|
|
|
|
|
def getAllLuceneReleases():
|
2015-02-10 13:09:53 -05:00
|
|
|
s = load('https://archive.apache.org/dist/lucene/java')
|
2014-09-11 08:55:42 -04:00
|
|
|
|
|
|
|
releases = set()
|
|
|
|
for r in reVersion1, reVersion2:
|
|
|
|
for tup in r.findall(s):
|
|
|
|
if tup[-1].lower() == '-alpha':
|
|
|
|
tup = tup[:3] + ('0',)
|
|
|
|
elif tup[-1].lower() == '-beta':
|
|
|
|
tup = tup[:3] + ('1',)
|
|
|
|
elif tup[-1] == '':
|
|
|
|
tup = tup[:3]
|
|
|
|
else:
|
|
|
|
raise RuntimeError('failed to parse version: %s' % tup[-1])
|
|
|
|
releases.add(tuple(int(x) for x in tup))
|
|
|
|
|
|
|
|
l = list(releases)
|
|
|
|
l.sort()
|
|
|
|
return l
|
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2016-01-10 14:42:37 -05:00
|
|
|
def confirmAllReleasesAreTestedForBackCompat(smokeVersion, unpackPath):
|
2014-09-11 08:55:42 -04:00
|
|
|
|
|
|
|
print(' find all past Lucene releases...')
|
|
|
|
allReleases = getAllLuceneReleases()
|
2014-09-25 05:56:14 -04:00
|
|
|
#for tup in allReleases:
|
|
|
|
# print(' %s' % '.'.join(str(x) for x in tup))
|
2014-09-11 08:55:42 -04:00
|
|
|
|
2022-05-20 07:20:57 -04:00
|
|
|
testedIndicesPaths = glob.glob('%s/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/*-cfs.zip' % unpackPath)
|
2014-09-11 08:55:42 -04:00
|
|
|
testedIndices = set()
|
|
|
|
|
2022-05-20 07:20:57 -04:00
|
|
|
reIndexName = re.compile(r'^[^.]*.(.*?)-cfs.zip')
|
|
|
|
for name in testedIndicesPaths:
|
|
|
|
basename = os.path.basename(name)
|
|
|
|
version = reIndexName.fullmatch(basename).group(1)
|
|
|
|
tup = tuple(version.split('.'))
|
2015-05-29 10:17:04 -04:00
|
|
|
if len(tup) == 3:
|
|
|
|
# ok
|
|
|
|
tup = tuple(int(x) for x in tup)
|
|
|
|
elif tup == ('4', '0', '0', '1'):
|
|
|
|
# CONFUSING: this is the 4.0.0-alpha index??
|
|
|
|
tup = 4, 0, 0, 0
|
|
|
|
elif tup == ('4', '0', '0', '2'):
|
|
|
|
# CONFUSING: this is the 4.0.0-beta index??
|
|
|
|
tup = 4, 0, 0, 1
|
2022-05-20 07:20:57 -04:00
|
|
|
elif basename == 'unsupported.5x-with-4x-segments-cfs.zip':
|
2015-05-29 10:17:04 -04:00
|
|
|
# Mixed version test case; ignore it for our purposes because we only
|
|
|
|
# tally up the "tests single Lucene version" indices
|
|
|
|
continue
|
2022-05-20 07:20:57 -04:00
|
|
|
elif basename == 'unsupported.5.0.0.singlesegment-cfs.zip':
|
2016-03-07 10:38:04 -05:00
|
|
|
tup = 5, 0, 0
|
2015-05-29 10:17:04 -04:00
|
|
|
else:
|
|
|
|
raise RuntimeError('could not parse version %s' % name)
|
|
|
|
|
|
|
|
testedIndices.add(tup)
|
2014-09-11 08:55:42 -04:00
|
|
|
|
|
|
|
l = list(testedIndices)
|
|
|
|
l.sort()
|
|
|
|
if False:
|
|
|
|
for release in l:
|
|
|
|
print(' %s' % '.'.join(str(x) for x in release))
|
|
|
|
|
|
|
|
allReleases = set(allReleases)
|
|
|
|
|
|
|
|
for x in testedIndices:
|
|
|
|
if x not in allReleases:
|
|
|
|
# Curious: we test 1.9.0 index but it's not in the releases (I think it was pulled because of nasty bug?)
|
|
|
|
if x != (1, 9, 0):
|
|
|
|
raise RuntimeError('tested version=%s but it was not released?' % '.'.join(str(y) for y in x))
|
|
|
|
|
|
|
|
notTested = []
|
|
|
|
for x in allReleases:
|
|
|
|
if x not in testedIndices:
|
2016-01-10 14:42:37 -05:00
|
|
|
releaseVersion = '.'.join(str(y) for y in x)
|
|
|
|
if releaseVersion in ('1.4.3', '1.9.1', '2.3.1', '2.3.2'):
|
2014-09-11 08:55:42 -04:00
|
|
|
# Exempt the dark ages indices
|
|
|
|
continue
|
2016-01-10 14:42:37 -05:00
|
|
|
if x >= tuple(int(y) for y in smokeVersion.split('.')):
|
|
|
|
# Exempt versions not less than the one being smoke tested
|
|
|
|
print(' Backcompat testing not required for release %s because it\'s not less than %s'
|
|
|
|
% (releaseVersion, smokeVersion))
|
|
|
|
continue
|
2014-09-11 08:55:42 -04:00
|
|
|
notTested.append(x)
|
|
|
|
|
|
|
|
if len(notTested) > 0:
|
|
|
|
notTested.sort()
|
|
|
|
print('Releases that don\'t seem to be tested:')
|
|
|
|
failed = True
|
|
|
|
for x in notTested:
|
|
|
|
print(' %s' % '.'.join(str(y) for y in x))
|
|
|
|
raise RuntimeError('some releases are not tested by TestBackwardsCompatibility?')
|
|
|
|
else:
|
|
|
|
print(' success!')
|
|
|
|
|
2016-05-25 16:09:22 -04:00
|
|
|
|
2014-08-28 04:01:50 -04:00
|
|
|
def main():
|
|
|
|
c = parse_config()
|
2016-05-25 16:09:22 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
# Pick <major>.<minor> part of version and require script to be from same branch
|
|
|
|
scriptVersion = re.search(r'((\d+).(\d+)).(\d+)', scriptutil.find_current_version()).group(1).strip()
|
2016-05-25 16:09:22 -04:00
|
|
|
if not c.version.startswith(scriptVersion + '.'):
|
|
|
|
raise RuntimeError('smokeTestRelease.py for %s.X is incompatible with a %s release.' % (scriptVersion, c.version))
|
|
|
|
|
2014-08-28 04:01:50 -04:00
|
|
|
print('NOTE: output encoding is %s' % sys.stdout.encoding)
|
2019-06-11 04:17:10 -04:00
|
|
|
smokeTest(c.java, c.url, c.revision, c.version, c.tmp_dir, c.is_signed, c.local_keys, ' '.join(c.test_args),
|
|
|
|
downloadOnly=c.download_only)
|
2012-04-08 14:22:14 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2019-06-11 04:17:10 -04:00
|
|
|
def smokeTest(java, baseURL, gitRevision, version, tmpDir, isSigned, local_keys, testArgs, downloadOnly=False):
|
2013-04-21 09:26:54 -04:00
|
|
|
startTime = datetime.datetime.now()
|
2018-02-26 23:33:41 -05:00
|
|
|
|
2021-11-24 02:20:04 -05:00
|
|
|
# Tests annotated @Nightly are more resource-intensive but often cover
|
|
|
|
# important code paths. They're disabled by default to preserve a good
|
|
|
|
# developer experience, but we enable them for smoke tests where we want good
|
|
|
|
# coverage.
|
2022-01-14 07:51:16 -05:00
|
|
|
testArgs = '-Dtests.nightly=true %s' % testArgs
|
2021-11-24 02:20:04 -05:00
|
|
|
|
2022-05-17 20:26:06 -04:00
|
|
|
# We also enable GUI tests in smoke tests (LUCENE-10531)
|
|
|
|
testArgs = '-Dtests.gui=true %s' % testArgs
|
|
|
|
|
2012-09-26 14:33:46 -04:00
|
|
|
if FORCE_CLEAN:
|
2011-06-04 06:37:48 -04:00
|
|
|
if os.path.exists(tmpDir):
|
|
|
|
raise RuntimeError('temp dir %s exists; please remove first' % tmpDir)
|
2012-04-06 09:33:54 -04:00
|
|
|
|
|
|
|
if not os.path.exists(tmpDir):
|
2011-06-04 06:37:48 -04:00
|
|
|
os.makedirs(tmpDir)
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
lucenePath = None
|
2012-08-03 17:18:14 -04:00
|
|
|
print()
|
|
|
|
print('Load release URL "%s"...' % baseURL)
|
2012-04-08 14:22:14 -04:00
|
|
|
newBaseURL = unshortenURL(baseURL)
|
|
|
|
if newBaseURL != baseURL:
|
2012-08-03 17:18:14 -04:00
|
|
|
print(' unshortened: %s' % newBaseURL)
|
2012-04-08 14:22:14 -04:00
|
|
|
baseURL = newBaseURL
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
for text, subURL in getDirEntries(baseURL):
|
|
|
|
if text.lower().find('lucene') != -1:
|
|
|
|
lucenePath = subURL
|
|
|
|
|
|
|
|
if lucenePath is None:
|
|
|
|
raise RuntimeError('could not find lucene subdir')
|
|
|
|
|
2018-09-15 15:28:12 -04:00
|
|
|
print()
|
|
|
|
print('Get KEYS...')
|
|
|
|
if local_keys is not None:
|
|
|
|
print(" Using local KEYS file %s" % local_keys)
|
|
|
|
keysFile = local_keys
|
|
|
|
else:
|
|
|
|
keysFileURL = "https://archive.apache.org/dist/lucene/KEYS"
|
|
|
|
print(" Downloading online KEYS file %s" % keysFileURL)
|
2020-10-08 15:25:51 -04:00
|
|
|
scriptutil.download('KEYS', keysFileURL, tmpDir, force_clean=FORCE_CLEAN)
|
2018-09-15 15:28:12 -04:00
|
|
|
keysFile = '%s/KEYS' % (tmpDir)
|
|
|
|
|
2012-08-03 17:18:14 -04:00
|
|
|
print()
|
|
|
|
print('Test Lucene...')
|
2021-10-13 09:24:14 -04:00
|
|
|
checkSigs(lucenePath, version, tmpDir, isSigned, keysFile)
|
2019-06-11 04:17:10 -04:00
|
|
|
if not downloadOnly:
|
2021-10-26 15:21:30 -04:00
|
|
|
unpackAndVerify(java, tmpDir, 'lucene-%s.tgz' % version, gitRevision, version, testArgs)
|
2021-10-13 09:24:14 -04:00
|
|
|
unpackAndVerify(java, tmpDir, 'lucene-%s-src.tgz' % version, gitRevision, version, testArgs)
|
2019-06-11 04:17:10 -04:00
|
|
|
print()
|
2021-10-13 09:24:14 -04:00
|
|
|
print('Test Maven artifacts...')
|
|
|
|
checkMaven(baseURL, tmpDir, gitRevision, version, isSigned, keysFile)
|
2019-06-11 04:17:10 -04:00
|
|
|
else:
|
2021-10-13 09:24:14 -04:00
|
|
|
print("\nLucene test done (--download-only specified)")
|
2012-03-19 13:36:27 -04:00
|
|
|
|
2013-04-21 09:26:54 -04:00
|
|
|
print('\nSUCCESS! [%s]\n' % (datetime.datetime.now() - startTime))
|
2012-09-24 15:37:53 -04:00
|
|
|
|
2021-10-13 09:24:14 -04:00
|
|
|
|
2011-06-04 06:37:48 -04:00
|
|
|
if __name__ == '__main__':
|
2012-08-03 18:48:27 -04:00
|
|
|
try:
|
|
|
|
main()
|
2014-08-28 04:01:50 -04:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
print('Keyboard interrupt...exiting')
|
|
|
|
|