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
This commit is contained in:
Matthew Treinish 2016-02-26 16:40:04 -05:00
parent a8e4c8322d
commit 551a4fc136
No known key found for this signature in database
GPG Key ID: FD12A0F214C9E177
1 changed files with 5 additions and 1 deletions

View File

@ -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()