Skip to content

Commit 49503f0

Browse files
janhoyiamsanjay
andauthored
SmokeTestRelease Added support for multiple JDK (backport 9x) (#3342)
(cherry picked from commit 98aa723) Signed-off-by: Jan Høydahl <[email protected]> Co-authored-by: Sanjay Dutt <[email protected]>
1 parent 74f79f4 commit 49503f0

File tree

2 files changed

+95
-79
lines changed

2 files changed

+95
-79
lines changed

dev-tools/scripts/README.md

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,30 @@ Used to validate new release candidates (RC). The script downloads an RC from a
1515
or local folder, then runs a number of sanity checks on the artifacts, and then runs
1616
the full tests.
1717

18-
usage: smokeTestRelease.py [-h] [--tmp-dir PATH] [--not-signed]
19-
[--local-keys PATH] [--revision REVISION]
20-
[--version X.Y.Z(-ALPHA|-BETA)?]
21-
[--test-java12 JAVA12_HOME] [--download-only]
22-
url ...
23-
18+
usage: smokeTestRelease.py [-h] [--tmp-dir PATH] [--not-signed] [--local-keys PATH] [--revision REVISION] [--version X.Y.Z(-ALPHA|-BETA)?] [--test-alt-java TEST_ALT_JAVA] [--download-only] [--dev-mode] url ...
19+
2420
Utility to test a release.
2521

2622
positional arguments:
2723
url Url pointing to release to test
28-
test_args Arguments to pass to ant for testing, e.g.
29-
-Dwhat=ever.
24+
test_args Arguments to pass to gradle for testing, e.g. -Dwhat=ever.
3025

31-
optional arguments:
26+
options:
3227
-h, --help show this help message and exit
33-
--tmp-dir PATH Temporary directory to test inside, defaults to
34-
/tmp/smoke_solr_$version_$revision
28+
--tmp-dir PATH Temporary directory to test inside, defaults to /tmp/smoke_solr_$version_$revision
3529
--not-signed Indicates the release is not signed
36-
--local-keys PATH Uses local KEYS file instead of fetching from
37-
https://archive.apache.org/dist/solr/KEYS
38-
--revision REVISION GIT revision number that release was built with,
39-
defaults to that in URL
30+
--local-keys PATH Uses local KEYS file instead of fetching from https://archive.apache.org/dist/solr/KEYS
31+
--revision REVISION GIT revision number that release was built with, defaults to that in URL
4032
--version X.Y.Z(-ALPHA|-BETA)?
4133
Version of the release, defaults to that in URL
42-
--test-java12 JAVA12_HOME
43-
Path to Java12 home directory, to run tests with if
44-
specified
34+
--test-alt-java TEST_ALT_JAVA
35+
Path to Java alternative home directory, to run tests with if specified
4536
--download-only Only perform download and sha hash check steps
37+
--dev-mode Enable dev mode, will not check branch compatibility
4638

4739
Example usage:
48-
python3 -u dev-tools/scripts/smokeTestRelease.py https://dist.apache.org/repos/dist/dev/solr/solr-9.0.1-RC2-revc7510a0...
40+
python3 -u dev-tools/scripts/smokeTestRelease.py https://dist.apache.org/repos/dist/dev/solr/solr-10.0.0-RC1-rev-c7510a0...
41+
4942

5043
### releaseWizard.py
5144

dev-tools/scripts/smokeTestRelease.py

Lines changed: 83 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
# must have a working gpg, tar in your path. This has been
4242
# tested on Linux and on Cygwin under Windows 7.
4343

44+
BASE_JAVA_VERSION = "11"
45+
SOLRJ_JAVA_VERSION = "11"
46+
4447
cygwin = platform.system().lower().startswith('cygwin')
4548
cygwinWindowsRoot = os.popen('cygpath -w /').read().strip().replace('\\','/') if cygwin else ''
4649

@@ -141,15 +144,18 @@ def checkJARMetaData(desc, jarFile, gitRevision, version):
141144

142145
s = decodeUTF8(z.read(MANIFEST_FILE_NAME))
143146

147+
compileJDK = BASE_JAVA_VERSION
148+
if 'solrj' in desc or 'api' in desc:
149+
compileJDK = SOLRJ_JAVA_VERSION
144150
for verify in (
145151
'Specification-Vendor: The Apache Software Foundation',
146152
'Implementation-Vendor: The Apache Software Foundation',
147153
'Specification-Title: Apache Solr Search Server:',
148154
'Implementation-Title: org.apache.solr',
149-
'X-Compile-Source-JDK: 11',
150-
'X-Compile-Target-JDK: 11',
155+
'X-Compile-Source-JDK: %s' % compileJDK,
156+
'X-Compile-Target-JDK: %s' % compileJDK,
151157
'Specification-Version: %s' % version,
152-
'X-Build-JDK: 11.',
158+
'X-Build-JDK: %s.' % BASE_JAVA_VERSION,
153159
'Extension-Name: org.apache.solr'):
154160
if type(verify) is not tuple:
155161
verify = (verify,)
@@ -288,12 +294,14 @@ def checkSigs(urlString, version, tmpDir, isSigned, keysFile):
288294
gpgLogFile = '%s/solr.gpg.import.log' % tmpDir
289295
run('gpg --homedir %s --import %s' % (gpgHomeDir, keysFile), gpgLogFile)
290296

297+
logfile = '%s/solr.assertions.log' % tmpDir
298+
291299
if mavenURL is None:
292-
stopGpgAgent(gpgHomeDir, logFile)
300+
stopGpgAgent(gpgHomeDir, logfile)
293301
raise RuntimeError('solr is missing maven')
294302

295303
if dockerURL is None:
296-
stopGpgAgent(gpgHomeDir, logFile)
304+
stopGpgAgent(gpgHomeDir, logfile)
297305
raise RuntimeError('solr is missing docker')
298306

299307
if changesURL is None:
@@ -660,47 +668,50 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
660668

661669
validateCmd = './gradlew --no-daemon check -p solr/documentation'
662670
print(' run "%s"' % validateCmd)
663-
java.run_java11(validateCmd, '%s/validate.log' % unpackPath)
664-
665-
print(" run tests w/ Java 11 and testArgs='%s'..." % testArgs)
666-
java.run_java11('./gradlew --no-daemon test %s' % testArgs, '%s/test.log' % unpackPath)
667-
print(" run integration tests w/ Java 11")
668-
java.run_java11('./gradlew --no-daemon integrationTest -Dversion.release=%s' % version, '%s/itest.log' % unpackPath)
669-
print(" build binary release w/ Java 11")
670-
java.run_java11('./gradlew --no-daemon dev -Dversion.release=%s' % version, '%s/assemble.log' % unpackPath)
671-
testSolrExample("%s/solr/packaging/build/dev" % unpackPath, java.java11_home, False)
672-
673-
if java.run_java17:
674-
print(" run tests w/ Java 17 and testArgs='%s'..." % testArgs)
675-
java.run_java17('./gradlew --no-daemon clean test %s' % testArgs, '%s/test-java17.log' % unpackPath)
676-
print(" run integration tests w/ Java 17")
677-
java.run_java17('./gradlew --no-daemon integrationTest -Dversion.release=%s' % version, '%s/itest-java17.log' % unpackPath)
678-
print(" build binary release w/ Java 17")
679-
java.run_java17('./gradlew --no-daemon dev -Dversion.release=%s' % version, '%s/assemble-java17.log' % unpackPath)
680-
testSolrExample("%s/solr/packaging/build/dev" % unpackPath, java.java17_home, False)
671+
java.run_java(validateCmd, '%s/validate.log' % unpackPath)
672+
673+
print(" run tests w/ Java %s and testArgs='%s'..." % (BASE_JAVA_VERSION, testArgs))
674+
java.run_java('./gradlew --no-daemon test %s' % testArgs, '%s/test.log' % unpackPath)
675+
print(" run integration tests w/ Java %s" % BASE_JAVA_VERSION)
676+
java.run_java('./gradlew --no-daemon integrationTest -Dversion.release=%s' % version, '%s/itest.log' % unpackPath)
677+
print(" build binary release w/ Java %s" % BASE_JAVA_VERSION)
678+
java.run_java('./gradlew --no-daemon dev -Dversion.release=%s' % version, '%s/assemble.log' % unpackPath)
679+
testSolrExample("%s/solr/packaging/build/dev" % unpackPath, java.java_home, False)
680+
681+
if java.run_alt_javas:
682+
for run_alt_java, alt_java_version in zip(java.run_alt_javas, java.alt_java_versions):
683+
print(" run tests w/ Java %s and testArgs='%s'..." % (alt_java_version, testArgs))
684+
run_alt_java('./gradlew --no-daemon clean test %s' % testArgs, '%s/test-java%s.log' % (unpackPath, alt_java_version))
685+
print(" run integration tests w/ Java %s" % alt_java_version)
686+
run_alt_java('./gradlew --no-daemon integrationTest -Dversion.release=%s' % version, '%s/itest-java%s.log' % (unpackPath, alt_java_version))
687+
print(" build binary release w/ Java %s" % alt_java_version)
688+
run_alt_java('./gradlew --no-daemon dev -Dversion.release=%s' % version, '%s/assemble-java%s.log' % (unpackPath, alt_java_version))
689+
testSolrExample("%s/solr/packaging/build/dev" % unpackPath, run_alt_java, False)
681690

682691
else:
683692
# Binary tarball
684693
checkAllJARs(os.getcwd(), gitRevision, version)
685694

686-
print(' copying unpacked distribution for Java 11 ...')
687-
java11UnpackPath = '%s-java11' % unpackPath
688-
if os.path.exists(java11UnpackPath):
689-
shutil.rmtree(java11UnpackPath)
690-
shutil.copytree(unpackPath, java11UnpackPath)
691-
os.chdir(java11UnpackPath)
692-
print(' test solr example w/ Java 11...')
693-
testSolrExample(java11UnpackPath, java.java11_home, isSlim)
694-
695-
if java.run_java17:
696-
print(' copying unpacked distribution for Java 17 ...')
697-
java17UnpackPath = '%s-java17' % unpackPath
698-
if os.path.exists(java17UnpackPath):
699-
shutil.rmtree(java17UnpackPath)
700-
shutil.copytree(unpackPath, java17UnpackPath)
701-
os.chdir(java17UnpackPath)
702-
print(' test solr example w/ Java 17...')
703-
testSolrExample(java17UnpackPath, java.java17_home, isSlim)
695+
print(' copying unpacked distribution for Java %s ...' % BASE_JAVA_VERSION)
696+
javaBaseVersionUnpackPath = '%s-java%s' % (unpackPath, BASE_JAVA_VERSION)
697+
if os.path.exists(javaBaseVersionUnpackPath):
698+
shutil.rmtree(javaBaseVersionUnpackPath)
699+
shutil.copytree(unpackPath, javaBaseVersionUnpackPath)
700+
os.chdir(javaBaseVersionUnpackPath)
701+
print(' test solr example w/ Java %s...' % BASE_JAVA_VERSION)
702+
testSolrExample(javaBaseVersionUnpackPath, java.java_home, isSlim)
703+
704+
if java.run_alt_javas:
705+
for run_alt_java, alt_java_version in zip(java.run_alt_javas, java.alt_java_versions):
706+
print("The alt version of java", run_alt_java, alt_java_version)
707+
print(' copying unpacked distribution for Java %s ...' % alt_java_version)
708+
javaAltVersionUnpackPath = '%s-java%s' % (unpackPath, alt_java_version)
709+
if os.path.exists(javaAltVersionUnpackPath):
710+
shutil.rmtree(javaAltVersionUnpackPath)
711+
shutil.copytree(unpackPath, javaAltVersionUnpackPath)
712+
os.chdir(javaAltVersionUnpackPath)
713+
print(' test solr example w/ Java %s...' % alt_java_version)
714+
testSolrExample(javaAltVersionUnpackPath, run_alt_java, isSlim)
704715

705716
os.chdir(unpackPath)
706717

@@ -1019,30 +1030,42 @@ def crawl(downloadedFiles, urlString, targetDir, exclusions=set()):
10191030
sys.stdout.write('.')
10201031

10211032

1022-
def make_java_config(parser, java17_home):
1023-
def _make_runner(java_home, version):
1024-
print('Java %s JAVA_HOME=%s' % (version, java_home))
1033+
def make_java_config(parser, alt_java_homes):
1034+
def _make_runner(java_home, is_base_version=False):
10251035
if cygwin:
10261036
java_home = subprocess.check_output('cygpath -u "%s"' % java_home, shell=True).decode('utf-8').strip()
10271037
cmd_prefix = 'export JAVA_HOME="%s" PATH="%s/bin:$PATH" JAVACMD="%s/bin/java"' % \
10281038
(java_home, java_home, java_home)
10291039
s = subprocess.check_output('%s; java -version' % cmd_prefix,
10301040
shell=True, stderr=subprocess.STDOUT).decode('utf-8')
1031-
if s.find(' version "%s' % version) == -1:
1032-
parser.error('got wrong version for java %s:\n%s' % (version, s))
1041+
actual_version = re.search(r'version "([1-9][0-9]*)', s).group(1)
1042+
print('Java %s JAVA_HOME=%s' % (actual_version, java_home))
1043+
1044+
# validate Java version
1045+
if is_base_version:
1046+
if BASE_JAVA_VERSION != actual_version:
1047+
parser.error('got wrong base version for java %s:\n%s' % (BASE_JAVA_VERSION, s))
1048+
else:
1049+
if int(actual_version) < int(BASE_JAVA_VERSION):
1050+
parser.error('got wrong version for java %s, less than base version %s:\n%s' % (actual_version, BASE_JAVA_VERSION, s))
10331051
def run_java(cmd, logfile):
10341052
run('%s; %s' % (cmd_prefix, cmd), logfile)
1035-
return run_java
1036-
java11_home = os.environ.get('JAVA_HOME')
1037-
if java11_home is None:
1038-
parser.error('JAVA_HOME must be set')
1039-
run_java11 = _make_runner(java11_home, '11')
1040-
run_java17 = None
1041-
if java17_home is not None:
1042-
run_java17 = _make_runner(java17_home, '17')
1053+
return run_java, actual_version
10431054

1044-
jc = namedtuple('JavaConfig', 'run_java11 java11_home run_java17 java17_home')
1045-
return jc(run_java11, java11_home, run_java17, java17_home)
1055+
java_home = os.environ.get('JAVA_HOME')
1056+
if java_home is None:
1057+
parser.error('JAVA_HOME must be set')
1058+
run_java, _ = _make_runner(java_home, True)
1059+
run_alt_javas = []
1060+
alt_java_versions = []
1061+
if alt_java_homes:
1062+
for alt_java_home in alt_java_homes:
1063+
run_alt_java, version = _make_runner(alt_java_home)
1064+
run_alt_javas.append(run_alt_java)
1065+
alt_java_versions.append(version)
1066+
print("alt java ", run_alt_javas, alt_java_versions)
1067+
jc = namedtuple('JavaConfig', 'run_java java_home run_alt_javas alt_java_homes alt_java_versions')
1068+
return jc(run_java, java_home, run_alt_javas, alt_java_homes, alt_java_versions)
10461069

10471070
version_re = re.compile(r'(\d+\.\d+\.\d+(-ALPHA|-BETA)?)')
10481071
revision_re = re.compile(r'rev-([a-f\d]+)')
@@ -1064,8 +1087,8 @@ def parse_config():
10641087
help='GIT revision number that release was built with, defaults to that in URL')
10651088
parser.add_argument('--version', metavar='X.Y.Z(-ALPHA|-BETA)?',
10661089
help='Version of the release, defaults to that in URL')
1067-
parser.add_argument('--test-java17', metavar='java17_home',
1068-
help='Path to Java17 home directory, to run tests with if specified')
1090+
parser.add_argument('--test-alt-java', action='append',
1091+
help='Path to Java alternative home directory, to run tests with if specified')
10691092
parser.add_argument('--download-only', action='store_true', default=False,
10701093
help='Only perform download and sha hash check steps')
10711094
parser.add_argument('--dev-mode', action='store_true', default=False,
@@ -1094,7 +1117,7 @@ def parse_config():
10941117
if c.local_keys is not None and not os.path.exists(c.local_keys):
10951118
parser.error('Local KEYS file "%s" not found' % c.local_keys)
10961119

1097-
c.java = make_java_config(parser, c.test_java17)
1120+
c.java = make_java_config(parser, c.test_alt_java)
10981121

10991122
if c.tmp_dir:
11001123
c.tmp_dir = os.path.abspath(c.tmp_dir)
@@ -1197,4 +1220,4 @@ def smokeTest(java, baseURL, gitRevision, version, tmpDir, isSigned, local_keys,
11971220
try:
11981221
main()
11991222
except KeyboardInterrupt:
1200-
print('Keyboard interrupt...exiting')
1223+
print('Keyboard interrupt...exiting')

0 commit comments

Comments
 (0)