# 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
#
#
# 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.
import os
import tarfile
import threading
import subprocess
import signal
import shutil
import hashlib
import httplib
import re
import urllib2
import urlparse
import sys
import HTMLParser
import filecmp
import platform
import checkJavaDocs
# 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
# tested on Linux and on Cygwin under Windows 7.
if version == '1.5':
elif version == '1.6':
elif version == '1.7':
else:
try:
except KeyError:
try:
except KeyError:
try:
except KeyError:
verifyJavaVersion('1.5')
verifyJavaVersion('1.6')
verifyJavaVersion('1.7')
# TODO
# + verify KEYS contains key that signed the release
# + make sure changes HTML looks ok
# - check maven
# - check JAR manifest version
# - check no "extra" files
# - make sure jars exist inside bin release
# - run "ant test"
# - make sure docs exist
# Set to True to avoid re-downloading the packages...
# Deref any redirects
while True:
r = h.getresponse()
if newLoc is not None:
else:
break
links = []
return links
return
try:
while True:
if s == '':
break
finally:
if not success:
print ' test basics...'
artifact = None
keysURL = None
changesURL = None
mavenURL = None
artifacts = []
if text == 'KEYS':
elif text == 'maven/':
elif artifact == None:
if project == 'solr':
else:
sigs = []
else:
if sigs != expectedSigs:
raise RuntimeError('%s: artifact %s has wrong sigs: expected %s but got %s' % (project, artifact, expectedSigs, sigs))
sigs = []
if sigs != []:
if sigs != expectedSigs:
raise RuntimeError('%s: artifact %s has wrong sigs: expected %s but got %s' % (project, artifact, expectedSigs, sigs))
if project == 'lucene':
'lucene-%s.tgz' % version,
'lucene-%s.zip' % version]
else:
'apache-solr-%s.tgz' % version,
'apache-solr-%s.zip' % version]
if keysURL is None:
print ' downloading Apache RAT...'
download('apache-rat-incubating-0.8-bin.tar.bz2',
else:
print ' apache RAT already downloaded...'
print ' get KEYS'
# Set up clean gpg world; import keys file:
if mavenURL is None:
if project == 'lucene':
if changesURL is None:
print ' download %s...' % artifact
print ' verify sig'
# Test sig (this is done with a clean brand-new GPG world)
# Forward any GPG warnings, except the expected one (since its a clean world)
f.close()
# Test trust (this is done with the real users config)
print ' verify trust'
# Forward any GPG warnings:
f.close()
print ' check changes HTML...'
changesURL = None
contribChangesURL = None
if text == 'Changes.html':
elif text == 'Contrib-Changes.html':
if changesURL is None:
if contribChangesURL is None:
s = load(changesURL)
"Checks all CHANGES.txt under this dir."
# NOTE: O(N) but N should be smallish:
if 'CHANGES.txt' in files:
#print 'CHECK %s' % fullPath
if not isHTML:
if project == 'lucene':
else:
if t != '*'+artifact:
if t != '*'+artifact:
while True:
x = f.read(65536)
if x == '':
break
m.update(x)
s.update(x)
f.close()
sha1Actual = s.hexdigest()
if md5Actual != md5Expected:
raise RuntimeError('MD5 digest mismatch for %s: expected %s but got %s' % (artifact, md5Expected, md5Actual))
if sha1Actual != sha1Expected:
raise RuntimeError('SHA1 digest mismatch for %s: expected %s but got %s' % (artifact, sha1Expected, sha1Actual))
return links[(i+1):]
print ' unpack %s...' % artifact
# make sure it unpacks to proper subdir
if project == 'solr':
else:
if l != [expected]:
if project == 'lucene':
if isSrc:
fileName += '.txt'
if fileName not in l:
if not isSrc:
if project == 'lucene':
'lucene-core-%s-javadoc' % version,
'lucene-test-framework-%s' % version,
'lucene-test-framework-%s-javadoc' % version)
else:
expectedJARs = ()
for fileName in expectedJARs:
fileName += '.jar'
if fileName not in l:
if project == 'lucene':
if isSrc:
else:
extras = ()
for e in extras:
if e not in l:
l.remove(e)
if project == 'lucene':
if len(l) > 0:
if isSrc:
print ' FAILED:'
raise RuntimeError('source release has JARs...')
print ' FAILED:'
raise RuntimeError('source release has WARs...')
print ' run "ant validate"'
print ' run "ant rat-sources"'
run('%s; ant -lib %s/apache-rat-0.8.jar rat-sources' % (javaExe('1.7'), tmpDir), '%s/rat-sources.log' % unpackPath)
if project == 'lucene':
print ' run tests w/ Java 5...'
# test javadocs
print ' generate javadocs w/ Java 5...'
print '\n***WARNING***: javadocs want to fail!\n'
# disabled: RM cannot fix all this, see LUCENE-3887
#raise RuntimeError('javadoc summaries failed')
else:
print ' run tests w/ Java 6...'
# test javadocs
print ' generate javadocs w/ Java 6...'
print ' run tests w/ Java 7...'
# test javadocs
print ' generate javadocs w/ Java 7...'
print ' test solr example w/ Java 6...'
print ' test solr example w/ Java 7...'
print ' check NOTICE'
else:
if project == 'lucene':
else:
print ' test solr example w/ Java 6...'
print ' test solr example w/ Java 7...'
print ' check Lucene\'s javadoc JAR'
expected = """
=========================================================================
== Apache Lucene Notice ==
=========================================================================
"""
raise RuntimeError('Solr\'s NOTICE.txt does not have the verbatim copy, plus header/footer, of Lucene\'s NOTICE.txt')
try:
while True:
if line == '':
break
f.flush()
# print 'SOLR: %s' % line.strip()
finally:
f.close()
print ' start Solr instance (log=%s)...' % logFile
env = {}
server = subprocess.Popen(['java', '-jar', 'start.jar'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
# Make sure Solr finishes startup:
print ' startup done'
try:
print ' test utf8...'
print ' index example docs...'
print ' run query...'
print 'FAILED: response is:\n%s' % s
raise RuntimeError('query on solr example instance failed')
finally:
# Stop server:
print ' stop server (SIGINT)...'
# Give it 10 seconds to gracefully shut down
if serverThread.isAlive():
# Kill server:
print '***WARNING***: Solr instance didn\'t respond to SIGINT; using SIGKILL now...'
if serverThread.isAlive():
# Shouldn't happen unless something is seriously wrong...
print '***WARNING***: Solr instance didn\'t respond to SIGKILL; ignoring...'
# disabled: RM cannot fix all this, see LUCENE-3887
# raise RuntimeError('javadoc problems')
print '\n***WARNING***: javadocs want to fail!\n'
print ' test demo...'
if isSrc:
# allow lucene dev version to be either 3.3 or 3.3.0:
cp = 'build/core/lucene-core-{0}-SNAPSHOT.jar{1}build/contrib/demo/classes/java'.format(version, sep)
cp += '{1}build/core/lucene-core-{0}-SNAPSHOT.jar{1}build/contrib/demo/classes/java'.format(version[:-2], sep)
else:
cp = 'build/core/lucene-core-{0}-SNAPSHOT.jar{1}build/contrib/demo/classes/java'.format(version, sep)
else:
docsDir = 'docs'
run('%s; java -cp "%s" org.apache.lucene.demo.IndexFiles -index index -docs %s' % (javaExe('1.5'), cp, docsDir), 'index.log')
run('%s; java -cp "%s" org.apache.lucene.demo.SearchFiles -index index -query lucene' % (javaExe('1.5'), cp), 'search.log')
if m is None:
raise RuntimeError('lucene demo\'s SearchFiles found no results')
else:
if numHits < 100:
print ' got %d hits for query "lucene"' % numHits
# Locate the release branch in subversion
releaseBranchSvnURL = None
if text == releaseBranchText:
print ' get POM templates',
print
print ' download artifacts',
print
print ' verify that each binary artifact has a deployed POM...'
print ' verify that there is an artifact for each POM template...'
print ' verify that all non-Mavenized deps are deployed...'
nonMavenizedDeps = dict()
print ' check for javadoc and sources artifacts...'
print " verify deployed POMs' coordinates..."
print ' verify maven artifact sigs',
print ' verify that non-Mavenized deps are same as in the binary distribution...'
print ' verify that Maven artifacts are same as in the binary distribution...'
print ' download %s...' % distribution,
print ' unpack %s...' % distribution
print ' unpack Solr war...'
distributionFiles[project] = []
return distributionFiles
distFilenames = dict()
if not depOrigFilename in distFilenames:
if not identical:
raise RuntimeError('Deployed non-mavenized dep %s differs from distribution dep %s'
distFilenames = dict()
raise RuntimeError('Maven artifact %s is not present in %s binary distribution'
# TODO: Either fix the build to ensure that maven artifacts *are* identical, or recursively compare contents
# identical = filecmp.cmp(artifact, distFilenames[artifactFilename], shallow=False)
# if not identical:
# raise RuntimeError('Maven artifact %s is not identical to %s in %s binary distribution'
# % (artifact, distFilenames[artifactFilename], project))
while True:
if bytes == '': break
if md5Actual != md5Expected:
raise RuntimeError('MD5 digest mismatch for %s: expected %s but got %s'
if sha1Actual != sha1Expected:
raise RuntimeError('SHA1 digest mismatch for %s: expected %s but got %s'
"""
- check for non-mavenized dependencies listed in the grandfather POM template
- nonMavenizedDependencies is populated with a map from non-mavenized dependency
artifact path to the original jar path
"""
pomDirs = []
if artifactId == 'maven-resources-plugin':
if artifactId == 'maven-install-plugin':
elif pomFile: # Find non-Mavenized deps with associated POMs
doc2 = None
if releaseBranchSvnURL is None:
break
else:
break
if doc2 is not None: break
if groupId is None:
if version is None:
"""Verify Maven artifact signatures"""
# Set up clean gpg world; import keys file:
# Test sig (this is done with a clean brand-new GPG world)
# Forward any GPG warnings, except the expected one (since its a clean world)
f.close()
# Test trust (this is done with the real users config)
# Forward any GPG warnings:
f.close()
print
"""verify that each binary jar and war has a corresponding POM file"""
"""
verify that each POM's coordinate (drawn from its content) matches
its filepath, and verify that the corresponding artifact exists.
"""
POMpath = '%s/%s/%s/%s-%s.pom' \
raise RuntimeError("Mismatch between POM coordinate %s:%s:%s and filepath: %s"
# Verify that the corresponding artifact exists
"""verify that each POM template's artifact is present in artifacts"""
if artifactId == 'maven-deploy-plugin':
if not skipDeploy:
# Ignore POMversion, since its value will not have been interpolated
allPOMtemplates = []
if sourceLocation is None:
else:
sourceLocation += 'dev-tools/maven/'
crawl(allPOMtemplates, sourceLocation, targetDir, set(['Apache Subversion'])) # Ignore "Apache Subversion" links
if POMtemplates['lucene'] is None:
if POMtemplates['solr'] is None:
if POMtemplates['grandfather'] is None:
if text not in exclusions:
else:
def main():
print
print
if not DEBUG:
lucenePath = None
solrPath = None
print 'Load release URL...'
if lucenePath is None:
raise RuntimeError('could not find lucene subdir')
if solrPath is None:
raise RuntimeError('could not find solr subdir')
print
print 'Test Lucene...'
print
print 'Test Solr...'
print 'Test Maven artifacts for Lucene and Solr...'
if __name__ == '__main__':
main()