Apache Solr open-source search software
LUCENE-5909: Smoke tester now has better command line parsing and optionally also runs on Java 8
Uwe Schindler9cba8eb45f72
diff --git a/build.xml b/build.xmlindex f3b35c674d9..026daabdbe7 100644--- a/build.xml+++ b/build.xml@@ -37,9 +37,8 @@<property name="maven-version" value="2.2.1"/><property name="maven.dependencies.filters.file" location="lucene/build/maven.dependencies.filters.properties"/>- <property name="fakeRelease" location="lucene/build/fakeRelease"/>- <property name="fakeReleaseTmp" location="lucene/build/fakeReleaseTmp"/>- <property name="fakeReleaseVersion" value="${version.base}"/>+ <property name="smokeTestRelease.dir" location="lucene/build/smokeTestRelease/dist"/>+ <property name="smokeTestRelease.tmp" location="lucene/build/smokeTestRelease/tmp"/><property name="smokeTestRelease.testArgs" value=""/><target name="-projecthelp">@@ -372,52 +371,60 @@ File | Project Structure | Platform Settings | SDKs):<fileset dir="solr" includes="build.xml" /></subant></target>-- <target name="-load-env">- <!-- load the properties only here, so not on every invocation /usr/bin/env is called: -->- <property environment="env"/>- </target>- <target name="-env-JAVA7_HOME" depends="-load-env" if="env.JAVA7_HOME">- <property name="JAVA7_HOME" value="${env.JAVA7_HOME}"/>+ <target name="-nightly-smoke-java8params" if="smokeTestRelease.java8">+ <!-- convert path to UNIX style, so windows backslashes don't hurt escaping: -->+ <pathconvert targetos="unix" property="-smokeTestRelease.java8params">+ <regexpmapper from="^(.*)$" to="--test-java8 '\1'"/>+ <path location="smokeTestRelease.java8"/>+ </pathconvert></target>-- <target name="nightly-smoke" description="Builds an unsigned release and smoke tests it" depends="clean,-env-JAVA7_HOME">- <fail unless="JAVA7_HOME">JAVA7_HOME property or environment variable is not defined.</fail>- <exec executable="${python32.exe}" failonerror="true">++ <target name="nightly-smoke" description="Builds an unsigned release and smoke tests it, pass '-DsmokeTestRelease.java8=/path/to/jdk1.8.0' to enable Java 8)"+ depends="clean,-nightly-smoke-java8params">+ <fail message="To run nightly smoke, the JDK must be exactly Java 1.7, was: ${java.specification.version}">+ <condition>+ <not><equals arg1="${java.specification.version}" arg2="1.7"/></not>+ </condition>+ </fail>+ <property name="-smokeTestRelease.java8params" value=""/><!-- (if not yet defined) -->+ <exec executable="${python32.exe}" failonerror="true" taskname="python32"><arg value="-V"/>- </exec>- <subant target="prepare-release-no-sign" inheritall="false" failonerror="true">- <fileset dir="lucene" includes="build.xml" />- <fileset dir="solr" includes="build.xml" />- <property name="version" value="${fakeReleaseVersion}" />- </subant>- <mkdir dir="${fakeRelease}"/>- <copy todir="${fakeRelease}/lucene">- <fileset dir="lucene/dist"/>- </copy>- <copy todir="${fakeRelease}/solr">- <fileset dir="solr/package"/>- </copy>- <makeurl file="${fakeRelease}" validate="false" property="fakeRelease.uri"/>- <exec executable="${python32.exe}" failonerror="true">- <arg value="-u"/>- <!-- Tell Python not to write any bytecode cache into the filesystem: -->- <arg value="-B"/>- <arg file="dev-tools/scripts/smokeTestRelease.py"/>- <arg value="--revision"/>- <arg value="skip"/>- <arg value="--version"/>- <arg value="${fakeReleaseVersion}"/>- <arg value="--tmp-dir"/>- <arg file="${fakeReleaseTmp}"/>- <arg value="--not-signed"/>- <arg value="${fakeRelease.uri}"/>- <arg value="${smokeTestRelease.testArgs}"/>- <env key="JAVA7_HOME" file="${JAVA7_HOME}"/>- </exec>- <delete dir="${fakeRelease}"/>- <delete dir="${fakeReleaseTmp}"/>+ </exec>+ <subant target="prepare-release-no-sign" inheritall="false" failonerror="true">+ <fileset dir="lucene" includes="build.xml" />+ <fileset dir="solr" includes="build.xml" />+ <!-- pass ${version.base} here to emulate a real release, without appendix like "-SNAPSHOT": -->+ <property name="version" value="${version.base}" />+ </subant>+ <mkdir dir="${smokeTestRelease.dir}"/>+ <copy todir="${smokeTestRelease.dir}/lucene">+ <fileset dir="lucene/dist"/>+ </copy>+ <copy todir="${smokeTestRelease.dir}/solr">+ <fileset dir="solr/package"/>+ </copy>+ <local name="url"/>+ <makeurl file="${smokeTestRelease.dir}" validate="false" property="url"/>+ <exec executable="${python32.exe}" failonerror="true" taskname="smoker">+ <arg value="-u"/>+ <!-- Tell Python not to write any bytecode cache into the filesystem: -->+ <arg value="-B"/>+ <arg file="dev-tools/scripts/smokeTestRelease.py"/>+ <arg line="${-smokeTestRelease.java8params}"/>+ <arg value="--revision"/>+ <arg value="skip"/>+ <!-- pass ${version.base} here to emulate a real release, without appendix like "-SNAPSHOT": -->+ <arg value="--version"/>+ <arg value="${version.base}"/>+ <arg value="--tmp-dir"/>+ <arg file="${smokeTestRelease.tmp}"/>+ <arg value="--not-signed"/>+ <arg value="${url}"/>+ <arg value="${smokeTestRelease.testArgs}"/>+ </exec>+ <delete dir="${smokeTestRelease.dir}"/>+ <delete dir="${smokeTestRelease.tmp}"/></target><target name="check-svn-working-copy" description="Checks the status of the SVN working copy">diff --git a/dev-tools/scripts/buildAndPushRelease.py b/dev-tools/scripts/buildAndPushRelease.pyindex 6666bcbd8fe..2ffa386561a 100644--- a/dev-tools/scripts/buildAndPushRelease.py+++ b/dev-tools/scripts/buildAndPushRelease.py@@ -82,7 +82,7 @@ def getSVNRev():return rev-def prepare(root, version, gpgKeyID, gpgPassword, doTest):+def prepare(root, version, gpgKeyID, gpgPassword):print()print('Prepare release...')if os.path.exists(LOG):@@ -96,10 +96,8 @@ def prepare(root, version, gpgKeyID, gpgPassword, doTest):print(' svn rev: %s' % rev)log('\nSVN rev: %s\n' % rev)- if doTest:- # Don't run tests if we are gonna smoke test after the release...- print(' ant clean test')- run('ant clean test')+ print(' ant clean test')+ run('ant clean test')print(' clean checkout')scrubCheckout()@@ -258,8 +256,6 @@ def parse_config():if not os.path.isdir(config.root):# TODO: add additional svn check to ensure dir is a real lucene-solr checkoutparser.error('Root path is not a valid lucene-solr checkout')- if config.smoke_test is not None and os.path.exists(config.smoke_test):- parser.error('Smoke test path already exists')config.version = read_version(config.root)print('Building version: %s' % config.version)@@ -278,7 +274,7 @@ def main():c = parse_config()if c.prepare:- rev = prepare(c.root, c.version, c.key_id, c.key_password, key.smoke_test is None)+ rev = prepare(c.root, c.version, c.key_id, c.key_password)else:os.chdir(root)rev = open('rev.txt', encoding='UTF-8').read()@@ -292,11 +288,8 @@ def main():if url is not None:print(' URL: %s' % url)-- if c.smoke_test is not None:- import smokeTestRelease- smokeTestRelease.DEBUG = False- smokeTestRelease.smokeTest(url, rev, c.version, c.smoke_test, c.sign is not None, '')+ print('Next set the PYTHON_EXEC env var and you can run the smoker tester:')+ print(' $PYTHON_EXEC %s %s' % (sys.argv[0], url))if __name__ == '__main__':try:diff --git a/dev-tools/scripts/smokeTestRelease.py b/dev-tools/scripts/smokeTestRelease.pyindex c8ff8eaf68a..1b7a79e4448 100644--- a/dev-tools/scripts/smokeTestRelease.py+++ b/dev-tools/scripts/smokeTestRelease.py@@ -42,6 +42,7 @@ import checkJavadocLinksimport ioimport codecsimport textwrap+from collections import namedtuple# This tool expects to find /lucene and /solr off the base URL. You# must have a working gpg, tar, unzip in your path. This has been@@ -60,30 +61,6 @@ def unshortenURL(url):return response.getheader('Location')return url-def javaExe(version):- if version == '1.7':- path = JAVA7_HOME- else:- raise RuntimeError("unknown Java version '%s'" % version)- if cygwin:- path = os.popen('cygpath -u "%s"' % path).read().strip()- return 'export JAVA_HOME="%s" PATH="%s/bin:$PATH" JAVACMD="%s/bin/java"' % (path, path, path)--def verifyJavaVersion(version):- s = os.popen('%s; java -version 2>&1' % javaExe(version)).read()- if s.find(' version "%s.' % version) == -1:- raise RuntimeError('got wrong version for java %s:\n%s' % (version, s))--# http://s.apache.org/lusolr32rc2-env = os.environ-try:- JAVA7_HOME = env['JAVA7_HOME']-except KeyError:- raise RuntimeError('please set JAVA7_HOME in the env before running smokeTestRelease')-print('JAVA7_HOME is %s' % JAVA7_HOME)--verifyJavaVersion('1.7')-# TODO# + verify KEYS contains key that signed the release# + make sure changes HTML looks ok@@ -616,7 +593,7 @@ def getDirEntries(urlString):if text == 'Parent Directory' or text == '..':return links[(i+1):]-def unpackAndVerify(project, tmpDir, artifact, svnRevision, version, testArgs, baseURL):+def unpackAndVerify(java, project, tmpDir, artifact, svnRevision, version, testArgs, baseURL):destDir = '%s/unpack' % tmpDirif os.path.exists(destDir):shutil.rmtree(destDir)@@ -636,14 +613,14 @@ def unpackAndVerify(project, tmpDir, artifact, svnRevision, version, testArgs, braise RuntimeError('unpack produced entries %s; expected only %s' % (l, expected))unpackPath = '%s/%s' % (destDir, expected)- verifyUnpacked(project, artifact, unpackPath, svnRevision, version, testArgs, tmpDir, baseURL)+ verifyUnpacked(java, project, artifact, unpackPath, svnRevision, version, testArgs, tmpDir, baseURL)LUCENE_NOTICE = NoneLUCENE_LICENSE = NoneSOLR_NOTICE = NoneSOLR_LICENSE = None-def verifyUnpacked(project, artifact, unpackPath, svnRevision, version, testArgs, tmpDir, baseURL):+def verifyUnpacked(java, project, artifact, unpackPath, svnRevision, version, testArgs, tmpDir, baseURL):global LUCENE_NOTICEglobal LUCENE_LICENSEglobal SOLR_NOTICE@@ -727,34 +704,56 @@ def verifyUnpacked(project, artifact, unpackPath, svnRevision, version, testArgsraise RuntimeError('source release has WARs...')print(' run "ant validate"')- run('%s; ant validate' % javaExe('1.7'), '%s/validate.log' % unpackPath)+ java.run_java7('ant validate', '%s/validate.log' % unpackPath)if project == 'lucene':print(" run tests w/ Java 7 and testArgs='%s'..." % testArgs)- run('%s; ant clean test %s' % (javaExe('1.7'), testArgs), '%s/test.log' % unpackPath)- run('%s; ant jar' % javaExe('1.7'), '%s/compile.log' % unpackPath)- testDemo(isSrc, version, '1.7')+ java.run_java7('ant clean test %s' % testArgs, '%s/test.log' % unpackPath)+ java.run_java7('ant jar', '%s/compile.log' % unpackPath)+ testDemo(java.run_java7, isSrc, version, '1.7')print(' generate javadocs w/ Java 7...')- run('%s; ant javadocs' % javaExe('1.7'), '%s/javadocs.log' % unpackPath)+ java.run_java7('ant javadocs', '%s/javadocs.log' % unpackPath)checkJavadocpathFull('%s/build/docs' % unpackPath)+ if java.run_java8:+ print(" run tests w/ Java 8 and testArgs='%s'..." % testArgs)+ java.run_java8('ant clean test %s' % testArgs, '%s/test.log' % unpackPath)+ java.run_java8('ant jar', '%s/compile.log' % unpackPath)+ testDemo(java.run_java8, isSrc, version, '1.8')++ print(' generate javadocs w/ Java 8...')+ java.run_java8('ant javadocs', '%s/javadocs.log' % unpackPath)+ checkJavadocpathFull('%s/build/docs' % unpackPath)+else:os.chdir('solr')print(" run tests w/ Java 7 and testArgs='%s'..." % testArgs)- run('%s; ant clean test -Dtests.slow=false %s' % (javaExe('1.7'), testArgs), '%s/test.log' % unpackPath)-+ java.run_java7('ant clean test -Dtests.slow=false %s' % testArgs, '%s/test.log' % unpackPath)+# test javadocsprint(' generate javadocs w/ Java 7...')- run('%s; ant clean javadocs' % javaExe('1.7'), '%s/javadocs.log' % unpackPath)+ java.run_java7('ant clean javadocs', '%s/javadocs.log' % unpackPath)checkJavadocpathFull('%s/solr/build/docs' % unpackPath, False)print(' test solr example w/ Java 7...')- run('%s; ant clean example' % javaExe('1.7'), '%s/antexample.log' % unpackPath)- testSolrExample(unpackPath, JAVA7_HOME, True)- os.chdir('..')+ java.run_java7('ant clean example', '%s/antexample.log' % unpackPath)+ testSolrExample(unpackPath, java.java7_home, True)++ if java.run_java8:+ print(" run tests w/ Java 8 and testArgs='%s'..." % testArgs)+ java.run_java8('ant clean test -Dtests.slow=false %s' % testArgs, '%s/test.log' % unpackPath)+ print(' generate javadocs w/ Java 8...')+ java.run_java8('ant clean javadocs', '%s/javadocs.log' % unpackPath)+ checkJavadocpathFull('%s/solr/build/docs' % unpackPath, False)++ print(' test solr example w/ Java 8...')+ java.run_java8('ant clean example', '%s/antexample.log' % unpackPath)+ testSolrExample(unpackPath, java.java8_home, True)++ os.chdir('..')print(' check NOTICE')testNotice(unpackPath)@@ -763,28 +762,39 @@ def verifyUnpacked(project, artifact, unpackPath, svnRevision, version, testArgscheckAllJARs(os.getcwd(), project, svnRevision, version, tmpDir, baseURL)if project == 'lucene':- testDemo(isSrc, version, '1.7')+ testDemo(java.run_java7, isSrc, version, '1.7')+ if java.run_java8:+ testDemo(java.run_java8, isSrc, version, '1.8')++ print(' check Lucene\'s javadoc JAR')+ checkJavadocpath('%s/docs' % unpackPath)else:checkSolrWAR('%s/example/webapps/solr.war' % unpackPath, svnRevision, version, tmpDir, baseURL)print(' copying unpacked distribution for Java 7 ...')- java7UnpackPath = '%s-java7' %unpackPath+ java7UnpackPath = '%s-java7' % unpackPathif os.path.exists(java7UnpackPath):shutil.rmtree(java7UnpackPath)shutil.copytree(unpackPath, java7UnpackPath)os.chdir(java7UnpackPath)print(' test solr example w/ Java 7...')- testSolrExample(java7UnpackPath, JAVA7_HOME, False)+ testSolrExample(java7UnpackPath, java.java7_home, False)++ if java.run_java8:+ print(' copying unpacked distribution for Java 8 ...')+ java8UnpackPath = '%s-java8' % unpackPath+ if os.path.exists(java8UnpackPath):+ shutil.rmtree(java8UnpackPath)+ shutil.copytree(unpackPath, java8UnpackPath)+ os.chdir(java8UnpackPath)+ print(' test solr example w/ Java 8...')+ testSolrExample(java8UnpackPath, java.java8_home, False)os.chdir(unpackPath)testChangesText('.', version, project)- if project == 'lucene' and not isSrc:- print(' check Lucene\'s javadoc JAR')- checkJavadocpath('%s/docs' % unpackPath)-def testNotice(unpackPath):solrNotice = open('%s/NOTICE.txt' % unpackPath, encoding='UTF-8').read()luceneNotice = open('%s/lucene/NOTICE.txt' % unpackPath, encoding='UTF-8').read()@@ -918,7 +928,7 @@ def checkJavadocpathFull(path, failOnMissing=True):if checkJavadocLinks.checkAll(path):raise RuntimeError('broken javadocs links found!')-def testDemo(isSrc, version, jdk):+def testDemo(run_java, isSrc, version, jdk):if os.path.exists('index'):shutil.rmtree('index') # nuke any index from any previous iteration@@ -930,8 +940,8 @@ def testDemo(isSrc, version, jdk):else:cp = 'core/lucene-core-{0}.jar{1}demo/lucene-demo-{0}.jar{1}analysis/common/lucene-analyzers-common-{0}.jar{1}queryparser/lucene-queryparser-{0}.jar'.format(version, sep)docsDir = 'docs'- run('%s; java -cp "%s" org.apache.lucene.demo.IndexFiles -index index -docs %s' % (javaExe(jdk), cp, docsDir), 'index.log')- run('%s; java -cp "%s" org.apache.lucene.demo.SearchFiles -index index -query lucene' % (javaExe(jdk), cp), 'search.log')+ run_java('java -cp "%s" org.apache.lucene.demo.IndexFiles -index index -docs %s' % (cp, docsDir), 'index.log')+ run_java('java -cp "%s" org.apache.lucene.demo.SearchFiles -index index -query lucene' % cp, 'search.log')reMatchingDocs = re.compile('(\d+) total matching documents')m = reMatchingDocs.search(open('search.log', encoding='UTF-8').read())if m is None:@@ -942,7 +952,7 @@ def testDemo(isSrc, version, jdk):raise RuntimeError('lucene demo\'s SearchFiles found too few results: %s' % numHits)print(' got %d hits for query "lucene"' % numHits)print(' checkindex with %s...' % jdk)- run('%s; java -ea -cp "%s" org.apache.lucene.index.CheckIndex index' % (javaExe(jdk), cp), 'checkindex.log')+ run_java('java -ea -cp "%s" org.apache.lucene.index.CheckIndex index' % cp, 'checkindex.log')s = open('checkindex.log').read()m = re.search(r'^\s+version=(.*?)$', s, re.MULTILINE)if m is None:@@ -1250,6 +1260,31 @@ def crawl(downloadedFiles, urlString, targetDir, exclusions=set()):downloadedFiles.append(path)sys.stdout.write('.')+def make_java_config(parser, java8_home):+ def _make_runner(java_home, version):+ print('Java %s JAVA_HOME=%s' % (version, java_home))+ if cygwin:+ java_home = subprocess.check_output('cygpath -u "%s"' % java_home).read().decode('utf-8').strip()+ 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')+ if s.find(' version "%s.' % version) == -1:+ parser.error('got wrong version for java %s:\n%s' % (version, s))+ def run_java(cmd, logfile):+ run('%s; %s' % (cmd_prefix, cmd), logfile)+ return run_java+ java7_home = os.environ.get('JAVA_HOME')+ if java7_home is None:+ parser.error('JAVA_HOME must be set')+ run_java7 = _make_runner(java7_home, '1.7')+ run_java8 = None+ if java8_home is not None:+ run_java8 = _make_runner(java8_home, '1.8')++ jc = namedtuple('JavaConfig', 'run_java7 java7_home run_java8 java8_home')+ return jc(run_java7, java7_home, run_java8, java8_home)+version_re = re.compile(r'(\d+\.\d+\.\d+(-ALPHA|-BETA)?)')revision_re = re.compile(r'rev(\d+)')def parse_config():@@ -1268,9 +1303,11 @@ def parse_config():help='SVN revision number that release was built with, defaults to that in URL')parser.add_argument('--version', metavar='X.Y.Z(-ALPHA|-BETA)?',help='Version of the release, defaults to that in URL')+ parser.add_argument('--test-java8', metavar='JAVA8_HOME',+ help='Path to Java8 home directory, to run tests with if specified')parser.add_argument('url', help='Url pointing to release to test')- parser.add_argument('test_args', nargs=argparse.REMAINDER, metavar='ARGS',- help='Arguments to pass to ant for testing, e.g. -Dwhat=ever')+ parser.add_argument('test_args', nargs=argparse.REMAINDER,+ help='Arguments to pass to ant for testing, e.g. -Dwhat=ever.')c = parser.parse_args()if c.version is not None:@@ -1287,6 +1324,8 @@ def parse_config():if revision_match is None:parser.error('Could not find revision in URL')c.revision = revision_match.group(1)++ c.java = make_java_config(parser, c.test_java8)if c.tmp_dir:c.tmp_dir = os.path.abspath(c.tmp_dir)@@ -1303,9 +1342,9 @@ def parse_config():def main():c = parse_config()print('NOTE: output encoding is %s' % sys.stdout.encoding)- smokeTest(c.url, c.revision, c.version, c.tmp_dir, c.is_signed, ' '.join(c.test_args))+ smokeTest(c.java, c.url, c.revision, c.version, c.tmp_dir, c.is_signed, ' '.join(c.test_args))-def smokeTest(baseURL, svnRevision, version, tmpDir, isSigned, testArgs):+def smokeTest(java, baseURL, svnRevision, version, tmpDir, isSigned, testArgs):startTime = datetime.datetime.now()@@ -1340,15 +1379,15 @@ def smokeTest(baseURL, svnRevision, version, tmpDir, isSigned, testArgs):print('Test Lucene...')checkSigs('lucene', lucenePath, version, tmpDir, isSigned)for artifact in ('lucene-%s.tgz' % version, 'lucene-%s.zip' % version):- unpackAndVerify('lucene', tmpDir, artifact, svnRevision, version, testArgs, baseURL)- unpackAndVerify('lucene', tmpDir, 'lucene-%s-src.tgz' % version, svnRevision, version, testArgs, baseURL)+ unpackAndVerify(java, 'lucene', tmpDir, artifact, svnRevision, version, testArgs, baseURL)+ unpackAndVerify(java, 'lucene', tmpDir, 'lucene-%s-src.tgz' % version, svnRevision, version, testArgs, baseURL)print()print('Test Solr...')checkSigs('solr', solrPath, version, tmpDir, isSigned)for artifact in ('solr-%s.tgz' % version, 'solr-%s.zip' % version):- unpackAndVerify('solr', tmpDir, artifact, svnRevision, version, testArgs, baseURL)- unpackAndVerify('solr', tmpDir, 'solr-%s-src.tgz' % version, svnRevision, version, testArgs, baseURL)+ unpackAndVerify(java, 'solr', tmpDir, artifact, svnRevision, version, testArgs, baseURL)+ unpackAndVerify(java, 'solr', tmpDir, 'solr-%s-src.tgz' % version, svnRevision, version, testArgs, baseURL)print()print('Test Maven artifacts for Lucene and Solr...')diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 8b89d66f150..c07cf8c97c1 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -127,6 +127,11 @@ Bug FixesMockDirectoryWrapper to have it simulate a virus checker holding afile open and preventing deletion (Robert Muir, Mike McCandless)+Build++* LUCENE-5909: Smoke tester now has better command line parsing and+ optionally also runs on Java 8. (Ryan Ernst, Uwe Schindler)+======================= Lucene 4.10.0 ======================New Features