Skip to content

Instantly share code, notes, and snippets.

@krummas
Last active November 13, 2015 15:43
Show Gist options
  • Save krummas/40c2af8c050216df1a0d to your computer and use it in GitHub Desktop.
Save krummas/40c2af8c050216df1a0d to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import json
import urllib2
import sys
BASE_URL = 'http://cassci.datastax.com/job/%s/api/json'
def get_test_urls(jsonresponse, max_build_count):
urllist = []
builds = jsonresponse['builds']
buildcount = max_build_count
if len(builds) < max_build_count:
buildcount = len(builds)
for x in xrange(0, buildcount):
urllist.append(builds[x]['url'])
return urllist
def failed(status):
if status in ['FAILED', 'REGRESSION']:
return True
return False
def get_failed_tests(urls):
failed_tests = set()
for url in urls:
try:
response = urllib2.urlopen("%stestReport/api/json"%url).read()
except:
print "could not get %stestReport/api/json"%url
continue
testreport = json.loads(response)
for x in testreport['suites']:
for case in x['cases']:
if failed(case['status']):
failed_tests.add("%s.%s" % (case['className'], case['name']))
return failed_tests
if __name__ == '__main__':
if len(sys.argv) != 3:
print "syntax is: casscicompare.py <global_job_name> <your_job_name>"
exit(1)
global_job_name = sys.argv[1]
local_job_name = sys.argv[2]
local_failures = get_failed_tests(get_test_urls(json.loads(urllib2.urlopen(BASE_URL%(local_job_name)).read()), 1))
global_failures = get_failed_tests(get_test_urls(json.loads(urllib2.urlopen(BASE_URL%(global_job_name)).read()), 10))
local_only = local_failures - global_failures
for test in local_only:
print test
print len(local_only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment