From 551a4fc1368a4a2bf45fc8f1de4cbb1d1ced575b Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Fri, 26 Feb 2016 16:40:04 -0500 Subject: [PATCH] Use first test from subunit_stream for run_at value There is an issue when there is a backlog or a worker crashes when we start to work through the gearman queue all the newly added runs to the subunit2sql db have a run_at value of when it was processed, not when it was actually run. The subunit2sql cli (and corresponding pythong api) by default uses the current time as the run_at time when creating a new run. However there is option which allows you to specify the value for run_at. This commit uses the first test run from the subunit as the run_at value to ensure that we have a somewhat accurate run_at value for the run in the db regardless of when the subunit stream is actually processed. Change-Id: I55663476865ec3739faf1b077aff7a02d0e0fa79 --- files/subunit-gearman-worker.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/files/subunit-gearman-worker.py b/files/subunit-gearman-worker.py index bcaab0f..981eff7 100644 --- a/files/subunit-gearman-worker.py +++ b/files/subunit-gearman-worker.py @@ -182,7 +182,11 @@ class Subunit2SQLProcessor(object): logging.debug('Converting Subunit V2 stream to SQL') stream = read_subunit.ReadSubunit(subunit_v2, targets=self.extra_targets) - shell.process_results(stream.get_results()) + results = stream.get_results() + start_time = sorted( + [results[x]['start_time'] for x in results if x != 'run_time'])[0] + shell.CONF.set_override('run_at', start_time.isoformat()) + shell.process_results(results) subunit_v2.close()