aboutsummaryrefslogtreecommitdiff
path: root/bigtop-tests
diff options
context:
space:
mode:
authorAlan Gates <gates@hortonworks.com>2016-03-18 13:51:49 -0700
committerAlan Gates <gates@hortonworks.com>2016-03-18 13:51:49 -0700
commit7d39a5cf6669e5be7f1c0954864b0919823de9ab (patch)
treea96816117db879b2b18d301bec412829a9b4b053 /bigtop-tests
parent01f38feb1ab197c156d418c3818440a385ee1f3e (diff)
Initial python to find public APIs in Hadoop and compare them to output of the jar analyzer. This needs integrated with James' scripts to replace the GPL jar analyzer.
Diffstat (limited to 'bigtop-tests')
-rwxr-xr-xbigtop-tests/spec-tests/runtime/src/test/python/find-public-apis.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/bigtop-tests/spec-tests/runtime/src/test/python/find-public-apis.py b/bigtop-tests/spec-tests/runtime/src/test/python/find-public-apis.py
new file mode 100755
index 00000000..091c496e
--- /dev/null
+++ b/bigtop-tests/spec-tests/runtime/src/test/python/find-public-apis.py
@@ -0,0 +1,80 @@
+#!/usr/bin/python
+
+'''
+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.
+'''
+
+import os
+import re
+import warnings
+from optparse import OptionParser
+
+def main():
+ parser = OptionParser()
+ parser.add_option("-d", "--directory", help="Top level directory of source tree")
+ parser.add_option("-r", "--report", help="API compatibility report file, in HTML format")
+
+ (options, args) = parser.parse_args()
+
+ # Get the ATS endpoint if it's not given.
+ if options.directory == None:
+ print "You must specify a top level directory of the source tree"
+ return 1
+
+ if options.report == None:
+ print "You must specify the report to check against"
+ return 1
+
+ publicClasses = set()
+ for directory in os.walk(options.directory):
+ for afile in directory[2]:
+ if re.search("\.java$", afile) != None:
+ handle = open(os.path.join(directory[0], afile))
+ # Figure out the package we're in
+ pre = re.search("org/apache/hadoop[\w/]*", directory[0])
+ if pre == None:
+ warnings.warn("No package for " + directory[0])
+ continue
+ package = pre.group(0)
+ expecting = 0
+ for line in handle:
+ if re.search("@InterfaceAudience.Public", line) != None:
+ expecting = 1
+ classname = re.search("class (\w*)", line)
+ if classname != None and expecting == 1:
+ publicClasses.add(package + "/" + classname.group(1))
+ expecting = 0
+ handle.close()
+
+ handle = open(options.report)
+ haveChecked = set()
+ for line in handle:
+ classre = re.search("mangled: <b>(org/apache/hadoop[\w/]+)", line)
+ if classre != None:
+ classname = classre.group(1)
+ if classname not in haveChecked:
+ if classname in publicClasses:
+ print "Warning, found change in public class " + classname
+ haveChecked.add(classname)
+ handle.close()
+
+
+
+
+main()
+
+