You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2013/04/26 14:03:15 UTC

svn commit: r1476154 - in /lucene/dev/trunk: ./ dev-tools/ dev-tools/scripts/smokeTestRelease.py

Author: mikemccand
Date: Fri Apr 26 12:03:13 2013
New Revision: 1476154

URL: http://svn.apache.org/r1476154
Log:
SOLR-4766: detect when maven war/jar has different contents (file name + size) from the corresponding binary release

Modified:
    lucene/dev/trunk/   (props changed)
    lucene/dev/trunk/dev-tools/   (props changed)
    lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py

Modified: lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py?rev=1476154&r1=1476153&r2=1476154&view=diff
==============================================================================
--- lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py (original)
+++ lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py Fri Apr 26 12:03:13 2013
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 import os
+import zipfile
 import codecs
 import tarfile
 import zipfile
@@ -973,7 +974,7 @@ def getDistributionsForMavenChecks(tmpDi
 def checkJavadocAndSourceArtifacts(nonMavenizedDeps, artifacts, version):
   for project in ('lucene', 'solr'):
     for artifact in artifacts[project]:
-      if artifact.endswith(version + '.jar') and artifact not in list(nonMavenizedDeps.keys()):
+      if artifact.endswith(version + '.jar') and artifact not in nonMavenizedDeps:
         javadocJar = artifact[:-4] + '-javadoc.jar'
         if javadocJar not in artifacts[project]:
           raise RuntimeError('missing: %s' % javadocJar)
@@ -986,7 +987,7 @@ def checkIdenticalNonMavenizedDeps(distr
     distFilenames = dict()
     for file in distributionFiles[project]:
       distFilenames[os.path.basename(file)] = file
-    for dep in list(nonMavenizedDeps.keys()):
+    for dep in nonMavenizedDeps.keys():
       if ('/%s/' % project) in dep:
         depOrigFilename = os.path.basename(nonMavenizedDeps[dep])
         if not depOrigFilename in distFilenames:
@@ -996,6 +997,15 @@ def checkIdenticalNonMavenizedDeps(distr
           raise RuntimeError('Deployed non-mavenized dep %s differs from distribution dep %s'
                             % (dep, distFilenames[depOrigFilename]))
 
+def getZipFileEntries(fileName):
+  entries = []
+  with zipfile.ZipFile(fileName) as zf:
+    for zi in zf.infolist():
+      entries.append((zi.filename, zi.file_size))
+  # Sort by name:
+  entries.sort()
+  return entries
+
 def checkIdenticalMavenArtifacts(distributionFiles, nonMavenizedDeps, artifacts, version):
   reJarWar = re.compile(r'%s\.[wj]ar$' % version) # exclude *-javadoc.jar and *-sources.jar
   for project in ('lucene', 'solr'):
@@ -1005,11 +1015,20 @@ def checkIdenticalMavenArtifacts(distrib
       distFilenames[baseName] = file
     for artifact in artifacts[project]:
       if reJarWar.search(artifact):
-        if artifact not in list(nonMavenizedDeps.keys()):
+        entries = getZipFileEntries(artifact)
+        if artifact not in nonMavenizedDeps:
           artifactFilename = os.path.basename(artifact)
-          if artifactFilename not in list(distFilenames.keys()):
+          if artifactFilename not in distFilenames:
             raise RuntimeError('Maven artifact %s is not present in %s binary distribution'
                               % (artifact, project))
+          else:
+            binaryEntries = getZipFileEntries(distFilenames[artifactFilename])
+            if binaryEntries != entries:
+              raise RuntimeError('Maven artifact %s has different contents than binary distribution\n  maven:\n%s\n  binary:\n%s\n' % \
+                    (artifactFilename,
+                     '\n'.join('    %s [%d bytes]' % (name, size) for name, size in entries),
+                     '\n'.join('    %s [%d bytes]' % (name, size) for name, size in binaryEntries)))
+          
          # 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: