From 89558dfeade9f0f9dc5f302c995f6275c656867f Mon Sep 17 00:00:00 2001 From: Nick Hurley Date: Mon, 4 Feb 2013 12:15:27 -0800 Subject: [PATCH] Make points for a run line up on the graphs We do this by setting the timestamp for the run (which is used for graphing purposes) once we know we can actually do the run. We also sleep for a second in order to avoid having 2 different runs show up with the same timestamp. This also has the happy effect of making it so sum(totals) in the sql queries for the graphs don't end up showing weird spikes on a day when multiple runs are made. Hooray! --- srinfogatherer.py | 3 +-- srmaster.py | 15 ++++++++++++++- srscheduler.py | 4 ++-- srworker.py | 6 +++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/srinfogatherer.py b/srinfogatherer.py index 92be3ac..0cd671e 100644 --- a/srinfogatherer.py +++ b/srinfogatherer.py @@ -8,7 +8,6 @@ import json import logging import os import platform -import time import stoneridge @@ -52,7 +51,7 @@ class StoneRidgeInfoGatherer(object): info = {'test_machine':machine_info, 'test_build':build_info, 'testrun':{}, - 'date':int(time.time())} + 'date':stoneridge.get_config_int('run', 'tstamp')} logging.debug('gathered info: %s' % (info,)) outdir = stoneridge.get_config('run', 'out') diff --git a/srmaster.py b/srmaster.py index cf48d8c..51cf6f7 100644 --- a/srmaster.py +++ b/srmaster.py @@ -6,6 +6,7 @@ import logging import os import subprocess +import time import uuid import stoneridge @@ -65,13 +66,25 @@ class StoneRidgeMaster(stoneridge.QueueListener): # recovery we can do. return + # In order to have the points for each OS/netconfig match up with each + # other for a particular test run (good for graphing), we set the + # timestamp once we know we're going to actually run the test (which is + # right now, after we've cloned the builds). + # We also sleep for one second, so we don't accidentally have 2 + # different runs show up at the same time as each other on the graphs. + # Sure, it's unlikely, but sleeping for a second won't kill us, and + # better safe than sorry! + tstamp = int(time.time()) + time.sleep(1) + for nc in netconfigs: queue = self.queues.get(nc, None) if queue is None: logging.warning('Got request for invalid netconfig %s' % (nc,)) continue - queue.enqueue(operating_systems=operating_systems, srid=srid) + queue.enqueue(operating_systems=operating_systems, srid=srid, + tstamp=tstamp) def daemon(): diff --git a/srscheduler.py b/srscheduler.py index 5bd4459..fdab9bd 100644 --- a/srscheduler.py +++ b/srscheduler.py @@ -22,7 +22,7 @@ class StoneRidgeScheduler(stoneridge.QueueListener): self.rpc_queue) } - def handle(self, srid, operating_systems): + def handle(self, srid, operating_systems, tstamp): for o in operating_systems: runner = self.runners.get(o, None) if runner is None: @@ -30,7 +30,7 @@ class StoneRidgeScheduler(stoneridge.QueueListener): continue logging.debug('Calling to run %s on %s' % (srid, o)) - res = runner(srid=srid, netconfig=self.netconfig) + res = runner(srid=srid, netconfig=self.netconfig, tstamp=tstamp) if res['ok']: logging.debug('Run of %s on %s succeeded' % (srid, o)) diff --git a/srworker.py b/srworker.py index be635f9..3d445fc 100644 --- a/srworker.py +++ b/srworker.py @@ -8,7 +8,6 @@ import os import subprocess import sys import tempfile -import time import stoneridge @@ -29,14 +28,14 @@ class StoneRidgeWorker(stoneridge.RpcHandler): self.runconfig = None # Needs to be here so reset doesn't barf self.reset() - def handle(self, srid, netconfig): + def handle(self, srid, netconfig, tstamp): # Have a logger just for this run logdir = 'stoneridge_%s_%s' % (srid, netconfig) self.logdir = os.path.join(self.srlogdir, logdir) if os.path.exists(self.logdir): # Don't blow away the old logs, just make a new directory for this # run of the srid - self.logdir = '%s_%s' % (self.logdir, int(time.time())) + self.logdir = '%s_%s' % (self.logdir, tstamp) os.makedirs(self.logdir) logging.debug('Running test with logs in %s' % (self.logdir,)) @@ -80,6 +79,7 @@ class StoneRidgeWorker(stoneridge.RpcHandler): f.write('metadata = %s\n' % (metadata,)) f.write('info = %s\n' % (info,)) f.write('xpcoutleaf = %s\n' % (srxpcout,)) + f.write('tstamp = %s\n' % (tstamp,)) f.write('srid = %s\n' % (srid,)) self.logger.debug('srnetconfig: %s' % (self.srnetconfig,))