Permalink
Browse files

Log ALL the things!

  • Loading branch information...
1 parent 1c53e42 commit a5b0f9f4d6340599e378a1c54399305236dd34ae @nwgh nwgh committed Oct 31, 2012
View
@@ -9,38 +9,52 @@
import stoneridge
+import logging
+
class StoneRidgeArchiver(object):
"""A class to zip up all the results and logging from a stone ridge
run, and put the results with the stone ridge archvies.
"""
def run(self):
+ logging.debug('archiver running')
with file(os.path.join(stoneridge.outdir, 'info.json'), 'rb') as f:
info = json.load(f)
+ logging.debug('loaded info %s' % (info,))
arcname = 'stoneridge_%s_%s_%s' % (info['date'],
info['test_machine']['name'],
info['test_build']['revision'])
+ logging.debug('archive name %s.zip' % (arcname,))
filename = os.path.join(stoneridge.archivedir, '%s.zip' % (arcname,))
if not os.path.exists(stoneridge.archivedir):
+ logging.debug('making archive directory %s' %
+ (stoneridge.archivedir,))
os.mkdir(stoneridge.archivedir)
+
+ logging.debug('opening zip file for writing')
zfile = zipfile.ZipFile(filename, mode='w')
# Put all the files under a directory in the zip named for the zip
# file itself, for easy separation when unzipping multiple archives
# in the same place
+ logging.debug('adding files to zip')
for dirpath, dirs, files in os.walk(stoneridge.outdir):
dirname = dirpath.replace(stoneridge.outdir, arcname, 1)
+ logging.debug('directory %s -> %s' % (dirpath, dirname))
# Add the directories to the zip
for d in dirs:
+ logging.debug('subdirectory %s' % (d,))
zfile.write(os.path.join(dirpath, d),
arcname=os.path.join(dirname, d))
# Add the files to the zip
for f in files:
+ logging.debug('file %s' % (f,))
zfile.write(os.path.join(dirpath, f),
arcname=os.path.join(dirname, f))
+ logging.debug('closing zip file')
zfile.close()
@stoneridge.main
View
@@ -8,14 +8,20 @@
import stoneridge
+import logging
+
@stoneridge.main
def main():
"""A simple cleanup program for stone ridge that blows away the working
directory
"""
+ logging.debug('cleaner running')
parser = stoneridge.ArgumentParser()
parser.parse_args()
if stoneridge.workdir and os.path.exists(stoneridge.workdir):
+ logging.debug('removing workdir %s' % (stoneridge.workdir,))
shutil.rmtree(stoneridge.workdir)
if stoneridge.xpcoutdir and os.path.exists(stoneridge.xpcoutdir):
+ logging.debug('removing xpcshell output directory %s' %
+ (stoneridge.xpcoutdir,))
shutil.rmtree(stoneridge.xpcoutdir)
View
@@ -12,58 +12,82 @@
import stoneridge
+import logging
+
class StoneRidgeCollator(object):
"""Takes the data we've collected from our tests and puts it into formats
the graph server can handle. This is saved into json files for the uploader
to do its thing with
"""
def run(self):
+ logging.debug('collator running')
outfiles = glob.glob(os.path.join(stoneridge.xpcoutdir, '*.out'))
+ logging.debug('found outfiles %s' % (outfiles,))
+ logging.debug('loading info from %s' %
+ (os.path.join(stoneridge.outdir, 'info.json'),))
with file(os.path.join(stoneridge.outdir, 'info.json'), 'rb') as f:
info = json.load(f)
+ logging.debug('loaded info: %s' % (info,))
for ofile in outfiles:
+ logging.debug('processing %s' % (ofile,))
# Make a new copy of the base info
results = copy.deepcopy(info)
del results['date']
results['testrun'] = {'date':info['date'], 'suite':None, 'options':{}}
results['results'] = collections.defaultdict(list)
results['results_aux'] = collections.defaultdict(list)
+ logging.debug('initial testrun: %s' % (results['testrun'],))
# Figure out the test-specific data
fname = os.path.basename(ofile)
suite = fname.split('.')[0]
results['testrun']['suite'] = suite
+ logging.debug('suite: %s' % (suite,))
# Read the raw data
+ logging.debug('reading raw data')
with file(ofile, 'rb') as f:
testinfo = json.load(f)
+ logging.debug('raw testinfo: %s' % (testinfo,))
# Stick the raw data into the json to be uploaded
+ logging.debug('processing raw data')
for k, vlist in testinfo.items():
+ logging.debug('k: %s, vlist: %s' % (k, vlist))
for v in vlist:
+ logging.debug('v: %s' % (v,))
if k == 'total':
+ logging.debug('appending total %s' % (v['total'],))
# The graph server calculates totals for us, we just keep
# our calculations around for verification in case
results['results_aux']['totals'].append(v['total'])
else:
+ logging.debug('appending %s total %s' % (k, v['total']))
results['results'][k].append(v['total'])
for s in ('start', 'stop'):
key = '%s_%s' % (k, s)
+ logging.debug('appending %s %s stamp %s' %
+ (k, s, v[s]))
results['results_aux'][key].append(v[s])
# Turn our defaultdicts into regular dicts for jsonification
results['results'] = dict(results['results'])
results['results_aux'] = dict(results['results_aux'])
+ logging.debug('results: %s' % (results['results'],))
+ logging.debug('aux results: %s' % (results['results_aux'],))
# Copy the raw data into our output directory
+ logging.debug('copying raw data to archivable directory')
shutil.copyfile(ofile, os.path.join(stoneridge.outdir, fname))
# Write our json results for uploading
upload_filename = 'upload_%s.json' % (suite,)
+ logging.debug('upload filename: %s' % (upload_filename,))
upload_file = os.path.join(stoneridge.outdir, upload_filename)
with file(upload_file, 'wb') as f:
+ logging.debug('jsonifying %s' % (results,))
json.dump(results, f)
@stoneridge.main
View
@@ -10,39 +10,51 @@
import stoneridge
+import logging
+
class StoneRidgeDnsUpdater(object):
def __init__(self, restore):
self.restore = restore
self.peer = ('127.0.0.1', 63250)
+ logging.debug('restore: %s' % (restore,))
+ logging.debug('peer: %s' % (peer,))
def _converse(self, msgtype, msgdata=None):
+ logging.debug('msgtype: %s' % (msgtype,))
+ logging.debug('msgdata: %s' % (msgdata,))
if msgdata is None:
msgdata = ''
# Set up our connection
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(self.peer)
+ logging.debug('socket connected')
# First message is type + length of following message
msghdr = struct.pack('cB', msgtype, len(msgdata))
+ logging.debug('sending header %s' % (msghdr,))
sock.send(msghdr)
# Send the data if we have any
if msgdata:
+ logging.debug('sending data %s' % (msgdata,))
sock.send(msgdata)
# Get our result and clean up
result = sock.recv(2)
+ logging.debug('received result %s' % (result,))
sock.close()
if result != 'ok':
- sys.stderr.write('Error %ssetting dns server\n' %
+ logging.error('Could not %sset dns server' %
('re' if msgtype == 'r' else ''))
def _set_dns(self, dnsserver):
+ logging.debug('setting dns server to %s' % (dnsserver,))
self._converse('s', dnsserver)
def _reset_dns(self):
+ logging.debug('resetting dns server')
self._converse('r')
# XXX - WARNING! UGLY HACK BELOW!
@@ -52,17 +64,20 @@ def _reset_dns(self):
# before we can try to do anything that would use the WAN interface
# (such as uploading results).
if stoneridge.os_name == 'windows':
+ logging.debug('sleeping 15 seconds for the windows hack')
time.sleep(15)
def run(self):
+ logging.debug('dns updater running')
if self.restore:
self._reset_dns()
return
+ logging.debug('Searching for dns server for netconfig %s' %
+ (stoneridge.current_netconfig,))
dns_server = stoneridge.get_config('dns', stoneridge.current_netconfig)
if dns_server is None:
- sys.stderr.write('Error finding dns server for config %s\n' %
- (stoneridge.current_netconfig,))
+ logging.error('Error finding dns server')
return
self._set_dns(dns_server)
View
@@ -8,26 +8,36 @@
import stoneridge
+import logging
+
class StoneRidgeDownloader(object):
"""Downloads the firefox archive and the tests.zip for a the machine this is
running on and puts them in the stone ridge working directory
"""
def __init__(self):
self.server = stoneridge.get_config('download', 'server')
self.downloadroot = stoneridge.get_config('download', 'root')
+ logging.debug('server = %s' % (self.server,))
+ logging.debug('download root = %s' % (self.downloadroot,))
def _download_file(self, filename):
url = 'http://%s/%s/%s/%s' % (self.server, self.downloadroot,
stoneridge.download_platform, filename)
+ logging.debug('downloading %s from %s' % (filename, url))
r = requests.get(url)
if r.status_code != 200:
+ logging.critical('Error downloading %s: %s' % (filename,
+ r.status_code))
raise Exception, 'Error downloading %s: %s' % (filename,
r.status_code)
with file(filename, 'wb') as f:
f.write(r.content)
def run(self):
+ logging.debug('downloader running')
if not os.path.exists(stoneridge.downloaddir):
+ logging.debug('creating download directory %s' %
+ (stoneridge.downloaddir,))
os.mkdir(stoneridge.downloaddir)
os.chdir(stoneridge.downloaddir)
@@ -11,12 +11,16 @@
import stoneridge
+import logging
+
class StoneRidgeInfoGatherer(object):
"""Gathers information about the platform stone ridge is running on as well
as the build that stone ridge is being run against
"""
def run(self):
+ logging.debug('info gatherer running')
info_file = os.path.join(stoneridge.bindir, 'application.ini')
+ logging.debug('parsing ini file at %s' % (info_file,))
cp = ConfigParser.SafeConfigParser()
cp.read([info_file])
@@ -48,11 +52,14 @@ def run(self):
'test_build':build_info,
'testrun':{},
'date':int(time.time())}
+ logging.debug('gathered info: %s' % (info,))
if not os.path.exists(stoneridge.outdir):
+ logging.debug('making outdir %s' % (stoneridge.outdir,))
os.mkdir(stoneridge.outdir)
with file(os.path.join(stoneridge.outdir, 'info.json'), 'wb') as f:
+ logging.debug('dumping json to file')
json.dump(info, f)
@stoneridge.main
Oops, something went wrong.

0 comments on commit a5b0f9f

Please sign in to comment.